« Close

Datasheets and User Guides

App Notes

Software & Driver

 

3.2.2 Low-Level Streaming

Introduction

Streaming is a data input/output mode of the T7 that collects data at a constant rate and is capable of fast data-collection and data-output rates (approximately 100 kHz). Stream mode is complicated but can easily be executed using the LJM stream functions. The rest of this section is about low-level stream protocol. For details on how to configure stream, see Stream Mode.

 

The Basics

There are three input/output combinations of stream mode:

Stream-in: The T7 collects data and streams it to the host.

Stream-out: The T7 does not collect data but streams it out. (See Stream Out)

Stream-in-out: The T7 collects data and streams it to the host. It also streams data out.

The stream channels determine which of these modes are used. Streamable channels may be either stream-in or stream-out.

Executing stream mode involves the following:

  • Stream setup
  • Stream start
  • Stream-in data collection
  • Stream-out buffer updates (See Stream Out)
  • Stream stop

Note that Spontaneous (Auto-Response) stream mode is the mode where the T7 sends data without a Modbus command request. Spontaneous stream mode is not compatible with WiFi T7 connections. WiFi T7 stream requires Command-Response stream.

 

Setup

Stream setup requires configuration of the registers that LJM_eStreamStart takes care of and some others:

Register Listing

Stream Configuration
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_SETTLING_US 4008 FLOAT32 R/W
STREAM_RESOLUTION_INDEX 4010 UINT32 R/W
STREAM_BUFFER_SIZE_BYTES 4012 UINT32 R/W
STREAM_CLOCK_SOURCE 4014 UINT32 R/W
STREAM_AUTO_TARGET 4016 UINT32 R/W
STREAM_NUM_SCANS 4020 UINT32 R/W
STREAM_EXTERNAL_CLOCK_DIVISOR 4022 UINT32 R/W
STREAM_ENABLE 4990 UINT32 R/W
STREAM_SCANLIST_ADDRESS#(0:127) 4100 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_SETTLING_US
- Address: 4008
Time in microseconds to allow signals to settle after switching the mux. Default=0. If set to a value < 1 the T7 will automatically determine the necessary settling time. When the sample rate is above 60kHz settling time will be set to ~5 us. Max is 4400.
  • Data type: FLOAT32  (type index = 3)
  • Readable and writable
  • Default value: 0
STREAM_RESOLUTION_INDEX
- Address: 4010
The resolution index for stream readings. A larger resolution index generally results in lower noise and longer sample times.
  • Data type: UINT32  (type index = 1)
  • Readable and writable
  • Default value: 0
  • T7-specific details: Valid values: 0-8. 0=Default=>1.
STREAM_BUFFER_SIZE_BYTES
- Address: 4012
Size of the stream data buffer in bytes. A value of 0 equates to the default value. Must be a power of 2, as it takes 2 bytes to hold 1 sample. Size in samples is STREAM_BUFFER_SIZE_BYTES/2. Size in scans is (STREAM_BUFFER_SIZE_BYTES/2)/STREAM_NUM_ADDRESSES. Changes while stream is running do not affect the currently running stream.
  • Data type: UINT32  (type index = 1)
  • Readable and writable
  • Default value: 0
  • T7-specific details: Max size is 32768. Default size is 4096.
STREAM_CLOCK_SOURCE
- Address: 4014
Controls which clock source will be used to run the main stream clock. 0 = Internal crystal, 2 = External clock source on CIO3 (T7 will expect external stream clock on CIO3). All other values reserved.
  • Data type: UINT32  (type index = 1)
  • Readable and writable
  • Default value: 0
  • Minimum firmware version: 1.0110
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
  • Minimum firmware version: 0.9108
STREAM_NUM_SCANS
- Address: 4020
The number of scans to run before automatically stopping (stream-burst). 0 = run continuously. Limit for STREAM_NUM_SCANS is 2^32-1, but if the host is not reading data as fast as it is acquired you also need to consider STREAM_BUFFER_SIZE_BYTES.
  • Data type: UINT32  (type index = 1)
  • Readable and writable
  • Default value: 0
STREAM_EXTERNAL_CLOCK_DIVISOR
- Address: 4022
The number of pulses per stream scan when using an external clock.
  • Data type: UINT32  (type index = 1)
  • Readable and writable
  • Default value: 0
