Chapter 3 Programming Your Universal Counter for Remote Operation

Programming Examples

To Use Macros (QuickBASIC)

'This program is useful for writing macros for the counter. Softkeys 'are available at the bottom of the computer screen to help determine 'the status of the macros.

'The SUB sendhp sends commands to the HP 53131A

DECLARE SUB sendhp (code$)

 

REM $INCLUDE: 'QBSETUP.BAS'

'Required by HP 82335A

DIM SHARED source AS LONG

'Address and select code

DIM maxlength AS INTEGER

 

DIM actual AS INTEGER

 

DIM length AS INTEGER

 

maxlength = 6400

 

DIM answer AS STRING

 

DIM namemacro AS STRING

 

DIM commandmacro AS STRING

 

DIM results AS STRING * 6400

 

DIM macros AS STRING

 

source = 703

'HP 53131A at address 3

isc& = 7

'Select code 7

state% = 1

 

CLS

 

CALL IOEOI(isc&, state%)

'Make sure EOI enabled

CALL sendhp("*RST")

'Reset the 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 register

CALL sendhp(":STAT:PRES")

'Preset enable registers and transition

 

'filters for operation and questionable

 

'status structures.

CALL sendhp(":INIT:CONT OFF")

'Put counter in Single

KEY 1, "Free"

 

KEY 2, "Enable"

 

KEY 3, "Display"

 

KEY 4, "Query"

 

KEY 5, "Define"

 

KEY 6, "Delete1"

 

KEY 7, "Purge"

 

KEY 8, "Disable"

 

KEY 9, "Send"

 

KEY 10, "QUIT"

 

FOR i = 1 TO 10

 

KEY(i) ON

 

NEXT i

 

KEY ON

 

3-88

Programming Guide