Register Programming Example

This example program reads the ID and Device Type registers and then reads the Status register. Next, the program closes a signal path from channel CH031 to COM 05, writes the value 20480 (5000 hexadecimal) to register 20h and then writes the value 38 (26 hexadecimal) to register 28h. Then, the program resets the module to open all channels. A typical printout for the program is:

#includeIDDevceStausLeftRightegisterregister-hand-<visahandregisterType28hAssemblyRegister.=h>for0xFFFFgister=Both0xFFBE=Assemblies0x2180h24h6=0x=0x05000260

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h>

ViSession defaultRM,rf_mux; void err_handler();

void wait();

void main(void)

{

unsigned short reg_20h, reg_22h; /* Registers for Left-hand assembly*/ unsigned short reg_24h, reg_26h; /* Registers for Right-hand assy*/

unsigned short reg_28h;

/* Register for both assemblies */

unsigned short id_reg, dt_reg;

/* ID and device type registers */

unsigned short stat_reg; /* status register */

/* create and open a device session */

ViStatus err;

viOpenDefaultRM (&defaultRM);

viOpen (defaultRM,"GPIB-VXI0::9::120",VI_NULL,VI_NULL,&rf_mux);

/* reset the module */

err = viOut16(rf_mux,VI_A16_SPACE,0x04,1); if(err < VI_SUCCESS)err_handler(rf_mux,err);

/* wait 1 second (must wait at least 100 usec before writing a "0") */

wait(1);

err = viOut16(rf_mux,VI_A16_SPACE,0x04,0);

Appendix B

Register-Based Programming 49

Page 49
Image 49
Agilent Technologies E1470A user manual Register Programming Example, Create and open a device session