Chapter 3 Programming Your Universal Counter for Remote Operation

Elements of SCPI Commands

To Make a Frequency Measurement (QuickBASIC)

'This program sets up the counter to make 10 frequency measurements 'on channel 1 using a 0.1 second gate time.

'The results are printed on the computer CRT.

'Data is sent in ASCII format to preseve 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 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

 

'Counter at address 3

isc& = 7

 

'Select code 7

state% = 1

 

'Used in IOEOI

CLS

 

'Clear 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 register

CALL sendhp(":STAT:PRES")

'Preset enable registers and transition

 

'filters for operation and questionable

 

'status structures

CALL sendhp(":func " + CHR$(34) + "FREQ 1" + CHR$(34)) 'Measure frequency

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

'These 3 lines enable using

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

'time arming with a 0.1 second

CALL sendhp(":FREQ:ARM:STOP:TIM .1")

 

'gate time

CLS

 

'Clear computer screen

FOR i = 1 TO samples

 

 

CALL sendhp("READ:FREQ?")

 

'Initiate a measurement and

 

 

'get the result

CALL IOENTERS(source&, freqs(i), 23, actf%) 'Read the ASCII characters PRINT "Frequency"; i; "= "; freqs(i)

NEXT i

END

SUB sendhp (code$)

CALL iooutputs(source, code$, LEN(code$))

END SUB

Programming Guide

3-77