Serial interface to the AVS-47

The AVS-47 [1] is a lab instrument for accurate measurement of electrical resistance. The AVS supports remote readout and commanding via a digital computer interface port. This interface port uses Picobus, a proprietary communication protocol by Picowatt.

This post describes a method to access the AVS-47 with custom software via a direct cable between the AVS-47 Picobus port and the serial port of the computer. This method does not depend on Labview or any particular driver or software library. It can be implemented from scratch in C or Python or any language that provides low-level access to the serial port.

Picobus protocol

Picobus [2] is a synchronous serial protocol based on 4 signals: CP (clock pulse), DC (data from computer), DI (data from instrument), AL (alarm). Bus transactions are initiated by the computer. A transaction starts with the computer sending an 8-bit address, followed by both the computer and the AVS simultaneously sending 48 bits of data.

Special protocol converters are available to translate Picobus to GPIB which can then be connected to the computer via a GPIB-USB adapter. I don't like these converters. Their intermediate layer of protocol translation opens up a new set of potential communication errors and makes it much more difficult to debug such errors.

Direct connection to serial port

The Picobus port can also be accessed via a direct cable to the RS-232 serial port of the computer. Alternatively, an RS-232-to-USB converter can be used, for example if the computer does not have physical RS-232 ports available.

The usual RX/TX lines of the RS-232 port are not used. Instead, the Picobus communication lines are connected to 4 modem control lines on the RS-232 port as follows [2]:

RS-232 side
(DE9 connector)
AVS-47 side
(DB25 connector)
(not connected) pin 1 = cable shield
pin 7 = RTS (to AVS) pin 4 = CP (clock pulse)
pin 8 = CTS (from AVS) pin 5 = DI (data from instrument)
pin 6 = DSR (from AVS) pin 6 = AL (alarm)
pin 5 = GND pin 7 = GND
pin 4 = DTR (to AVS) pin 20 = DC (data from computer)

The cable shield should be attached to the connector shell at the PC side, but not at the AVS-47 side to avoid ground loops.

Implementing the Picobus protocol

Operating the Picobus is now a matter of manipulating the modem control lines in a particular pattern. The following pseudo-code shows the correct sequence of bit operations.

proc sendrecv(addrbits, txbits, rxbits): # Send 8 address bits for b := 7 downto 0 do setRTS(0) # falling CP setDTR(addrbits[b]) # send address bit on DC sleep(bittime) setRTS(1) # rising CP sleep(bittime) # Strobe (3 pulses on DC while CP remains low) setRTS(0) setDTR(0) sleep(bittime) for b := 2 downto 0 do setDTR(1) sleep(bittime) setDTR(0) sleep(bittime) # Send/receive 48 data bits for b := 47 downto 0 do rxbits[b] := getCTS() # receive data bit on DI setRTS(0) # falling CP setDTR(txbits[b]) # send data bit on DC sleep(bittime) setRTS(1) # rising CP sleep(bittime) # Strobe (3 pulses on DC while CP remains low) setRTS(0) setDTR(0) sleep(bittime) for b := 2 downto 0 do setDTR(1) sleep(bittime) setDTR(0) sleep(bittime)

The sleep duration bittime is typically 1 ms. Faster bit rates are possible with a physical serial port on the computer (e.g. 100 μs) but not all USB-to-RS-232 converters can so quickly detect changes on the modem control lines.

Note that the most significant bits of the address and data are transferred first, the least significant bits last.

The default Picobus address of the AVS-47 is 1, i.e. addrbits[7...0] = 0000001.

Meaning of the 48 data bits

The 48 bits from computer to AVS specify a new configuration that the AVS will use for subsequent measurements. The 48 bits from AVS to computer contain the last measured value, as well as the configuration used by the AVS during the last measurement.

Note that the AVS will only accept a new configuration from the computer in REMOTE mode. In LOCAL mode, the AVS listens to its front-panel switches and ignores the configuration bits from the computer (except for the LOCAL/REMOTE bit).

The meaning of the 48 bits can be found in LabView example code provided by PicoWatt [3]:

48 bits to AVS (txbits)
bits 47 ... 32 digital reference, or 0 when not used
bits 31 ... 24 3 to change digital reference, or 0 when not used
bits 23 ... 22 00
bits 21 ... 20 Input mode: 00 = ZERO; 01 = MEAS; 10 = CAL
bits 19 ... 17 Channel (CH0 ... CH7)
bits 16 ... 14 Display mode: 000 = R; 001 = dR; etc.
bits 13 ... 11 Excitation
000 = 0
001 = 3 μV
010 = 10 μV
...
111 = 3 mV
bits 10 ... 8 Range
000 = OPEN
001 = 2 Ohm
010 = 20 Ohm
...
111 = 2 MOhm
bit 7 0
bit 6 0 = LOCAL, 1 = REMOTE
bit 5 0
bit 4 0 = enable AL, 1 = disable AL
bit 3 ... 0 0000

48 bits from AVS (rxbits)
bits 47 ... 43 (ignored)
bit 42 1 = ADC overrange
bit 41 0 = negative sign; 1 = positive sign
bit 40 decimal digit 4 (leftmost digit)
bits 39 ... 36 decimal digit 3
bits 35 ... 32 decimal digit 2
bits 31 ... 28 decimal digit 1
bits 27 ... 24 decimal digit 0 (rightmost digit)
bits 23 ... 22 (ignored)
bits 21 ... 20 Actual input mode
bits 19 ... 17 Actual channel (CH0 ... CH7)
bits 16 ... 14 Actual display mode
bits 13 ... 11 Actual excitation
bits 10 ... 8 Actual range
bit 7 (ignored)
bit 6 0 = LOCAL, 1 = REMOTE
bit 5 (ignored)
bit 4 0 = AL enabled, 1 = AL disabled
bit 3 ... 0 (ignored)

The 48 bits from the AVS (rxbits) contain the measured value in the form of binary-coded decimal digits. The measured resistance (in Ohm) can be determined from the numerical value of the decimal digits together with the range setting.

if (not ADC_overrange) and (range > 0) then disp = ( digit_4 + 0.1 * digit_3 + 0.01 * digit_2 + 0.001 * digit_1 + 0.0001 * digit_0 ) if not sign: disp = - disp resistance_ohm = disp * 10**(range-1)

The AL signal

The AL signal is used by the AVS to indicate that a new measurement is complete. The signal becomes inactive during communication between computer and AVS, then becomes active again as soon as the AVS completes its next measurement. The computer can monitor the AL signal (by reading the status of the DSR modem line) to wait for measurement completion.

References