完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,最重要的是,抱歉我的英文不好,我是法国人我在VB6中编写了一个程序,在易失性存储器加载点后通过RS-232在hp33120A中加载波形,我发送了一个OPC?
查询当我读取响应时,我有一个超时。 非常感谢您的帮助我的程序的一部分:(在此之前我将流量控制设置为DTR-DSR并将波特率设置为9600'查询可用于存储用户定义波形的非易失性存储器插槽的数量Fgen.WriteString“DATA :NVOLatile:FREE?“strGReturned = Fgen.ReadString'strGRuturned将包含”0“(内存已满),”1“,”2“,”3“或”4“如果CInt(strGReturned)= 0那么'我们 擦除所有内存Fgen.WriteString“DATA:DELete:ALL”MsgBox(“发生器的内存已满,除活动信号外所有波形都被删除”)结束如果'内存可用,我们加载波形Me.MessageLog.Text = MessageLog。 Text& vbCrLf&“Operation Loading”& strSignalName&“...”'所有点都在strSignalName中连接,信号频率也在strFrequency中设置strWaveformPoints = waveformLoad(IniFilePath,strSignalName,strFrequency)Debug.Print“Avant =>“& strWaveformPoints”如果点不用逗号分隔,如果是InStr(strWaveformPoints,“,”) = 0然后'临时字符串Dim strTemp As String strTemp =“”'删除字符串中的空格strWaveformPoints = Trim(strWaveformPoints)'caracters用逗号分隔For indice%= 1 To Len(strWaveformPoints) - 1 strTemp = strTemp& ; Mid(strWaveformPoints,indice,1)& “,”'Debug.Print strTemp Next indice'最后一点后面不会出现逗号strTemp = strTemp& 中(strWaveformPoints,Len(strWaveformPoints),1)'现在表达式满足生成器要求strWaveformPoints = strTemp结束如果Debug.Print“Apres =>”& strWaveformPoints Fgen.WriteString“DISP:TEXT'LOADING”& strSignalName& “'''发送一个字符需要1.1毫秒,因此超时应该涵盖所有传输持续时间Debug.Print Len(strWaveformPoints)Fgen.IO.Timeout = 1.1 *(Len(strWaveformPoints)+ 20)+ 10000 Debug.Print Fgen.IO .Timeout'从任意波形发生器的后面板启用触发器Fgen.WriteString“Trig:Sour ext”'启用突发模式Fgen.WriteString“BM:状态开启”'在易失性存储器中加载点延迟500 Fgen.WriteString“数据挥发 ,“& 对于其他命令,strWaveformPoints'超时固定为20秒Fgen.IO.Timeout = 20000'发送另一个命令后1s暂停生成器延迟1000'检查操作是否完成'返回“1”到前面的命令后输出缓冲区 已执行Fgen.WriteString“* OPC?” '从输出缓冲区中获取字符串strGReturned = Fgen.ReadString'我们清空输出缓冲区Fgen.FlushRead'在AWG前端打印成功Fgen.WriteString“DISP:TEXT'SUCCESS'”'将波形存储在非易失性存储器中,因此 ,无需再次加载Fgen.WriteString“DATA:COPY”& strSignalName& “,挥之不去” 以上来自于谷歌翻译 以下为原文 Hello, Before all, sorry for my bad english, i'm french I wrote a program in VB6 to load a waveform in the hp33120A by RS-232 after loading points in volatile memory, I send an OPC? query When I read response, I have a timeout. Your help will be greatly appreciated A part of my program: (before that I set flow control to DTR-DSR and baud rate to 9600 'Query the number of non-volatile memory slots available to store user-defined waveforms Fgen.WriteString "DATA:NVOLatile:FREE?" strGReturned = Fgen.ReadString ' strGReturned will contains “0” (memory is full), “1”, “2”, “3”, or “4” If CInt(strGReturned) = 0 Then 'We erase all the memory Fgen.WriteString "DATA:DELete:ALL" MsgBox ("Generator's memory is full, all waveform are deleted except the active signal") End If 'Memory is available, we load waveform Me.MessageLog.Text = MessageLog.Text & vbCrLf & "Operation Loading " & strSignalName & " ..." 'All points are concatenate in strSignalName, signal frequency is also set in strFrequency strWaveformPoints = waveformLoad(IniFilePath, strSignalName, strFrequency) Debug.Print "Avant => " & strWaveformPoints 'if points are not separated by commas If InStr(strWaveformPoints, ",") = 0 Then 'a temporary string Dim strTemp As String strTemp = "" 'deleting space in the string strWaveformPoints = Trim(strWaveformPoints) 'caracters are separated by a comma For indice% = 1 To Len(strWaveformPoints) - 1 strTemp = strTemp & Mid(strWaveformPoints, indice, 1) & ", " 'Debug.Print strTemp Next indice 'The last point will not be followed by a comma strTemp = strTemp & Mid(strWaveformPoints, Len(strWaveformPoints), 1) 'Now expression fulfils the generator requirement strWaveformPoints = strTemp End If Debug.Print "Apres => " & strWaveformPoints Fgen.WriteString "DISP:TEXT 'LOADING" & strSignalName & "'" 'sending a caracter takes 1.1 ms, therefore the timeout should cover all transmission duration Debug.Print Len(strWaveformPoints) Fgen.IO.Timeout = 1.1 * (Len(strWaveformPoints) + 20) + 10000 Debug.Print Fgen.IO.Timeout 'Enabling trig from the rear panel of the arbitrary waveform generator Fgen.WriteString "Trig:Sour ext" 'Enabling burst mode Fgen.WriteString "BM:State On" 'loading points in volatile memory Delay 500 Fgen.WriteString "DATA VOLATILE, " & strWaveformPoints 'Timeout is fixed to 20 seconds for other commands Fgen.IO.Timeout = 20000 '1s pause for the generator before sending another command Delay 1000 'Check if operations are complete 'Return “1” to the output buffer after the previous commands have been executed Fgen.WriteString "*OPC?" 'Get the string from the output buffer strGReturned = Fgen.ReadString 'We empty the output buffer Fgen.FlushRead 'Print success in AWG front-end Fgen.WriteString "DISP:TEXT 'SUCCESS'" 'Store waveform in non volatile memory, therefore, no need to load it again Fgen.WriteString "DATA:COPY " & strSignalName & ", VOLATILE" |
|
相关推荐
3个回答
|
|
你好,我们又见面了!
啊,是的...当你在引号内发送“ n”时,它会向仪器发送ascii字符“”和“n”,这些字符不是该SCPI命令的有效字符。 要终止命令并让仪器知道您已完成发送指令,您必须使用新行(或回车符和新行)终止。 Microsoft Windows对新行使用CR + LF(Chr(13)& Chr(10),回车符和换行符)。 您将不得不检查您的VB6文档,但我相信 r n(CR + LF)的Visual Basic命令是vbCrLf。 如果我是正确的,那么你会想要使用Dim字符串strMyStr =“0,1,0,1,1,0,0,0,1”+ vbCrLf最好的问候,谢丽尔 以上来自于谷歌翻译 以下为原文 Hi, Again! Ah, yes... when you send the "n" inside the quotes, it sends the ascii characters "" and "n" to the instrument, and those are not valid characters for that SCPI command. To terminate the command and let the instrument know you are done sending instructions, you must terminate with a new line (or a carriage return and new line). Microsoft Windows uses the CR+LF (Chr(13) & Chr(10), carriage return and line feed) for the new line. You will have to check your VB6 documentation, but I believe the Visual Basic command for rn (CR+LF) is vbCrLf. If i am correct, then you would want to use Dim string strMyStr = "0, 1, 0, 1, 1, 0, 0, 0, 1" + vbCrLf Best Regards, Cheryl |
|
|
|
嗨,再次,你说改变终止角色并没有改变任何东西。
如果您仍然收到无效字符错误,则仪器会认为您正在发送非SCPI字符,例如#,$,%或。 您可能希望检查VB6文档或使用总线分析器来验证发送到仪器的内容。 如果您不再收到无效字符错误但仍然超时,请检查您的VB6文档,了解如何在字符串末尾发送vbCrLf。 Microsoft通常使用_both_回车符和换行符来表示新行。 如果您要同时发送回车和换行以指示新线路,请检查硬件握手。 您需要确保您的PC使用硬件握手,并且您使用的RS-232电缆使用针脚4上的DTR和仪器侧针脚6上的DSR。 如果使用直通电缆而不是交叉电缆或未连接这些引脚,则仪器上的DTR将与DTR连接或PC上没有任何东西,并且握手将无法工作。 用户指南的第197页显示了一些常见的引脚。 以上来自于谷歌翻译 以下为原文 Hi, Again, You said that changing the termination character didn't change anything. If you are still getting the invalid character error, the instrument thinks you are sending a non-SCPI character, such as #, $, % or . You may wish to check your VB6 documentation or use a bus analyzer to verify what is being sent to the instrument. If you are no longer getting the invalid character error but are still getting the timeout, then please check your VB6 documentation on how to send the vbCrLf at the end of the string. Microsoft typically uses _both_ the carriage return and line feed to indicate a new line. If you are sending both the carriage return and line feed to indicate a new line, then please check the hardware handshaking. You will need to make sure your PC is using hardware handshaking, and the RS-232 cable you are using uses DTR on pin 4 and DSR on pin 6 on the instrument side. If a straight through cable is used rather than a crossover cable or if those pins are not connected, then DTR on the instrument will connect with DTR or nothing on the PC and the handshaking will not work. Page 197 of the User's Guide shows some common pinouts. |
|
|
|
kingnet9999 发表于 2019-8-21 18:52 嗨cldiller,修复了“无效字符”问题,因为我用vbCrLf替换了终止字符。 但它没有解决超时问题。 今天早上发生的事情,我测试我的程序,它的工作。 我加载我的积分并且没有发生超时。 我无法解释。 我刚刚对OPC发表评论? 查询,结果没有超时...然后,为了确定它是否有罪,我取消注释它,这不是查询...神秘无论如何,感谢您的支持。 以上来自于谷歌翻译 以下为原文 Hi cldiller, The "Invalid character" issue was fixed since I replace the termination character by vbCrLf. But it didn't resolve the timeout problem. Something happening this morning, I test my program and it's work. I load my points and no timeout occurs. I cannot explain. I've just put in comment the OPC? query and the result is no timeout ... Then to be sure that It was or not the guilty, I uncomment it and It wasn't the query ... mystery Anyway, Thanks for all your support. |
|
|
|
只有小组成员才能发言,加入小组>>
1230 浏览 0 评论
2351 浏览 1 评论
2160 浏览 1 评论
2026 浏览 5 评论
2908 浏览 3 评论
974浏览 1评论
关于Keysight x1149 Boundary Scan Analyzer
707浏览 0评论
N5230C用“CALC:MARK:BWID?”获取Bwid,Cent,Q,Loss失败,请问大佬们怎么解决呀
808浏览 0评论
1230浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 06:31 , Processed in 1.465017 second(s), Total 83, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号