Download COMMUNICATIONS

Transcript
the devices being addressed.
board-level interface API to
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
The eZ80 has more than
the XML-RPC server. These
0
Talk
Listen
A5
A4
A3
A2
A1
enough speed to keep up with
routines mirror those of the
Table 1—A simple byte command byte format can address a device in a sinthe real-time demands of the
well-known
API used by
gle byte. Address 31 is reserved for the “untalk” and “unlisten” commands.
GPIB bus.
GPIB libraries for various
Each GPIB bus has one controller in devices into a listen state. After that,
platforms like Windows and Linux.
charge (CIC). It’s the function of the
The functions map directly into the
you can send commands to “unliscontroller to send commands and
network control functions provided
ten” and “untalk” the devices so that
specify who may talk on the bus.
by the XML-RPC server to the
the bus is in a known state. The conBecause our controller acts in place of
client software. Because of time
troller then addresses itself as a talker
a PC and runs the client application,
constraints, we implemented the
by sending its talk address followed
it acts as the CIC for the bus.
functions for demonstrating the
by the listener address.
The handshaking signals pertinent
board’s functionality (SendIFC,
Handshaking transmission data is
to our design include: Interface Clear
SendCmds, SendDataBytes, Send,
the same for command and data
(IFC), Attention (ATN), Service
bytes. First, the driver makes sure
ReceiveSetup, RcvRespMsg, and
Request (SRQ), Not Ready for Data
that NRFD isn’t asserted, indicating
Receive) rather than the entire stan(NRFD), Data Available (DAV), Not
that all of the addressees are ready for
dard API.
Data Accepted (NDAC), and End or
data. The driver then places the data
Identify (EOI). The controller takes
on the bus and asserts DAV. When all
XML-RPC SERVER
control of the bus by pulling the IFC
of the devices have accepted the data,
The network GPIB controller
signal low for at least 100 µs upon
NDAC will go high and the driver can requires a network server with a proinitialization. To keep the bus quiesde-assert DAV. This cycle is repeated
tocol that can manage GPIB requests
cent during periods of inactivity, we
for each byte sent.
and responses from remote clients.
keep ATN asserted, which forces all
There are three different ways to
The primary requirements for the proof the other devices off the bus. A
terminate the transmission: assert
tocol are that it must be simple, it
device can assert SRQ if it needs
EOI on the last byte, send a line feed
must operate reliably over an IP netservice.
(0x0A), or do both (see Photo 1). In
work, and it must be built on top of
Addresses in GPIB commands are
order to receive data, the driver must
the ZTP TCP/IP protocol stack. We
5 bits along. One bit is unused. The
first address another device as a talker. considered the implementation of a
other 2 bits specify whether the
Again, the driver begins by asserting
proprietary server and protocol, but
address is a talk address or a listen
ATN, and it then “untalks” and
because of its simplicity, broad plataddress. The range is from one to 31
“unlistens” all devices on the bus.
form support, and ease of implemen(see Table 1). But because primary
The driver then addresses itself as the
tation, we selected the XML-RPC for
address (PAD) 31 is reserved, it leaves
listener and addresses the new talker.
the task.
a total of 31 addresses for use on the
Following this, the driver can deThe XML-RPC protocol performs
bus (zero through 30). By convention,
assert ATN and begin to receive data
remote procedure calls using HTTP
PAD 0 is reserved for the controller,
from the talker.
as a transport and XML as the data
but this isn’t mandatory.
Handshaking received data takes on
encoding. Requests are issued via a
There are two types of data on the
the opposite role from a send. After
standard HTTP-POST request, norGPIB bus: commands and data.
ATN is de-asserted, the bus has been
mally to the /RPC2 URI path on the
Asserting ATN when you place the
turned over to another device as the
server. The server always sends a
command data on the bus identifies
talker, so the transceivers must be
response to a request. An example
the former. The CIC is the only
switched out of Talk Enable mode.
XML-RPC request/response
device allowed to send commands
The driver then raises NRFD and
sequence for a GPIB send function is
and assert ATN. Commands are indiasserts NDAC to
vidual bytes used to specify which
indicate that it’s
devices should listen and which
ready to receive data.
should talk. Command bytes also
After DAV goes low,
exist that “untalk” or “unlisten” all
the driver asserts
devices on the bus. Any number of
NRFD and retrieves
command bytes can be sent while
the data from the bus.
ATN is low. All devices on the bus
This cycle repeats for
must monitor these commands.
each byte of data.
To send data, the driver first needs
Again, the transmisto set “talk enable” on the transsion is terminated by
ceivers to ensure that you’re driving
an EOI or a line feed.
the correct signals onto the bus. ATN
The GPIB driver
Photo 1—Take a look at the GPIB control lines. ATN is de-asserted so these
are data cycles. EOI signals the end of the transaction.
is then driven low to force all of the
provides a standard
www.circuitcellar.com
CIRCUIT CELLAR®
Issue 178
May 2005
67