Instruction manual

Chapter 3 Programming Your Counter for Remote Operation
Programming Examples
Programming Guide 3-57
3
Making a Frequency Measurement (QuickBASIC)
’This program configures the instrument to make 10 frequency measurements
’on channel 2.
’The results are printed on the computer monitor.
’Data is sent in ASCII format to preserve resolution.
’The SUB sendhp sends commands to the instrument
DECLARE SUB sendhp (code$)
DIM SHARED source AS LONG ’Address and select code
DIM i AS INTEGER ’i is used for loops
DIM samples AS INTEGER
samples = 10 ’Number of measurements
DIM freqs(10) AS STRING * 23 ’String to be read
’Reading ASCII formatted data
’gives results to the correct
’resolution. Must be read into
’a string. The maximum number
’of characters that can ever be
’sent is 20 per measurement.
source& = 703 ’instrument at address 3
isc&p; = 7 ’Select code 7
state% = 1 ’Used in IOEOI
CLS ’Clear screen
CALL IOEOI(isc&p;, state%) ’Make sure EOI enabled
CALL IOCLEAR(source&) ’Clear the instrument and interface
CALL sendhp("*RST") ’Reset instrument and stop autotriggering
CALL sendhp("*CLS") ’Clear event registers and error queue
CALL sendhp("*SRE 0") ’Clear service request enable register
CALL sendhp("*ESE 0") ’Clear event status enable register
CALL sendhp(":STAT:PRES") ’Preset enable registers and
’transition filters for operation and
’questionablestatus structures
CALL sendhp(":CONF:FREQ DEFAULT,DEFAUTL,(@2)
‘Set to measure frequency in Band 2
CLS 'Clear computer screen
FOR i = 1 TO samples
CALL sendhp("INIT:IMM") 'Initiate a measurement and
CALL sendhp("READ?") 'get the result
CALL IOENTERS(source&ng, freqs(i), 23, actf%)
'Read the ASCII characters
PRINT "Frequency"; i; "= "; freqs(i)
NEXT i
END
' Subroutine to send command to Agilent 5314xA/
SUB sendhp (code$)
CALL iooutputs(source, code$, LEN(code$))
END SUB