public bool InitializeU2751A_WELLA(string ConnectString)
        {
            bool   devReady = false;
            string idnTemp;

            ioRelayWellACntrl = new FormattedIO488();     // Create the formatted I/O object
            devReady          = U2751A_WellA_Connect(ConnectString);
            if (devReady == false)
            {
                devReadyStatus = false;
                //throw new Exception("Connect to U2751A_WELLA failed on " + ConnectString);
                //MessageBox.Show("Connect to U2751A_WELLA failed on " + ConnectString);
            }
            else
            {
                devReadyStatus = true;
                ioRelayWellACntrl.WriteString("*RST", true);        // Reset
                ioRelayWellACntrl.WriteString("*CLS", true);        // Clear
                ioRelayWellACntrl.WriteString("*IDN?", true);       // Read ID string
                idnTemp = ioRelayWellACntrl.ReadString();

                IDN_SwitchA = idnTemp;

                OnAgilentMessage(new AgilentMessageEventArgs("Connect to U2751A WellA suceess! U2751A WellA IDN: " + idnTemp.ToString()));
            }

            return(devReadyStatus);
        }
Example #2
0
 public virtual bool Initialize(string strVISAAddress)
 {
     try
     {
         if (bIsSimulationMode)
         {
             Initialized = true;
             return(true);
         }
         if (ioM == null)
         {
             ioM = new FormattedIO488();
             rmM = new ResourceManager();
         }
         ioM.IO         = (IMessage)rmM.Open(strVISAAddress, AccessMode.NO_LOCK, 10000, "");
         ioM.IO.Timeout = 10000;
         Initialized    = true;
         return(true);
     }
     catch (Exception ex)
     {
         Log(ex.Message);
         Initialized = false;
         return(false);
     }
 }
Example #3
0
        private static double SetAndTakeSingleMeasurement(FormattedIO488 THDMeter, FormattedIO488 SigGen, double setVoltage, VoltUnits Units)
        {
            string dcOffset;

            if (Units == VoltUnits.Volts)
            {
                dcOffset = string.Format("OF {0:F3} VO; AC; ", setVoltage);
            }
            else
            {
                dcOffset = string.Format("OF {0:F3} MV; AC; ", setVoltage);
            }

            SigGen.WriteString(dcOffset, true);
            System.Threading.Thread.Sleep(1000);
            THDMeter.WriteString(@":READ?");
            double voltage = THDMeter.ReadNumber();

            if (Units == VoltUnits.Millivolts)
            {
                voltage *= 1000;
            }

            return(voltage);
        }
Example #4
0
 protected void Open(string ConnectionString)
 {
     this.ConnectionString = ConnectionString;
     rm       = new ResourceManager();
     ioobj    = new FormattedIO488();
     ioobj.IO = (Ivi.Visa.Interop.IMessage)rm.Open(ConnectionString, AccessMode.NO_LOCK, 0, "");
 }
Example #5
0
        public void CheckDMMError(FormattedIO488 myDmm)
        {
            myDmm.WriteString("SYST:ERR?", true);
            string errStr = myDmm.ReadString();

            if (errStr.Contains("No error")) //If no error, then return
            {
                return;
            }
            //If there is an error, read out all of the errors and return them in an exception
            else
            {
                string errStr2 = "";
                do
                {
                    myDmm.WriteString("SYST:ERR?", true);
                    errStr2 = myDmm.ReadString();
                    if (!errStr2.Contains("No error"))
                    {
                        errStr = errStr + "\n" + errStr2;
                    }
                } while (!errStr2.Contains("No error"));
                throw new Exception("Exception: Encountered system error(s)\n" + errStr);
            }
        }
Example #6
0
        public static bool Read(byte address, out string valueRead)
        {
            resourceManager = new ResourceManager();
            ioObject        = new FormattedIO488();
            string addr = $"GPIB::{address.ToString()}::INSTR";

            try
            {
                ioObject.IO = (IMessage)resourceManager.Open(addr, AccessMode.NO_LOCK, 0, "");
                Thread.Sleep(20);
                valueRead = ioObject.ReadString();
                return(true);
            }
            catch
            {
                valueRead = "";
                return(false);
            }
            finally
            {
                try { ioObject.IO.Close(); }
                catch { }
                try { Marshal.ReleaseComObject(ioObject); }
                catch { }
                try { Marshal.ReleaseComObject(resourceManager); }
                catch { }
            }
        }
 /// <summary>
 /// New instance of MetersModel with parameters. Fills in any needed property to start a connection with the device.
 /// </summary>
 /// <param name="visaOrIP">IP or VISA of the machine. If isIP = true, fill in an ip, else a VISA address.</param>
 /// <param name="timeout">Timeout time for the device in miliseconds.</param>
 /// <param name="isIP">Checks if an IP or VISA address has been filled in.</param>
 /// <example>new MetersModel("TCPIP::192.168.1.200::INSTR", 120000, false) </example>
 public MetersModel(string ip, int timeout)
 {
     _rMngr = new ResourceManager();
     _dev = new FormattedIO488();
     Ip = ip;
     TimeOut = timeout;
 }
