1. Limit Testing
This program uses limit testing to check that the frequency is above a preset value.
#include “decl.h”
#include <stdio.h>
#include <process.h>
main ()
{
int Counter, Status, i;
char InString[80];
Counter = ibfind(“DEV10");
/*Set continuous frequency measurement*/
ibwrt(Counter, “*RST; *CLS; :FUNC ‘Freq 1’; :INIT:CONT ON”,
41);
/*Enable limit monitoring, limit 1 MHz*/
ibwrt(Counter, “:CALC:LIM ON; LIM:UPP 1E6; UPP:STAT ON”, 38);
ibwrt(Counter, “:STAT:DREG0:ENAB 2; *SRE 1", 26);
/*Wait until the limit is passed*/
printf(“Waiting for limit to be passed\n”);
ibwait(Counter, RQS);
/**Read status and device status register**/
ibrsp(Counter, &Status);
ibwrt(Counter, “:STAT:DREG0:EVEN?”, 17);
ibrd(Counter, InString, 80);
/*Read frequency**/
ibwrt(Counter, “READ?”, 5);
ibrd(Counter, InString, 80);
InString[ibcnt] = ‘\0’;
printf(“Frequency = %s\n”, InString);
/*Disable continuous measurement*/
ibwrt(Counter, “:INIT:CONT OFF”, 14);
exit(0);
}
Programming Examples
4-14 ‘C’ for National Instruments PC-IIA, Limit Testing