3.2.2 Low-Level Streaming [T-Series Datasheet] | LabJack
« Close

Datasheets and User Guides

App Notes

Software & Driver


3.2.2 Low-Level Streaming [T-Series Datasheet]


Stream mode is complicated but can easily be executed using the high-level LJM stream functions. LJM is recommend for all users, except users that need to integrate a T-series device into a system that cannot use LJM. The rest of this section is about manually executing stream protocol without LJM. For an introduction to stream and for additional configurations, see 3.2 Stream Mode.

Executing stream mode involves the following:

  • Stream setup
  • Stream start
  • Stream-in data collection, if any stream includes stream-in channels
  • Stream-out buffer updates, if stream includes stream-out channels (See 3.2.1 Stream-Out)
  • Stream stop

Spontaneous Stream vs. Command-Response Stream:

Data can be sent to the host in one of two data collection modes:

  • Spontaneous: In spontaneous mode, packets are automatically sent to the host as soon as there is enough data to fill a packet. The packet size is adjustable. See the register definitions below.
  • Command-Response (CR): In CR mode, the stream data is stored in the device’s buffer and must be read out using a command. CR mode is useful for when the connection is unreliable.

T-series devices connected via either USB and Ethernet are capable of both spontaneous stream and command-response stream.

T7-Pro only: T7-Pro devices connected via WiFi are capable of only command-response stream.


Manual stream setup requires configuration of the registers that LJM_eStreamStart automatically configures:

Manual Stream Setup
Name Start Address Type Access

STREAM_SCANRATE_HZ             Write a value to specify the number of times per second that all channels in the stream scanlist will be read. Max stream speeds are based on Sample Rate which is NumChannels*ScanRate. Has no effect when using an external clock. A read of this register returns the actual scan rate, which can be slightly different due to rounding. For scan rates >152.588, the actual scan interval is multiples of 100 ns. Assuming a core clock of 80 MHz the internal roll value is (80M/(8*DesiredScanRate))-1 and the actual scan rate is then 80M/(8*(RollValue+1). For slower scan rates the scan interval resolution is changed to 1 us, 10 us, 100 us, or 1 ms as needed to achieve the longer intervals.

4002 FLOAT32 R/W

STREAM_NUM_ADDRESSES             The number of entries in the scanlist

4004 UINT32 R/W

STREAM_SAMPLES_PER_PACKET             Specifies the number of data points to be sent in the data packet. Only applies to spontaneous mode.

4006 UINT32 R/W

STREAM_AUTO_TARGET             Controls where data will be sent. Value is a bitmask.<br>bit 0: 1 = Send to Ethernet 702 sockets,<br>bit 1: 1 = Send to USB,<br>bit 4: 1 = Command-Response mode.<br>All other bits are reserved.

4016 UINT32 R/W

STREAM_SCANLIST_ADDRESS#(0:127)             A list of addresses to read each scan. In the case of Stream-Out enabled, the list may also include something to write each scan.

4100 UINT32 R/W

STREAM_ENABLE             Write 1 to start stream. Write 0 to stop stream. Reading this register returns 1 when stream is enabled. When using a triggered stream the stream is considered enabled while waiting for the trigger.

4990 UINT32 R/W

Additional Configuration Notes

Additionally, address 4018 (STREAM_DATATYPE) must be written with the value 0. Note that address 4018 (STREAM_DATATYPE) is not in ljm_constants.json and is not compatible with LJM_NameToAddress.

STREAM_ENABLE must be written last.

For other stream configuration registers, which are not required for all streams, see 3.2 Stream Mode.

Data Collection

Spontaneous Stream: Once stream has been initiated with STREAM_ENABLE, the device sends data to the target indicated by STREAM_AUTO_TARGET until STREAM_ENABLE is written with the value 0. Stream-out streams that do not contain stream-in channels (see above) do not send data.

Modbus Feedback Spontaneous Packet Protocol:

Bytes 0-1: Transaction ID

Bytes 2-3: Protocol ID

Bytes 4-5: Length, MSB-LSB

Bytes 6: 1 (Unit ID)

Byte 7: 76 (Function #)

Byte 8: 16

Byte 9: Reserved

Bytes 10-11: Backlog Bytes

Bytes 12-13: Status Code

Byte 14-15: Additional status information

Byte 16+: Stream Data (raw sample = 2 bytes MSB-LSB)

Command-Response Stream: When collecting data using command-response stream mode, data must be read from STREAM_DATA_CR (address 4500). Data is automatically discarded as it is read. 

Modbus Feedback Command-Response Packet Protocol:

Bytes 0-1: Transaction ID

Bytes 2-3: Protocol ID

Bytes 4-5: Length, MSB-LSB

Bytes 6: 1 (Unit ID)

Byte 7: 76 (Function #)

Bytes 8-9: Number of samples in this read

Bytes 10-11: Backlog Bytes

Bytes 12-13: Status Code

Byte 14-15: Additional status information

Byte 16+: Stream Data (raw sample = 2 bytes MSB-LSB)

Backlog Bytes:

Backlog Bytes is the number bytes contained in the device stream buffer after reading. To convert BacklogBytes to the number of scans still on the device:

BacklogScans = BacklogBytes / (bytesPerSample * samplesPerScan)

Where bytesPerSample is 2 and samplesPerScan is the number of channels. 

Status Codes:

  • 2940: Auto-recovery Active.
  • 2941: Auto-recovery End. Additional Status Information is the number of scans skipped. A scan consisting of all 0xFFFF values indicates the separation between old data and new data.
  • 2942: Scan Overlap
  • 2943: Auto-recovery End Overflow
  • 2944: Stream Burst Complete


To stop stream, write 0 to STREAM_ENABLE. All stream modes expect to be stopped, except for burst stream (see STREAM_NUM_SCANS for more information on bust stream).

Code Example

A general low-level stream example written in C/C++ can be found here.