附件是两个执行相同操作的程序。
一个使用Visa Com用C#编写,第二个用C#和Visa编写。
该程序的目的是使用数据类型DINT获取一些读数。
你为什么要使用DINT?
这是使用全部8.5位分辨率删除数据的最快方法。
从用户手册第135页开始:•对于DCV数字化,当积分时间为1.4μs时,应使用SINT存储器/输出格式。
当积分时间>1.4μs时,请使用DINT存储器/输出格式。
(这些格式将在第4章中详细讨论。)为了尽可能快地将样本传输到读数存储器和/或控制器,您可以使用SINT输出/存储器格式进行高达10.8u s的积分时间。
然而,当积分时间> 1.4 us时,A / D转换器产生的分辨率比SINT格式所容许的更多(最低有效位被丢弃)。
每当使用积分时间> 10.8u s的SINT输出/存储器格式时,万用表必须转换来自A / D转换器的数据,并且不能保持高速模式。
当积分时间> 10.8u s时,应使用DINT内存/输出格式(与高速模式兼容)。
计划1:使用系统;
使用System.Collec
tions.Generic;
使用System.Text;
使用Ivi.Visa.Interop;
namespace DINT_3458A {class Program {public static void Main(){StringBuilder strDataCommand = new StringBuilder();
string instAddress =“GPIB0 :: 22 :: INSTR”;
ResourceManagerClass oRm = new ResourceManagerClass();
FormattedIO488Class oFio = new FormattedIO488Class();
//打开仪器会话。
oFio.IO =(IMessage)oRm.Open(instAddress,AccessMode.NO_LOCK,2000,“”);
oFio.IO.Timeout = 10000;
//将超时设置为10秒//重置仪器oFio.WriteString(“RESET”,true);
//查询Idendity字符串和报告。
oFio.WriteString(“END ALWAYS”,true);
//设置endline终止,以便您可以从仪器oFio.WriteString(“ID?”,true)中检索数据;
//识别仪器并打印到屏幕字符串strResult = oFio.ReadString();
Console.WriteLine(“Instrument Identity String:”+ strResult);
//关闭内存,直接通过总线oFio.WriteString(“MEM OFF”,true)获取数据;
//指定DATA FORMAT oFio.WriteString(“MFORMAT DINT”,true);
oFio.WriteString(“OFORMAT DINT”,true);
//配置仪器oFio.WriteString(“DCV 10”,true);
oFio.WriteString(“TRIG AUTO”,true);
oFio.WriteString(“NRDGS 5”,true);
//将每个触发器的读数设置为所需的值oFio.WriteString(“NPLC 1”,true);
//设置所需数量的NPLC,增加更高精度oFio.WriteString(“ISCALE?”,true);
//获取比例值,以便您可以转换DINT数据double scale = 0;
string scalestring;
scalestring = oFio.ReadString();
scale = double.Parse(scalestring); //将字符串结果转换为double oFio.WriteString(“END ON”,true);
//必须使用带有多个读数的END ON oFio.WriteString(“T
ARM SGL”,true);
//触发仪器1次然后变为保持字节[] rawdata = new byte [22];
// size应至少为nrdgs * 4 +2 double [] scaleddata = new double [5];
// size应至少为nrdgs //读取DINT数据rawdata = oFio.IO.Read(22);
// nrdgs * 4 + 2 byte [] tempBuffer = new byte [4];
//转换DINT读数据并用ISCALE缩放然后输出到屏幕(int i = 0; i {tempBuffer [3] = rawdata [i * 4]; tempBuffer [2] = rawdata [i * 4 + 1]
; tempBuffer [1] = rawdata [i * 4 + 2]; tempBuffer [0] = rawdata [i * 4 + 3]; scaleddata
= System.BitConverter.ToInt32(tempBuffer,0)* scale; Console.WriteLine
(scaleddata );} Console.WriteLine(“Measurement Finished n”); Console.WriteLine(“按任意键关闭......”); Console.ReadLine(); oFio.IO.Close();
}}}
以上来自于谷歌翻译
以下为原文
Attached are two programs that do the same thing. One is written in C# using Visa Com, the second using C# and Visa.
The purpose of this program is to take a handful of readings using the data type DINT. Why would you want to use DINT? It is the fastest method for removing data with all 8.5 digits of resolution. From the user's manual page 135:
• For DCV digitizing, you should use the SINT memory/output format when
the integration time is 1.4μs. Use the DINT memory/output format when
the integration time is >1.4μs. (These formats are discussed in detail in
Chapter 4.)
To achieve the fastest possible transfer of samples to reading memory and/or the
controller, you can use the SINT output/memory format for integration times up to
10.8u s. However when the integration time is >1.4 us, the A/D converter is
producing more bits of resolution than can be accommodated by the SINT format
(the least significant bit(s) are discarded). Whenever using the SINT
output/memory format with integration times >10.8u s, the multimeter must
convert the data coming from the A/D converter and cannot maintain the
high-speed mode. You should use the DINT memory/output format (which is
compatible with the high-speed mode) when the integration time is >10.8u s.
Program 1:
using System;
using System.Collections.Generic;
using System.Text;
using Ivi.Visa.Interop;
namespace DINT_3458A
{
class Program
{
public static void Main()
{
StringBuilder strDataCommand = new StringBuilder();
string instAddress = "GPIB0::22::INSTR";
ResourceManagerClass oRm = new ResourceManagerClass();
FormattedIO488Class oFio = new FormattedIO488Class();
//Open session for instrument.
oFio.IO = (IMessage)oRm.Open(instAddress, AccessMode.NO_LOCK, 2000, "");
oFio.IO.Timeout = 10000; //set timeout to 10 seconds
//Reset instrument
oFio.WriteString("RESET", true);
//Query Idendity string and report.
oFio.WriteString("END ALWAYS", true); //Set endline termination so you can retrieve data from instrument
oFio.WriteString("ID?", true); // Identify Instrument and print to screen
string strResult = oFio.ReadString();
Console.WriteLine("Instrument Identity String: " + strResult);
//Turn off memory, take data directly over bus
oFio.WriteString("MEM OFF", true);
// Specify DATA FORMAT
oFio.WriteString("MFORMAT DINT", true);
oFio.WriteString("OFORMAT DINT", true);
//Configure the instrument
oFio.WriteString("DCV 10", true);
oFio.WriteString("TRIG AUTO", true);
oFio.WriteString("NRDGS 5", true); //Set number of readings per trigger to desired value
oFio.WriteString("NPLC 1", true); //Set desired number of NPLCs, increase for greater accuracy
oFio.WriteString("ISCALE?", true); //Get scale value so you can convert DINT data
double scale = 0;
string scalestring;
scalestring = oFio.ReadString();
scale = double.Parse(scalestring);//Convert string result to double
oFio.WriteString("END ON", true); //Have to use END ON with multiple readings
oFio.WriteString("TARM SGL", true); //Triggers the instrument 1 time then becomes hold
byte[] rawdata = new byte[22]; //size should be at least nrdgs*4 +2
double[] scaleddata = new double[5]; //size should be at least nrdgs
//Read the DINT data
rawdata = oFio.IO.Read(22); //nrdgs*4 + 2
byte[] tempBuffer = new byte[4];
//Convert the DINT reading data and scale it with ISCALE then output to screen
for (int i = 0; i < 5; i++)
{
tempBuffer[3] = rawdata[i * 4];
tempBuffer[2] = rawdata[i * 4 + 1];
tempBuffer[1] = rawdata[i * 4 + 2];
tempBuffer[0] = rawdata[i * 4 + 3];
scaleddata = System.BitConverter.ToInt32(tempBuffer, 0) * scale;
Console.WriteLine(scaleddata);
}
Console.WriteLine("Measurement Finishedn");
Console.WriteLine("Press any key to close...");
Console.ReadLine();
oFio.IO.Close();
}
}
}
附件