25
6.6.1
Sending Commands via the GPIB
Commands sent via the GPIB follow exactly the same syntax as for the RS232 interface.
Commands must be terminated by a Carriage Return <CR> character, (ASCII 13). A Line
Feed <LF> may be sent if desired but is not needed and will have no effect. (Your GPIB
controller may send <CRLF> by default). Provided it is operating (as opposed to being in
TEST mode) the ILM will accept commands at all times. Where commands produce a
response message, this should be read before a further command is issued.
6.6.2
Accepting Responses via the GPIB
Messages returned via the GPIB consist, by default, of an ASCII character string,
terminated by a <CR>. If your controller expects <LF> as a terminating character, this
may be achieved by sending an initial "Q2" command after power up. Note that the
"Q2" command itself produces no response message but that all subsequent messages
are terminated by the <CRLF> pair. The interface never asserts the EOI line at the end of
a message, instead allowing either <CR> or <LF> to be used as the End-of-String (EOS)
character.
6.6.3
The Status Byte, Use of a Serial Poll
One of the problems with a GPIB interface is knowing when a message is available to be
read. If a device is addressed to TALK but has no data available, it will wait indefinitely,
unless the controller includes a TIMEOUT facility (see section 6.6.10). There are a number
of ways by which the controller can determine when data is available. The simplest, but
least reliable way is to "know" from the command which has been sent, whether a reply
is to be expected. This is fine until something unexpected happens.
A better alternative is to read a STATUS BYTE from the instrument by conducting a
SERIAL POLL of it. The ILM interface will always respond to a serial poll and will return a
status byte. Three bits in this byte have significance for ILM as follows.
Bit 6 (Value 64 decimal)
RQS (Requesting Service)
Bit 4 (Value 16 decimal)
MAV (Message Available)
Bit 1 (Value 2 decimal)
BAV (Byte Available)
The bit positions for the RQS and MAV bits are as specified in IEEE-488.1 and IEEE-488.2
respectively. (Note the convention here is that the Least Significant Bit is Bit 0. This is
sometimes referred to as data line D1. Thus lines D1 to D8 correspond to Bits 0 to 7.)
The BAV bit is set as soon as at least one byte is available to be read. The MAV bit is set
when a complete message up to and including the <CR> or <LF> character is available to
be read. The RQS bit indicates that the instrument has requested service by asserting the
GPIB SRQ line true (see section 6.6.4).
The status byte may be read as many times as the controller wishes. The MAV and BAV
bits will reflect the current status of the interface at the time the byte is read (but see
below). Hence once set, they will remain set until the message has been read. The RQS
bit behaves differently (in accordance with IEEE-488.1). The first time the status byte is
read after the interface has requested service, it will be set. The act of reading the status
byte clears the service request bit and at the same time allows the interface to release the
Service Request Line (see below). It will not be asserted again unless a further service
request is issued.