C#编程Unisource 4100 GPIB DMM

C#编程Unisource 4100 GPIB DMM,c#,visa,gpib,C#,Visa,Gpib,我正在尝试从我的Unisource 4100 GPIB DMM读取电压测量值。我知道我可以连接到设备,因为我可以通过命令“*RST”和“*IDN”获得适当的响应,但是我无法通过其他命令(如“SYST:ERR”或“CONF:VOLT:DC 1000,0.001”)获得任何响应。我已经在安捷伦34410A上测试了我正在尝试的代码,并设法得到了我想要的响应,但没有使用Unisource 4100。我正在使用NI GPIB-USB-HS控制器与进行接口。我已经包括了下面的代码。SCPI命令是否不适用于所

我正在尝试从我的Unisource 4100 GPIB DMM读取电压测量值。我知道我可以连接到设备,因为我可以通过命令“*RST”和“*IDN”获得适当的响应,但是我无法通过其他命令(如“SYST:ERR”或“CONF:VOLT:DC 1000,0.001”)获得任何响应。我已经在安捷伦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();

        }

    }
使用系统;
使用System.Collections.Generic;
使用系统线程;
使用系统文本;
使用Ivi.Visa.Interop;
名称空间csharp示例
{
类电压示例
{
静态void Main(字符串[]参数)
{
VoltageExample DmmClass=new VoltageExample();//创建此类的实例,以便我们可以从Main调用函数
Ivi.Visa.Interop.ResourceManager rm=new Ivi.Visa.Interop.ResourceManager();//打开一个新的资源管理器
Ivi.Visa.Interop.FormattedIO488 myDmm=新建Ivi.Visa.Interop.FormattedIO488();//打开新的格式化IO 488会话
尝试
{
string DutAddr=“GPIB0::12::INSTR”;//用于GPIB的字符串
myDmm.IO=(IMessage)rm.Open(DutAddr,AccessMode.NO_LOCK,10000,“”;//打开DMM的句柄,超时2秒
//myDmm.IO.Timeout=20000;
myDmm.IO.Clear();//首先发送设备清除
myDmm.WriteString(“*RST”,true);//重置设备
myDmm.WriteString(“*IDN?”,true);//获取IDN字符串
string IDN=myDmm.ReadString();
Console.WriteLine(IDN);//报告DMM的身份
myDmm.WriteString(“*TST?”,true);//获取IDN字符串
睡眠(5000);
string TST=myDmm.ReadString();
Console.WriteLine(TST);//报告DMM的身份
myDmm.WriteString(“SYST:ERR?”,true);//获取IDN字符串
string ERR=myDmm.ReadString();
Console.WriteLine(ERR);//报告DMM的身份
myDmm.WriteString(“CONF:VOLT:DC 1000,0.001”,true);
DateTime time=DateTime.Now;//用于测量时间差以获取所有读数的计时器
时间跨度差异;
控制台写入线(“以伏特为单位的测量”);

for(int i=0;并非所有GPIB工具都支持SCPI命令。事实上,很多工具都不支持(即使它们响应*IDN?或*RST).作为第一个呼叫端口,我会翻出手册-我快速搜索了一下google,但找不到UniSource产品的太多内容-DVM有没有可以参考的手册?我找不到。我发现万用表放在旁边,决定让它工作。我花了一些时间四处寻找用户手册以及其他Unisour产品ce手册,但是我没有太多的luckHm。如果没有手册,那么很难说你的代码有什么问题。仪器很可能与SCPI不兼容。即使兼容,它也可能不会响应所有命令。或者,它可能像不使用正确的终端c一样平凡人物