Communications protocol and commands (obsolete code version LZ34C711)

The default communication protocol shipped with the LazyFish is 38400 baud, 8 bits, no parity, 1 stop bit (38.4K baud, 8N1). To poll the LazyFish, send either an ASCII W or ASCII R. After an R, the LazyFish will respond with a 48-byte string representing 8 decimal numbers between 0 and 65535. These 8 numbers are all the measurements the LazyFish can make: there are 4 transmitters and 2 receivers, and the eight numbers are all the transmit-receive pairs. The W command returns 4 numbers (24 bytes), representing the signal on the currently selected receive channel due to each of the four transmitters.

Protocol: 38.4K baud, 8N1

    Your Command

    R

    W

    S

    T

    C0

    C1

    C2

    C3

    Ixyz

    X0

    X1

    X2

    X3

    Kn

    U

    V

    Meaning

    Read all 8 chans.

    Read 4 chans.

    Read single chan.

    Test command...return raw sampled values.

    Read from uncommited ADC chan 0.

    Change to RCV chan 1

    Change to RCV chan 2

    Read from uncommited ADC chan 3.

    Change integration parameters

    Change to TX chan 0.

    Change to TX chan 1.

    Change to TX chan 2.

    Change to TX chan 3.

    Set arbitrary TX mask n (be careful!)

    Get URL of driver download page.

    Get code version.

    Lazyfish response (example)

    00000 11111 22222 33333 44444 55555 65535 65535[CR]

    00000 11111 22222 33333[CR]

    65535[CR]

    00255 00255 00255 00255[CR]

    None

    None

    None

    None

    None

    None

    None

    None

    None

    None

    http://jrs.www.media.mit.edu/~jrs/lazydrv

    LZ34C711


R command

Read all eight channels (all pairs made with the 4 transmitters and 2 receivers). This command is not affected by the C, X, or K commands.

W command, C command

Read 4 channels (each of the 4 transmitters paired with the currently selected receive channel). This command is not affected by the X or K commands since it automatically choses the transmitters, but is affected by the C command, which choses the receive channel. The LazyFish has two analog front end receive channels, which can be selected using C1 or C2. The commands C0 and C3 select two uncommitted ADC channels (with no op-amp front ends). To use the LazyFish as a data acquisition board (to measure a DC voltage to and return it to the computer), you'd use C0 or C3, followed by the T command.


S command

Read a single channel. Uses the currently selected transmitter or transmit mask, and the currently selected receive channel. The transmit channel (or channels) is selected by the X or K commands (whichever was issued last). The receive channel is determined by the C command.

T commnd

The main purpose of the T command is to check whether the front end is clipping. This command returns 4 raw ADC samples (0, pi/2, pi, 3pi/2). The range of values is 0 to 255. For consistency with other commands, these are 5 byte decimal ASCII numbers (so the first two digits of each number are 0). If any of the 4 values returned by this command are 0 or 255, the front end is clipping. To eliminate clipping, the transmit burst length parameter z can be decreased, or the electrode geometry can be changed. To eliminate clipping by changing the electrode geometry, the electrode sizes can be decreased, the distance between the electrodes can be increased, or a grounded shield can be placed in the vicinity of the electrodes.


I command

The parameters x,y, and z are each single bytes. The default values of x,y, and z are 1, 20, and 7. The product x*y specifies the number of measurements to be integrated each time the LazyFish receives a poll command. The z value is the length (in periods) of the transmit burst used to excite the resonant transmitter. If the receive front end is clipping (which can be determined by connecting an oscilloscope to test points on the board, or using the T command), this value should be decreased. The shorter excitation burst will prevent the transmitter from ringing all the way up to its maximum 80V peak-to-peak swing, and thus should prevent the receive front end from clipping.

The total measurement time is proportional to the product x*y*z. Increasing x*y will decrease the measurement noise, as will increasing z (up to the point that the front end clips). But the increased measurement time means that the sensor update rate is lower. The default parameter values represent a good tradeoff between update rate and measurement noise.


X command

This selects a transmitter. X0 picks transmitter 0, X1 picks transmitter 1, and so on. The command works by writing the appropriate value into the transmit mask. You can also set the transmit mask directly by using the K command (below). Since the R and W commands reset the transmit mask automatically, X and K do not affect R or W. Modifying the transmit mask does affect S and T, however.

K command

This selects a transmit mask, which gives you raw control over which pins are activated when the unit transmits. With this command, you could activate multiple transmitters simultaneously, if for some reason you wanted to. Bit 7 of the mask controls pin B7. A one in the mask indicates that the corresponding pin should be used as a transmitter. Note that not every pin in the B port is actually a transmitter. In particular, pins B0 and B1 are normally used for serial communication, so writing a 1 into these bits is probably not a good idea. Since the R and W commands reset the transmit mask automatically, X and K do not affect R or W. Modifying the transmit mask does affect S and T, however.

U command

Get URL for driver download page. For current code rev, returns http://jrs.www.media.mit.edu/~jrs/lazydrv.

V command

Returns code version. Current code versions are LZ34C71 (compiled for PIC16C71) and LZ34C711 (for PIC16C711).