您好,最重要的是,抱歉我的英文不好,我是法国人我在VB6中编写了一个程序,在易失性存储器加载点后通过RS-232在hp33120A中加载波形,我发送了一个OPC?
查询当我读取响应时,我有一个超时。
非常感谢您的帮助我的程序的一部分:(在此之前我将流量控制设置为DTR-DSR并将波特率设置为9600'查询可用于存储用户定义波形的非易失性存储器插槽的数量Fgen.WriteString“DATA
:NVOLa
tile: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"