STREAM_ENABLE
- Address: 4990
Write 1 to start stream. Write 0 to stop stream.
  • Data type: UINT32  (type index = 1)
  • Readable and writable
  • Minimum firmware version: 0.9421
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

 

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.

The following registers do not necessarily need to be written, as the defaults may be adequate:

  • STREAM_SETTLING_US
  • STREAM_RESOLUTION_INDEX
  • STREAM_BUFFER_SIZE_BYTES
  • STREAM_NUM_SCANS

Data Collection

Once stream has been initiated with STREAM_ENABLE, the T7 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.

When reading using Command-Response mode, STREAM_DATA_CR (address 4500) automatically discards old data as you read.

 

Modbus Feedback Spontaneous (Auto-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 #)

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).

 

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. E.g. 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.

 

12 comments

I am trying to use modbus to read AIN from LabJack T7-Pro with C-R mode. I am using programming language which is not among supported ones, so I am mostly interested in "raw" modbus communication. I am concerned that STREAM_BUFFER_SIZE_BYTES has a sensible default as I can see 0 there and that doesn't look like a sensible buffer size. It also says that it should be a power of 2 for some reason. On the other hand over here http://forums.labjack.com/index.php?showtopic=7082 I can see that STREAM_BUFFER_SIZE_BYTES (default=4096, max=32768) as per LabJack support So I am a bit confused and would like to confirm that settings I'm trying to use make sense and my understanding of the flow looks correct. Here are the registers I am setting at initialization: STREAM_SCANRATE_HZ 4002 FLOAT32 = NumChannels*ScanRate = 3*1000.0 = 3000.0 STREAM_NUM_ADDRESSES 4004 UINT32 = 3 STREAM_SAMPLES_PER_PACKET 4006 UINT32 = 1000 STREAM_SETTLING_US 4008 FLOAT32 = 100.0 STREAM_RESOLUTION_INDEX 4010 UINT32 = 8 STREAM_BUFFER_SIZE_BYTES 4012 UINT32 = 32768 ... STREAM_AUTO_TARGET 4016 UINT32 = 8 (CR mode) ... STREAM_ENABLE 4990 UINT32 = 1 Then I was planning to read STREAM_DATA_CR in a loop and every iteration to read 3000 words (UINT16) from the register with the address returned by reading from address STREAM_DATA_CR (sort of an indirection as far as I understood the map). Now I couldn't find out if I need to advance the address returned it in any way or if I should check validity of 3000 samples read from this address. You C example uses spontaneous mode instead of C-R, but I would very much prefer C-R mode as it looks safer in terms of data loss in my case. I would really appreciate your input on that. Best regards, I.S.P.

Yes, the default size for STREAM_BUFFER_SIZE_BYTES is 4096 and the max size is 32768.

Here are corrections and additional information to your settings:  

STREAM_AUTO_TARGET 4016 UINT32 = 16 (CR mode)

Stream mode does not support a scan rate of 3000 with 3 channels with a STREAM_RESOLUTION_INDEX of 8. With 3 channels and a settling of 100 us, you would need to bump the resolution index down to 3. Look at table A1.4 for max. stream data rates with various settings:

http://labjack.com/support/datasheets/t7/appendix-a-1

STREAM_SAMPLES_PER_PACKET is not used in command/response stream mode.

"Then I was planning to read STREAM_DATA_CR in a loop and every iteration to read 3000 words (UINT16) from the register with the address returned by reading from address STREAM_DATA_CR (sort of an indirection as far as I understood the map)."

Actually, you only need to read data directly from STREAM_DATA_CR. There is no indirection like you were thinking. Reading STREAM_DATA_CR returns bytes as follows:

    Normal Modbus header,
    number of samples (U16),
    DeviceBufferStatus(U16),
    StreamStatus (U16),
    StreamStatusAdditionalInfo (U16),
    Uncalibrated Samples (U16)..

Regarding programming and using the LJM library, what programming language are you using? Even though we don't have a specific interface or examples for it, most languages provides a way to access libraries like our LJM library. Stream mode is easier to use with the LJM library.

