Maximum AIN's that can be read using getFeedaback function | LabJack
 

Maximum AIN's that can be read using getFeedaback function

5 posts / 0 new
Last post
albertobueno
Maximum AIN's that can be read using getFeedaback function

Hi!

I am trying to read the 13 AIN's of my U6-PRO 24 bit every second. For that I use the following code in Python (2.73 Spyder):

import u6
d =u6.U6()
Channel = [0,1,2,3,4,5,6,7,8,9,10,11,12]
Gain = [0,0,0,0,0,0,0,0,0,0,0,0,0]
Resolution = [12,12,12,12,12,12,12,12,12,12,12,12,12]
Settling = [0,0,0,0,0,0,0,0,0,0,0,0,0]
feedbackArguments = []
for i in xrange(13):
   feedbackArguments.append(u6.AIN24(PositiveChannel=Channel[i], ResolutionIndex=Resolution[i], GainIndex=Gain[i], SettlingFactor=Settling[i]))
print feedbackArguments
ainBits = d.getFeedback(feedbackArguments)

Results:
[<u6.AIN24( PositiveChannel = 0, ResolutionIndex = 12, GainIndex = 0, SettlingFactor = 0, Differential = False )>, <u6.AIN24( PositiveChannel = 1, ResolutionIndex = 12, GainIndex = 0, SettlingFactor = 0, Differential = False )>, <u6.AIN24( PositiveChannel = 2, ResolutionIndex = 12, GainIndex = 0, SettlingFactor = 0, Differential = False )>, <u6.AIN24( PositiveChannel = 3, ResolutionIndex = 12, GainIndex = 0, SettlingFactor = 0, Differential = False )>, <u6.AIN24( PositiveChannel = 4, ResolutionIndex = 12, GainIndex = 0, SettlingFactor = 0, Differential = False )>, <u6.AIN24( PositiveChannel = 5, ResolutionIndex = 12, GainIndex = 0, SettlingFactor = 0, Differential = False )>, <u6.AIN24( PositiveChannel = 6, ResolutionIndex = 12, GainIndex = 0, SettlingFactor = 0, Differential = False )>, <u6.AIN24( PositiveChannel = 7, ResolutionIndex = 12, GainIndex = 0, SettlingFactor = 0, Differential = False )>, <u6.AIN24( PositiveChannel = 8, ResolutionIndex = 12, GainIndex = 0, SettlingFactor = 0, Differential = False )>, <u6.AIN24( PositiveChannel = 9, ResolutionIndex = 12, GainIndex = 0, SettlingFactor = 0, Differential = False )>, <u6.AIN24( PositiveChannel = 10, ResolutionIndex = 12, GainIndex = 0, SettlingFactor = 0, Differential = False )>, <u6.AIN24( PositiveChannel = 11, ResolutionIndex = 12, GainIndex = 0, SettlingFactor = 0, Differential = False )>, <u6.AIN24( PositiveChannel = 12, ResolutionIndex = 12, GainIndex = 0, SettlingFactor = 0, Differential = False )>]

Traceback (most recent call last):
File "<ipython-input-24-39539cefe778>", line 1, in <module>
 File "C:\Anaconda2\lib\site-packages\u6.py", line 446, in getFeedback
 self._checkCommandBytes(rcvBuffer, [0xF8])
File "C:\Anaconda2\lib\site-packages\LabJackPython.py", line 559, in _checkCommandBytes
raise LabJackException("Got a zero length packet.")
LabJackException: Got a zero length packet.

So I try to read up to 7 AIN's and like this, there is no error. Is this error a hardware limitation? or am I doing something wrong?

LabJack Support
labjack support's picture
"Got a zero length packet."

One solution would be two split your readings into multiple Feedback commands. Seems like 7 works for you, so one Feedback that reads AIN0-6 and another that reads AIN7-13.

Alternatively, you can adjust the timeout in the driver. On Windows you can do something like:

import u6
import LabJackPython

d =u6.U6()
# Set timeout to 2500
LabJackPython.ePut(d.handle, LabJackPython.LJ_ioPUT_CONFIG, LabJackPython.LJ_chCOMMUNICATION_TIMEOUT, 2500, 0)

# The rest of the code.


On Linux and Mac OS X, you will need to modify the Exodriver source code and rebuild/reinstall. You just need to modify this line in labjackusb.c:

#define LJ_LIBUSB_TIMEOUT_DEFAULT 1000 // Milliseconds to wait on USB transfers

And set it to something like 2500.

Last, make sure to use the "d.getCalibrationData()" call once after opening your U6. This is so voltage conversions use the calibration information from the U6.

LabJack Support
labjack support's picture
To add why you are getting

To add why you are getting the error, "Got a zero length packet." indicates the there was no response from the U6. The issue is that the command with 13 analog inputs will take over 2 seconds, but the read timeouts in the drivers are by default 1000 ms on Linux/Mac OS X and 1500 ms on Windows. So there is a timeout before the response was available.

albertobueno
Thanks for the fast reply as

Thanks for the fast reply as always! Im on windows, so the solution of modifying the timeout seems better.

Regarding the 2000 ms delay. For adding a timestamp to the values returned by getFeedback is it better to add the timestamp with the time when the getFeedback function is called or when it returns the values.

Also, this also means that the fastest scanning rate that I can have is around 2500 ms, right? 

Considering the above, is this the best approach for reading the 14 analogue inputs? I was thinking to receive the value of all the AIN,s every 1000 ms.

Which strategy do you recommend me to read all the 14 AIN's every second at 24 bits?

Have a nice day!

LabJack Support
labjack support's picture
"Regarding the 2000 ms delay.

"Regarding the 2000 ms delay. For adding a timestamp to the values returned by getFeedback is it better to add the timestamp with the time when the getFeedback function is called or when it returns the values."

I can't think of anything affected by the timestamp's placement.

"Also, this also means that the fastest scanning rate that I can have is around 2500 ms, right? "

2500 ms is the period of time that the driver will wait for a response before throwing an error. So operations need to complete in less that 2500 ms.

"Considering the above, is this the best approach for reading the 14 analogue inputs? I was thinking to receive the value of all the AIN,s every 1000 ms."

Sampling times are listed in table B-1 here:  https://labjack.com/support/datasheets/u6/appendix-b

It looks like resolution index 10 or 11 is the best we can do at that rate. Higher resolutions can be used by moving some of the signals to additional LabJack units to spread the sampling load.