USING hp3478ext AS A UNIVERSAL USB-UART-GPIB ADAPTER
GPIB DEBUGGER
hp3478ext implements basic line editor and command history functionality. While entering GPIB commands interactively doesn't seem to be practical for everyday use, it's quite useful for checking individual commands and learning how a particular device behaves.
Available line editor keys:
ENTER (\r) execute command UP (\x27[A) previous command in the history list DOWN (\x27[B) next command in the history list LEFT (\x27[D) move the cursor left RIGHT (\x27[C) move the cursor right BACKSPACE (\b), DELETE (\x7f) delete the character before the cursor
When using hp3478ext under software control, interactive mode should be turned off with the O1 or OI0 command.
HP 3478A EXTENSION MODE
Originally, the hp3478ext was designed as a hardware add-on to the HP 3478A multimeter. This assumes that the ATmega328P's firmware can operate without PC control, intercepting and responding to the 3478A's front panel keys. Such stand-alone operation is called an “extension mode” throughout this document. When using hp3478ext as a PC interface to remotely control GPIB devices, the extension mode should be disabled with OX0, O0 or O1 command.
COMMAND REFERENCE
D: transmit or receive ASCII data (ATN off)
This command receives data if the adapter is in the LISTEN state. The end of transmission is determined by receiving an end sequence (OR command). An absence of data (timeout) is represented by an empty string.
This command transmits data if the adapter is not in the LISTEN state. The payload immediately follows the command character. Depending on the OT (transmit end sequence) setting, a transfer is terminated with EOI, \r or \n.
Responses:
OK\r\n transmission complete TIMEOUT <len>\r\n timed out waiting for the device while transmitting (<len> is the number of bytes actually transmitted) \r\n timed out waiting for the device while receiving <payload> data received from the device
C: transmit an ASCII command (ATN on)
The C command transmits ASCII bytes with the ATN signal turned on. Transferred data is analysed to set the bus state as follows:
- The GPIB adapter will enter the LISTEN state if its listen address (+32) is in the command string.
- The GPIB adapter will exit the LISTEN state if its talk address (+64) or the unlisten command (?) is in the command string.
Responses:
OK\r\n transfer complete
TIMEOUT <len>\r\n timed out waiting for the device
(<len> is the number of bytes actually transmitted)
R, L: control REN signal
R turns REN on, L turns REN off.
Response:
OK\r\n
I: clear interface
Turns the IFC signal on for 1ms. The GPIB adapter will exit the LISTEN state.
Response:
OK\r\n
S: get status
Returns the state of the SRQ and REN lines as two ASCII characters, 0 or 1. The third character is the GPIB adapter’s state: 0 = TALK, 1 = LISTEN. Unlike the LISTEN state, in the TALK state it actually doesn't verify whether its TALK address was sent or not.
Response:
000\r\n three characters, as described above
P: enter "plotter" mode
In plotter mode, the GPIB adapter continuously attempts to read data from the bus. Send an ESCAPE (\x27) character to exit plotter mode.
Response:
<data> data read from the bus
O: option setting
Sets various options as described below. The syntax for the O command is as follows:
O<opt><val> set option <opt> to decimal <val>
O<opt> request an option’s current value
O? list all available options
O<opt><val>w set option <opt> to <val> and save it in EEPROM
O0 set to default values for interactive operation
O1 set to default values for non-interactive operation
Available options (<opt>):
X Enables or disables the HP 3478A extension mode. 1 = enable the HP 3478A extension mode. This mode conflicts with the GPIB commands described in this document. 0 = hp3478ext will not attempt to connect to the HP 3478A multimeter. This setting is assumed when using hp3478ext as a general purpose GPIB adapter. R Receive end sequence, which specifies when the THD, TUD and D commands will stop. 1 = CR, 2 = LF, 4 = EOI These bits may be ORed together so that any of the specified conditions will stop the transfer. T Transmit end sequence, which specifies what to send after the data is supplied using the D command. It accepts the same values as the R option. For example, 7 means to send CR followed by LF with EOI. I Enable or disable interactive mode. 0 = disable interactive mode. Turns off the line editor and echoing of commands, which disables the <GPIB> prompt. 1 = enable interactive mode. C Controller GPIB address. This address is recognised in GPIB commands so that the adapter knows it's in the LISTEN state. D Device GPIB address (the address of the HP 3478A). This is only used in hp3478ext’s extension mode. However, if this address is set to 31, the adapter will enter “plotter” mode upon start up (as if the P command was entered). B Baud rate. 0 = 115200, 2 = 500K, 3 = 1M, 4 = 2M. Note that the maximum available rate depends on the capabilities of the USB-UART chip that is being used. Responses: <opt_help> text returned from the O? command <val>\r\n option value in decimal OK option is set ERROR\r\n incorrect command syntax or value WRONG OPTION\r\n unknown option
?: quick help
Prints the command summary.
H: command list
Prints command history.
T: binary and hex transfer commands
THC transmit hex command
TBD transmit binary data
TBD<len> receive binary data
THD transmit hex data
THD<len> receive hex data
Data transmit or receive operation is determined by the LISTEN state of the adapter. For example, T is interpreted as receive, if the adapter is addressed as the listener. THC always transmits. (<len> is optional. It is one byte hex value and specifies maximum number of characters to receive.)
HEX data is an arbitrary length hex string terminated with an optional ; and \r\n. The line is terminated with EOI by default, so ; means that there is no EOI. When transmitting, the command buffer is limited to 64 bytes. The maximum payload size is (64 - sizeof("THD") - sizeof("\r")) = 30 bytes. There's no limit on the received hex string length.
Binary data consists of blocks prefixed with a one-byte length value. The block length is up to 127 bytes. The high-order bit of the length byte represents EOI at the end of the block. The transfer is terminated with a 0 byte (i.e., length = 0).
Responses:
ERROR\r\n incorrect command syntax TIMEOUT <len>\r\n timed out while transmitting (<len> = number of bytes sent, in decimal) OK\r\n send is complete (applies to TH commands) ;\r\n timed out receiving data for the THD command <payload> binary or hex payload (see example below) <txlen> status byte = number of bytes transmitted for each block (see example below) EXAMPLES
In all of the examples below, “=>” represents a request and “<=” represents a response. Characters that are escaped with a backslash “\” are non-printable characters in C notation. If the example demonstrates use of interactive mode, dialogue is presented as it is seen on the terminal (i.e., no special characters are shown).
Example 1: data formats
The following example explains how to send an EOI-terminated "HELLO WORLD\n" string in various formats.
Hex transmission:
=> THD48454c4c4f20;\r
<= OK\r\n
=> THD574f524c44210a\r
<= OK\r\n
Binary transmission:
=> TBD\r\x06HELLO \x87WORLD!\n
<= \x06\x07
ASCII transmission:
=> OT6\r\n
<= OK\r\n
=> DHELLO WORLD!
<= OK\r\n
Example 2: getting a reading from the HP 3478A
This example assumes a default controller address of 21 and multimeter address of 23.
<GPIB> CW5
OK
<GPIB> D
+1.87978E+0
<GPIB>
Example 3: serial polling - reading the status byte
<GPIB> THC183557
OK
<GPIB> THD1
01;
<GPIB> THC19