Thank you for reply, and pointing to the mistake I made in settings. I am using LISP and there is existing implementation of modbus subset that mostly works for my purposes. I sure can call C functions if I have to, however looking at your examples I don't seem to find any implementations using C-R mode. Should I have missed those, please kindly point me to the right direction. I searched through the site and sources I downloaded for "4500" as well as for "STREAM_DATA_CR" and didn't find anything useful. It seems like I am almost there with my attempts, but I still have a couple of small questions. Specifically I don't understand how to prevent buffer overflow in C-R mode and how many data can I read from 4500. Here are my updated settings. STREAM_SCANRATE_HZ 4002 FLOAT32 = NumChannels*ScanRate = 3*100.0 STREAM_NUM_ADDRESSES 4004 UINT32 = 3 STREAM_SAMPLES_PER_PACKET 4006 UINT32 = 512 (which probably wouldn't matter for C-R) STREAM_SETTLING_US 4008 FLOAT32 = 100.0 (I also tried 0, just in case, although I believe 100Hz should allow 100us delay without issues) STREAM_RESOLUTION_INDEX 4010 UINT32 = 7 STREAM_BUFFER_SIZE_BYTES 4012 UINT32 = 32768 STREAM_SCANLIST_ADDRESS#(0:127) 4100 UINT32 = 0, 2, 4 STREAM_AUTO_TARGET 4016 UINT32 = 16 (CR mode) STREAM_ENABLE 4990 UINT32 = 1 After I send all the values above into the device it starts to blink with it's led and if I write 0 into 4990 it stops which I consider a good sign. However if I try to read 1000 words from 4500 address (while device is blinking) I am receiving modbus error 2 (supposedly illegal data address) and after that device could not be stopped by writing 0 into 4990. If I read 500 words or less it works fine. How many words should I read from 4500? What should I do to prevent buffer overflow or in the other words, how should I mark samples as read or move the pointer or something? Here is what I receive, and eventually after a few reads of 500 words I see status 2940 (STREAM_STATUS_AUTO_RECOVER_ACTIVE) which means my buffer is full: (248 964 0 0 16474 47151 2942 60786 49215 947 49314 52572 49157 29578... (248 2344 0 0 49286 52227 2942 44505 49404 24230 49430 50290 49296 52517... (248 2864 0 0 49284 32201 2942 50716 49403 57314 49428 46086 49290 53092... (248 3280 0 0 49301 36860 2942 15311 49412 17204 49435 17217 49306 28776... ... (248 7160 0 0 49280 8184 2942 23922 49402 41373 49429 1949 49274 27423... (248 7432 2940 0 49272 4977 49385 2462 49396 15559 49425 49498 49289 53093... Any input will be very much appreciated.

To start off, note that the LJM C functions you would call would be the stream functions. I highly recommend you use those functions, because there are many caveats to T7 streaming and the LJM stream functions encapsulate those small and sometimes strange details for you.

I noticed that you mentioned this in your first comment:

You C example uses spontaneous mode instead of C-R, but I would very much prefer C-R mode as it looks safer in terms of data loss in my case.

