Introduction To Programming 19Sending Commands to and Receiving Data from the ModuleSending the Command “VOLT 5”
********************************************** Agilent BASIC ************************************************
2100 OUTPUT 70501;"VOLT 5" ! where 70501 means 7 is the select code of the GPIB interface 05 is the
2110 ! GPIB address of the mainframe, 01 is the slot number (secondary address)
2120 ! of the module
************************* GWBASIC (Agilent 82335A/82990A/61062B GPIB Command Library) ************************
2100 MODULE.ADDRESS=70501
2110 COMMAND$ - "VOLT 5"
2120 L - LENGTH(COMMAND$)
2130 CALL IOOUTPUTS(MODULE.ADDRESS,COMMAND$,L)
2140 IF PCIB.ERR&<>O THEN ERROR PCIB.BASERR’ ! ERROR TRAP
********************************** GWBASIC (National Instruments GPIB Interface) ********************************
2100 COMMAND$ = "VOLT 5"
2110 CALL IBWRT(MODULE.ADDRESS%, COMMAND$)
2120 IF IBSTA% &< 0 GOTO 5000 ! TRAP ERROR WITH ERROR HANDLER
2130 ! AT LINE 5000
Sending the Command “VOLT 5” in BASIC
*********************** Microsoft C (Agilent 82335A/82990A/61062B HPIB Command Library) *************************
/* Assumes that you have an error handler routine, called ‘error_handler’ that accepts a float. The error handler in then passed the float
that is returned from each call to the library. */
*include &<stdio.h>
*include &<chpib.h>
*include &<cfunc.h>
*define module_address 70501L
char *cmd;
cmd = "VOLT 5”;
error = iooutputs(MODULE_ADDRESS, cmd, strlen(cmd));
error_handler(error);
****************************** Microsoft C (National Instruments GPIB Interface) ************************************
/* Assumes that you have an error handler routine, called ‘error-handler’. The error handler is then passed the float that is returned from
each call to the library. */
*include &<stdio.h>
*include &<decl.h>
*define ERR (l&<&<15) /* Error is detected as bit i5 of ibsta */
int module-address; /* Device is configured in the GPIB.COM handler. Use ibfind() to assign a value to module-address. */
char *cmd;
cmd - "VOLT 5”
ibwrt(MODULE_ADDRESS, cmd, strlen(cmd));
if (ibsta & ERR)
error_handler();
Sending the Command "VOLT 5” in C