4-2
BIT 4886 051010
When sending these commands via the GPIB, these commands require a query to be added to
the command string to verify the previous command is complete. When the command is com-
plete, the unit updates the status byte and indicates MAV (Message Available, bit 4 - see Table
A-3) is true. MAV indicates that there is a response to be received by the computer, so when it
becomes set, the unit is ready for its next command after reading back the data from the query
that was added to the command string.
When sending the above commands via the RS 232 bus, data flow control must be enabled
(XON) for the unit to properly update flash memory.
The *OPC? query is ideal to check if the previous command is complete since it returns either a
1 or 0. It is important that it be sent as a part of the same string as the command that causes a
flash update. As an example, sending CAL:SAVE 12/31/2005;:*opc? or *opc?;:CAL:SAVE 12/
31/2005 are valid command strings. Sending the commands separately will not verify that the
previous command is complete. Figure 4-1 is a program written in C, incorporating these tech-
niques.
FIGURE 4-1. PROGRAMMING EXAMPLE TO VERIFY PREVIOUS COMMAND HAS COMPLETED
#include <formatio.h>
#include <utility.h>
#include <gpib.h>
#include <ansi_c.h>
/*Overhead for the use of a NATIONAL INSTRUMENTS gpib interface */
int unit_desc;
// handle for the national instruments controller
int GPIbus=0;
// GPIB card 0
int adr=6;
// Power Supply address
char status_byte;
// status byte from the power supply
#define MAV 0x10 /* bit 4 of the status byte is the Message AVailable bit by 488.2 specification */
/* Function Send_with_wait
INPUT: string to be sent to power supply
Description: adds the *OPC? query and performs serial polls to wait for the command to be completed.
*/
int Send_with_wait(char *command);
char snd[501];
// data to be sent to the power supply
char rcv [10];
// data from power supply
int j;
sprintf(snd,”%s;:*OPC?,command);
// Add *OPC? to the command
// so there is a response from the
// power supply
Send(GPIbus, adr, snd, strlen(snd), 2);
// Send the data to the power supply
for (j=0;j<500;j++)(
// loop until ready (5 seconds max)
Delay(.05);
// Wait for command to complete
ibrsp(unit_desc,&status_byte);
// get status byte
if ((status_byte& 0x10) ==0x10) break;)
// by looking for data in string
Receive (GPIbus, adr, rev, rev_buf_size,10);
// so the error queue will not receive a 410 error
}
main(
// test code to show operation of function.
unit_desc=ibdev(GPIbus,adr,adr/256,T100ms,1,0x40a);Delay(.005);
Send (GPIbus,adr,”VOLT 10;curr .01”,sizeof(“VOLT 10;curr .01”),NLEND;
Send_with_wait(“*SAV 10”);
}