Agilent Technologies E1563A Stereo Receiver User Manual


 
Register-Based Programming 141Appendix B
Beginning of Program
/* This program resets the E1563A/E1564A, reads the ID Register, the Device */
/* Type Register, the Status Register, makes measurements and retrieves data*/
/* Programmed with MS Visual C++ version 2.0 using Agilent VISA I/O calls. */
#include <visa.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
/* function prototypes */
void err_handler();
void wait (int wait_seconds);
void reset(ViSession vi, ViStatus x);
Program Main
void main(void)
{
unsigned short id_reg, dt_reg;/* ID and Device Type */
unsigned short stat_reg; /* Status Register */
unsigned short cvt_reg, cache_reg; /* last value and cache registers */
double last_reading, reading; /* decimal values of readings */
int i;
/* create and open a device session */
ViStatus err;
ViSession defaultRM, digitizer;
ViOpenDefaultRM(&defaultRM);
/* GPIB interface address is 9 */
/* digitizer logical address switch = 40 (factory setting) */
ViOpen(defaultRM,”GPIB-VXI0::9::40”,VI_NULL,VI_NULL,&digitizer);
/* reset the E1563A/E1564A */
reset(digitizer, err);
Read ID and Device Type Registers
/********* read the digitizer's ID and Device Type registers *********/
err=ViIn16(digitizer,VI_A16_SPACE,0x00,&id_reg); /* read reg 00 */
if (err<VI_SUCCESS) err_handler(digitizer,err);
err=ViIn16(digitizer,VI_A16_SPACE,0x02,&dt_reg); /* read reg 02 */
if (err<VI_SUCCESS) err_handler(digitizer,err);
printf(“ID register = 0x%4X\n”,id_reg)
printf(“Device Type register = 0x%4X\n”,dt_reg);