完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我们正在使用3458A数字万用表,使用VISA远程编程(C ++)来控制GPIB。
手册指出可以通过发送“TEST”来运行自我文本。 它还指定完成大约需要50秒。 什么是监控完成操作的好方法? 一个编程示例将是方便的.Brian 以上来自于谷歌翻译 以下为原文 We're using a 3458A DMM, programmed remotely (C++) using VISA to control through the GPIB. The manual states that self-text can be run by sending "TEST". It also specifies that it takes approximately 50 seconds to complete. What is a good way to monitor the operation for completion? A programming example would be handy. Brian |
|
相关推荐
10个回答
|
|
我的C ++有点生疏,但你需要做的是相当于以前的串行轮询(SPOLL),现在在C ++中执行该命令的命令是viReadSTB。如果你在3458A手册中查找SPOLL你可以看到
如果使用viReadSTB命令,将获得的结果。 我会试着为你举一个例子,但这可能需要一段时间,所以我想我现在会分享这个。 我会尽快发布一个例子。 如果你在签证文件中查找viReadSTB,你可以找到更多。在我的3458A程序中,我通常命名我的vi,Inst_dmm。 我计划命名我将存储结果SPOLL的变量。 因此,我的C ++代码的一小段内容很可能如下所示:short SPOLL; viClear(Inst_dmm); viPrintf(Inst_dmm, “复位 n”); viPrintf(Inst_dmm,“结束总是 n”); viPrintf(Inst_dmm,“TEST n”); //等待45秒,我不记得在C ++中等待你的C ++程序员的正确上下文 ll可能会回想一下如何正确执行此操作(Inst_dmm,& SPOLL);然后检查viReadSTB的结果是否报告3458A的某种IF语句已完成测试。希望这有助于您入门。 你以前用C ++编写过3458A程序吗? 以上来自于谷歌翻译 以下为原文 My C++ is a bit rusty, but what you need to do is the equivalent of what used to be a serial poll (SPOLL), the command to do that now in C++ is viReadSTB. If you look up SPOLL in 3458A manual you can see the results you will get if you use the viReadSTB command. I'll try to throw an example together for you but that may take awhile so I thought I would share this now. I'll try and post an example soon. If you look up the viReadSTB in the visa documentation you can find out a little more. In my 3458A programs I generally name my vi, Inst_dmm. I plan on naming the variable that I will store my result SPOLL. So a small snippet of my C++ code will most likely look like this: short SPOLL; viClear(Inst_dmm); viPrintf(Inst_dmm,"resetn"); viPrintf(Inst_dmm,"end alwaysn"); viPrintf(Inst_dmm,"TESTn"); //wait 45 seconds, I don't remember the correct context to do a wait in C++ if your a C++ programmer you'll probably recall how to do this properly viReadSTB(Inst_dmm, &SPOLL); Then some sort of IF statement that checks if the result of the viReadSTB is reporting the 3458A has completed the test. Hopefully that will help get you started. Have you ever written a 3458A program in C++ before? |
|
|
|
好的,看起来很不错。
看起来你可以使用机顶盒? 查询做类似的事情。这是我工作的第一个3458A程序,但是我已经完成了其他的VISA设备。在C ++中没有标准的“等待”,它总是依赖于实现。 在Windows中,它是:Sleep(t); // t ==以毫秒为单位的时间感谢信息,Brian 以上来自于谷歌翻译 以下为原文 Ok, that looks pretty good. Looks like you can use the STB? query to do something similar. This is first 3458A program I've worked on, but I have done other VISA devices. There is no standard "wait" in C++, it's always implementation-dependent. In Windows, it is: Sleep(t); // t == time in milliseconds Thanks for the information, Brian |
|
|
|
感谢您的信息.3458A是在SCPI之前开发的STB吗?
不会工作,你必须使用我在上一篇文章中提到的那个命令。 以上来自于谷歌翻译 以下为原文 Thanks for the info. The 3458A was developed pre-SCPI so STB? will not work, you have to use that command I mentioned in the previous post. |
|
|
|
哦?
STB? 在手册中,03458-90014:Ch 6 / pg 245.Brian 以上来自于谷歌翻译 以下为原文 Oh? STB? is in the manual, 03458-90014: Ch 6 /pg 245. Brian |
|
|
|
对不起,我在想* STB?
这是一个SCPI的事情,你是对的,你可以使用STB吗?但我会建议使用另一个命令,因为当你执行STB? 命令,就绪位(位4)始终清零(未准备好),因为万用表正在处理STB? 命令。 因此,如果您使用另一个命令,DMM将始终看起来很忙,您可以判断DMM是否实际上仍然处于忙碌状态。 以上来自于谷歌翻译 以下为原文 Sorry I was thinking of *STB? which is a SCPI thing, you are correct you can use STB? However I would suggest using the other command because when you execute the STB? Command, the ready bit (bit 4) is always clear (not ready) because the multimeter is processing the STB? command. So the DMM will always look busy, if you use the other command you can tell if the DMM is actually still busy or not. |
|
|
|
|
|
|
|
好吧,这是一个快速而肮脏的程序,我把它放在一起进行自我测试,不确定我的IF语句是否有用,但它只是建立在上面的东西。
确保将visa32.lib添加到链接器:#include“stdafx.h”#include #include #include #include #include #include using namespace std; // //这个宏简化了代码的读取并提供了错误检查 // #defineCHECK(func) do { ViStatus _s =(func); if(_s { fprintf(stderr,“错误:%s返回%d n”,#func,_s); exit(0 ); } } while(0)//指定仪器的VISA地址// GPIB,USB 2.0或LAN说明//使用主VISA配置器获取VISA地址//由Agilent Connection Expert处理的配置//您 必须确定每个工具的系统VISA地址#define DEFAULT_ADDRESS_3458“GPIB0 :: 22 :: INSTR”void main(){ViSession viDefaultRM,Inst_dmm; ViRsrc TxtAddress_dmm = DEFAULT_ADDRESS_3458; unsigned short spoll; charid [256]; charerror [256]; ////初始化Instruments进行通信并将它们设置为重置条件//将接口配置为20秒超时// CHECK(viOpenDefaultRM(&amp; viDefaultRM)); //打开DMM CHECK路径(vi 打开(viDefaultRM,TxtAddress_dmm,VI_NULL,20000,&amp; Inst_dmm)); CHECK(viSetAttribute(Inst_dmm,VI_ATTR_TMO_VALUE,700000)); //重置并检查IDviClear(Inst_dmm); viPrintf(Inst_dmm, “复位 n”); viPrintf(Inst_dmm,“end always n”); viPrintf(Inst_dmm,“ID? n”); viScanf(Inst_dmm,“%t n”,&amp; id); cout //开始自我testviPrintf(Inst_dmm,“ TEST n“); //等待50秒睡眠(50000); //检查测试是否完成并检查错误❖ReadSTB(Inst_dmm,&amp; spoll); cout if(spoll == 0){viPrintf(Inst_dmm,”ERRSTR ? n“); viScanf(Inst_dmm,”%t n“,&amp; error); cout cout} else {viPrintf(Inst_dmm,”ERRSTR? n“); viScanf(Inst_dmm,”%t n“, &amp; error); cout} CHECK(viClose(Inst_dmm)); 检查(viClose(viDefaultRM)); coutchar wait = getchar();} 以上来自于谷歌翻译 以下为原文 Alright here is a quick and dirty program I put together for a selft test, No sure my IF statement is all that useful but it's just something to build on. Make sure to add visa32.lib to your linker: #include "stdafx.h" #include #include #include #include #include #include using namespace std; // // This macro simplifies the reading of code and yet provides error checking // #define CHECK(func) do { ViStatus _s = (func); if (_s < 0) { fprintf(stderr, "Error: %s returned %dn", #func, _s); exit(0); } } while (0) // Specify the VISA addresses for instruments // GPIB, USB 2.0, or LAN are illustrated // Use Primary VISA Configurator to obtain VISA addresses // Configuration handled by Agilent Connection Expert // You must determine your system's VISA Address for each instrument #define DEFAULT_ADDRESS_3458 "GPIB0::22::INSTR" void main() { ViSession viDefaultRM, Inst_dmm; ViRsrc TxtAddress_dmm = DEFAULT_ADDRESS_3458; unsigned short spoll; char id[256]; char error[256]; // // Initialize Instruments for communication and set them to reset condition // Configure the interface for 20 second timeout // CHECK(viOpenDefaultRM(&viDefaultRM)); // Open path to DMM CHECK(viOpen(viDefaultRM, TxtAddress_dmm, VI_NULL, 20000, &Inst_dmm)); CHECK(viSetAttribute(Inst_dmm, VI_ATTR_TMO_VALUE, 700000)); //Reset and check ID viClear(Inst_dmm); viPrintf(Inst_dmm,"resetn"); viPrintf(Inst_dmm,"end alwaysn"); viPrintf(Inst_dmm,"ID?n"); viScanf(Inst_dmm, "%tn", &id); cout << "ID : " << id << endl; //Begin self test viPrintf(Inst_dmm,"TESTn"); //wait 50 seconds Sleep(50000); //Check to see if test completed and check for errors viReadSTB(Inst_dmm, &spoll); cout << "SPOLL = " << spoll << endl; if (spoll == 0) { viPrintf(Inst_dmm,"ERRSTR?n"); viScanf(Inst_dmm, "%tn", &error); cout << "Self Test Completed" << endl; cout << "Error check: " << error << endl; } else { viPrintf(Inst_dmm,"ERRSTR?n"); viScanf(Inst_dmm, "%tn", &error); cout << "Error check: " << error << endl; } CHECK(viClose(Inst_dmm)); CHECK(viClose(viDefaultRM)); cout<< "Press any key to exit" << endl; char wait = getchar(); } |
|
|
|
4864165sas 发表于 2019-7-9 15:05 谢谢你的代码! 我注意到你正在硬编码这个程序中的仪器地址。 我试图从配置文件或命令行中获取地址。 它存储在c ++ std :: string中。 您是否碰巧知道将其转换为viOpen所需的ViRsrc类型的方法? 以上来自于谷歌翻译 以下为原文 Thank you for the code! I notice you are hardcoding the instrument address in this program. I am trying to pick up an address out of a configuration file, or from the command line. It is stored in a c++ std::string. Do you happen to know a way to convert that to the ViRsrc type needed for viOpen? |
|
|
|
您好jkrause,类型ViRsrc本质上是基本C类型(char *)。 std :: string函数c_str()返回一个const char *而不是char *。 这些类型不兼容。 你有两个转换std:string的选项如下://选项1 std :: string str =“TCPIP0 :: a-mx3104a-10123.lvld.agilent.com :: inst0 :: INSTR”; const char * visaAddr = str.c_str(); viOpen(rm,(char *)visaAddr,VI_NULL,VI_NULL,&amp; vi); //可以直接做(char *)str.c_str()//选项2 std :: string str2 =“TCPIP0 :: a-mx3104a-10123.lvld.agilent.com :: inst0 :: INSTR”; char * visaAddr2 = new char [str.length()+ 1]; strcpy(visaAddr2,str2.c_str()); viOpen(RM,visaAddr2,VI_NULL,VI_NULL,&安培; 6); 连接 以上来自于谷歌翻译 以下为原文 Hi jkrause, The type ViRsrc is essentially the base C type (char *). The std::string function c_str() returns a const char * and not a char *. These types are incompatible. You have a couple options for the conversion of std:string below: //Option 1 std::string str = "TCPIP0::a-mx3104a-10123.lvld.agilent.com::inst0::INSTR"; const char * visaAddr = str.c_str(); viOpen(rm,(char *)visaAddr,VI_NULL,VI_NULL,&vi); //could directly just do (char *)str.c_str() //Option 2 std::string str2 = "TCPIP0::a-mx3104a-10123.lvld.agilent.com::inst0::INSTR"; char *visaAddr2 = new char[str.length() + 1]; strcpy(visaAddr2, str2.c_str()); viOpen(rm,visaAddr2,VI_NULL,VI_NULL,&vi); Connectivity |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
1221 浏览 0 评论
2346 浏览 1 评论
2155 浏览 1 评论
2021 浏览 5 评论
2900 浏览 3 评论
964浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
700浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
801浏览 0评论
1223浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 14:37 , Processed in 1.559992 second(s), Total 95, Slave 78 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号