完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
附件是两个执行相同操作的程序。
一个使用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.Collections.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(“TARM 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(); } } } 附件
|
|
相关推荐
1个回答
|
|
计划2:使用系统;
使用System.Collections.Generic; 使用System.Linq; 使用System.Text; namespace _3458A_DINT_Visa32cs {class Program {static void Main(string [] args){int RM; int DMM; string id; byte [] byteid = new byte [100]; visa32.viOpenDefaultRM(out RM); visa32.viOpen(RM,“GPIB0 :: 22 :: INSTR”,visa32.VI_NULL,20000,out DMM); visa32.viPrintf(DMM,“END ALWAYS n”); //设置终止线终止,这样您就可以从仪器visa32.viPrintf(DMM,“ID? n”)中检索数据; //识别仪器并打印到屏幕visa32.viScanf(DMM,“%t”,byteid); id = Encoding.ASCII.GetString(byteid); Console.WriteLine(“仪器标识字符串:”+ id); //关闭内存,直接通过总线visa32.viPrintf(DMM,“MEM OFF n”)获取数据; //指定DATA FORMAT visa32.viPrintf(DMM,“MFORMAT DINT n”); visa32.viPrintf(DMM,“OFORMAT DINT n”); //配置仪器visa32.viPrintf(DMM,“DCV 10 n”); visa32.viPrintf(DMM,“TRIG AUTO n”); visa32.viPrintf(DMM,“NRDGS 5 n”); //将每个触发器的读数设置为所需值visa32.viPrintf(DMM,“NPLC 1 n”); //设置所需数量的NPLC,增加更高的准确度visa32.viPrintf(DMM,“ISCALE? n”); //获取比例值,以便您可以转换DINT数据double scale = 0; string scalestring; visa32.viRead(DMM,out scalestring,100); scale = double.Parse(scalestring); //将字符串结果转换为double visa32.viPrintf(DMM,“END ON n”); //必须使用带有多个读数的END ON visa32.viPrintf(DMM,“TARM SGL n”); //触发仪器1次然后变为保持字节[] rawdata = new byte [22]; // size应至少为nrdgs * 4 +2 double [] scaleddata = new double [5]; // size应至少为nrdgs //读取DINT数据visa32.viScanf(DMM,“%5ly”,rawdata); // nrdgs * 4 + 2 //转换DINT读数据并用ISCALE缩放然后输出到屏幕(int i = 0; i {scaleddata = System.BitConverter.ToInt32(rawdata,(i * 4) )* scale; //通过缩放因子转换4字节读数Console.WriteLine(scaleddata );} Console.WriteLine(“Measurement Finished n”); Console.WriteLine(“按任意键关闭......” ); Console.ReadLine(); visa32.viClose(DMM); visa32.viClose(RM);}}} 以上来自于谷歌翻译 以下为原文 Program 2: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _3458A_DINT_Visa32cs { class Program { static void Main(string[] args) { int RM; int DMM; string id; byte[] byteid = new byte[100]; visa32.viOpenDefaultRM(out RM); visa32.viOpen(RM, "GPIB0::22::INSTR", visa32.VI_NULL, 20000, out DMM); visa32.viPrintf(DMM,"END ALWAYSn"); //Set endline termination so you can retrieve data from instrument visa32.viPrintf(DMM,"ID?n"); // Identify Instrument and print to screen visa32.viScanf(DMM,"%t",byteid); id = Encoding.ASCII.GetString(byteid); Console.WriteLine("Instrument Identity String: " + id); //Turn off memory, take data directly over bus visa32.viPrintf(DMM,"MEM OFFn"); // Specify DATA FORMAT visa32.viPrintf(DMM,"MFORMAT DINTn"); visa32.viPrintf(DMM,"OFORMAT DINTn"); //Configure the instrument visa32.viPrintf(DMM,"DCV 10n"); visa32.viPrintf(DMM,"TRIG AUTOn"); visa32.viPrintf(DMM,"NRDGS 5n"); //Set number of readings per trigger to desired value visa32.viPrintf(DMM,"NPLC 1n"); //Set desired number of NPLCs, increase for greater accuracy visa32.viPrintf(DMM,"ISCALE?n"); //Get scale value so you can convert DINT data double scale = 0; string scalestring; visa32.viRead(DMM, out scalestring,100); scale = double.Parse(scalestring);//Convert string result to double visa32.viPrintf(DMM,"END ONn"); //Have to use END ON with multiple readings visa32.viPrintf(DMM,"TARM SGLn"); //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 visa32.viScanf(DMM,"%5ly", rawdata); // nrdgs*4 + 2 //Convert the DINT reading data and scale it with ISCALE then output to screen for (int i = 0; i < 5; i++) { scaleddata = System.BitConverter.ToInt32(rawdata, (i*4)) * scale; //converting 4 byte readings by scaling factor Console.WriteLine(scaleddata); } Console.WriteLine("Measurement Finishedn"); Console.WriteLine("Press any key to close..."); Console.ReadLine(); visa32.viClose(DMM); visa32.viClose(RM); } } } 附件
|
|
|
|
只有小组成员才能发言,加入小组>>
1283 浏览 0 评论
2371 浏览 1 评论
2189 浏览 1 评论
2062 浏览 5 评论
2946 浏览 3 评论
1104浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
751浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
922浏览 0评论
1284浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 20:59 , Processed in 1.361929 second(s), Total 76, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号