Skip to main content
Skip table of contents

13.7 Asynchronous Serial [T-Series Datasheet]

Overview

The T-Series devices have universal asynchronous receiver-transmitter (UART) functionality available that supports 3.3V logic level (CMOS/TTL) asynchronous (asynch) serial communication. The TX (transmit) and RX (receive) lines can appear on any digital I/O.  Baud rates up to 38400 are supported, but the device's processor is heavily loaded at that rate.  The number of data bits, number of stop bits, and parity are all controllable.

Asynchronous (UART) vs. RS-232

The T-series asynchronous support and the RS-232 standard are the same in terms of timing and protocol, but different in terms of electrical specifications.  Connection to an RS-232 device will require a converter chip such as the MAX233, which inverts the logic and shifts the voltage levels.  On a T-series device, a low is 0 volts (inputs recognize 0.0 to 0.5) and a high (1) is 3.3 volts (inputs recognize 2.64 to 5.8 volts).  With RS-232, a low (0) is 3 to 25 volts and a high (1) is -3 to -25 volts; RS-232 has unique voltage levels and is inverted.

Lua Scripting

Lua scripting is often convenient for serial applications.  For example, you might write a script that does the serial communication to get a new reading from the serial device once per second, and puts that reading in a USER_RAM register.  This puts the complications of serial communication in a script running on the T-series device itself, and then the host software can just do a simple read of the USER_RAM register when convenient.  We have many serial examples available for Lua scripting.

A direct connection to a serial device is preferable

This serial link is not an alternative to the USB/Ethernet/WiFi connection. Rather, the host application will write/read data to/from the T-series device over USB/Ethernet/WiFi, and the T-series device communicates with some other device using the serial protocol. Using this serial protocol is considered an advanced topic. A good knowledge of the protocol is recommended, and a logic analyzer or oscilloscope might be needed for troubleshooting.

If it is practical to run a cable directly from the host computer to the serial device, that is usually a better than putting the T-series device inbetween.  Use a standard USB<=>RS-232 adapter/converter/dongle (or RS-485 or RS-422).

Multiple asynchronous ports on a single LabJack

The asynchronous feature can only be enabled on one pair of pins at a time, and to be more specific only one RX pin can read data at a time.  When the asynchronous feature is enabled on a pair of pins, a buffer is set up and the RX pin reads any data that comes in and stores it in the buffer.  This is useful for devices that spontaneously send out data where all that data is wanted all the time.  Most serial devices, however, act in a command-response manner where the LabJack sends a command that requests a reading and the device responds with the reading.  For these it is easy to do multiple ... just re-do the configuration writes whenever communication is desired on different pins.

How-To

Device Control Basics

  • All T-series device features are controlled by reading and writing Modbus TCP registers via Modbus TCP (either directly or through our LJM library).
  • We have register descriptions throughout documentation detailing relevant register names, starting addresses, types, and access permissions (read/write).
  • See Section 3.0 Communication for other detailed communication information.

Process

  1. Initial Configuration
  2. Transmit Data
  3. Receive Data
  4. Debugging data parity errors (if enabled)

Initial Configuration

Several registers need to be written to in order to configure the T-Series device for Asynch communication.

  • TX/RX data lines (ASYNCH_TX_DIONUM, ASYNCH_RX_DIONUM)
  • Baud rate configuration (ASYNCH_BAUD)
  • Configure RX buffer size (ASYNCH_RX_BUFFER_SIZE_BYTES)
  • Configure number of bits, number of stop bits, and the parity. (ASYNCH_NUM_DATA_BITS,​​​​ ASYNCH_NUM_STOP_BITS, ASYNCH_PARITY)

After configuring the various registers, the ASYNCH feature should be enabled by writing a 1 to (ASYNCH_ENABLE).

Transmit Data

In order to transmit data a user must do the following:

  1. Configure the number of bytes that needs to be sent (ASYNCH_NUM_BYTES_TX)
  2. Send data to the T-Series device using  the LJM_eWriteNameArray function (ASYNCH_DATA_TX)
  3. Write a 1 to the "GO" register (ASYNCH_TX_GO)
    note: The process of writing a 1 to the GO register instructs the T-Series device to transmit the buffered data via the TX line.

Receive Data

T-Series devices buffer received Asynch data up to the size defined in the configuration step when writing to the register "ASYNCH_RX_BUFFER_SIZE_BYTES".  The usual method for reading data from the buffer is to do the following:

  1. Read how many bytes of information have been received by the device (ASYNCH_NUM_BYTES_RX)
  2. Read data from the T-Series device RX buffer using the LJM_eReadNameArray function (ASYNCH_DATA_RX)
    note: When ever possible, it is recommended to read an even number of bytes from the DATA_RX buffer.

Debugging Data Parity Errors

Examples

For performing asynchronous communication from a computer, see the LJM C examples or the LJM LabVIEW examples.

For performing asynchronous communication on device, see the Lua scripting examples.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.