Example #8
0
        private static Measurement TakeMeasurement(FormattedIO488 src, FormattedIO488 gen, int measurement, AmplitudeCalibration AmpCal)
        {
            // HP 3325B drifts so Check to see if the user wants amplitude calibration
            if (AmpCal == AmplitudeCalibration.On)
            {
                gen.WriteString("AC;");
                System.Threading.Thread.Sleep(2000);
            }

            // Take a THD reading
            src.WriteString(@":INIT;", true);
            System.Threading.Thread.Sleep(6000);
            src.WriteString(@":SENSe:DISTortion:THD?;", true);
            System.Threading.Thread.Sleep(1000);
            double thd = src.ReadNumber();

            //src.WriteString(@": INIT;");
            src.WriteString(@":SENSe:DISTortion:HARMonic:MAGNitude? 2,2;", true);
            System.Threading.Thread.Sleep(1000);
            double harm2 = src.ReadNumber();

            src.WriteString(@":SENSe:DISTortion:HARMonic:MAGNitude? 3,3;", true);
            System.Threading.Thread.Sleep(1000);
            double harm3 = src.ReadNumber();

            src.WriteString(@":SENSe:DISTortion:HARMonic:MAGNitude? 4,4;", true);
            System.Threading.Thread.Sleep(1000);
            double harm4 = src.ReadNumber();

            return(new Measurement(measurement, thd, harm2, harm3, harm4, DateTime.Now));
        }
Example #9
0
        public static bool Write(byte address, string command)
        {
            resourceManager = new ResourceManager();
            ioObject        = new FormattedIO488();
            string addr = $"GPIB::{address.ToString()}::INSTR";

            try
            {
                ioObject.IO = (IMessage)resourceManager.Open(addr, AccessMode.NO_LOCK, 0, "");
                Thread.Sleep(20);
                ioObject.WriteString(data: command, flushAndEND: true);
                return(true);
            }
            catch
            {
                return(false);
            }
            finally
            {
                try { ioObject.IO.Close(); }
                catch { }
                try { Marshal.ReleaseComObject(ioObject); }
                catch { }
                try { Marshal.ReleaseComObject(resourceManager); }
                catch { }
            }
        }
