Chapter 3 Programming Your Universal Counter for Remote Operation

Elements of SCPI Commands

To Use Limits to Filter Data Before Measuring Statistics (Turbo C)

/* This program instructs the counter to determine the statistics of 50 Period measurements that are within programmed test limit values. Periods that are outside of the limits are not included in the statistics. The Limit graph is displayed so you can see if measurements are in limit. To alert the program that the statistics are ready, bit 8 in the Operation Status Register is used. When statistics are being calculated, this bit is high, when they are complete, this bit goes low. By using the transition filters, an SRQ can be generated when statistics are complete (the transition from high to low of bit 8 in the Operation Status register.)*/

#include <stdio.h>

/* used for printf() */

#include <dos.h>

/* used for delay() */

#include "CHPIB.H"

/* HP-IB library constant declarations */

#include "CFUNC.H"

/* HP-IB library function prototypes */

void sendhp(char *);

/* function to send command to counter */

/* global data */

long ctr=703; /* Counter is at address 03. HP-IB is at select code 7 */ int error;

void main()

 

 

{

 

 

long isc=7;

/* Select code 7 */

 

int condition=1;

/* Used in IOSTATUS */

int status;

/* Used in IOSTATUS */

int state=1;

/* Used in IOEOI

*/

char mean[23];

/* mean variable */

 

char minimum[23];

/* minimum variable */

char maximum[23];

/* maximum variable */

char sdev[23];

/* standard deviation variable */

int length=23;

/* Used in IOENTERS */

clrscr();

/* Clear the computer CRT */

IORESET(isc);

/* Clear the HP-IB interface */

sendhp("*RST");

/* Reset the counter */

sendhp("*CLS");

/* Clear event registers and error queue */

sendhp("*SRE 0");

/* Clear service request enable register */

sendhp("*ESE 0");

/* Clear event status enable register */

sendhp(":STAT:PRES");

/* Preset enable registers and transition

 

filters for operation and questionable

 

status structures */

Programming Guide

3-93

Page 161
Image 161
HP 53131A, 132A manual HP-IB library constant declarations