Three-Wire Handshake Process. NI TNT4882 Programmer Reference
Реклама
Реклама
Appendix C Introduction to the GPIB
Three-Wire Handshake Process
GPIB devices use the three-wire handshake process to transfer information. The threewire handshake process is identical for command and data transfers. During command transfers, the Controller drives the DIO and DAV lines; all devices drive the NRFD and
NDAC lines. During data transfers, the Talker drives the DIO and DAV lines; all
Listeners drive the NRFD and NDAC lines.
Devices drive the NDAC and NRFD lines with open-collector drivers, so if any device drives NDAC (or NRFD) to a low voltage level, the signal is logically asserted (true).
If no device drives NDAC (or NRFD) to a low voltage level, the signal floats to a high voltage level; thus, the signal is logically unasserted (false).
The following actions occur during the three-wire handshake process (refer to
Figure C-5):
1.
The Talker (or Controller) places data on the DIO lines and waits at least T1 seconds.
2.
After the T1 delay, the Talker waits until the Listener unasserts NRFD. NRFD unasserted (not Not-Ready-For Data) indicates that the Listener can receive the data byte.
3.
The Talker asserts DAV to indicate that new data is valid on the DIO lines.
4.
The Listener asserts NRFD to signal a Not Ready Status (Don't Send More Yet).
5.
When the Listener accepts the current byte (by placing it in some internal buffer or by otherwise processing it), the Listener unasserts NDAC.
6.
The Talker unasserts DAV.
7.
The Listener asserts NDAC, then the Talker executes step 1 to begin transferring the next byte.
Physical and Electrical Specifications
To achieve the GPIB’s high data transfer rate, you must limit the physical distance between devices and the number of devices on the bus. This limitation is necessary because the GPIB is a transmission line system. Any distance beyond the maximum allowable cable length, as well as any excess GPIB device loads, can surpass interface circuit drive capability.
The IEEE 488 standard dictates the following limits:
• The total length of all cables is less than or equal to 2 m times the number of connected devices—up to a total of 20 m.
© National Instruments Corp.
C-13 TNT4882 Programmer Reference
Introduction to the GPIB Appendix C
• No more than 15 devices are connected to each bus, with at least two-thirds of the devices powered on.
If you must exceed these limits, you can purchase bus extenders and expanders.
Controllers, Talkers, and Listeners
All buses operate under rules that ensure that data passes reliably and that instruments do not use the bus simultaneously. To determine which device has active control of the bus, devices are categorized as Controllers, Talkers, or Listeners. Whenever two devices communicate, one device will be a Talker and the other will be a Listener. In addition, one device will always be a Controller.
Controllers
Most GPIB systems consist of one computer and a variety of instruments. In this type of system, the computer is typically the System Controller. If multiple computers are connected, several devices can have Controller capability, but only one Controller is active, or Controller-In-Charge (CIC), at a time. Active control can pass from the current CIC to an idle Controller.
For each GPIB system, you must define a System Controller. You usually define the
System Controller through jumper settings on the GPIB interface board, a software configuration file, or both. Only one device on the bus, the System Controller, can make itself the CIC.
The four primary responsibilities of a Controller are the following:
• Defining the communication links.
• Responding to devices requesting service.
• Sending GPIB commands.
• Passing/receiving control.
TNT4882 Programmer Reference C-14 © National Instruments Corp.
Appendix C Introduction to the GPIB
Talkers and Listeners
You can set most GPIB devices to be either Talkers or Listeners. However, some devices only talk or only listen. Each device accepts its own command set and has its own method of terminating data strings. Talkers and Listeners have the following properties:
• Talkers
- Are instructed by the Controller to talk.
- Place data on the GPIB.
- Permit only one device to talk at a time.
• Listeners
- Are instructed by the Controller to listen.
- Read data that the Talker places on the GPIB.
- Permit several devices to be Listeners simultaneously.
You can compare GPIB operation to a classroom. The instructor (Controller) controls the communication of data between the students (devices). The instructor decides who talks and who listens. On the GPIB, a device cannot talk or listen unless the Controller explicitly tells it to do so.
Figure C-6 shows a system setup example.
© National Instruments Corp.
C-15 TNT4882 Programmer Reference
Introduction to the GPIB
Controller
System Controller
GPIB
Multimeter
– 300.0005 V
Oscilloscope
Plotter
Figure C-6. System Setup Example
Appendix C
TNT4882 Programmer Reference C-16 © National Instruments Corp.
Appendix C Introduction to the GPIB
Data and Command Messages
In a classroom, when the instructor tells the students who is the Talker and who are the
Listeners, his or her information is a command—not the actual data information that the instructor will send. On the GPIB, this distinction is not so intuitive. The bus management line, ATN, determines what type of message you are sending on the bus. If this line is unasserted, the information on the bus is a data message; if this line is asserted, the information is a command message from the Controller to all devices. The devices on the GPIB monitor the ATN line, determine the data type, and treat the data appropriately.
GPIB Addressing Protocol
In a classroom, an instructor either speaks to the entire class or to a particular student. To speak to a student, the instructor first addresses that student by name.
Addressing on the GPIB follows the same idea. Before any communication can take place on the bus, you must address the Talker and Listener. Before any data passes between devices, the Controller determines who talks and who listens.
In the classroom, you address people by their names. However, on the GPIB, each device
(including the Controller) has a unique primary GPIB address in the range of 0 to 30
(decimal). The Controller places a command message specifying the addresses of the
Talker and Listener devices on the bus.
The Controller sends a single byte (8 bits) of information for a Talker or Listener address command message. Address command messages have the following format:
Bit
Data
7 6 5 4
TA LA X
3 2 1 0
X X X X
Bits 0 through 4 contain the binary GPIB primary address of the device in communication, and either bit 5—Listener Address (LA)—or bit 6—
Talker Address (TA)—will be set if the device is a Talker or a Listener. Bit 7 is never used and is considered a don’t care bit. For simplicity, assume bit 7 is zero.
© National Instruments Corp.
C-17 TNT4882 Programmer Reference
Introduction to the GPIB Appendix C
Consider an example in which a Controller at primary GPIB address 0 talks to a device at primary GPIB address 1. To establish the communication link, the Controller must send its GPIB talk address and the device's listen address over the GPIB. In this example, these addresses are as follows:
Bit Patterns Sent to Set Up Talker
Bit pattern: 01000000
010 00000
Hexadecimal value:
TA ADR Talker's GPIB Address is 0
0100 0000
4 0 Hex 40 = ASCII "@"
Refer to the Multiline Interface Command Messages table (in Appendix F) and find the hex 40 location. On the same row under the Msg column, you see the message MTA0, which means My Talk Address 0. Hex 40 is the command message for setting device 0 to be a Talker.
Bit Patterns Sent to Set Up Listener
Bit pattern: 00100001
001 00001
LA ADR Listener's GPIB Address is 1
0010 0001 Hexadecimal value:
2 1 Hex 21 = ASCII "!"
Refer to the Multiline Interface Command Messages table and find the hex 21 location.
On the same row under the Msg column, you see the message MLA1, which means My
Listen Address 1. Hex 21 is the command message for setting device 1 to be a Listener.
TNT4882 Programmer Reference C-18 © National Instruments Corp.
Appendix C Introduction to the GPIB
Reading the Multiline Interface Command Messages Table
By using the Multiline Interface Command Messages table, you can understand how the
GPIB circuitry interprets the bit patterns to produce the proper message commands. The
Multiline Interface Command Messages table is organized into four groups of columns.
The left or first group of columns (hex 00–1F) represents the primary GPIB addresses.
Moving to the right to the next group of columns (hex 20–3F), you will find the corresponding listen addresses (MLA). The listen address of a device is formed by adding hex 20 to the GPIB primary address. Again, move right to the next group of columns (hex 40–5F) for the corresponding talk addresses (MTA). You form the talk address of a device by adding hex 40 to the GPIB primary address.
Secondary Addressing
A device can have a secondary address. A secondary address is in the range of 0 to 30 decimal (IE hex). To form a secondary address command (bit pattern), add 96 decimal
(60 hex) to the secondary address. You address a device with a secondary address by sending the primary GPIB address, then the corresponding secondary address. With secondary addressing, you can assign up to 961 talk and listen addresses. Most instruments do not use secondary addressing. In the Multiline Interface Command
Messages table, the group of columns on the right (hex 60–7F) represents the secondary
GPIB address commands.
Unaddressing Command Messages
The CIC uses two special command messages to clear the bus of Talkers and Listeners before assigning new Talkers and Listeners. These command messages are Untalk and
Unlisten. The Untalk (UNT) command (hex 5F (ASCII “_”)) unaddresses the current
Talker. The Untalk command is merely a command for convenience, because addressing one Talker automatically unaddresses all others. The Unlisten (UNL) command (hex 3F
(ASCII “?”)) unaddresses all current Listeners on the bus. You cannot unaddress only a single Listener if you have previously addressed several Listeners. You must use the
UNL command to guarantee that you address only desired Listeners.
Termination Methods
When devices send data over the GPIB, they use up to three different methods to signify the end of a data transfer. These methods are EOS, EOI, and the count method.
Termination methods in GPIB are necessary only for data messages, not for command messages.
© National Instruments Corp.
C-19 TNT4882 Programmer Reference
Introduction to the GPIB Appendix C
EOS Method
The EOS method uses an EOS character, which signifies the termination of data that devices send on the GPIB. This EOS character can be any character. However, it is commonly a carriage return (hex 0D) or a line feed (hex 0A) that the Talker places as the last character in a data string. The Listener reads individual data bytes from the Talker until the Listener reads the EOS character. When the Listener reads the EOS character, it knows that there is no more data, so it completes the read operation.
You must configure the Talker and Listener to use the EOS method before the communication takes place. Many devices send specific EOS characters and look for specific characters from other devices, so it is important for you to read the documentation for all devices to see which termination method the devices use.
To use the EOS method in a classroom setting, the instructor and students would use a certain word to finish all communication within the classroom. As with the GPIB, the instructor and students would define this method and the word used before any communication took place. In the GPIB and in the classroom, the termination signal is sent by using the normal data path (data lines in GPIB, or speech in the classroom).
EOI Method
The EOI method uses the GPIB EOI line, which is separate from the eight data lines on the GPIB. In the EOI method, when the Talker sends the last byte of data in the transmission, it sets the EOI line high to specify that the byte is the last byte to be sent.
The Listener monitors the EOI line and recognizes when there is no more data. You must establish ahead of time whether the Talker will use the EOI method, so you can correctly configure the Listener to watch the EOI line.
Students could use the EOI method in the classroom: they would wave device cards in the air to signal when they have finished speaking. This form of communication is separate from the method of sending data (speech), but the other Listeners can monitor this communication while they receive data (hear the speech).
Count Method
The count method uses neither the EOI line nor the EOS character. In the count method, the device that receives information specifies the number of bytes to read. Through this method, a listening device reads a specified amount of data and prevents the talking device from sending more data. If you do not clear the remaining data from the bus, you can recover it later.
Students can use the count method in the classroom. Students count the words of someone who is talking. The Listener announces that he or she will listen to only a
TNT4882 Programmer Reference C-20 © National Instruments Corp.
Appendix C Introduction to the GPIB specified number of words. Beyond this number of words, the Listener will not hear any further information from the Talker. If the Listener wants more information, he or she requests more words from the Talker.
Combinations of Termination Methods
You can use any combination of the three termination methods to terminate communication on the GPIB. For example, you can specify an EOS character and also use the EOI line method. In this case, when the end of the string is reached, the device sending the data will send an EOS character and assert the EOI line. When you use more than one method, the first termination method recognized causes the termination. In this example, the EOS character or EOI line causes termination, depending on which method the device recognizes first.
In general, when you use more than one termination method at a time, all methods are logically ORed together for a result. Therefore, if you use all three methods, the communication termination will take place if the device sees the EOS character, the system asserts the EOI line, or the count value has been reached.
Serial Polling
Servicing SRQs
In the classroom, an instructor is in charge of the class and controls activity. The GPIB works in a similar fashion: the Controller bus controls when tasks are performed. In the classroom, a student must have permission to speak, and on the GPIB, no device can communicate unless it is addressed to talk on the bus. A device may, however, need to communicate with the Controller before the Controller tells it to talk. In a classroom, students who have something to say usually raise their hands. On the GPIB, any device can assert the SRQ line, which is separate from the data lines. SRQ informs the
Controller that a device needs attention. The next section discusses how the SRQ line is asserted and how the device that asserts it is identified.
Serial Polling Devices
This section investigates how the GPIB handles the SRQ line. Remember the SRQ line purpose: signaling to the Controller that a device needs attention. When SRQ is asserted, it is the responsibility of the Controller to determine who requested service by checking all devices individually. Checking the devices individually is known as polling the devices. The Controller can poll devices in two ways: in serial or in parallel. This appendix discusses serial polling.
Serial polling obtains specific information from a device. When you serial poll, the
Controller sends a special command message—Serial Poll Enable (SPE)—to the device,
© National Instruments Corp.
C-21 TNT4882 Programmer Reference
Introduction to the GPIB Appendix C directing it to return its serial poll status byte. The SPE message sets the IEEE 488.1
serial poll mode in the device, so when the device is addressed to talk, it returns a single
8-bit status byte. This serial poll status byte is different for each type of instrument; except for one bit, you must refer to the instrument user manual for information on the other bits. Bit 6 (hex 40) of any serial poll status byte indicates whether a device requested service by asserting the SRQ line. The device uses the other seven bits of the status byte to specify why it needs attention.
After the Controller reads the status byte, it sends another command message, Serial Poll
Disable (SPD), to the device. The SPD message terminates the serial poll mode, thus returning the device to its normal Talker/Listener state. Once a device requesting service is serial polled, it usually unasserts the SRQ line.
When a serial poll is conducted, the following sequence of events occurs:
System Controller GPIB Device
UNListen (UNL)
Device Listen Address
Serial Poll Enable (SPE)
Device Talk Address
Device as Listener
Generates Serial Poll Byte
Device Set as Talker
Read (IBRD) Serial Poll
Byte from Device
Serial Poll Disable (SPD)
UNTalk (UNT) All Devices
Serial Poll Byte Returned
Turns off Serial Poll Mode
Figure C-7. Events During a Serial Poll
TNT4882 Programmer Reference C-22 © National Instruments Corp.
Appendix C Introduction to the GPIB
Status Byte Model for IEEE 488.1
IEEE 488.1 defines only bit 6, the RQS bit, of the serial poll status byte (see the following table). If a device is requesting service, it sets RQS. The meaning of the remaining bits is device dependent.
7 RQS 5 4 3 2 1 0 Status Byte Register
ESR and SRE Registers
The IEEE 488.2 standard defines a set of commands for controlling the GPIB. The standard also defines a new method of working with the SRQ line on the GPIB. This section applies only to those GPIB devices that are IEEE 488.2 compatible. If a device is only IEEE 488.1 compatible, the previous section applies.
Status Byte Model for IEEE 488.2
IEEE 488.2 describes a scheme for status reporting. This scheme is required for all
IEEE 488.2 instruments. With this scheme, the Controller can obtain status information for every instrument in the system. This scheme builds on and extends the IEEE 488.1
status byte shown in the above table. Three bits of this status byte are defined. The
IEEE 488.2 standard defines the RQS bit like the IEEE 488.1 standard. IEEE 488.2 adds the Event Status Bit (ESB) and the Message Available (MAV) bit. The manufacturer defines other bits. The RQS bit indicates the device has requested service by asserting the SRQ line. The ESB indicates that one of the standard events defined in the Standard
Event Status Register has occurred. By setting the corresponding bits in the Standard
Event Status Enable Register, you define which standard events will set the ESB. The
MAV bit indicates whether a message is available in the instrument output queue. By setting the corresponding bits in the Service Request Enable Register, you can configure an instrument to assert the SRQ line based on the bits of its status register.
The IEEE 488.2 standard defines a dual role for the RQS bit. This bit is also known as the Master Summary Status (MSS) bit. The MSS bit indicates whether there is at least one reason for the instrument to request service. The status of this bit is returned only in response to the status byte (STB) query; its status is not sent in response to a serial poll because this bit is not part of the IEEE 488.1 status byte (see Figure C-8).
© National Instruments Corp.
C-23 TNT4882 Programmer Reference
Introduction to the GPIB Appendix C
Service
Request
Generation
7 6 5 4 3 2 1 0
&
&
&
&
&
&
&
&
7 6 5 4 3 2 1 0
Standard
Event Status Register
*ESR?
Queue
Not-Empty
Standard
Event Status Enable
Register
*ESE <NR f >
*ESE?
Output Queue
RQS
7 6
MSS
ESB MAV
3 2 1 0 read by Serial Poll
Status Byte Register read by *STB?
&
&
&
&
&
&
&
7 5 4 3 2 1 0
Service Request
Enable Register
*SRE <NR f >
*SRE?
Figure C-8. IEEE 488.2 Standard Status Structures
TNT4882 Programmer Reference C-24 © National Instruments Corp.
Appendix C Introduction to the GPIB
Parallel Polling
Parallel polling is another way to get information from a device that requests service.
Parallel polling differs from serial polling in two ways: all configured devices are polled simultaneously (that is, in parallel) and a Controller initiates a parallel poll sequence (any device requests the initiation of a serial poll sequence).
Overview of Parallel Polls
A parallel poll is an exchange of messages between the Controller and other system devices. The Controller sends the IDY message true to the other devices; each device responds to the IDY message by sending one PPR message (PPR1, PPR2, PPR3, PPR4,
PPR5, PPR6, PPR7, or PPR8) to the Controller. Each device usually sends a different
PPR message. (See the Physical Representation of the PPR Message section in this chapter.) Each device can send its PPR message either true or false. See Figure C-9.
Controller
PPR1 = true
IDY
PPR4 = False
Device
Device
PPR6 = true
Device
Figure C-9. Example Exchange of Messages During a Parallel Poll
© National Instruments Corp.
C-25 TNT4882 Programmer Reference
Изтегляне
Реклама