6. Statistics
(Only for PM6680B and PM6681)
In this example, the counter makes 10000 measurements and uses the statistical func
-
tions to determine MAX, MIN, MEAN, and Standard Deviation. All four results are
sent to the controller.
50 CNTNAME$ = “DEV10"
60 CALL IBFIND (CNTNAME$, CNT%)
70 ‘
80 ‘
90 WRT$ = “*RST; *CLS; *SRE 16; :FUNC ‘Freq 1’; :ACQ:APER MIN”
100 CALL IBWRT (CNT%, WRT$)
110 WRT$ = “:INP:LEV:AUTO Off”
120 CALL IBWRT (CNT%, WRT$)
130 ‘
140 ‘ —— Enable statistics on 10000 measurements ——
150 WRT$ = “:CALC:AVER:STAT ON; COUN 10000"
160 CALL IBWRT (CNT%, WRT$)
170 ‘
180 ‘ ==== Start measurement ====
190 WRT$ = “:Init; *OPC?”
200 CALL IBWRT (CNT%, WRT$)
210 ‘
220 ‘ —— Wait for operation complete (MAV) ——
230 PRINT “WAITING FOR MEASUREMENT TO GET READY”
240 MASK% = &H800
250 CALL IBWAIT (CNT%, MASK%)
260 ‘
270 ‘ —— Read status and response ——
280 CALL IBRSP (CNT%, SPR%)
290 MSG$ = SPACE$(255)
300 CALL IBRD (CNT%, MSG$)
310 ‘
320 ‘ —— Maximum ——
330 WRT$ = “:CALC:AVER:TYPE MAX; :CALC:IMM?”
340 CALL IBWRT (CNT%, WRT$)
350 MSG$ = SPACE$(255)
360 CALL IBRD (CNT%, MSG$)
370 PRINT “MAXIMUM = ”; LEFT$(MSG$, IBCNT%)
380 ‘
390 ‘ —— Minimum ——
400 WRT$ = “:CALC:AVER:TYPE MIN; :CALC:IMM?”
410 CALL IBWRT (CNT%, WRT$)
420 MSG$ = SPACE$(255)
Programming Examples
GW-Basic for National Instruments PC-IIA, Setting Up the Interface 4-11