Skip to content

Instantly share code, notes, and snippets.

@asanza
Created October 7, 2016 20:55
Show Gist options
  • Save asanza/4e2719744fb0a41c8828e21dc2b7f012 to your computer and use it in GitHub Desktop.
Save asanza/4e2719744fb0a41c8828e21dc2b7f012 to your computer and use it in GitHub Desktop.
hpib commands
## HP-IB commands
Any type of control action on the HP-IB bus is called a 'command'. What makes the HP-IB bus a bit complicated is that there are four different types of commands: Single- or uni-line commands, universal multiline commands, addressed commands and secondary commands. Universal multiline commands, addressed commands and secondary commands all use more than one bus line, and therefore transport so-called multiline messages.
This needs a bit more explanation. In general, the number of bus lines should be as low as possible. Any additional line means more wires and more bus drivers. Therefore, HP-IB commands in general are just bytes put on the bus with the handshake as described above, but with ATN asserted. The byte value determines which command is issued. Universal multiline commands and addressed commands are both working that way. The only difference is that universal multiline commands do not require a communication context set up before (they simply apply to all devices on the bus), wheras the addressed commands will only be recognized by devices which have been configured as listeners or talker before (depending on the command). Commands for unaddressing devices as talker or listeners (putting devices back into idle state) are examples for universal multiline commands. Asserting any of the bus management lines is called 'single- or uni-line command', and they always apply immediately to all devices which are connected to the bus without any handshake, and therefore can be asserted at any time, even during a byte transfer.
Now all the command types explained above have one thing in common: They are all well defined within the IEEE-488 standard, and every command has its meaning. But the HP-IB standard also allows device-specific commands, which have a meaning for a certain device only, which again is defined by the manufacturer of the device and not within the standard. This type of command is called a 'secondary command', since it in general follows a universal multiline command holding the primary address (such as TAD or LAD). One of the possible uses of a secondary command is to select (=address) a subsystem within a device, so the secondary command is also called a 'secondary address'. As with the primary address, the range for secondary address is 0 to 30. The combination of a primary address with a secondary address is also called "extended addressing" since it allows up to 31 x 31 = 961 entities to get identfied.
Basically, by using a byte as command information, up to 256 different commands are possible. Practically, the most significant bit of a command is reserved (used for parity), and the next two bits are used to identify addressing commands (talker, listener, secondary), so there are in fact up to 32 commands left in addition to talker and listener adressing & unadressing. The following tables show how the bus management lines and command byte codes are assigned within the HP-IB standard.
So as a summary, every device on an HP-IB bus has its own unique primary address, which is between 0 and 30. If so-called extended addressing is used, every device can keep its own set of secondary addresses (again between 0 and 30) for up to 31 subunits. For fully addressing a subunit, the controller must use a combination of the primary and the secondary address.
Note: Please don't confuse this extended addressing with the fact, that interfaces may also allow more than one single primary address. In that case, the interface acts towards the bus simply a single device which can be selected or configured with more than one primary address. If a device uses two primary addresses the first is normally called the major address, and the other address is called the minor address.
## Notation
The sequence of a bus transaction is normally described as sequence of mnemonics. A typical 13-byte data transfer of the string "HELLO WORLD" terminated with Carriage Return & Line Feed from the controller (we assume primary address 21) to a device (assumed at primary address 1) shows like this:
```
Mnemonic Comment
UNL // puts any current listener back into idle state
LAD 1 // addresses the device at primary address 1 as listener
MTA 55 // the controller addresses itself as talker (address 21 = hex 15)
DAB 'H' // the controller sends the data string to the device (ASCII codes)
DAB 'E'
DAB 'L'
DAB 'L'
DAB 'O'
DAB ' '
DAB 'W'
DAB 'O'
DAB 'R'
DAB 'L'
DAB 'D'
DAB '\r' // send CR character (hex 0D)
DAB '\n' // send LF character (hex 0A)
UNT // the controller untalks itself
UNL // unaddresses all listeners on the bus state of the data lines without parity
```
Note that the single-/uni-line commands are not mentioned, the only line which is of relevance in this case is the Attention (ATN) line, which is automatically asserted during every command and unasserted during the data transmission (the series of DAB). Also note that parity is not used on the commands (if parity is enabled, HP-IB is normally using odd parity, which means that the MSB will be set if the sum of all bits without the parity bit is even, but parity in fact is not part of the IEEE-488 standard).
## Single-/uni-line messages (apply to all devices immediately):
| Mnemonic | Full Name | Description|
|-----------|-----------|-----------|
| ATN | Attention | Controls whether the bus in in command mode (ATN active low) or in data mode (ATN inactive high)|
| IFC | Interface Clear | Initializes the interface to an idle state (no activity on the bus)|
| SRQ | Service Request | Alerts the controller to a need for communication|
| REN | Remote Enable | Enables all devices to respond to remote program control when addressed to listen|
| EOI | End or Identify | Indicates the last data byte of a multibyte sequence, also used with ATN asserted simultaneously to conduct a Parallel Poll (cause all devices to assert their status bit)|
## Multiline Messages
### Addressed commands
| Mnemonic | Full Name | Decimal Code | Hex Code | Description|
|-----------|-----------|--------------|----------|------------|
|MLA |My Listen Address | x + 32 | x + 20 | LAD matching the own primary address. Used for example by the controller to address itself as listener (with x the current primary address of the controller)
| MTA | My Talk Address | x + 64 | x + 40 | TAD matching the own primary address. Used for example by the controller to address itself as talker (with x the current primary address of the controller) |
| LAD x | Device Listen Address | 32-62 | 20-3E | Group of commands used to address the device with address x = code - 32 as listener
| UNL | Unlisten | 63 | 3F | Used to put all devices currently addressed as listeners back into idle state (there is no way to unlisten just one listener separately from the others)
| TAD x | Device Talk Address | 64-94 | 40-5E | Group of commands used to address the device with address x = code - 64 as talker, at the same time unaddresses the previous talker (there can be just one single talker at a time) |
| UNT | Untalk | 95 | 5F | Used to put the device currently addressed as talker back into idle state |
| SAD x | Secondary Device Address | 96-126 | 60-7E | Group of commands used to do second level addressing (device specific, x = code - 96)|
### Universal multiline commands (apply to all devices):
| Mnemonic | Full Name | Decimal Code | Hex Code | Description |
|-----------|-----------|--------------|----------|-------------|
| LLO | Local Lockout| 17 | 11 |Disables a particular front-panel or rear-panel local reset or return-to-local control (use REN to re-enable the control)|
| DCL | (Universal) Device Clear | 20 | 14 | Causes all devices to return to a defined, device-dependent state |
| PPU | Parallel Poll Unconfigure | 21 | 15 | Resets all devices which are in a Parallel Poll state back into idle state (not responding to a Parallel Poll) |
| SPE | Serial Poll Enable | 24 | 18 | Establishes Serial Poll mode for all devices on the bus. Once addressed to talk, each device will return a single status byte.|
| SPD | Serial Poll Disable | 25 | 19 | Terminates Serial Poll mode, so that no device responds on being addressed to talk with its status byte any more. |
### Addressed commands (apply to listeners/talkers only):
| Mnemonic | Full Name | Decimal Code | Hex Code | Description |
|------------|-----------|--------------|----------|-------------|
|GTL | Go to Local | 1 | 1 | Causes all devices currently addressed as listeners to return to local panel control (exit remote state) |
| SDC | Selected Device Clear | 4 | 4 | Causes all devices which have been previously addressed to listen to return to a defined, device-dependent state |
| PPC | Parallel Poll Configure | 5 | 5 | Causes the devices being addressed as listeners to be configured to a Parallel Poll response specified by the following secondary (secondary codes 96-111) or to disable Parallel Poll response (secondary code 112) |
| GET | Group Execute Trigger | 8 | 8 | Initiates a pre-programmed, device dependent action simultaneously for any device which has been previously addressed to listen (e.g. start with measuring) |
| TCT | Take Control | 9 | 9 | Causes the device previously addressed to talk to begin operating as a bus controller (controller-in-charge) |
| PPE | Parallel Poll Enable | 96-111 | 60-6F | Group of secondary commands sent after a Parallel Poll Configure (PPC) command has been received for configuring the Parallel Poll response of the addressed device - the three least significant code bits specify the response line and bit 3 defines the condition of response (sense bit) |
| PPD | Parallel Poll Disable | 112 | 70 | Secondary command for disabling the Parallel Poll response of the addressed device after a Parallel Poll Configure (PPC) command has been received |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment