示例#1
0
        public override double ReadResistance()
        {
            lock (m_lock)
            {
                try
                {
                    double data;
                    //Configure the meter to 10k ohm range and fast mode (least resolution)
                    //driver34405.Resistance.Configure(10E+3, Agilent34405ResolutionEnum.Agilent34405ResolutionLeast);

                    if (m_config != LAST_CONFIG.RESISTORS)
                    {
                        m_scpi.SendScpi(":CONFigure:RESistance AUTO,MAX");
                        m_config = LAST_CONFIG.RESISTORS;
                    }



                    data = double.Parse(m_scpi.QueryScpi(":READ?"));
                    Console.WriteLine("2-Wire Resistance measurement: {0} Ohms", data);

                    return(data);
                }
                catch (Exception err)
                {
                    throw (new SystemException(err.Message));
                }
            }
        }
示例#2
0
        public override double ReadDCCurrent(bool trigger, double range, int avg = 1)
        {
            lock (m_lock)
            {
                try
                {
                    double data = 0;

                    //Configure the meter to 100mA range and fast mode (least resolution)
                    //driver34405.Current.DCCurrent.Configure(100E-3, Agilent34405ResolutionEnum.Agilent34405ResolutionLeast);

                    if (m_config != LAST_CONFIG.DC_CURRENT)
                    {
                        m_scpi.SendScpi(":CONFigure:CURRent:DC AUTO, MAX");
                        m_config = LAST_CONFIG.DC_CURRENT;
                    }


                    m_scpi.SendScpi("INIT");

                    if (trigger == true)
                    {
                        //Measure  10 times

                        int ctr;
                        for (ctr = 0; ctr < avg; ctr++)
                        {
                            m_scpi.SendScpi(":INITiate:IMMediate");
                            Thread.Sleep(100);
                            //Init trigger
                            data += Fetch();
                            Console.WriteLine("{0} AC Current", data);
                        }
                        return(data / ctr);
                    }
                    else
                    {
                        data = double.Parse(m_scpi.QueryScpi(":READ?"));
                        Console.WriteLine("DC Current measurement: {0} Amps", data);
                        return(data);
                    }
                }
                catch (Exception err)
                {
                    throw (new SystemException(err.Message));
                }
            }
        }
示例#3
0
        public override double ReadDCVoltage(bool trigger, int avg = 1)
        {
            lock (m_lock)
            {
                try
                {
                    if (m_config != LAST_CONFIG.DC_VOLTAGE)
                    {
                        m_scpi.SendScpi(":CONFigure:VOLTage:DC AUTO,MAX");
                        m_config = LAST_CONFIG.DC_VOLTAGE;
                    }
                    m_scpi.SendScpi("INIT");


                    double data = 0;
                    if (trigger == true)
                    {
                        int ctr;
                        for (ctr = 0; ctr < avg; ctr++)
                        {
                            m_scpi.SendScpi(":INITiate:IMMediate");
                            Thread.Sleep(10);
                            data += Fetch();
                        }
                        return(data / ctr);
                    }
                    else
                    {
                        string res = m_scpi.QueryScpi(":READ?");
                        Console.WriteLine("Raw DC Volts measurement: {0} Volts", res);
                        return(double.Parse(res));
                    }
                }
                catch (Exception err)
                {
                    throw (new SystemException(err.Message));
                }
            }
        }