Chapter 3 Programming Your Universal Counter for Remote Operation
Elements of SCPI Commands
Programming Guide 3-63
To Perform Limit Testing (HP BASIC)
10 ! This program sets up the counter to make period measurements
20 ! indefinitely until an out of limits measurement occurs.
30 ! The upper limit is 1 usec and the lower limit is 500 nsec.
40 ! If a measurement falls outside of these limits, the counter will
50 ! stop measuring and report the out of limits value to the computer
60 ! ASCII format is used to preserve resolution.
70 Lower=5.00E-7 ! Lower limit for period
80 Upper=1.E-6 ! Upper limit for period
90 DIM Result$[22] ! Read out of limit period into Result$
100 ASSIGN @Count TO 703 ! Assign I/O path for the counter
110 CLEAR 703 ! Clear the counter and interface
120 OUTPUT @Count;"*RST" ! Reset the counter
130 OUTPUT @Count;"*CLS" ! Clear event registers and error queue
140 OUTPUT @Count;"*SRE 0" ! Clear service request enable register
150 OUTPUT @Count;"*ESE 0 " ! Clear event status enable register
160 OUTPUT @Count;":STAT:PRES" ! Preset enable registers and
170 ! transition filters for Operation and
180 ! Questionable status structures
190 OUTPUT @Count;":FUNC ""PER 1""" ! Measure period on channel 1
200 ! Note that the function selected must be a quoted string.
210 ! The actual string sent to the counter is "PER 1".
220 !
230 OUTPUT @Count;":FREQ:ARM:STAR:SOUR IMM" ! These two lines enable
240 OUTPUT @Count;":FREQ:ARM:STOP:SOUR IMM" ! Automatic arming.
250 !
260 OUTPUT @Count;":CALC2:LIM:STAT ON" ! Enable limit testing
270 OUTPUT @Count;":CALC2:LIM:DISP GRAP" ! Show the analog limit graph
280 OUTPUT @Count;":CALC2:LIM:LOWER ";Lower ! Set lower limit to 500 ns
290 OUTPUT @Count;":CALC2:LIM:UPPER ";Upper ! Set upper limit to 1 us
300 OUTPUT @Count;":INIT:AUTO ON" ! Stop when out of limit
310 OUTPUT @Count;":STAT:QUES:ENAB 1024" ! 1024 is out of limit bit
320 OUTPUT @Count;"*SRE 8" ! Enable SRQ on questionable
330 ! data register event
340 ON INTR 7 GOTO Out_of_limits ! If SRQ goto out_of_limits
350 ENABLE INTR 7;2 ! Enable the interrupt
360 OUTPUT @Count;":INIT:CONT ON" ! Start making measurements
370 Loop_here:GOTO Loop_here ! Loop while in limits
380 !
390 Out_of_limits: ! Here because SRQ line
400 Status_byte=SPOLL(703) ! asserted Serial poll counter
410 OUTPUT @Count;"FETCH:PERIOD?" ! Query the counter
420 ENTER @Count;Result$ ! Read the period
430 PRINT "Out of limits measurement is ";Result$;" seconds"
440 PRINT "Status byte is ";Status_byte ! Should be 72 (64+8)
450 LOCAL 703 ! Return counter to local
460 END