Example #10
0
 public virtual string Initial(string Adress)
 {
     try
     {
         this.Adress = Adress;
         rm          = new ResourceManager();
         Device      = new FormattedIO488();
         Device.IO   = (IMessage)rm.Open(Adress, AccessMode.NO_LOCK, 2000, "");
         Device.IO.Clear();
         Device.WriteString("*IDN?");
         string RD = Device.ReadString();
         Name         = RD;
         Model        = Name.Split(',')[1];
         SerialNumber = RD;
         if (Model == "U2000A")
         {
             //Device.WriteString("CAL:ZERO:TYPE INT");
             //Device.WriteString("CAL:ALL");
             //Device.WriteString("*OPC?");
             //int i = 0;
             //while(Conversion.Val(Device.ReadString())==0)
             //{
             //    i++;
             //    if (i > 10000000) break;
             //}
             Device.WriteString("UNIT:POW W");
         }
         return("Ok_" + RD);
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Example #11
0
        private void InitializeU3606A(string ConnectString)
        {
            bool devReady = false;
            string idnTemp;

            ioMultiMeterCntrl = new FormattedIO488Class();   // Create the formatted I/O object

            devReady = U3606A_Connect(ConnectString);
            if (devReady == false)
            {
                throw new Exception("Connect to U3606A failed on " + ConnectString);
            }
            else
            {
                ioMultiMeterCntrl.WriteString("*RST", true);              // Reset
                ioMultiMeterCntrl.WriteString("*CLS", true);              // Clear
                ioMultiMeterCntrl.WriteString("*IDN?", true);             // Read ID string
                idnTemp = ioMultiMeterCntrl.ReadString();

                Trace.WriteLine("Connect to U3606A suceess! U3606A IDN: " + idnTemp.ToString());

                ioMultiMeterCntrl.WriteString("SYST:BEEP:STAT OFF", true);

                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.0001", true); // 10mA range with 100uA resolution

                ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.000001", true);  // 10mA range with 1uA resolution
            }
        }
 static void Instrument_Write(FormattedIO488 instrument_control_object, string command)
 {
     /*
      *  Purpose: Used to send commands to the instrument.
      *
      *  Parameters:
      *      instrument_control_object - The reference to the instrument object created external to this function. It is passed
      *                                  in by reference so that it retains all values upon exiting this function, making it
      *                                  consumable to all other calling functions.
      *
      *      command - The command string issued to the instrument in order to perform an action.
      *
      *  Returns:
      *      None
      *
      *  Revisions:
      *      2019-06-04      JJB     Initial revision.
      */
     if (echo_command == true)
     {
         Console.WriteLine("{0}", command);
     }
     instrument_control_object.WriteString(command + "\n");
     return;
 }
Example #13
0
 /// <summary>
 /// 连接仪表
 /// </summary>
 /// <param name="IP"></param>
 public override void Connect()
 {
     try
     {
         #region Socket 连接方式
         messageBased = new FormattedIO488();
         ResourceManager grm = new ResourceManager();
         messageBased.IO                = (IMessage)grm.Open("TCPIP0::" + IP + "::5025::SOCKET", AccessMode.NO_LOCK, 2000, "");
         messageBased.IO.Timeout        = 200000;
         messageBased.IO.SendEndEnabled = !messageBased.IO.SendEndEnabled;
         messageBased.IO.TerminationCharacterEnabled = !messageBased.IO.TerminationCharacterEnabled;
         if (ReadIDN(out string IDN))
         {
             Connected = true;
         }
         else
         {
             Connected = false;
         }
         #endregion
     }
     catch (Exception ex)
     {
         Connected = false;
         Close();
         Windows.Forms.MessageBox.Show(ex.ToString());
     }
 }
Example #14
0
 public override void Connect()
 {
     try
     {
         messageBased = new FormattedIO488();
         ResourceManager grm = new ResourceManager();//TCPIP0::192.168.8.219::inst0::INSTR
         messageBased.IO                = (IMessage)grm.Open("TCPIP0::" + IP + "::inst0::INSTR", AccessMode.NO_LOCK, 2000, "");
         messageBased.IO.Timeout        = 200000;
         messageBased.IO.SendEndEnabled = !messageBased.IO.SendEndEnabled;
         messageBased.IO.TerminationCharacterEnabled = !messageBased.IO.TerminationCharacterEnabled;
         if (ReadIDN(out string IDN))
         {
             Connected = true;
         }
         else
         {
             Connected = false;
         }
     }
     catch (Exception ex)
     {
         Connected = false;
         Close();
         MessageBox.Show(ex.ToString());
     }
 }
Example #15
0
        private static void SetAndTakeSingleFrequencyMeasurement(FormattedIO488 THDMeter, FormattedIO488 SigGen, out string PassFailResult, out double voltage, VoltageFrequencyValue val)
        {
            switch (val.WaveType)
            {
            case Waves.Sine:
                SigGen.WriteString("FU1;", true);
                break;

            case Waves.Square:
                SigGen.WriteString("FU2;", true);
                break;

            case Waves.Triangle:
                SigGen.WriteString("FU3;", true);
                break;

            case Waves.PosRamp:
                SigGen.WriteString("FU4;", true);
                break;
            }

            var FreqStr = string.Format("FR {0:F9} ", val.SetFrequency);

            switch (val.FrequencyUnits)
            {
            case FreqUnits.Hz:
                FreqStr += "HZ;";
                break;

            case FreqUnits.KHz:
                FreqStr += "KH;";
                break;

            case FreqUnits.MHz:
                FreqStr += "MH;";
                break;
            }

            SigGen.WriteString(FreqStr, true);

            SigGen.WriteString("AM 1.0 VO;", true);

            var DCOffsetStr = string.Format("OF {0:F2} VO; AC;", val.SetPoint);

            SigGen.WriteString(DCOffsetStr, true);

            System.Threading.Thread.Sleep(2000);

            THDMeter.WriteString(@":READ?");
            voltage = THDMeter.ReadNumber();

            if ((voltage >= val.MinValue) & (voltage <= val.MaxValue))
            {
                PassFailResult = "Pass";
            }
            else
            {
                PassFailResult = "Fail";
            }
        }
Example #16
0
        public void Init()
        {
            try
            {
                ResourceManager mgr = new ResourceManager();
                // create the formatted io object
                myN1010A = new FormattedIO488();

                //get VISA address from textbox1
                addr = "TCPIP0::localhost::hislip0,4880::INSTR";

                // open IO driver session
                myN1010A.IO = (IMessage)mgr.Open(addr.ToString());

                //set timeout
                myN1010A.IO.Timeout = 20000;

                myN1010A.IO.TerminationCharacter        = 10;
                myN1010A.IO.TerminationCharacterEnabled = true;
            }
            catch (Exception ex)
            {
                throw new Exception($"N1092D初始化失败,{ex.Message}");
            }
        }
Example #17
0
        public string IdentifySignalGenerator(string strVISAAddress)
        {
            string strRet = "NOINSTRUMENT";

            try
            {
                if (ioM == null)
                {
                    ioM = new FormattedIO488();
                    rmM = new ResourceManager();
                }
                ioM.IO         = (IMessage)rmM.Open(strVISAAddress, AccessMode.NO_LOCK, 10000, "");
                ioM.IO.Timeout = 10000;
                Initialized    = true;
                this.SendCommand("*idn?");
                this.Read(ref strRet);
                ioM.IO.Close();
            }
            catch (Exception ex)
            {
                Log(ex.Message);
                Initialized = false;
                //r//eturn false;
            }
            return(strRet);
        }
Example #18
0
        private void InitializeU3606A(string ConnectString)
        {
            bool   devReady = false;
            string idnTemp;

            ioMultiMeterCntrl = new FormattedIO488Class();   // Create the formatted I/O object

            devReady = U3606A_Connect(ConnectString);
            if (devReady == false)
            {
                throw new Exception("Connect to U3606A failed on " + ConnectString);
            }
            else
            {
                ioMultiMeterCntrl.WriteString("*RST", true);              // Reset
                ioMultiMeterCntrl.WriteString("*CLS", true);              // Clear
                ioMultiMeterCntrl.WriteString("*IDN?", true);             // Read ID string
                idnTemp = ioMultiMeterCntrl.ReadString();

                Trace.WriteLine("Connect to U3606A suceess! U3606A IDN: " + idnTemp.ToString());


                ioMultiMeterCntrl.WriteString("SYST:BEEP:STAT OFF", true);

                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.0001", true); // 10mA range with 100uA resolution

                ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.000001", true);  // 10mA range with 1uA resolution
            }
        }
Example #19
0
        private Boolean Connect(String VisaAdd)
        {
            Boolean connected = false;

            if (String.IsNullOrEmpty(VisaAdd))
            {
                MessageBox.Show("IP Address 가 입력되지 않았습니다.");
                return(connected);
            }

            ResourceManager rm = new ResourceManager();

            DestroyInst();
            inst = new FormattedIO488();
            try
            {
                inst.IO = rm.Open(VisaAdd) as IMessage;
                inst.InstrumentBigEndian = false;
                connected = true;
            }
            catch
            {
                DestroyInst();
            }
            return(connected);
        }
Example #20
0
        private void button5_Click(object sender, EventArgs e)
        {
            ResourceManager rm;
            FormattedIO488  myDmm;

            rm    = new ResourceManager();
            myDmm = new FormattedIO488();
            string DutAddr = "USB0::0x2A8D::0x5418::MY57190037::0::INSTR";

            myDmm.IO = (IMessage)rm.Open(DutAddr, AccessMode.NO_LOCK, 2000, "");
            myDmm.IO.Clear();
            ////myDmm.WriteString("SYST:PRES");
            //myDmm.WriteString("INIT:CONT OFF");
            myDmm.WriteString("FETC1:POW:AC?");

            //myDmm.WriteString("MEAS2:POW:AC? -70DBM,1,(@1)");
            string Pow;

            Pow = "gdfdg";
            Pow = Pow + " ";
            Pow = myDmm.ReadString();
            double d;

            d = Conversion.Val(Pow);
            string k;

            k             = "ghg";
            k             = d.ToString("0.##E+0");
            textBox1.Text = k;
        }
        public bool InitializeU3606A(string ConnectString)
        {
            string idnTemp;

            ioMultiMeterCntrl = new FormattedIO488();   // Create the formatted I/O object

            if (ConnectString == "")
            {
                //MessageBox.Show("Error Due to invalid instrument alias: " + ConnectString);
                //return "Error Due to invalid instrument alias: null";
                devReadyStatus = false;
                return(devReadyStatus);
            }

            devReadyStatus = U3606A_Connect(ConnectString);
            if (devReadyStatus)
            {
                ioMultiMeterCntrl.WriteString("*RST", true);              // Reset
                ioMultiMeterCntrl.WriteString("*CLS", true);              // Clear
                ioMultiMeterCntrl.WriteString("*IDN?", true);             // Read ID string
                idnTemp = ioMultiMeterCntrl.ReadString();

                IDN_MultiMeter = idnTemp;

                Trace.WriteLine("Connect to U3606A suceess! U3606A IDN: " + idnTemp.ToString());
                //MessageBox.Show("Connect to U3606A suceess! U3606A IDN: " + idnTemp.ToString());

                ioMultiMeterCntrl.WriteString("SYST:BEEP:STAT OFF", true);

                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.000001", true); // 10mA range with 1uA resolution
                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.0000001", true);  // 10mA range with 0.1uA resolution

                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.1,0.00001", true); // 100mA range with 10uA resolution
                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.1,0.000001", true);  // 100mA range with 1uA resolution

                if (CyBLE_MTK_Application.Properties.Settings.Default.DMM_ConfigCmd.StartsWith("CONF:CURR"))
                {
                    ioMultiMeterCntrl.WriteString(CyBLE_MTK_Application.Properties.Settings.Default.DMM_ConfigCmd, true);
                }
                else
                {
                    ioMultiMeterCntrl.WriteString("CONF:CURR 1,0.0001", true);  // 1A range with 100uA resolution
                }
                //ioMultiMeterCntrl.WriteString("CONF:CURR 1,0.00001", true);  // 1A range with 10uA resolution;

                /*
                 * By my test, "CONF:CURR 1, 0.00001" can't set resolution to 10uA.
                 * But use the following command can't reset resolution to 10uA
                 */
                //ioMultiMeterCntrl.WriteString("CURR:RES 1E-05", true);

                //ioMultiMeterCntrl.WriteString("CONF:CURR 3,0.001", true);  // 3A range with 1mA resolution
                //ioMultiMeterCntrl.WriteString("CONF:CURR 3,0.0001", true);  // 3A range with 100uA resolution; By my test it is not supported

                //return "Connect to U3606A Successfully!!! U3606A IDN: " + idnTemp.ToString();
            }

            return(devReadyStatus);
        }
Example #22
0
        public override FormattedIO488 initializeGPIB(string GPIBAddr)
        {
            FormattedIO488  visaGPIB = new FormattedIO488();
            ResourceManager grm      = new ResourceManager();

            visaGPIB.IO = (IMessage)grm.Open(GPIBAddr);
            return(visaGPIB);
        }
Example #23
0
        public override string Visa_GPIBQuery(FormattedIO488 iO488, string cmdstr)
        {
            string VisaStr = string.Empty;

            iO488.WriteString(cmdstr, true);
            VisaStr = iO488.ReadString();
            return(VisaStr);
        }
 // Constructors
 internal protected SCPIDriver()
 {
     _driver     = new FormattedIO488();
     Initialized = false;
     _closed     = false;
     GPIBAddress = null;
     _timeout    = 0;
 }
Example #25
0
 private void button_end_Click(object sender, EventArgs e)
 {
     System.Runtime.InteropServices.Marshal.ReleaseComObject(INST);
     System.Runtime.InteropServices.Marshal.ReleaseComObject(RM);
     INST = null;
     RM   = null;
     Application.Exit();
 }
Example #26
0
        public DisposeResources(FormattedIO488 dmm)
        {
            if (dmm.IO == null)
            throw new ArgumentNullException("Resource is null.");

              resource = dmm;

              disposed = false;
        }
Example #27
0
 static void instrWrite(FormattedIO488 instr, string cmd)
 {
     if (echoCmd == true)
     {
         Console.WriteLine("{0}", cmd);
     }
     instr.WriteString(cmd + "\n");
     return;
 }
Example #28
0
        public static string GPIBG <T>(T t, string data, string addr) where T : GPIBAbstract
        {
            string         dataResult;
            FormattedIO488 formattedIO488 = t.initializeGPIB(addr);

            dataResult = t.Visa_GPIBQuery(formattedIO488, data);
            t.Visa_GPIBClose(formattedIO488);
            return(dataResult);
        }
Example #29
0
        public Ke37XX InitializeDMM(double timeStep, string channelNumber, double nplc)
        {
            try
            {
                Ke37XX          DMM  = new Ke37XX();
                FormattedIO488  udT  = new FormattedIO488();
                ResourceManager udTR = new ResourceManager();



                if (DMM.Initialized == false)
                {
                    DMM.Initialize("GPIB0::16::INSTR", false, true, "");
                }

                DMM.Channel.Close("2001:2060,6009:6060");

                DMM.Measurement.Nplc      = nplc;// 0.0005, 0.11 for accurate ultrafast;
                DMM.Measurement.AutoDelay = Ke37XXAutoDelayEnum.Ke37XXAutoDelayOff;

                DMM.Measurement.Function = Ke37XXMeasurementFunctionEnum.Ke37XXMeasurementFunctionDCVolts;

                DMM.Measurement.AutoRange = true;

                DMM.Measurement.AutoZero = Ke37XXAutoZeroEnum.Ke37XXAutoZeroOnce;

                DMM.Measurement.Configuration.Create("DCVoltsCfg");

                DMM.Scan.CreateScanList(channelNumber, "DCVoltsCfg");

                udT.IO = (IMessage)udTR.Open("GPIB::16::INSTR", AccessMode.NO_LOCK, 10000, "");

                // udT.WriteString("PERIOD = trigger.timer[1]", true);
                // udT.WriteString("PERIOD.delay = " + timeStep, true);

                // udT.WriteString("PERIOD.stimulus = scan.trigger.EVENT_SCAN_START", true);

                // udT.WriteString("PERIOD.count = 1", true);

                // udT.WriteString("scan.trigger.measure.stimulus = PERIOD.EVENT_ID", true);

                DMM.Scan.Mode = Ke37XXScanModeEnum.Ke37XXScanModeOpenAll;

                DMM.Display.Text = "Initialized";

                return(DMM);
            }
            catch
            {
                MessageBox.Show("DMM Initialization Failure", "Error!", MessageBoxButtons.OK);
            }

            Ke37XX BAD = new Ke37XX();

            return(BAD);
        }
Example #30
0
        private void button1_Click(object sender, EventArgs e)
        {
            var rm   = new ResourceManager();
            var conn = new FormattedIO488();

            conn.IO = (IMessage)rm.Open(textboxAddress.Text);
            conn.IO.Clear();
            conn.WriteString("*IDN?", true);
            MessageBox.Show(conn.ReadString());
        }
        public Control(string address)
        {
            this.obj = new FormattedIO488();
            ResourceManager rMgr = new ResourceManager();

            this.obj.IO = (IMessage)rMgr.Open(srcAddress, AccessMode.NO_LOCK, 2000, null);
            this.obj.IO.Clear();

            Query("*OPC?", true);
            ID = Query("*IDN?", true);
        }
Example #32
0
        public Ke37XX InitializeDMM(double timeStep, string channelNumber, double nplc)
        {
            try
            {
                Ke37XX DMM = new Ke37XX();
                FormattedIO488 udT = new FormattedIO488();
                ResourceManager udTR = new ResourceManager();

                if (DMM.Initialized == false)
                {
                    DMM.Initialize("GPIB0::16::INSTR", false, true, "");
                }

                DMM.Channel.Close("2001:2060,6009:6060");

                DMM.Measurement.Nplc = nplc;// 0.0005, 0.11 for accurate ultrafast;
                DMM.Measurement.AutoDelay = Ke37XXAutoDelayEnum.Ke37XXAutoDelayOff;

                DMM.Measurement.Function = Ke37XXMeasurementFunctionEnum.Ke37XXMeasurementFunctionDCVolts;

                DMM.Measurement.AutoRange = true;

                DMM.Measurement.AutoZero = Ke37XXAutoZeroEnum.Ke37XXAutoZeroOnce;

                DMM.Measurement.Configuration.Create("DCVoltsCfg");

                DMM.Scan.CreateScanList(channelNumber, "DCVoltsCfg");

                udT.IO = (IMessage)udTR.Open("GPIB::16::INSTR", AccessMode.NO_LOCK, 10000, "");

               // udT.WriteString("PERIOD = trigger.timer[1]", true);
               // udT.WriteString("PERIOD.delay = " + timeStep, true);

               // udT.WriteString("PERIOD.stimulus = scan.trigger.EVENT_SCAN_START", true);

               // udT.WriteString("PERIOD.count = 1", true);

               // udT.WriteString("scan.trigger.measure.stimulus = PERIOD.EVENT_ID", true);

                DMM.Scan.Mode = Ke37XXScanModeEnum.Ke37XXScanModeOpenAll;

                DMM.Display.Text = "Initialized";

                return DMM;
            }
            catch
            {
                MessageBox.Show("DMM Initialization Failure", "Error!", MessageBoxButtons.OK);
            }

            Ke37XX BAD = new Ke37XX();

            return BAD;
        }
Example #33
0
        private string InitializeU3606A(string ConnectString)
        {
            bool   devReady = false;
            string idnTemp;

            ioMultiMeterCntrl = new FormattedIO488();   // Create the formatted I/O object

            if (ConnectString == "")
            {
                //MessageBox.Show("Error Due to invalid instrument alias: " + ConnectString);
                return("Error Due to invalid instrument alias: null");
            }

            devReady = U3606A_Connect(ConnectString);
            if (devReady == false)
            {
                //throw new Exception("Connect to U3606A failed on " + ConnectString);
                //MessageBox.Show("Connect to U3606A failed on " + ConnectString);
                return("Connect to U3606A failed on " + ConnectString);
            }
            else
            {
                ioMultiMeterCntrl.WriteString("*RST", true);              // Reset
                ioMultiMeterCntrl.WriteString("*CLS", true);              // Clear
                ioMultiMeterCntrl.WriteString("*IDN?", true);             // Read ID string
                idnTemp = ioMultiMeterCntrl.ReadString();

                Trace.WriteLine("Connect to U3606A suceess! U3606A IDN: " + idnTemp.ToString());
                //MessageBox.Show("Connect to U3606A suceess! U3606A IDN: " + idnTemp.ToString());

                ioMultiMeterCntrl.WriteString("SYST:BEEP:STAT OFF", true);

                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.000001", true); // 10mA range with 1uA resolution
                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.01,0.0000001", true);  // 10mA range with 0.1uA resolution

                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.1,0.00001", true); // 100mA range with 10uA resolution
                //ioMultiMeterCntrl.WriteString("CONF:CURR 0.1,0.000001", true);  // 100mA range with 1uA resolution

                ioMultiMeterCntrl.WriteString("CONF:CURR 1,0.0001", true);  // 1A range with 100uA resolution
                //ioMultiMeterCntrl.WriteString("CONF:CURR 1,0.00001", true);  // 1A range with 10uA resolution;

                /*
                 * By my test, "CONF:CURR 1, 0.00001" can't set resolution to 10uA.
                 * But use the following command can't reset resolution to 10uA
                 */
                //ioMultiMeterCntrl.WriteString("CURR:RES 1E-05", true);

                //ioMultiMeterCntrl.WriteString("CONF:CURR 3,0.001", true);  // 3A range with 1mA resolution
                //ioMultiMeterCntrl.WriteString("CONF:CURR 3,0.0001", true);  // 3A range with 100uA resolution; By my test it is not supported

                return("Connect to U3606A Successfully!!! U3606A IDN: " + idnTemp.ToString());
            }
        }
Example #34
0
 public Agilent()
 {
     try
     {
         //create the formatted io object
         ioDmm = new FormattedIO488Class();
     }
     catch (SystemException ex)
     {
         MessageBox.Show("FormattedIO488Class object creation failure. " + ex.Source + "  " + ex.Message, "GPIBMeasConfig", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public GPIBInstrument(string address)
        {
            //initalize the resources necessary to communicate
            rMgr = new ResourceManager();
            src = new FormattedIO488();

            //set the address
            GPIBAddress = address;

            //open the connection
            src.IO = (IMessage)rMgr.Open(GPIBAddress, AccessMode.NO_LOCK, 2000, null);
            src.IO.Timeout = 2000;
        }
Example #36
0
        public void CheckDMMError(FormattedIO488 myDmm)
        {
            myDmm.WriteString("SYST:ERR?", true);
            string errStr = myDmm.ReadString();
            if (errStr.Contains("No error")) //If no error, then return
                return;
            //If there is an error, read out all of the errors and return them in an exception
            else
            {
                string errStr2 = "";
                do
                {
                    myDmm.WriteString("SYST:ERR?", true);
                    errStr2 = myDmm.ReadString();
                    if (!errStr2.Contains("No error")) errStr = errStr + "\n" + errStr2;

                } while (!errStr2.Contains("No error"));
                throw new Exception("Exception: Encountered system error(s)\n" + errStr);
            }
        }
Example #37
0
        public FormattedIO488 InitializeAgilent6760()
        {
            try
            {

                ResourceManager pS2RM = new ResourceManager();
                FormattedIO488 pS2 = new FormattedIO488();

                pS2.IO = (IMessage)pS2RM.Open("GPIB0::7::INSTR", AccessMode.NO_LOCK, 20000, "");

                return pS2;
            }
            catch
            {
                MessageBox.Show("Error initializing Agilent PS", "Error!", MessageBoxButtons.OK);
            }

            FormattedIO488 BAD = new FormattedIO488();

            return BAD;
        }
Example #38
0
        public FormattedIO488 InitializeAgilent6032()
        {
            try
            {
                // Initialization Logic
                ResourceManager pS1RM = new ResourceManager();
                FormattedIO488 pS1 = new FormattedIO488();

                pS1.IO = (IMessage)pS1RM.Open("GPIB0::5::INSTR", AccessMode.NO_LOCK, 20000, "");

                pS1.IO.WriteString("VSET 24.0\n");

                return pS1;
            }
            catch
            {
                MessageBox.Show("Initialization Error", "Error!", MessageBoxButtons.OK);
            }

            FormattedIO488 BAD = new FormattedIO488();
            return BAD;
        }
Example #39
0
        /// <summary>
        /// Connect to an instrument with a specific Visa Alias.
        /// </summary>
        /// <param name="_VisaAlias">The visa alias of the instrument you are connecting to, set with Keysight IO Library Suite</param>
        public AgilentU3606A(string _VisaAlias)
        {
            try
            {
                rMgr = new ResourceManager();
                src = new FormattedIO488();

                VisaAlias = _VisaAlias;

                tmr1.Elapsed += new System.Timers.ElapsedEventHandler(tmr1_Elapsed);
                tmr1.AutoReset = false; //Allow the timer to expire once.
                tmr1.Interval=1000; //Default to 1 second timer.
                src.IO = (IMessage)rMgr.Open(VisaAlias);
                src.IO.Timeout = 10000;
                Current = new CurrentMeasurements();
                myWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #40
0
        protected virtual void Dispose(bool disposing)
        {
            // If you need thread safety, use a lock around these
            // operations, as well as in your methods that use the resource.
            if (!disposed)
            {
                if (disposing)
                {
                    if (resource != null)
                        resource.IO.Close(); // Dispose();
                    Console.WriteLine("Object disposed.");
                }

                // Indicate that the instance has been disposed.
                resource = null;
                disposed = true;
            }
        }
Example #41
0
 protected Instrument(InstrumentInfo instrInfo)
 {
     mgr = new ResourceManager();
     dmm = new FormattedIO488();
     this.instrInfo = instrInfo;
 }
 /// <summary>
 /// New instance without arguments. Doesn't fill up any parameters or doesn't start any connection.
 /// </summary>
 public MetersModel()
 {
     _rMngr = new ResourceManager();
     _dev = new FormattedIO488();
 }
Example #43
0
        public void InitializeU2651A(string ConnectString)
        {
            bool devReady = false;
            string idnTemp;

            ioSwitchCntrl = new FormattedIO488Class();    // Create the formatted I/O object

            devReady = U2651A_Connect(ConnectString);
            if (devReady == false)
            {
                throw new Exception("Connect to U2651A failed on " + ConnectString);
            }
            else
            {
                ioSwitchCntrl.WriteString("*RST", true);            // Reset
                ioSwitchCntrl.WriteString("*CLS", true);            // Clear
                ioSwitchCntrl.WriteString("*IDN?", true);           // Read ID string
                idnTemp = ioSwitchCntrl.ReadString();               

                OnAgilentMessage(new AgilentMessageEventArgs("Connect to U2651A suceess! U2651A IDN: " + idnTemp.ToString()));
            }
        }
Example #44
0
        public void InitializeU2722A(string ConnectString)
        {
            bool devReady = false;
            string idnTemp;

            ioVoltCntrl = new FormattedIO488Class();   // Create the formatted I/O object

            devReady = U2722A_Connect(ConnectString);
            if (devReady == false)
            {
                throw new Exception("Connect to U2722A failed on " + ConnectString);
            }
            else
            {
                ioVoltCntrl.WriteString("*RST", true);              // Reset
                ioVoltCntrl.WriteString("*CLS", true);              // Clear
                ioVoltCntrl.WriteString("*IDN?", true);             // Read ID string
                idnTemp = ioVoltCntrl.ReadString();                 

                OnAgilentMessage(new AgilentMessageEventArgs("Connect to U2722A suceess! U2722A IDN: " + idnTemp.ToString()));

                //VICD - Set line frequency to 50Hz (This effects measurement accuracy)
                //VICD - Future Dev - Low - Check U2722 for errors at initialization
                //VICD - Future Dev - Med - Add VOLT:LIM command to set a maximum output voltage
                ioVoltCntrl.WriteString("SYST:LFREQ F50HZ", true);
                // Set the inital voltage range to 20V
                ioVoltCntrl.WriteString("VOLT:RANG R20V, (@1)", true);
                ioVoltCntrl.WriteString("VOLT:RANG R20V, (@2)", true);
                ioVoltCntrl.WriteString("VOLT:RANG R20V, (@3)", true);
                // Set the initial output voltage to 0.0V
                ioVoltCntrl.WriteString("VOLT 0, (@1)", true);
                ioVoltCntrl.WriteString("VOLT 0, (@2)", true);
                ioVoltCntrl.WriteString("VOLT 0, (@3)", true);
                // VICD - Set the current ranges
                ioVoltCntrl.WriteString("CURR:RANG " + CURRENT_RANGE_CH1 + " , (@1)", true);
                ioVoltCntrl.WriteString("CURR:RANG " + CURRENT_RANGE_CH2 + " , (@2)", true);
                ioVoltCntrl.WriteString("CURR:RANG " + CURRENT_RANGE_CH3 + " , (@3)", true);
                // VICD - Set the current limits
                ioVoltCntrl.WriteString("CURR:LIM " + CURRENT_LIMIT_CH1 + " , (@1)", true);
                ioVoltCntrl.WriteString("CURR:LIM " + CURRENT_LIMIT_CH2 + " , (@2)", true);
                ioVoltCntrl.WriteString("CURR:LIM " + CURRENT_LIMIT_CH3 + " , (@3)", true);
            }
        }
Example #45
0
 public void switchPowerOnOff(FormattedIO488 PS1, int chanNum, bool powerFlag)
 {
     // Switches power On/Off
     if (powerFlag == true) // power is already on so switch off
     {
         PS1.IO.WriteString("OUTP OFF,(@" + chanNum.ToString() + ")\n");
     }
     else // power is off so switch on
     {
         PS1.IO.WriteString("OUTP ON,(@" + chanNum.ToString() + ")\n");
     }
 }
Example #46
0
        public bool switchRelay(FormattedIO488 ps2, bool flag)
        {
            if (flag == false)
            {
                ps2.IO.WriteString("VOLT 9.0,(@2)\n");
                ps2.IO.WriteString("OUTP ON,(@2)\n");
                flag = true;

                return flag;
            }

            if (flag == true)
            {
                ps2.IO.WriteString("OUTP OFF,(@2)\n");
                flag = false;

                return flag;
            }

            return flag;
        }
Example #47
0
        public void warmingProfile(FormattedIO488 ps1, FormattedIO488 ps2, Ke37XX DMM)
        {
            int iscanCount = 50000;

            double[] dTdt = new double[iscanCount + 1];
            double[] time = new double[iscanCount + 1];
            double[] temp = new double[iscanCount + 1];
            double[] temp2 = new double[iscanCount + 1];
            double[] timeDiff = new double[iscanCount + 1];
            double[] data = new double[iscanCount + 1];
            double[] readings = new double[iscanCount + 1];
            double[] tErr = new double[iscanCount + 1];
            double[] tErrInt = new double[iscanCount + 1];
            double amps;

            string sbufferName = "Mybuffer";
            DMM.Measurement.Buffer.Clear(sbufferName);

            DMM.Display.Clear();

            DMM.Display.Text = "Scanning...";

            DMM.Scan.ScanCount = 1;

            DMM.Measurement.Buffer.Create(sbufferName, 50000);

            DMM.System.DirectIO.IO.Timeout = 10000;

            DMM.Timer.Reset();

            int i = 0;

            Stopwatch debugTimer = new Stopwatch();

            while (ExperimentReadyFlag == false)
            {

                time[i] = DMM.Timer.Measure();

                DMM.Scan.Execute(sbufferName);

                readings = DMM.Measurement.Buffer.ReadingData.GetAllFormattedReadings(sbufferName);

                temp[i] = getTemp(readings[0]);

                tErr[i] = setTemp - temp[i];

                if (i > 2)
                    tErrInt[i] = tErrInt[i - 1] + tErr[i];

               // debugTimer.Start();

                if (i > 5)
                {
                    int kk = i - 2;

                    timeDiff[i] = time[i] - time[i - 1];

                    dTdt[i] = (8 * (temp[kk + 1] - temp[kk - 1]) + (temp[kk - 2] - temp[kk + 2])) / (12 * (timeDiff[i]));
                }
                else
                {
                    dTdt[i] = 0;
                }

                DMM.Display.Clear();

                DMM.Display.Text = "Temp: " + String.Format("{0:0.000}", temp[i]) + " C";

                Debug.WriteLine("Temp: " + temp[i]);

                amps = 0.45 * tErr[i] + 0.0015 * tErrInt[i];

                Debug.WriteLine(tErr[i].ToString() + "         " + tErrInt[i].ToString());

                if (amps > 4)
                    amps = 4;

                if (amps < 0)
                    amps = 0;

                ps1.IO.WriteString("ISET " + amps + "\n");

                i++;

               // debugTimer.Stop();

              //  Debug.WriteLine(debugTimer.ElapsedMilliseconds.ToString());

                //debugTimer.Reset();

            }

            DMM.Display.Clear();

            DMM.Display.Text = "Finished!";
        }
Example #48
0
        public void importedCurrentProfileNoMeasurement(double[] ampArrayD, Ke37XX DMM, Hardware basicSetup, FormattedIO488 pS1, FormattedIO488 pS2)
        {
            double[] timeArray = TimeArray.ToArray();

            timeStepArray = new double[timeArray.Length];

            timeStepArrayInt = new int[timeArray.Length];

            for (int i = 0; i <= timeArray.Length - 2; i++)
            {
                timeStepArray[i] = -1000*(timeArray[i] - timeArray[i + 1]);

                timeStepArray[i] = Math.Round(timeStepArray[i], 0);

                timeStepArrayInt[i] = (int)timeStepArray[i] - 4;

                if (checkBox4.Checked == true)
                {
                    timeStepArrayInt[i] = (int)(1000 * const_timeStep) - 4;
                    Debug.WriteLine(timeStepArray[i].ToString());
                }

            }

            int iscanCount = SampleNumberDMMHalf + 100;
            int ibufferSize = iscanCount;

            double amps = constantA;

            double[] dTdt = new double[SampleNumberDMMHalf + 1];
            double[] time = new double[SampleNumberDMMHalf + 1];
            double[] temp = new double[SampleNumberDMMHalf + 1];
            double[] temp2 = new double[SampleNumberDMMHalf + 1];
            double[] timeDiff = new double[SampleNumberDMMHalf + 1];
            double[] data = new double[SampleNumberDMMHalf + 1];
            double[] readings = new double[SampleNumberDMMHalf + 1];
            double[] ampstoWrite = new double[SampleNumberDMMHalf + 1];

            string sbufferName = "Mybuffer";

            DMM.Display.Clear();

            DMM.Display.Text = "Scanning...";

            DMM.Scan.ScanCount = SampleNumberDMMHalf;

            DMM.Measurement.Buffer.Create(sbufferName, ibufferSize);

            DMM.System.DirectIO.IO.Timeout = 10000;

            DMM.Timer.Reset();

            DMM.Scan.ExecuteBackground(sbufferName);

            for (int i = 0; i <= ampArrayD.Length-1; i++)
            {
                Thread.Sleep(timeStepArrayInt[i]);

                pS1.IO.WriteString("ISET " + ampArrayD[i] + "\n");

                if (relayFlag == false & readRelayArray[i] == 1)
                {
                    relayFlag = switchRelay(pS2, relayFlag);
                }

                if (relayFlag == true & readRelayArray[i] == 0)
                {
                    relayFlag = switchRelay(pS2, relayFlag);
                }

            }

            readings = DMM.Measurement.Buffer.ReadingData.GetAllFormattedReadings(sbufferName);

            double[] timereadings = DMM.Measurement.Buffer.TimeStampData.GetAllRelativeTimeStamps(sbufferName);

            for (int i = 0; i <= readings.Length - 1; i++)
            {
                temp[i] = getTemp(readings[i]);

            }

            for (int j = 0; j <= readings.Length - 1; j++)
            {
                toWriteAmp[j] = 0;
                toWriteTemp[j] = temp[j];
                toWriteTime[j] = timereadings[j];
                toWriteTemp2[j] = 0;
            }
            pS1.IO.WriteString("ISET 2.0\n");

            //switchRelay(pS2, relayFlag); // Turns relay back off

            DMM.Display.Clear();

            DMM.Display.Text = "Finished!";

            //writeFile(temp, time, dTdt, iscanCount, ampstoWrite); // Writes data to .csv file
            newWriteFile();

            Cleanup();

            switchRelay(pS2, relayFlag);
        }