« Close

Datasheets and User Guides

App Notes

Software & Driver

 

3.2.2 Low-Level Streaming [T-Series Datasheet]

Overview

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.

Setup

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

Manual Stream Setup
Name Start Address Type Access
STREAM_SCANRATE_HZ 4002 FLOAT32 R/W
STREAM_NUM_ADDRESSES 4004 UINT32 R/W
STREAM_SAMPLES_PER_PACKET 4006 UINT32 R/W
STREAM_AUTO_TARGET 4016 UINT32 R/W
STREAM_SCANLIST_ADDRESS#(0:127) 4100 UINT32 R/W
STREAM_ENABLE 4990 UINT32 R/W
STREAM_SCANRATE_HZ
- Address: 4002
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 and 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.
  • Data type: FLOAT32  (type index = 3)
  • Readable and writable
  • Default value: 0
STREAM_NUM_ADDRESSES
- Address: 4004
The number of entries in the scanlist
  • Data type: UINT32  (type index = 1)
  • Readable and writable
  • Default value: 0
STREAM_SAMPLES_PER_PACKET
- Address: 4006
Specifies the number of data points to be sent in the data packet. Only applies to spontaneous mode.
  • Data type: UINT32  (type index = 1)
  • Readable and writable
  • Default value: 0
STREAM_AUTO_TARGET
- Address: 4016
Controls where data will be sent. Value is a bitmask. bit 0: 1 = Send to Ethernet 702 sockets, bit 1: 1 = Send to USB, bit 4: 1 = Command-Response mode. All other bits are reserved.
  • Data type: UINT32  (type index = 1)
  • Readable and writable
  • Default value: 0
  • T7:
STREAM_SCANLIST_ADDRESS#(0:127)
- Starting Address: 4100
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.
  • Data type: UINT32  (type index = 1)
  • Readable and writable
  • Default value: 0