Can you explain that? Command-Response streaming actually has much higher overhead than Spontaneous, so Spontaneous is actually much better. E.g. if you're using Ethernet and a TCP packet is takes a (relatively) long time to get through the network, the decreased overhead of using Spontaneous stream means that you're less likely to trigger an Auto Recovery on the T7 (or in other words, less likely to overflow the T7's data buffer).

LJM uses Spontaneous streaming for USB and Ethernet connections and C-R for Wifi (due to Wifi limitations). What connection type(s) are you using?

If I haven't convinced you that using LJM's stream functions are the way to go, then please let us know and I would be delighted to continue helping you understand how to perform low-level C-R stream.

Best regards,

Rory (A different LabJack employee than the previous LabJack comment in this thread.)

Hi Rory, Thank you for reply. I am not concerned about performance as the process measured is slow. I am mostly concerned about precision and steady sampling period (I'd like to use device internal clock to have constant sampling rate otherwise I'd just read AINs directly from the channels). Spontaneous mode requires a second TCP connection which makes it a lot harder to fit into existing code (I am replacing another ADC that allows to read internal buffer without any problem). So if you could let me know how to use C-R mode that would be about all I need. I am using TCP over Eithernet and I have 3 channels that are changing at a rate less than 10Hz so 100Hz sampling will work just fine (I'd read even slower if it'd be possible to use higher STREAM_RESOLUTION_INDEX and increase precision). With 32678 buffer that gives me at least 50 seconds of time which is actually comparable to total recording time. I have something almost working and I'm just missing a couple of details I mentioned earlier (how much I should read and how to prevent buffer overflow).

I see, thanks for explaining that. It's always interesting to see how our devices are being communicated with.

How much you can read:

Taken from the LJM_eStreamStart page:

1.  MaxBytesPerPacket:  Maximum number of bytes per Modbus TCP packet sent between the device and host.  For the T7 the limits are 64/1040/500 bytes for USB/Ethernet/WiFi, respectively.

2.  MaxSamplesPerPacket: A stream data packet has 16 bytes of overhead and each sample needs 2 bytes, so based on MaxByesPerPacket above the maximum number of samples per packet for the T7 is 24/512/242 for USB/Ethernet/WiFi, respectively.

This should be valid for your application, as well.

Preventing buffer overflow

Reading from 4500 (STREAM_DATA_CR) automatically consumes the stream data from the device. You do not need to mark samples as read or move the device buffer pointer.

Also, as may be obvious, you'll want to read often enough that the buffer does not fill. Having a large STREAM_BUFFER_SIZE_BYTES helps, but you still need to read at rate that is equal to the data rate (or faster). This doesn't sound like a problem for a slow sample rate as you have.

 

Please let us know if you have additional questions / comments.

Thanks,

Rory

Thank you for the answers provided. It seems to work almost as expected. By almost I mean that I am seeing FLOAT32 values in response received in C-R mode, even though I expected raw UINT16 as per one of replies above. This doesn't cause me any trouble, in fact I'm quite happy that I don't need to read calibration values and such. I just wanted to know if that is expected behaviour and if so, am I correct in the assumption that all calibration has been already applied and that this is essentially equivalent to using AINs (seems like that comparing values I receive with what UI shows in Kipling).

What are you writing to 4018 / STREAM_DATATYPE? You should be writing 0 to indicate UINT16 values that will need calibration, since writing 3 to indicate pre-calibrated FLOAT32 values is not officially supported. In the future, we plan on possibly having 4018 / STREAM_DATATYPE automatically be 0 without writing to it.

This probably isn't the answer you wanted, but given that LJM uses UINT16 data during stream, the FLOAT32 data won't be well tested. It is conceivable that we would support FLOAT32 stream data in the future, but we have no plans to do so at the moment.

There is an example of reading calibration constants from the device and of calibrating raw UINT16 values into floats in the lowlevel C/C++ stream example. See the function ainBinToVolts for calibrating data, and note that AIN14 (address 28) is temperature, so the psuedocode for calibrating AIN14 is:

calibratedFloat32 = rawUINT16Value * CAL.Temp_Slope + CAL.Temp_Offset

(We'll update the example code soon to add this part)

That's very good to know - it was exactly the answer I was looking for.

One more question on that matter.

Is it possible to stream differential channel values at all or could they only be read one by one?

Yes, you can stream differential channels by setting them up using the regular method of writing to 41000 / AIN#(0:254)_NEGATIVE_CH.

Similarly, configurations take effect during stream when applied to

 

  • 40000 / AIN#(0:254)_RANGE,
  • 41500 / AIN#(0:254)_RESOLUTION_INDEX, and
  • 42000 / AIN#(0:254)_SETTLING_US

 

I thought I'm done with questions, but I can't find how to use calibration constants in differential mode. How do I convert uint16 to floats in that mode? Also I read here http://labjack.com/sites/default/files/2015/04/T7-Datasheet-Export-20150... that there are two converters (I guess two amplifiers) on T7-PRO I have. Which leads me to a question: How do I set and/or determine which ones to use? Thank you in advance, you've been really responsive and helpful so far!

You actually don't need to worry about any of that. Just convert the uint16 values you read from stream to floats, because the T7/T7-Pro will take care of which converter to use and will return uint16 values that are differential readings (for AIN which are configured to be differential).

The 2 converters on a T7-Pro are the High Speed converter and the High Resolution converter. The High Resolution converter is not supported for stream (http://labjack.com/support/datasheets/t7/communication/stream-mode).

Edit: Qualified when differential readings are returned.