Agilent Technologies E1470A Register Programming Example, Create and open a device session

Page 49

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

Image 49
Contents E1470-90002 Page Contents Appendix C RF Switch Error Messages Index Government Restricted Rights Agilent Technologies Warranty StatementDocumentation History Safety SymbolsManufacturer’s Address Manufacturer’s NameDeclares, that the product Product Name Model NumberPage Switching Diagram Using This ChapterChapter Cascade Relays COM 33 332 Creating Multiple Multiplexers Configuring the RF Switch ChapterMaximum POWER. The maximum RF power that can be applied RF Switch ConfigurationChapter Configuring the RF Switch On this moduleSetting the Logical Address Setting the Interrupt Request Level Installing User Wiring Configuring the RF Switch Chapter Connecting User WiringSMB Connectors and Connector Housings Assembling SMB Connector JacksUser Connections Wiring RF Switch Installing Device DriversProgramming the RF Switch Chapter Addressing the SwitchProgramming Examples Chapter Programming the RF SwitchProgramming the RF Switch Chapter Example Closing a Signal Path Example Opening Closing Signal Paths Example Saving Recalling Module States Programming the RF Switch Chapter Common Commands Format Command TypesScpi Commands Format Chapter RF Switch Command ReferenceLinking Commands Scpi Command ReferenceRF Switch Command Reference Chapter DIAGnosticCLOSe DIAGnosticDIAGnosticOPEN DIAGnosticCLOSe?DIAGnosticOPEN relay,relay... opens individual relays on Reset to its power-on state Common to NCDIAGOPEN333 DIAGnosticOPEN?RSTDIAGThis programCLOS042,043,053,054,256REL?returns DIAGnosticRELAY?ROUTePATHCOMMon ROUTeExample Closing Channel Path 10002 SYSTem SYSTemERRor?SYSTemVERSion? Command Ieee 488.2 Common Commands Quick ReferenceDescription Commands Quick ReferenceAppendix a Appendix a RF Switch SpecificationsRF Switch Specifications Appendix a About This Appendix Appendix BRegister Addressing Addressing OverviewFigure B-1. Register Address Locations Within VXI A16 Base AddressA16 Address Space Outside the Command Module Table B-1. General Register-based Programming Method Register DefinitionsTable B-2. Register Map Register-Based Programming Appendix BTable B-4. Control Register Bit Pattern write Table B-3. Status Register Bit Patterns readRelay Control Registers Vxie Table B-10. Writing to Relay Control Registers Create and open a device session Register Programming ExampleWait 5 seconds before resetting module Void errhandler /* Error Handling Routine Register-Based Programming Appendix B Appendix C Appendix C RF Switch Error MessagesRF Switch Error Messages Appendix C Index IndexIndex E1470-90002