Expanded Names Addresses
STREAM_SCANLIST_ADDRESS0, STREAM_SCANLIST_ADDRESS1, STREAM_SCANLIST_ADDRESS2, STREAM_SCANLIST_ADDRESS3, STREAM_SCANLIST_ADDRESS4, STREAM_SCANLIST_ADDRESS5, STREAM_SCANLIST_ADDRESS6, STREAM_SCANLIST_ADDRESS7, STREAM_SCANLIST_ADDRESS8, STREAM_SCANLIST_ADDRESS9, STREAM_SCANLIST_ADDRESS10, STREAM_SCANLIST_ADDRESS11, STREAM_SCANLIST_ADDRESS12, STREAM_SCANLIST_ADDRESS13, STREAM_SCANLIST_ADDRESS14, STREAM_SCANLIST_ADDRESS15, STREAM_SCANLIST_ADDRESS16, STREAM_SCANLIST_ADDRESS17, STREAM_SCANLIST_ADDRESS18, STREAM_SCANLIST_ADDRESS19, STREAM_SCANLIST_ADDRESS20, STREAM_SCANLIST_ADDRESS21, STREAM_SCANLIST_ADDRESS22, STREAM_SCANLIST_ADDRESS23, STREAM_SCANLIST_ADDRESS24, STREAM_SCANLIST_ADDRESS25, STREAM_SCANLIST_ADDRESS26, STREAM_SCANLIST_ADDRESS27, STREAM_SCANLIST_ADDRESS28, STREAM_SCANLIST_ADDRESS29, STREAM_SCANLIST_ADDRESS30, STREAM_SCANLIST_ADDRESS31, STREAM_SCANLIST_ADDRESS32, STREAM_SCANLIST_ADDRESS33, STREAM_SCANLIST_ADDRESS34, STREAM_SCANLIST_ADDRESS35, STREAM_SCANLIST_ADDRESS36, STREAM_SCANLIST_ADDRESS37, STREAM_SCANLIST_ADDRESS38, STREAM_SCANLIST_ADDRESS39, STREAM_SCANLIST_ADDRESS40, STREAM_SCANLIST_ADDRESS41, STREAM_SCANLIST_ADDRESS42, STREAM_SCANLIST_ADDRESS43, STREAM_SCANLIST_ADDRESS44, STREAM_SCANLIST_ADDRESS45, STREAM_SCANLIST_ADDRESS46, STREAM_SCANLIST_ADDRESS47, STREAM_SCANLIST_ADDRESS48, STREAM_SCANLIST_ADDRESS49, STREAM_SCANLIST_ADDRESS50, STREAM_SCANLIST_ADDRESS51, STREAM_SCANLIST_ADDRESS52, STREAM_SCANLIST_ADDRESS53, STREAM_SCANLIST_ADDRESS54, STREAM_SCANLIST_ADDRESS55, STREAM_SCANLIST_ADDRESS56, STREAM_SCANLIST_ADDRESS57, STREAM_SCANLIST_ADDRESS58, STREAM_SCANLIST_ADDRESS59, STREAM_SCANLIST_ADDRESS60, STREAM_SCANLIST_ADDRESS61, STREAM_SCANLIST_ADDRESS62, STREAM_SCANLIST_ADDRESS63, STREAM_SCANLIST_ADDRESS64, STREAM_SCANLIST_ADDRESS65, STREAM_SCANLIST_ADDRESS66, STREAM_SCANLIST_ADDRESS67, STREAM_SCANLIST_ADDRESS68, STREAM_SCANLIST_ADDRESS69, STREAM_SCANLIST_ADDRESS70, STREAM_SCANLIST_ADDRESS71, STREAM_SCANLIST_ADDRESS72, STREAM_SCANLIST_ADDRESS73, STREAM_SCANLIST_ADDRESS74, STREAM_SCANLIST_ADDRESS75, STREAM_SCANLIST_ADDRESS76, STREAM_SCANLIST_ADDRESS77, STREAM_SCANLIST_ADDRESS78, STREAM_SCANLIST_ADDRESS79, STREAM_SCANLIST_ADDRESS80, STREAM_SCANLIST_ADDRESS81, STREAM_SCANLIST_ADDRESS82, STREAM_SCANLIST_ADDRESS83, STREAM_SCANLIST_ADDRESS84, STREAM_SCANLIST_ADDRESS85, STREAM_SCANLIST_ADDRESS86, STREAM_SCANLIST_ADDRESS87, STREAM_SCANLIST_ADDRESS88, STREAM_SCANLIST_ADDRESS89, STREAM_SCANLIST_ADDRESS90, STREAM_SCANLIST_ADDRESS91, STREAM_SCANLIST_ADDRESS92, STREAM_SCANLIST_ADDRESS93, STREAM_SCANLIST_ADDRESS94, STREAM_SCANLIST_ADDRESS95, STREAM_SCANLIST_ADDRESS96, STREAM_SCANLIST_ADDRESS97, STREAM_SCANLIST_ADDRESS98, STREAM_SCANLIST_ADDRESS99, STREAM_SCANLIST_ADDRESS100, STREAM_SCANLIST_ADDRESS101, STREAM_SCANLIST_ADDRESS102, STREAM_SCANLIST_ADDRESS103, STREAM_SCANLIST_ADDRESS104, STREAM_SCANLIST_ADDRESS105, STREAM_SCANLIST_ADDRESS106, STREAM_SCANLIST_ADDRESS107, STREAM_SCANLIST_ADDRESS108, STREAM_SCANLIST_ADDRESS109, STREAM_SCANLIST_ADDRESS110, STREAM_SCANLIST_ADDRESS111, STREAM_SCANLIST_ADDRESS112, STREAM_SCANLIST_ADDRESS113, STREAM_SCANLIST_ADDRESS114, STREAM_SCANLIST_ADDRESS115, STREAM_SCANLIST_ADDRESS116, STREAM_SCANLIST_ADDRESS117, STREAM_SCANLIST_ADDRESS118, STREAM_SCANLIST_ADDRESS119, STREAM_SCANLIST_ADDRESS120, STREAM_SCANLIST_ADDRESS121, STREAM_SCANLIST_ADDRESS122, STREAM_SCANLIST_ADDRESS123, STREAM_SCANLIST_ADDRESS124, STREAM_SCANLIST_ADDRESS125, STREAM_SCANLIST_ADDRESS126, STREAM_SCANLIST_ADDRESS127 Show All 4100, 4102, 4104, 4106, 4108, 4110, 4112, 4114, 4116, 4118, 4120, 4122, 4124, 4126, 4128, 4130, 4132, 4134, 4136, 4138, 4140, 4142, 4144, 4146, 4148, 4150, 4152, 4154, 4156, 4158, 4160, 4162, 4164, 4166, 4168, 4170, 4172, 4174, 4176, 4178, 4180, 4182, 4184, 4186, 4188, 4190, 4192, 4194, 4196, 4198, 4200, 4202, 4204, 4206, 4208, 4210, 4212, 4214, 4216, 4218, 4220, 4222, 4224, 4226, 4228, 4230, 4232, 4234, 4236, 4238, 4240, 4242, 4244, 4246, 4248, 4250, 4252, 4254, 4256, 4258, 4260, 4262, 4264, 4266, 4268, 4270, 4272, 4274, 4276, 4278, 4280, 4282, 4284, 4286, 4288, 4290, 4292, 4294, 4296, 4298, 4300, 4302, 4304, 4306, 4308, 4310, 4312, 4314, 4316, 4318, 4320, 4322, 4324, 4326, 4328, 4330, 4332, 4334, 4336, 4338, 4340, 4342, 4344, 4346, 4348, 4350, 4352, 4354 Show All
STREAM_ENABLE
- Address: 4990
Write 1 to start stream. Write 0 to stop stream.
  • Data type: UINT32  (type index = 1)
  • Readable and writable
  • T7:

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.
  • 2942: Scan Overlap
  • 2943: Auto-recovery End Overflow
  • 2944: Stream Burst Complete

Stop

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.