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
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
MsgBox ("Generator's memory is full, all waveform are deleted except the active signal")
'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) & ", "
'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
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
Fgen.IO.Timeout = 1.1 * (Len(strWaveformPoints) + 20) + 10000
'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
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
'Check if operations are complete
'Return “1” to the output buffer after the previous commands have been executed
'Get the string from the output buffer
strGReturned = Fgen.ReadString
'We empty the output buffer
'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"
Thanks for your reply.
Yes I've set the interface to SYST:REM and I have the indication in the front-end.
I think generator is always waiting for a caracter termination ( because i've tried to set a long timeout duration)
did I have to send for example :
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 \r\n (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
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 shows some common pinouts.
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