Technical data
296 Agilent Signal Generators Programming Guide
Creating and Downloading Waveform Files
Programming Examples
FileHandle = FreeFile()
On Error GoTo errorhandler
With SigGen 'Set up the signal generator to accept a download
.IO.Timeout = 5000 'Timeout 50 seconds
.WriteString "*RST" 'Reset the signal generator.
End With
numPoints = (FileLen(strFilename)) 'Get number of bytes in the file: 800 bytes
ReDim iq_data(0 To numPoints - 1) 'Dimension the iq_data array to the
'size of the IQ_DataVB file: 800 bytes
Open strFilename For Binary Access Read As #FileHandle 'Open the file for binary read
On Error GoTo file_error
For index = 0 To (numPoints - 1) 'Write the IQ_DataVB data to the iq_data array
Get #FileHandle, index + 1, data '(index+1) is the record number
iq_data(index) = data
Next index
Close #FileHandle 'Close the file
'Write the command to the Header string. NOTE: syntax
Header = "MEM:DATA ""/USER/WAVEFORM/IQ_DataVB"","
'Now write the data to the signal generator's non-volatile memory (NVWFM)
SigGen.WriteIEEEBlock Header, iq_data
SigGen.WriteString "*OPC?" 'Wait for the operation to complete
response = SigGen.ReadString 'Signal generator reponse to the OPC? query
Call MsgBox("Data downloaded to the signal generator", vbOKOnly, "Download")
Exit Sub
errorhandler:
MsgBox Err.Description, vbExclamation, "Error Occurred", Err.HelpFile, Err.HelpContext
Exit Sub
file_error:
Call MsgBox(Err.Description, vbOKOnly) 'Display any error message
Close #FileHandle
End Sub