« Close

Datasheets and User Guides

App Notes

Software & Driver

 

5.2.10 - StreamConfig

Stream mode operates on a table of channels that are scanned at the specified scan rate. Before starting a stream, you need to call this function to configure the table and scan clock. Requires U3 hardware version 1.21 or higher.

Table 5.2.10-1. StreamConfig Command Response

Command:      
Byte      
0 Checksum8    
1 0xF8    
2 NumChannels + 3    
3 0×11    
4 Checksum16 (LSB)    
5 Checksum16 (MSB)    
6 NumChannels    
7 SamplesPerPacket (1-25)   
8 Reserved    
9 ScanConfig    
    Bit 7: Reserved  
    Bit 6: Reserved  
    Bit 3: Internal stream clock frequency. 
      b0: 4 MHz
      b1: 48 MHz
    Bit 2: Divide Clock by 256 
    Bits 0-1: Resolution 
      b00: 12.8-bit effective
      b01: 11.9-bit effective
      b10: 11.3-bit effective
      b11: 10.5-bit effective
10-11 Scan Interval (1-65535)   
12 PChannel    
13 NChannel    
       
Repeat 12-13 for each channel     
       
Response:      
Byte      
0 Checksum8    
1 0xF8    
2 0×01    
3 0×11    
4 Checksum16 (LSB)    
5 Checksum16 (MSB)    
6 Errorcode    
7 0×00    
  • NumChannels: This is the number of channels you will sample per scan (1-25).
  • SamplesPerPacket: Specifies how many samples will be pulled out of the U3 FIFO buffer and returned per data read packet. For faster stream speeds, 25 samples per packet are required for data transfer efficiency. A small number of samples per packet would be desirable for low-latency data retrieval. Note that this parameter is not necessarily the same as the number of channels per scan. Even if only 1 channel is being scanned, SamplesPerPacket will usually be set to 25, so there are usually multiple scans per packet.
  • ScanConfig: Has bits to specify the stream base clock and effective resolution.
  • ScanInterval: (1-65535) This value divided by the clock frequency defined in the ScanConfig parameter, gives the interval (in seconds) between scans.
  • PChannel/NChannel: For each channel, these two parameters specify the positive and negative voltage measurement point. PChannel is 0-7 for FIO0-FIO7, 8-15 for EIO0-EIO15, 30 for temp sensor, 31 for Vreg, or 193-224 for digital/timer/counter channels. NChannel is 0-7 for FIO0-FIO7, 8-15 for EIO0-EIO15, 30 for Vref, or 31 for single-ended. Note that firmware does not support setting the negative channel 199. Instead, specify 31 for single ended measurements. When using the UD driver’s stream functions 199 will be automatically converted to 31 for ease of use.

10 comments

With regard to the base scan rate of 4 and 48 MHz (byte 9, bit 3).  Are the MHz base 10 (10^6) or base 2 (2^20)?  I had been assuming base 2, but from the effective scan rates I'm seeing it looks like they are actually base 10.

They are base 10.  48 MHz means 48000000 Hz, although from Appendix A the U3 clock is only 1.5% accurate.

 

What are the P and N Channel settings for the special extended voltage range on a U3-HV?

i.e. for -10 to +20

Using PChannel=[0] and NChannel=[31] works up to 10v but NChannel=[32] generates an error (in streamTest.py)

For the StreamConfig low-level function NChannel 32 is not valid.  Negative channel 32 is the special range channel that is implemented in software.  At the moment in LabJackPython and its U3 class' streamConfig implementation there is no support for channel 32, but the binaryToCalibratedAnalogVoltage method does support the special range -10 to +20 V under certain conditions (NChannel = 30, isSpecialSetting = True.  Section 2.6.1 of the U3 User's Guide discusses channel 32 more.), so using the raw stream data returned from the streamData method you can get the special range value with binaryToCalibratedAnalogVoltage method.

Let me look into implementing NChannel 32 into the streamConfig and processStreamData methods.  Shouldn't take too long, and I'll comment again when it is done.  

 

Channel 32 support has been added to the U3 class' streamConfig method.  You can download the latest LabJackPython with it here:

https://github.com/labjack/LabJackPython

To configure counter0 for example what are the P and N channels? Is it:

P: 210 (Counter0)

N: 31 (Single Ended)

P: 224 (TC_Capture)

N: 31 (Single Ended)

Regards

   
     
    

"Requires U3 hardware version 1.21."  Presumably "or newer", right?

"or 193.-224 for digital/timer/counter channels".  Is that a stray period?  Does this mean any value in the range is treated the same way?

"or 31/199 for single-ended".  That slash isn't division, right?  Is this a range like above?

Perhaps you could clarify the text wrt to the above...

LabJack Support's picture

"Requires U3 hardware version 1.21."
Yes, hardware version 1.21 or newer. I updated the page with this.

"or 193.-224 for digital/timer/counter channels"
That's a stray period which I just removed. 193 to 224 are digital I/O, timers and counters channels. Each channel in that range is a specific I/O which is documented further here:

https://labjack.com/support/datasheets/u3/operation/stream-mode/digital-...

"or 31/199 for single-ended"
That means 31 or 199 ("/"), and not a range ("-").

So setting NChannel to 193 is nonsense?  I'm reviewing my code, and there's a place where we configure a digital channel and set both PChannel and NChannel to 193... I think the author thought "or 31/199 for single-ended" meant any value in that range.

LabJack Support's picture

The NChannel value of 193 in your case is ignored. In general, if PChannel is 193 to 224 then NChannel is not applicable and ignored. NChannel still needs to be set though since there is a byte in the command for it.