REMOTE PROGRAMMING
4-15
TxGpib (sr720,"OUTF2"); /* verbose binary output */
TxGpib (sr720,"STRT;*WAI;XALL?"); /* trigger a measurement, wait until it's over, then
ask for results */
MakeTalk (sr720); /* make LCR a GPIB talker */
count = 15;
rarray (&status, &length, &count, data, &seg); /* read output into array data[] */
/* Check the programming section of the SR720 for
detailed information on binary return formats. */
/* split up status byte to check for errors and measurement type */
errs = data[2] & 15; /* mask = 0000 1111 */
mtype = data[2] & 48; /* mask = 0011 0000 */
mtype /= 16; /* now mtype = 0000 00xx */
switch (errs)
{
case 0: printf ("Measurement ok (no errors).\n"); break;
case 1: printf ("? No measurement made ?\n"); break;
case 2: printf ("Measurement overloaded.\n"); break;
case 4: printf ("Underrange error.\n"); break;
case 8: printf ("Overrange error.\n"); break;
case 15: printf ("Out of range error.\n"); break;
default: break;
}
/* transfer major parameter bytes(4) to create a single precision FP number */
memcpy (&maj, &data[3], 4); /* store four bytes as a floating point number */
/* now do the same for the minor parameter. */
memcpy (&min, &data[8], 4);
printf ("%s = %7.4e, %s = %7.5e.\n", mmaj[mtype], maj, mmin[mtype], min);
}
/* ******************************************************************* */
void InitGpib (void) /* initialize the CEC GPIB card as controller */
{
int my_address, system_controller;
unsigned seg;
/* find cec card address */
for ( seg=0x4000 ; seg < 0xF000 ; seg += 0x400 )
{ if ( (peek (seg,50) == 'C') && (peek (seg,51) == 'E') && (peek (seg,52) == 'C') ) break; }
if ( pc488_seg(seg))
{ printf ( " no gpib card installed\n"); exit(0); }
my_address = 21;
system_controller = 0;
initialize (&system_controller, &my_address); /* init controller (CEC) function */
transmit (&status, "IFC UNT UNL DCL REN"); /* device clear and remote enable */
}
/* ********************************************************************* */
void MakeTalk (int address) /* make device at address a talker */
{