Chapter 3 Programming Your Universal Counter for Remote Operation

Programming Examples

To Make a Frequency Measurement (HP BASIC)

10

! This program sets up the counter

to make 10 frequency

20

! measurements on channel 1, using

a 0.1 second gate time.

30

! The results are displayed on the computer CRT.

40

! ASCII format is used to preserve resolution.

50

!

 

 

60

 

INTEGER I

! Declare variables

70

 

DIM Freq$(10)[22]

! Declare string to enter data

80

 

 

! Using strings to enter ASCII format

90

 

 

! data yields results formatted to the

100

 

! correct resolution. ASCII is the

110

 

! default format for the counter.

120

Samples=10

! Take 10 measurements

130

!

 

140

ASSIGN @Count TO 703

! Assign I/O path for counter

150

CLEAR 703

! Clear the counter and interface

160

OUTPUT @Count;"*RST"

! Reset the counter

170

OUTPUT @Count;"*CLS"

! Clear event registers and error queue

180

OUTPUT @Count;"*SRE 0"

! Clear service request enable register

190

OUTPUT @Count;"*ESE 0"

! Clear event status enable register

200

OUTPUT @Count;":STAT:PRES"

! Preset enable registers and

210

 

! transition filters for operation and

220

 

! questionable status structures.

230OUTPUT @Count;":FUNC 'FREQ 1'" ! Measure frequency on channel 1

240OUTPUT @Count;":FREQ:ARM:STAR:SOUR IMM" ! These three lines enable

250OUTPUT @Count;":FREQ:ARM:STOP:SOUR TIM" ! Using time arming, with a

260OUTPUT @Count;":FREQ:ARM:STOP:TIM .100" ! 0.1 second gate time

270!

280

CLEAR SCREEN

! Clear the computer display

290

FOR I=1 TO Samples

! Start making measurements

300

OUTPUT @Count;"READ:FREQ?"

! Start a measurement and

310

 

! fetch the data

320

ENTER @Count;Freq$(I)

! Enter the frequency

330PRINT USING "11A,DD,4A,22A,3A";"Frequency (";I;") = ";Freq$(I);" Hz"

340NEXT I

350

LOCAL 703

! Return counter to local

360

END

 

3-62

Programming Guide

Page 130
Image 130
HP 132A, 53131A manual To Make a Frequency Measurement HP Basic, Clear Screen