Agilent Technologies E8663B Portable Generator User Manual


 
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 263
Creating and Downloading Waveform Files
Programming Examples
AMPLITUDE = 32767 ' Scale the amplitude for full range of the signal generators
' I/Q modulator DAC
pi = 3.141592
Dim intIQ_Data(0 To 2 * SAMPLES - 1) 'Array for I and Q integers: 400
ReDim iq_data(0 To (4 * SAMPLES - 1)) 'Need MSB and LSB bytes for each integer value: 800
'Create an integer array of I/Q pairs
For index = 0 To (SAMPLES - 1)
intIQ_Data(2 * index) = CInt(AMPLITUDE * Sin(2 * pi * index / SAMPLES))
intIQ_Data(2 * index + 1) = CInt(AMPLITUDE * Cos(2 * pi * index / SAMPLES))
Next index
'Convert each integer value to a hex string and then write into the iq_data byte array
'MSB, LSB ordered
For index = 0 To (2 * SAMPLES - 1)
strSrc = Hex(intIQ_Data(index)) 'convert the integer to a hex value
If Len(strSrc) <> 4 Then
strSrc = String(4 - Len(strSrc), "0") & strSrc 'Convert to hex format i.e "800F
End If 'Pad with 0's if needed to get 4
'characters i.e '0' to "0000"
hiHex = Mid$(strSrc, 1, 2) 'Get the first two hex values (MSB)
loHex = Mid$(strSrc, 3, 2) 'Get the next two hex values (LSB)
loByte = CByte("&H" & loHex) 'Convert to byte data type LSB
hiByte = CByte("&H" & hiHex) 'Convert to byte data type MSB
iq_data(2 * index) = hiByte 'MSB into first byte
iq_data(2 * index + 1) = loByte 'LSB into second byte
Next index
'Now write the data to the file
FileHandle = FreeFile() 'Get a file number
numPoints = UBound(iq_data) 'Get the number of bytes in the file
Open strFilename For Binary Access Write As #FileHandle Len = numPoints + 1