Thread: [33120A]:TimeOut after loading a string of points


Permlink Replies: 6 - Pages: 1 - Last Post: May 15, 2012 6:10 AM Last Post By: psow
psow

Posts: 4
Registered: 05/10/12
[33120A]:TimeOut after loading a string of points
Posted: May 10, 2012 7:14 AM
Click to report abuse...   Click to reply to this thread Reply
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"

cldiller

Posts: 23
Registered: 08/05/09
Re: [33120A]:TimeOut after loading a string of points
Posted: May 10, 2012 4:31 PM   in response to: psow in response to: psow
Click to report abuse...   Click to reply to this thread Reply
Hello,

Please check to see if you are using the SYSTem:REMote command to put the unit into remote mode. You can also check the front panel to make sure the remote indicator is displayed.

Best Regards,
Cheryl
psow

Posts: 4
Registered: 05/10/12
Re: [33120A]:TimeOut after loading a string of points
Posted: May 11, 2012 2:06 AM   in response to: cldiller in response to: cldiller
Click to report abuse...   Click to reply to this thread Reply
Hello,

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 :

Dim string strMyStr = "0, 1, 0, 1, 1, 0, 0, 0, 1" + "\n"
DATA:VOLATILE strMyStr

It will leads error : Invalid caracter

Do you have any ideas ?

Thx
cldiller

Posts: 23
Registered: 08/05/09
Re: [33120A]:TimeOut after loading a string of points
Posted: May 11, 2012 10:48 AM   in response to: psow in response to: psow
Click to report abuse...   Click to reply to this thread Reply
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 \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

Best Regards,
Cheryl

psow

Posts: 4
Registered: 05/10/12
Re: [33120A]:TimeOut after loading a string of points
Posted: May 14, 2012 2:26 AM   in response to: cldiller in response to: cldiller
Click to report abuse...   Click to reply to this thread Reply
Hello cldiller,

I've tried it but it doesn't resolve my problem.

I also set Termination Character to 13 or 10 and enable it but it doesn't change anything.

My configuration:

Set Fser = Fgen.IO
Fser.BaudRate = 9600
Fser.Parity = ASRL_PAR_NONE
Fser.DataBits = 8
Fser.FlowControl = ASRL_FLOW_DTR_DSR
'Fgen.IO.TerminationCharacterEnabled = True
Fgen.IO.TerminationCharacter = 13
"
With Fgen
'Reset generator
.WriteString "*RST"
'We enter in remote mode only if it is allowed (address contains ASRL)
If InStr(1, ioAddress, "ASRL", vbTextCompare) Then
'Enterring in remote mode
.WriteString "SYST:REM"
End If
Me.MessageLog.Text = MessageLog.Text & vbCrLf & " >>> Connected from " & ioAddress
.WriteString "OUTPut:Load 50"
.WriteString "BM:NCYC 1"
.WriteString "BM:Phase 0"
.WriteString "Trig:Sour Bus"
.WriteString "BM:State On"
.WriteString "VOLT 3 VPP"

End With

cldiller

Posts: 23
Registered: 08/05/09
Re: [33120A]:TimeOut after loading a string of points
Posted: May 14, 2012 11:55 AM   in response to: psow in response to: psow
Click to report abuse...   Click to reply to this thread Reply
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 shows some common pinouts.
psow

Posts: 4
Registered: 05/10/12
Re: [33120A]:TimeOut after loading a string of points
Posted: May 15, 2012 6:10 AM   in response to: cldiller in response to: cldiller
Click to report abuse...   Click to reply to this thread Reply
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.

Point your RSS reader here for a feed of the latest messages in all forums