Agilent Technologies E1465A Automobile Parts User Manual


 
Getting Started 17Chapter 1
Example: Closing
Relays (Turbo C)
This example assumes a PC with a GPIB Interface card (with command
library) running Borland Turbo C. The program closes row 03, column 12 of
an E1465A 16x16 matrix module at logical address 120 (secondary address
= 120/8 = 15) and queries the result. The result is returned to the controller
and displayed (1 = relay closed, 0 = relay open). See Chapter 4 for
information on the SCPI commands.
#include <stdio.h>
#include <chpib.h> /*Include file for GPIB*/
#define ISC 7L
#define MATRIX 70915L /*Matrix default address*/
#define TASK1 "*RST" /*Reset*/
#define TASK2 "CLOS (@10312)" /*Close row 3, column 12*/
#define TASK3 "CLOS? (@10312)" /*Query row 3, column 12*/
main()
{
char into[257];
int length = 256;
/*Output commands to matrix module*/
error_handler (IOTIMEOUT (7L,5.0), "TIMEOUT");
error_handler (IOOUTPUTS (MATRIX, TASK1, 4), "OUTPUT command");
error_handler (IOOUTPUTS (MATRIX, TASK2, 15), "OUTPUT
command");
error_handler (IOOUTPUTS (MATRIX, TASK3, 15), "OUTPUT
command");
/*Enter from matrix*/
error_handler (IOENTERS (MATRIX, into, &length), "ENTER command");
printf("Now let's see if the switch is closed: %s",into);
return;
}
int error_handler (int error, char *routine)
{
char ch;
if (error != NOERR)
{
printf ("\n Error %d %s \n", error, errstr(error));
printf (" in call to GPIB function %s \n\n", routine);
printf ("Press 'Enter' to exit: ");
scanf ("%c", &ch);
exit(0);
}
return 0;
}