Chapter 3 Programming Your Universal Counter for Remote Operation

Programming Examples

To Use Limits to Filter Data Before Measuring Stats (HPBASIC)

10! This program instructs the counter to determine the statistics of

20! 50 Period measurements that are within the limits defined by the

30! variables "Upper" and "Lower". Periods that are outside of

40! the limits are not included in the statistics. The Limit graph is

50! displayed so you can see if measurements are in limit.

60! To alert the program that the statistics are ready, bit 8 in the

70! Operation Status register is used. When statistics are being

80! calculated, this bit is high, when they are complete, the bit goes

90! low. By using the transition filters, an SRQ can be generated when

100! statistics are complete.

110! ASCII format is used to preserve resolution.

120!

130INTEGER I,Num_meas

140DIM Sdev$[22],Mean$[22],Minimum$[22],Maximum$[22]

150

Num_meas=50

! Statistics based on num_meas measurements

160

Upper=1.10E-7

! Upper period to be included in statistics

170

Lower=1.00E-7

! Lower period to be included in statistics

180

CLEAR SCREEN

 

190

ASSIGN @Count TO 703

 

200

CLEAR 703

! Clear the counter and interface

210

OUTPUT @Count;"*RST"

! Reset the counter

220

OUTPUT @Count;"*CLS"

! Clear event registers and error queue

230

OUTPUT @Count;"*SRE 0"

! Clear service request enable register

240OUTPUT @Count;"*ESE 0" ! Clear event status enable register

250OUTPUT @Count;":STAT:PRES" ! Preset enable registers and transition

260

 

! filters for operation and questionable

270

 

! status structures.

280

OUTPUT @Count;":FUNC 'PER'"

! Measure frequency on channel 1

290

 

! Note that the function must be

300

 

! a quoted string. The actual

310

 

! string sent to the counter

320

 

! is "PER".

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

340OUTPUT @Count;":FREQ:ARM:STOP:SOUR TIM" ! time arming with a 0.01

350OUTPUT @Count;":FREQ:ARM:STOP:TIM .01" ! second gate time.

360OUTPUT @Count;":STAT:OPER:ENABLE 256" ! Computing Statistics bit in

370

! Operation status register

380OUTPUT @Count;":STAT:OPER:NTR 256" ! When statistics are complete,

390OUTPUT @Count;":STAT:OPER:PTR 0" ! the bit will go from high to low

400

 

! so a negative transition is

410

 

! needed to enable the bit that

420

 

! is summarized in the Status Byte

430

 

! Register.

440

OUTPUT @Count;"*SRE 128"

! This is the bit from the

450

 

! Operation Status register that is

460

 

! summarized in the Status Byte

470

 

! Register.

480

 

! When it goes high, SRQ will be

490

 

! asserted.

3-66

Programming Guide