streamConfig Labjack Python confusion | LabJack

streamConfig Labjack Python confusion

3 posts / 0 new
Last post
sayo9394's picture
streamConfig Labjack Python confusion

I have the following setup;

PWM @ 21Khz signal is used to open a valve. The PWM is driven at 100% for 70ms to open the valve, then @30% for 100ms to keep the valve open (total open time = 150ms). So using a u3, I need to measure @ 10ms resolution ;

  1. The valve open duration
  2. The time between valve openings (valve opening rate/Period)

Currently the PWM is connected to a lowpass filter, gets converted to an analogue signal which is connected to PIN FIO5, then measure the time when the signal > than 0.5v (since @100% = 3.3v, @33% = ~1v) using python time.time() and time.wait(5ms) polling period. My measuring error is higher than 10ms.

Here comes in Steam Mode. Using the, I'm unable to config the labjack inorder to stream the analogue signal in FIO5 and get a better timing using the sampling rate;

    import u3
    SCAN_FREQUENCY = 10000
    d = None
    d = u3.U3()
    # Set the FIO5 to Analog
    print("Configuring U3 stream")
    d.streamConfig(NumChannels=1, PChannels=[0], NChannels=[31], Resolution=3, ScanFrequency=SCAN_FREQUENCY)

But i get the following error;

Configuring U3 stream

Traceback (most recent call last):

  File "", line 36, in <module>

    d.streamConfig(NumChannels=1, PChannels=[0], NChannels=[31], Resolution=3, ScanFrequency=SCAN_FREQUENCY)

  File "/usr/lib/python2.7/site-packages/", line 1048, in streamConfig

    self._writeRead(command, 8, [0xF8, 0x01, 0x11])

  File "/usr/lib/python2.7/site-packages/", line 578, in _writeRead

    self._checkCommandBytes(result, commandBytes)

  File "/usr/lib/python2.7/site-packages/", line 567, in _checkCommandBytes

    raise LowlevelErrorException(results[6], "\nThe %s returned an error:\n    %s" % (self.deviceName , lowlevelErrorToString(results[6])) )


The U3-LV returned an error:


This error is raised when you try to do an analog operation on a pin which is configured for digital. Use a command like ConfigIO to set the pin to analog.



LabJack Support
labjack support's picture
Your FIOAnalog configuration

Your FIOAnalog configuration looks correct in that FIO5 is set to analog input (the rest of the FIOs are set to digital I/O). You are getting the PIN_CONFIGURED_FOR_DIGITAL since you are current trying to stream AIN0/FIO0. Change "PChannels=[5]" in your streamConfig call and that should help.

Non-stream related, if using timing and delay functions with U3 command-response to read in an interval, take into account the time it takes to perform the U3 operations and adjust you delay time in your loop iteration based on that (for 5 ms, loopDelayTime = 5ms - u3OverheadTime). This kind of timing is demonstrated in the recently updated example. Note that this example is setting a DAC line in a loop, but demonstrates interval timing that accounts for delays in the loop.

sayo9394's picture
Thanks heaps for your fast

Thanks heaps for your fast response and fix. the script is working now.