// Setup for pulse width measurement
ibwrite(counter, “CONF:PWID (@1)”);
// Some settings...
ibwrite(counter, “AVER:STAT OFF;:ACQ:APER MIN”);
ibwrite(counter, “INP:LEV:AUTO OFF; :INP:LEV 0");
ibwrite(counter, ”FORMAT:TINF ON;:FORMAT ASCII");
// Check that setup was OK, all commands correctly spelled
etc
ibwrite(counter, “syst:err?”);
ibrd(counter, buf, 100L); buf[ibcnt]=0;
printf(“Setup error: %s\n”, buf);
// Measure 20 samples
for (i=0; i<20; i++) {
ibwrite(counter, “READ?”);
ibrd(counter, reading, 49L); reading[ibcnt]=0;
printf(“Result %d:%s”, i, reading);
}
do {
ibwrite(counter, “syst:err?”);
ibrd(counter, buf, 100L); buf[ibcnt]=0;
printf(“End error: %s\n”, buf);
} while (atoi(buf)!=0);
ibonl(counter, 0);
}
/********************
* Support functions *
********************/
void ibwrite(int counter, const char *string) {
ibwrt(counter, (char*) string, strlen(string));
}
void sleep (long mswait) {
time_t EndWait = clock() + mswait * (CLOCKS_PER_SEC/1000);
while (clock() < EndWait);
}
Programming Examples
4-4 Individual Mesurements (Ex. #1)