Chapter 3 Programming Your Universal Counter for Remote Operation

Programming Examples

To Perform Limit Testing (QuickBASIC)

'This program sets up the counter to make period measurements 'indefinitely until an out of limits measurement occurs. The upper 'limit is set to 1 us and the lower limit is set to 500 ns.

'If a measurement falls outside of these limits, the counter will 'stop measuring and send the out of limits period to the computer.

'The out of limit period is sent in ASCII format to preserve resolution. 'The SUB sendhp sends commands to the counter

DECLARE SUB sendhp (code$)

 

 

REM $INCLUDE: 'QBSETUP.BAS'

 

'Required by HP 82335A

DIM SHARED source AS LONG

 

'Address and select code

DIM period AS STRING * 23

 

'Period string, the maximum number

 

 

'of characters that can ever be

 

 

'sent is 23

DIM complete AS INTEGER

 

'

DIM statusbyte AS INTEGER

 

'Status byte variable

upper = .000001

 

'Upper period

lower = .0000005

 

'lower period

source& = 703

 

'Counter at address 3

isc& = 7

 

'Select code 7

complete = 0

 

'Used to check if stats received

state% = 1

 

'Used in IOEOI

priority% = 1

 

'Used in IOPEN

CLS

 

'Clear the screen

CALL IOEOI(isc&, state%)

'Make sure EOI enabled

CALL IOCLEAR(source&)

'Clear the counter and interface

CALL sendhp("*RST")

'Reset counter

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 registers

CALL sendhp(":STAT:PRES")

'preset filters for operation and

 

'questionable status structures

CALL sendhp(":FUNC " + CHR$(34) + "PER 1" + CHR$(34)) 'Measure period

'The function must be a quoted string. The actual string sent to the

'counter is "PER 1"

 

 

CALL sendhp(":FREQ:ARM:STAR:SOUR IMM")

'These 2 lines enable using

CALL sendhp(":FREQ:ARM:STOP:SOUR IMM")

'automatic arming

CALL sendhp(":CALC2:LIM:STAT ON")

'Enable limit testing

CALL sendhp(":CALC2:LIM:DISP GRAP")

'Show the analog limit graph

CALL sendhp(":CALC2:LIM:LOWER " + STR$(lower)) 'Set lower

limit

CALL sendhp(":CALC2:LIM:UPPER " + STR$(upper)) 'Set upper

limit

CALL sendhp(":INIT:AUTO ON")

'Stop when out of limit

CALL sendhp("*SRE 8")

'Enable SRQ on questionable data

 

'register event

 

CALL sendhp(":STAT:QUES:ENAB 1024")

'1024 is out of limit bit

3-78

Programming Guide