Chapter 3 Programming Your Counter for Remote Operation
Programming Examples
3-58
Programming Guide
3
Making a Frequency Measurement (C)
/* This program configures the counter to make 10 frequency measurements
on channel 1 followed by 10 on channel 2.
The results are displayed on the computer monitor.
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’. */
for (i=1; i<=samples ;i++)
{
sendhp(“INIT”);
/* Start a measurement
*/
sendhp(“DATA?”);
IOENTERS(ctr,freq,&length);
/* fetch the data
*/
length=strlen(freq);
/* Get length of result so
*/
freq[length-1]=’\0’;
/* the linefeed can be removed*/
printf (“Frequency %d = %s Hz\n”,i,freq);
}
printf(“Press a key to continue\n”);
getch();
sendhp(“:FUNC ‘FREQ 2’”);
/* Change channels
*/
for (i=1; i<=samples ;i++)
{
sendhp(“INIT;*WAI;:DATA?”);
/* Start a measurement
*/
IOENTERS(ctr,freq,&length);
/* fetch the data
*/
length=strlen(freq);
/* Get length of result so
*/
freq[length-1]=’\0’;
/* the linefeed can be removed*/
printf (“Frequency %d = %s Hz\n”,i,freq);
}
printf(“Press a key to continue\n”);
Summary of Contents for 53150A Series
Page 1: ... Programming Guide HP 53150A 151A 152A Microwave Frequency Counter ...
Page 2: ......
Page 10: ...Contents x Programming Guide ...
Page 11: ...1 Before You Start ...
Page 20: ...Chapter 1 Before You Start Related Documentation 1 10 Programming Guide 1 ...
Page 21: ...2 Command Summary A Quick Reference ...
Page 41: ...3 Programming Your Counter for Remote Operation ...
Page 101: ...4 Command Reference A Dictionary ...
Page 162: ...Chapter 4 Command Reference Common Commands 4 62 Programming Guide 4 ...
Page 163: ...5 Errors ...
Page 174: ...Chapter 5 Errors Error Types 5 12 Programming Guide 5 ...
Page 184: ......
Page 186: ... Manual Part Number 53150 90002 Printed in U S A NOVEMBER 1997 ...