Hardware Reference
In-Depth Information
The equivalent in C/C ++ would be:
int device; // Reserve space for returned data
char buffer[100]; // Reserve space for returned data
device = ibfind ("Volt Meter");
// First open the voltmeter device
ibclr (device);
// and then clear the device
ibwrt (device, "*RST");
// Send the command to reset the meter
ibwrt (device, "VDC");
// and then select the DC voltage range
ibwrt (device, "VAL?");
// Request the current voltage reading
ibrd (device, buffer,100);
// and read the value into the buffer
printf ("Voltage = %s\n" buffer);
// Now display the returned reading
Note that board I/O requires a more detailed understanding of the IEEE-488
bus and programs must explicitly send all of the command codes to set up each
bus operation. For example, the following code fragments (the first in BASIC
and the second in C/C ++ ) will send the commands UNL, UNT, MTA13, MLA0
(see Figure 8.5) to a board:
command$ = "?" + "_" + "M"+""
'Create the command string
CALL ibcmd (board%, command$)
' and send it to the board
command = "\0x3f\0x5f\0x4d\0x20";
// Create the command string
ibcmd (board%, command, 4);
// and send it to the board
Troubleshooting the
IEEE-488 bus
The IEEE-488 bus is generally well tempered and easy use. Despite this, occa-
sions do arise when the would-be system integrator is confounded by recalcitrant
hardware and software which just will not behave as expected. Fortunately, fault
finding on the IEEE-488 bus is usually very much simpler than when performing
a similar task on an asynchronous serially based system (e.g. an RS-422-based
network). There are two main reasons for this: firstly, the IEEE-488 bus standard
is open to much less variation in implementation and secondly, all signals use
standard TTL voltage levels. This latter fact permits the use of conventional
digital instruments (such as logic probes and pulsers - see page 428). Fur-
thermore, the controlling software often contains its own diagnostic routines
and will warn the user if, for example, an external device is not responding to
commands placed on the bus.
Where necessary, simple routines can be generated to exercise the bus (read-
ing and displaying status codes for each device and transaction). It should be a
relatively easy matter to isolate the fault by this means. Alternatively, remote
instruments can be checked by interfacing in a different (perhaps simpler) bus
configuration and checking that they perform correctly.
Finally, before delving into hardware, it is always worth checking the config-
uration of the software and the assignment of addresses to the various devices
employed within the system at an early stage. If it is necessary to check the state
of the various control signal lines (including EOI, SRQ NRFD, NDAC, etc.),
a common-or-garden logic probe can be used to check for activity (remember
that lines are active low).
Search WWH ::




Custom Search