Programming Examples

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.

#include “decl.h” #include <stdio.h> #include <process.h>

main ()

{

 

int

Counter, Status, i;

char

InString[80];

Counter = ibfind(“DEV10"); ibwrt(Counter, “*CLS; *SRE 16", 13);

ibwrt(Counter, “*RST; :FUNC ‘Freq 1’; :ACQ:APER MIN”, 38); ibwrt(Counter, “:INP:LEV:AUTO OFF”, 17);

/*Enable statistics on 10000 measurements*/ ibwrt(Counter, “:CALC:AVER:STAT ON; COUN 10000", 30); ibwrt(Counter, “:TRIG:COUN 10000", 16);

/*Start measurement*/ ibwrt(Counter, “:Init; *OPC?”, 12);

/*Wait for operation complete (MAV)*/ printf(“Waiting for measurement to get ready\n”); ibwait(Counter, RQS);

/**Read status and response**/ ibrsp(Counter, &Status); ibrd(Counter, InString, 80);

/*Read maximum value**/

ibwrt(Counter, “:CALC:AVER:TYPE MAX; :CALC:IMM?”, 31);

ibrd(Counter, InString, 80); InString[ibcnt] = ‘\0’; printf(“Maximum = %s\n”, InString);

4-20 ‘C’ for National Instruments PC-IIA, Statistics

Page 60
Image 60
Fluke PM6681R, PM6685R manual 20 ‘C’ for National Instruments PC-IIA, Statistics