0

Unisource 4100 GPIB DMM から電圧測定値を読み取ろうとしています。コマンド「*RST」および「*IDN?」で適切な応答が得られるので、デバイスに接続できることはわかっていますが、「SYST:ERR?」などの他のコマンドでは応答が得られません。または「CONF:VOLT:DC 1000, 0.001」。試行中のコードを Agilent 34410A でテストしたところ、必要な応答が得られましたが、Unisource 4100 では得られませんでした。NI GPIB-USB-HS コントローラを使用してインターフェースをとっています。以下のコードを含めました。SCPI コマンドは、すべての GPIB インターフェースで機能するわけではありませんか? Unisource 4100 から応答を引き出すには、どのような変更を加える必要がありますか?

参照用にいくつかのコードを含めました。

using System;
using System.Collections.Generic;
using System.Threading;
using System.Text;
using Ivi.Visa.Interop;


namespace CsharpExample
{
    class VoltageExample
    {

    static void Main(string[] args)
    {

        VoltageExample DmmClass = new VoltageExample(); //Create an instance of this class so we can call functions from Main


            Ivi.Visa.Interop.ResourceManager rm = new Ivi.Visa.Interop.ResourceManager(); //Open up a new resource manager
            Ivi.Visa.Interop.FormattedIO488 myDmm = new Ivi.Visa.Interop.FormattedIO488(); //Open a new Formatted IO 488 session 

        try
        {
            string DutAddr = "GPIB0::12::INSTR"; //String for GPIB

            myDmm.IO = (IMessage)rm.Open(DutAddr, AccessMode.NO_LOCK, 10000, ""); //Open up a handle to the DMM with a 2 second timeout
            //myDmm.IO.Timeout = 20000;


            myDmm.IO.Clear(); //Send a device clear first
            myDmm.WriteString("*RST", true); //Reset the device
            myDmm.WriteString("*IDN?", true); //Get the IDN string                
            string IDN = myDmm.ReadString();
            Console.WriteLine(IDN); //report the DMM's identity

            myDmm.WriteString("*TST?", true); //Get the IDN string 
            Thread.Sleep(5000);             
            string TST = myDmm.ReadString();
            Console.WriteLine(TST); //report the DMM's identity

            myDmm.WriteString("SYST:ERR?", true); //Get the IDN string    
            string ERR = myDmm.ReadString();
            Console.WriteLine(ERR); //report the DMM's identity

            myDmm.WriteString("CONF:VOLT:DC 1000, 0.001", true);
            DateTime time = DateTime.Now;  //Timer to measure the time difference to get all the readings
            TimeSpan diff;
            Console.WriteLine("Measurement in Volts");
            for(int i = 0; i<10; i++){
                //Configure for DCV 100V range, 100uV resolution
                myDmm.WriteString("READ?", true);
                String DCVResult = myDmm.ReadString();
                Console.WriteLine("DCV Reading = " + DCVResult); //report the DCV reading
                DmmClass.CheckDMMError(myDmm); //Check if the DMM has any errors
                Thread.Sleep(1000);
                diff = DateTime.Now.Subtract(time);
                //diff = DateTime.Now.Subtract(time.AddSeconds(1).AddMilliseconds(20));
                Console.WriteLine("\t\t\t" + diff);
            }

            myDmm.WriteString("CONF:RES 100, MAX", true);
            Console.WriteLine("Measurement in Ohms");
            for (int i = 0; i < 10; i++)
            {

                //Configure for res 1000 Ohm range, 100uV resolution
                myDmm.WriteString("READ?", true);
                String OHMResult = myDmm.ReadString();
                Console.WriteLine("Resistance Measurement = " + OHMResult); //report the DCV reading
                DmmClass.CheckDMMError(myDmm); //Check if the DMM has any errors
                Thread.Sleep(500);
            }


        }
        catch (Exception e)
        {
            Console.WriteLine("Error occured: " + e.Message);
        }
        finally
        {
            //Close out your resources
            try { myDmm.IO.Close(); }
            catch{}
            try{ System.Runtime.InteropServices.Marshal.ReleaseComObject(myDmm);}
            catch {}
            try{
            System.Runtime.InteropServices.Marshal.ReleaseComObject(rm);
            }
            catch {}
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();

        }

    }
4

0 に答える 0