Example #1
0
        public double MeasurePower(double valueThroughTheStructure, int NumberOfAverages, double TimeDelay, SourceMode sourceMode)
        {
            double measuredPower;
            KEITHLEY_2601A_SourceMode _sourceMode = KEITHLEY_2601A_SourceMode.Voltage;

            switch (sourceMode)
            {
            case SourceMode.Voltage:
            {
                _sourceMode = KEITHLEY_2601A_SourceMode.Voltage;
            } break;

            case SourceMode.Current:
            {
                _sourceMode = KEITHLEY_2601A_SourceMode.Current;
            } break;

            default:
                break;
            }
            var measuredPowerString = MeasureResistanceOrPowerValueInChannel(_SelectedChannel, _sourceMode, KEITHLEY_2601A_MeasureMode.Power, valueThroughTheStructure, NumberOfAverages, TimeDelay).TrimEnd('\n');
            var isSucceed           = double.TryParse(measuredPowerString, style, culture, out measuredPower);

            if (isSucceed)
            {
                return(measuredPower);
            }
            else
            {
                return(double.NaN);
            }
        }
            /// <summary>
            /// Sets source mode of appropriate channel
            /// </summary>
            /// <param name="Channel">Channel</param>
            /// <param name="SourceMode">Source mode (voltage / current)</param>
            public void SetChannelSourceMode(KEITHLEY_2602A_Channels Channel, KEITHLEY_2601A_SourceMode SourceMode)
            {
                var Command = "smu{0}.source.autorange{2} = smu{0}.AUTORANGE_ON ";

                CommandBuilder = new StringBuilder();

                Command  = Command.Insert(0, "smu{0}.source.func = smu{0}.{1} ");
                Command += "smu{0}.source.level{2} = 0 ";

                switch (SourceMode)
                {
                case KEITHLEY_2601A_SourceMode.Voltage:
                {
                    switch (Channel)
                    {
                    case KEITHLEY_2602A_Channels.ChannelA:
                    {
                        Command = CommandBuilder.AppendFormat(Command, "a", "OUTPUT_DCVOLTS", "v").ToString();
                        SendCommandRequest(Command);
                    } break;

                    case KEITHLEY_2602A_Channels.ChannelB:
                    {
                        Command = CommandBuilder.AppendFormat(Command, "b", "OUTPUT_DCVOLTS", "v").ToString();
                        SendCommandRequest(Command);
                    } break;

                    default:
                        break;
                    }
                } break;

                case KEITHLEY_2601A_SourceMode.Current:
                {
                    switch (Channel)
                    {
                    case KEITHLEY_2602A_Channels.ChannelA:
                    {
                        Command = CommandBuilder.AppendFormat(Command, "a", "OUTPUT_DCAMPS", "i").ToString();
                        SendCommandRequest(Command);
                    } break;

                    case KEITHLEY_2602A_Channels.ChannelB:
                    {
                        Command = CommandBuilder.AppendFormat(Command, "b", "OUTPUT_DCAMPS", "i").ToString();
                        SendCommandRequest(Command);
                    } break;

                    default:
                        break;
                    }
                } break;

                default:
                    break;
                }
            }
