HP 53150A Series Programming Manual page 98

Microwave frequency counter
Table of Contents

Advertisement

Chapter 3 Programming Your Counter for Remote Operation
Programming Examples
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 *);
/* global data */
long ctr=703;
int
error;
void main()
{
long isc=7;
int state=1;
int i;
int samples=10;
int length=23;
char freq[23];
IORESET(isc);
sendhp("*RST");
sendhp("*CLS");
sendhp("*SRE 0");
sendhp("*ESE 0");
sendhp(":STAT:PRES");
IOEOI(isc,state);
sendhp(":FUNC 'FREQ 1'");/* Measure frequency on channel 1
for (i=1; i<=samples ;i++)
{
sendhp("INIT");
sendhp("DATA?");
IOENTERS(ctr,freq,&length);
length=strlen(freq);
freq[length-1]='\0';
printf ("Frequency %d = %s Hz\n",i,freq);
}
printf("Press a key to continue\n");
getch();
sendhp(":FUNC 'FREQ 2'");
for (i=1; i<=samples ;i++)
{
sendhp("INIT;*WAI;:DATA?");
IOENTERS(ctr,freq,&length);
length=strlen(freq);
freq[length-1]='\0';
printf ("Frequency %d = %s Hz\n",i,freq);
}
printf("Press a key to continue\n");
3-58
/* function to send command to counter */
/* Counter is at address 03. HP-IB is at select code 7 */
/* Select code 7
/* Used in IOEOI
/* Used for loop counter
/* Number of measurements to take
/* Max number of bytes per measurements
/* Array to hold frequency string
/* Clear the HP-IB interface
/* Reset the counter
/* Clear event registers and error queue
/* Clear service request enable register
/* Clear event status enable register
/* Preset enable registers and transition
filters for operation and questionable
status structures
/* Enable use of EOI
Note that the function must
be a quoted string. The actual
string sent to the counter is 'FREQ 1'. */
/* Start a measurement
/* fetch the data
/* Get length of result so
/* the linefeed can be removed*/
/* Change channels
/* Start a measurement
/* fetch the data
/* Get length of result so
/* the linefeed can be removed*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
Programming Guide

Advertisement

Table of Contents
loading

This manual is also suitable for:

53152a series53151a series

Table of Contents