« Close

Datasheets and User Guides

App Notes

Software & Driver

 

3.2.1 - Streaming Digital Inputs, Timers, and Counters

There are special channel numbers that allow digital inputs, timers, and counters, to be streamed in with analog input data.

Table 3.2.1-1. Special Stream Channels

Channel #  
193 EIO_FIO
194 CIO
200 Timer0
201 Timer1
210 Counter0
211 Counter1
224 TC_Capture
230 Timer0 with reset
231 Timer1 with reset
240 Counter0 with reset
241 Counter1 with reset

Special Channels:

193: Returns the input states of 16 bits of digital I/O. FIO is the lower 8 bits and EIO is the upper 8 bits.

194: Returns the input states of 16 bits of digital I/O. CIO is the lower 8 bits.

200-201 and 210-211: Retrieves the least significant word (LSW, lower 2 bytes) of the specified timer/counter. At the same time that any one of these is sampled, the most significant word (MSW, upper 2 bytes) of that particular timer/counter is stored in an internal capture register (TC_Capture), so that the proper value can be sampled later in the scan. For any timer/counter where the MSW is wanted, channel number 224 must be sampled after that channel and before any other timer/counter channel. For example, a scan list of {200,224,201,224} would get the LSW of Timer0, the MSW of Timer0, the LSW of Timer1, and the MSW of Timer1. A scan list of {200,201,224} would get the LSW of Timer0, the LSW of Timer1, and the MSW of Timer1 (MSW of Timer0 is lost).

230-231 and 240-241: These channels perform the same operation as their 200-211 counterpart above, then reset the timer or counter.

 

Adding these special channels to the stream scan list does not configure those inputs. If any of the FIO or EIO lines have been configured as outputs, timers, counter, or analog inputs, a channel 193 read will still be performed without error but the values from those bits should be ignored. The timers/counters (200-224) must be configured before streaming using normal timer/counter configuration commands.

The timing for these special channels is the same as for normal analog channels. For instance, a stream of the scan list {0,1,200,224,201,224} counts as 6 channels, and the maximum scan rate is determined by taking the maximum sample rate at the specified resolution and dividing by 6.

It is not recommended to stream timers configured in mode 2 or 3 (32-bit period measurement). It is possible for the LSW to roll, but the MSW be captured before it is incremented. That means that only the LSW is reliable, and thus you might as well just use the 16-bit modes.

Mode 11, the upper 32 bits of the system timer, is not available for stream reads. Note that when streaming on the U3, the timing is known anyway (elapsed time = ScanNumber / ScanRate) and it does not make sense to stream the system timer modes 10 or 11.

6 comments

According to the Firmware page (and my own successful usage), channel 194 can be used for the MIO and CIO as of firmware 1.09 on the U3C. See http://labjack.com/support/u3/firmware-revision-history (click on "Older versions" under U3C). The current PDF Users Guide also fails to mention this fact.

It's also not clear from this doc what the NChannel should be for the digital PChannels. So, I used 31, which makes the most logical sense (and also works).

Channel 194 is currently not handled by upstream LabJackPython. I've fixed this in my fork (https://github.com/davclark/LabJackPython) and will submit a pull request.

Your fix for channel 194 in LabJackPython is in our repository now on github.  Thanks for pointing this out.

You wrote:

<cite>The timing for these special channels is the same as for normal analog channels. For instance, a stream of the scan list {0,1,200,224,201,224} counts as 6 channels, and the maximum scan rate is determined by taking the maximum sample rate at the specified resolution and dividing by 6.</cite>

But how do I determine the maximum scan rate if I'm not using any analogue channels? I just want to stream channel 193 (to read the FIO digital inputs) as fast as possible.

The timing for these channels is the same as for analog channels, so in your case you just have 1 channel and the maximum scan rate is 50 ksamples/second divided by 1 channel equals 50 kscans/second.  See Section 3.2.

mattswanpi's picture

<cite>Adding these special channels to the stream scan list does not configure those inputs..... The timers/counters (200-224) must be configured before streaming using normal timer/counter configuration commands.<cite>

So if I want to stream Ch 230 using LJStreamUD do I use 

ChP=230#!#224#

ChN=199#!#199#

in my LJStreamUD.cfg?

LabJack Support's picture

If you want to stream Timer0 with reset, then yes you stream the two channels 230 and 224 in that order. Channel 230 is the lower 2-bytes and channel 224 is the upper 2-bytes of the 4-byte Timer value.

In the LJStreamUD.cfg file that would look something like:

NumChan=2

ChP=200#!#224#!#
ChN=199#!#199#!#

Though you can also configure it in the LJStreamUD application which updates the LJStreamUD.cfg file.