Example #3
0
        public MeasureTimeTrace(IMotion motor, double startPosition, double destination, I_SMU measureDevice, KEITHLEY_2601A_SourceMode sourceMode, KEITHLEY_2601A_MeasureMode measureMode, double valueThroughTheStructure)
        {
            _Motor                    = motor;
            _StartPosition            = startPosition;
            _Destination              = destination;
            _MeasureDevice            = measureDevice;
            _SourceMode               = sourceMode;
            _MeasureMode              = measureMode;
            _ValueThroughTheStructure = valueThroughTheStructure;

            AllEventsHandler.Instance.TimeTraceMeasurementsStateChanged += OnTimeTraceMeasurementsStateChanged;
            AllEventsHandler.Instance.Motion += OnMotionPositionMeasured;
        }
        public MeasureTimeTrace(IMotion motor, double startPosition, double destination, I_SMU measureDevice, KEITHLEY_2601A_SourceMode sourceMode, KEITHLEY_2601A_MeasureMode measureMode, double valueThroughTheStructure)
        {
            _Motor = motor;
            _StartPosition = startPosition;
            _Destination = destination;
            _MeasureDevice = measureDevice;
            _SourceMode = sourceMode;
            _MeasureMode = measureMode;
            _ValueThroughTheStructure = valueThroughTheStructure;

            AllEventsHandler.Instance.TimeTraceMeasurementsStateChanged += OnTimeTraceMeasurementsStateChanged;
            AllEventsHandler.Instance.Motion += OnMotionPositionMeasured;
        }
            /// <summary>
            /// Sets value to the appropriate channel
            /// </summary>
            /// <param name="Value">Value to be set into device</param>
            /// <param name="SourceMode">Defines voltage or current value should be written to the device</param>
            /// <param name="Channel">Defines channel, on which the value is setted</param>
            public void SetValueToChannel(double Value, KEITHLEY_2601A_SourceMode SourceMode, KEITHLEY_2602A_Channels Channel)
            {
                SetChannelSourceMode(Channel, SourceMode);

                //Changing value to appropriate format

                var _Value = Value.ToString().Replace(',', '.');

                var script = "smu{0}.source.level{1} = {2} ";

                switch (Channel)
                {
                case KEITHLEY_2602A_Channels.ChannelA:
                {
                    CommandBuilder = new StringBuilder();

                    switch (SourceMode)
                    {
                    case KEITHLEY_2601A_SourceMode.Voltage:
                    {
                        script = CommandBuilder.AppendFormat(script, "a", "v", _Value).ToString();
                        SendCommandRequest(script);
                    } break;

                    case KEITHLEY_2601A_SourceMode.Current:
                    {
                        script = CommandBuilder.AppendFormat(script, "a", "i", _Value).ToString();
                        SendCommandRequest(script);
                    } break;

                    default:
                        break;
                    }
                } break;

                case KEITHLEY_2602A_Channels.ChannelB:
                {
                    CommandBuilder = new StringBuilder();

                    switch (SourceMode)
                    {
                    case KEITHLEY_2601A_SourceMode.Voltage:
                    {
                        script = CommandBuilder.AppendFormat(script, "b", "v", _Value).ToString();
                        SendCommandRequest(script);
                    } break;

                    case KEITHLEY_2601A_SourceMode.Current:
                    {
                        script = CommandBuilder.AppendFormat(script, "b", "i", _Value).ToString();
                        SendCommandRequest(script);
                    } break;

                    default:
                        break;
                    }
                } break;

                default:
                    break;
                }
            }
            /// <summary>
            /// Measures the resistance or power in appropriate channel
            /// </summary>
            /// <param name="Channel">Channel</param>
            /// <param name="SourceMode">Source mode (voltage / current)</param>
            /// <param name="MeasureMode">Measure mode (resistance / power)</param>
            /// <param name="NumberOfAverages">Number of averages per one measure</param>
            /// <param name="TimeDelay">Time delay between two measurenments</param>
            /// <returns></returns>
            public string MeasureResistanceOrPowerValueInChannel(KEITHLEY_2602A_Channels Channel, KEITHLEY_2601A_SourceMode SourceMode, KEITHLEY_2601A_MeasureMode MeasureMode, double valueThroughTheStructure, int NumberOfAverages, double TimeDelay)
            {
                var _TimeDelay = TimeDelay.ToString().Replace(',', '.');
                var _valueThroughTheStructure = valueThroughTheStructure.ToString().Replace(',', '.');
                var _limiti = (1.0).ToString().Replace(',', '.');
                var _limitv = (40.0).ToString().Replace(',', '.');

                var MeasuredValue = "";

                var R_Script =
                    "loadscript MeasureResistanceInChannel\n" +
                    "smu{0}.source.func = smu{0}.{1}\n" +
                    "smu{0}.source.autorange{2} = smu{0}.AUTORANGE_ON\n" +
                    "smu{0}.source.level{2} = {3}\n" +
                    "smu{0}.source.limit{4} = {5}\n" +
                    "smu{0}.measure.autorange{4} = smu{0}.AUTORANGE_ON\n" +
                    "display.screen = display.{6}\n" +
                    "display.smu{0}.measure.func = display.{7}\n" +
                    "trigger.clear()\n" +
                    "result = 0.0\n" +
                    "for parameterMeasure = 1, {8} do\n" +
                    "trigger.wait({9})\n" +
                    "result = result + smu{0}.measure.r()\n" +
                    "end\n" +
                    "result = result / {8}\n" +
                    "print (result)\n" +
                    "endscript\n" +
                    "MeasureResistanceInChannel()\n";

                var P_Script =
                    "loadscript MeasurePowerInChannel\n" +
                    "smu{0}.measure.autorange{1} = smu{0}.AUTORANGE_ON\n" +
                    "display.screen = display.{2}\n" +
                    "display.smu{0}.measure.func = display.{3}\n" +
                    "trigger.clear()\n" +
                    "result = 0.0\n" +
                    "for parameterMeasure = 1, {4} do\n" +
                    "trigger.wait({5})\n" +
                    "result = result + smu{0}.measure.p()\n" +
                    "end\n" +
                    "result = result / ({4} - 1)\n" +
                    "print (result)\n" +
                    "endscript\n" +
                    "MeasurePowerInChannel()\n";

                CommandBuilder = new StringBuilder();

                switch (MeasureMode)
                {
                case KEITHLEY_2601A_MeasureMode.Voltage:
                {
                    throw new NotImplementedException();
                }

                case KEITHLEY_2601A_MeasureMode.Current:
                {
                    throw new NotImplementedException();
                }

                case KEITHLEY_2601A_MeasureMode.Resistance:
                {
                    switch (Channel)
                    {
                    case KEITHLEY_2602A_Channels.ChannelA:
                    {
                        switch (SourceMode)
                        {
                        case KEITHLEY_2601A_SourceMode.Voltage:
                        {
                            R_Script = CommandBuilder.AppendFormat(R_Script, "a", "OUTPUT_DCVOLTS", "v", _valueThroughTheStructure, "i", _limiti, "SMUA", "MEASURE_OHMS", NumberOfAverages, _TimeDelay).ToString();
                            ExecuteQuery(R_Script, ref MeasuredValue);
                        } break;

                        case KEITHLEY_2601A_SourceMode.Current:
                        {
                            R_Script = CommandBuilder.AppendFormat(R_Script, "a", "OUTPUT_DCAMPS", "i", _valueThroughTheStructure, "v", _limitv, "SMUA", "MEASURE_OHMS", NumberOfAverages, _TimeDelay).ToString();
                            ExecuteQuery(R_Script, ref MeasuredValue);
                        } break;

                        default:
                            break;
                        }
                    } break;

                    case KEITHLEY_2602A_Channels.ChannelB:
                    {
                        switch (SourceMode)
                        {
                        case KEITHLEY_2601A_SourceMode.Voltage:
                        {
                            R_Script = CommandBuilder.AppendFormat(R_Script, "b", "OUTPUT_DCVOLTS", "v", _valueThroughTheStructure, "i", _limiti, "SMUB", "MEASURE_OHMS", NumberOfAverages, _TimeDelay).ToString();
                            ExecuteQuery(R_Script, ref MeasuredValue);
                        } break;

                        case KEITHLEY_2601A_SourceMode.Current:
                        {
                            R_Script = CommandBuilder.AppendFormat(R_Script, "b", "OUTPUT_DCAMPS", "i", _valueThroughTheStructure, "v", _limitv, "SMUB", "MEASURE_OHMS", NumberOfAverages, _TimeDelay).ToString();
                            ExecuteQuery(R_Script, ref MeasuredValue);
                        } break;

                        default:
                            break;
                        }
                    } break;

                    default:
                        break;
                    }
                } break;

                case KEITHLEY_2601A_MeasureMode.Power:
                {
                    switch (Channel)
                    {
                    case KEITHLEY_2602A_Channels.ChannelA:
                    {
                        switch (SourceMode)
                        {
                        case KEITHLEY_2601A_SourceMode.Voltage:
                        {
                            P_Script = CommandBuilder.AppendFormat(P_Script, "a", "i", "SMUA", "MEASURE_WATTS", NumberOfAverages, _TimeDelay).ToString();
                            ExecuteQuery(P_Script, ref MeasuredValue);
                        } break;

                        case KEITHLEY_2601A_SourceMode.Current:
                        {
                            P_Script = CommandBuilder.AppendFormat(P_Script, "a", "v", "SMUA", "MEASURE_WATTS", NumberOfAverages, _TimeDelay).ToString();
                            ExecuteQuery(P_Script, ref MeasuredValue);
                        } break;

                        default:
                            break;
                        }
                    } break;

                    case KEITHLEY_2602A_Channels.ChannelB:
                    {
                        switch (SourceMode)
                        {
                        case KEITHLEY_2601A_SourceMode.Voltage:
                        {
                            P_Script = CommandBuilder.AppendFormat(P_Script, "b", "i", "SMUA", "MEASURE_WATTS", NumberOfAverages, _TimeDelay).ToString();
                            ExecuteQuery(P_Script, ref MeasuredValue);
                        } break;

                        case KEITHLEY_2601A_SourceMode.Current:
                        {
                            P_Script = CommandBuilder.AppendFormat(P_Script, "b", "v", "SMUA", "MEASURE_WATTS", NumberOfAverages, _TimeDelay).ToString();
                            ExecuteQuery(P_Script, ref MeasuredValue);
                        } break;

                        default:
                            break;
                        }
                    } break;

                    default:
                        break;
                    }
                } break;

                default:
                    break;
                }

                return(MeasuredValue);
            }
            /// <summary>
            /// Sets value to the appropriate channel
            /// </summary>
            /// <param name="Value">Value to be set into device</param>
            /// <param name="SourceMode">Defines voltage or current value should be written to the device</param>
            /// <param name="Channel">Defines channel, on which the value is setted</param>
            public void SetValueToChannel(double Value, KEITHLEY_2601A_SourceMode SourceMode, KEITHLEY_2602A_Channels Channel)
            {
                SetChannelSourceMode(Channel, SourceMode);

                //Changing value to appropriate format

                var _Value = Value.ToString().Replace(',', '.');

                var script = "smu{0}.source.level{1} = {2} ";

                switch (Channel)
                {
                    case KEITHLEY_2602A_Channels.ChannelA:
                        {
                            CommandBuilder = new StringBuilder();

                            switch (SourceMode)
                            {
                                case KEITHLEY_2601A_SourceMode.Voltage:
                                    {
                                        script = CommandBuilder.AppendFormat(script, "a", "v", _Value).ToString();
                                        SendCommandRequest(script);
                                    } break;
                                case KEITHLEY_2601A_SourceMode.Current:
                                    {
                                        script = CommandBuilder.AppendFormat(script, "a", "i", _Value).ToString();
                                        SendCommandRequest(script);
                                    } break;
                                default:
                                    break;
                            }
                        } break;
                    case KEITHLEY_2602A_Channels.ChannelB:
                        {
                            CommandBuilder = new StringBuilder();

                            switch (SourceMode)
                            {
                                case KEITHLEY_2601A_SourceMode.Voltage:
                                    {
                                        script = CommandBuilder.AppendFormat(script, "b", "v", _Value).ToString();
                                        SendCommandRequest(script);
                                    } break;
                                case KEITHLEY_2601A_SourceMode.Current:
                                    {
                                        script = CommandBuilder.AppendFormat(script, "b", "i", _Value).ToString();
                                        SendCommandRequest(script);
                                    } break;
                                default:
                                    break;
                            }
                        } break;
                    default:
                        break;
                }
            }
            /// <summary>
            /// Measures the resistance or power in appropriate channel
            /// </summary>
            /// <param name="Channel">Channel</param>
            /// <param name="SourceMode">Source mode (voltage / current)</param>
            /// <param name="MeasureMode">Measure mode (resistance / power)</param>
            /// <param name="NumberOfAverages">Number of averages per one measure</param>
            /// <param name="TimeDelay">Time delay between two measurenments</param>
            /// <returns></returns>
            public string MeasureResistanceOrPowerValueInChannel(KEITHLEY_2602A_Channels Channel, KEITHLEY_2601A_SourceMode SourceMode, KEITHLEY_2601A_MeasureMode MeasureMode, double valueThroughTheStructure, int NumberOfAverages, double TimeDelay)
            {
                var _TimeDelay = TimeDelay.ToString().Replace(',', '.');
                var _valueThroughTheStructure = valueThroughTheStructure.ToString().Replace(',', '.');
                var _limiti = (1.0).ToString().Replace(',', '.');
                var _limitv = (40.0).ToString().Replace(',', '.');

                var MeasuredValue = "";

                var R_Script =
                    "loadscript MeasureResistanceInChannel\n" +
                    "smu{0}.source.func = smu{0}.{1}\n" +
                    "smu{0}.source.autorange{2} = smu{0}.AUTORANGE_ON\n" +
                    "smu{0}.source.level{2} = {3}\n" +
                    "smu{0}.source.limit{4} = {5}\n" +
                    "smu{0}.measure.autorange{4} = smu{0}.AUTORANGE_ON\n" +
                    "display.screen = display.{6}\n" +
                    "display.smu{0}.measure.func = display.{7}\n" +
                    "trigger.clear()\n" +
                    "result = 0.0\n" +
                    "for parameterMeasure = 1, {8} do\n" +
                    "trigger.wait({9})\n" +
                    "result = result + smu{0}.measure.r()\n" +
                    "end\n" +
                    "result = result / {8}\n" +
                    "print (result)\n" +
                    "endscript\n" +
                    "MeasureResistanceInChannel()\n";

                var P_Script =
                    "loadscript MeasurePowerInChannel\n" +
                    "smu{0}.measure.autorange{1} = smu{0}.AUTORANGE_ON\n" +
                    "display.screen = display.{2}\n" +
                    "display.smu{0}.measure.func = display.{3}\n" +
                    "trigger.clear()\n" +
                    "result = 0.0\n" +
                    "for parameterMeasure = 1, {4} do\n" +
                    "trigger.wait({5})\n" +
                    "result = result + smu{0}.measure.p()\n" +
                    "end\n" +
                    "result = result / ({4} - 1)\n" +
                    "print (result)\n" +
                    "endscript\n" +
                    "MeasurePowerInChannel()\n";

                CommandBuilder = new StringBuilder();

                switch (MeasureMode)
                {
                    case KEITHLEY_2601A_MeasureMode.Voltage:
                        {
                            throw new NotImplementedException();
                        }
                    case KEITHLEY_2601A_MeasureMode.Current:
                        {
                            throw new NotImplementedException();
                        }
                    case KEITHLEY_2601A_MeasureMode.Resistance:
                        {
                            switch (Channel)
                            {
                                case KEITHLEY_2602A_Channels.ChannelA:
                                    {
                                        switch (SourceMode)
                                        {
                                            case KEITHLEY_2601A_SourceMode.Voltage:
                                                {
                                                    R_Script = CommandBuilder.AppendFormat(R_Script, "a", "OUTPUT_DCVOLTS", "v", _valueThroughTheStructure, "i", _limiti, "SMUA", "MEASURE_OHMS", NumberOfAverages, _TimeDelay).ToString();
                                                    ExecuteQuery(R_Script, ref MeasuredValue);
                                                } break;
                                            case KEITHLEY_2601A_SourceMode.Current:
                                                {
                                                    R_Script = CommandBuilder.AppendFormat(R_Script, "a", "OUTPUT_DCAMPS", "i", _valueThroughTheStructure, "v", _limitv, "SMUA", "MEASURE_OHMS", NumberOfAverages, _TimeDelay).ToString();
                                                    ExecuteQuery(R_Script, ref MeasuredValue);
                                                } break;
                                            default:
                                                break;
                                        }
                                    } break;
                                case KEITHLEY_2602A_Channels.ChannelB:
                                    {
                                        switch (SourceMode)
                                        {
                                            case KEITHLEY_2601A_SourceMode.Voltage:
                                                {
                                                    R_Script = CommandBuilder.AppendFormat(R_Script, "b", "OUTPUT_DCVOLTS", "v", _valueThroughTheStructure, "i", _limiti, "SMUB", "MEASURE_OHMS", NumberOfAverages, _TimeDelay).ToString();
                                                    ExecuteQuery(R_Script, ref MeasuredValue);
                                                } break;
                                            case KEITHLEY_2601A_SourceMode.Current:
                                                {
                                                    R_Script = CommandBuilder.AppendFormat(R_Script, "b", "OUTPUT_DCAMPS", "i", _valueThroughTheStructure, "v", _limitv, "SMUB", "MEASURE_OHMS", NumberOfAverages, _TimeDelay).ToString();
                                                    ExecuteQuery(R_Script, ref MeasuredValue);
                                                } break;
                                            default:
                                                break;
                                        }
                                    } break;
                                default:
                                    break;
                            }
                        } break;
                    case KEITHLEY_2601A_MeasureMode.Power:
                        {
                            switch (Channel)
                            {
                                case KEITHLEY_2602A_Channels.ChannelA:
                                    {
                                        switch (SourceMode)
                                        {
                                            case KEITHLEY_2601A_SourceMode.Voltage:
                                                {
                                                    P_Script = CommandBuilder.AppendFormat(P_Script, "a", "i", "SMUA", "MEASURE_WATTS", NumberOfAverages, _TimeDelay).ToString();
                                                    ExecuteQuery(P_Script, ref MeasuredValue);
                                                } break;
                                            case KEITHLEY_2601A_SourceMode.Current:
                                                {
                                                    P_Script = CommandBuilder.AppendFormat(P_Script, "a", "v", "SMUA", "MEASURE_WATTS", NumberOfAverages, _TimeDelay).ToString();
                                                    ExecuteQuery(P_Script, ref MeasuredValue);
                                                } break;
                                            default:
                                                break;
                                        }
                                    } break;
                                case KEITHLEY_2602A_Channels.ChannelB:
                                    {
                                        switch (SourceMode)
                                        {
                                            case KEITHLEY_2601A_SourceMode.Voltage:
                                                {
                                                    P_Script = CommandBuilder.AppendFormat(P_Script, "b", "i", "SMUA", "MEASURE_WATTS", NumberOfAverages, _TimeDelay).ToString();
                                                    ExecuteQuery(P_Script, ref MeasuredValue);
                                                } break;
                                            case KEITHLEY_2601A_SourceMode.Current:
                                                {
                                                    P_Script = CommandBuilder.AppendFormat(P_Script, "b", "v", "SMUA", "MEASURE_WATTS", NumberOfAverages, _TimeDelay).ToString();
                                                    ExecuteQuery(P_Script, ref MeasuredValue);
                                                } break;
                                            default:
                                                break;
                                        }
                                    } break;
                                default:
                                    break;
                            }
                        } break;
                    default:
                        break;
                }

                return MeasuredValue;
            }
            /// <summary>
            /// Sets source mode of appropriate channel
            /// </summary>
            /// <param name="Channel">Channel</param>
            /// <param name="SourceMode">Source mode (voltage / current)</param>
            public void SetChannelSourceMode(KEITHLEY_2602A_Channels Channel, KEITHLEY_2601A_SourceMode SourceMode)
            {
                var Command = "smu{0}.source.autorange{2} = smu{0}.AUTORANGE_ON ";

                CommandBuilder = new StringBuilder();

                Command = Command.Insert(0, "smu{0}.source.func = smu{0}.{1} ");
                Command += "smu{0}.source.level{2} = 0 ";

                switch (SourceMode)
                {
                    case KEITHLEY_2601A_SourceMode.Voltage:
                        {
                            switch (Channel)
                            {
                                case KEITHLEY_2602A_Channels.ChannelA:
                                    {
                                        Command = CommandBuilder.AppendFormat(Command, "a", "OUTPUT_DCVOLTS", "v").ToString();
                                        SendCommandRequest(Command);
                                    } break;
                                case KEITHLEY_2602A_Channels.ChannelB:
                                    {
                                        Command = CommandBuilder.AppendFormat(Command, "b", "OUTPUT_DCVOLTS", "v").ToString();
                                        SendCommandRequest(Command);
                                    } break;
                                default:
                                    break;
                            }
                        } break;
                    case KEITHLEY_2601A_SourceMode.Current:
                        {
                            switch (Channel)
                            {
                                case KEITHLEY_2602A_Channels.ChannelA:
                                    {
                                        Command = CommandBuilder.AppendFormat(Command, "a", "OUTPUT_DCAMPS", "i").ToString();
                                        SendCommandRequest(Command);
                                    } break;
                                case KEITHLEY_2602A_Channels.ChannelB:
                                    {
                                        Command = CommandBuilder.AppendFormat(Command, "b", "OUTPUT_DCAMPS", "i").ToString();
                                        SendCommandRequest(Command);
                                    } break;
                                default:
                                    break;
                            }
                        } break;
                    default:
                        break;
                }
            }