Chapter 3 Programming Your Universal Counter for Remote Operation

Elements of SCPI Commands

To Make a Frequency Measurement (Turbo C)

/* This program sets up the counter to make 10 freqeuncy measurements on channel 1, using a 0.1 second gate time.

The results are displayed on the computer CRT

The program comments discuss the meaning of each command. ASCII result format is used to preserve resolution. */

#include <stdio.h> #include <string.h> #include "CHPIB.H" #include "CFUNC.H"

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 state=1;

 

/* Used in IOEOI

*/

 

int i;

 

/* Used for loop counter */

 

int samples=10;

 

/* Number of measurements to take */

 

int length=23;

 

/* Max number of bytes per measurements */

 

char freq[23];

 

/* Array to hold frequency string */

 

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 */

 

IOEOI(isc,state);

 

/* Enable use of EOI */

 

sendhp(":FUNC 'FREQ 1'");

 

/* Measure frequency on channel 1

 

 

 

 

 

Note that the function must

 

 

 

 

 

be a quoted string. The actual

 

 

 

 

 

string sent to the counter is

 

 

 

 

 

'FREQ 1'. */

 

sendhp(":FREQ:ARM:STAR:SOUR IMM");

/* These 3 lines enable the */

 

sendhp(":FREQ:ARM:STOP:SOUR TIM");

/* time arming mode with a */

 

sendhp(":FREQ:ARM:STOP:TIM .1");

/* 0.1 second gate time */

Programming Guide

3-91