Hi,
I am new to using LabJack and writing code in python. I was wondering how long it takes for a differential measurement (AIN0-1) on the U6?
Here is my code:
import u6
import time
lj = u6.U6()
AIN_FB_CMD = u6.AIN24(0, ResolutionIndex=0, GainIndex=0, Differential=True)
bits_array = []
start = time.time()
num_samples = 100
for i in range(num_samples):
bits, = lj.getFeedBack(AIN_FB_CMD) # how long does it take to get measurement?
bits_array.append(bits)
finish = time.time()
average_sample_time = ( finish - start ) / num_samples
I see my 4ms < average_sample_time < 6ms
According to U6 Appendix B, Table B-1 I would expect the differential reading given the chosen ResolutionIndex and GainIndex to take approx. 0.10 ms
Is the additional time that I see per sample a result of the appending of an array, a loop structure and a slow processor?
Any additional information regarding the differential sampling time would be much appreciated. Thank you very much.
Take a look at this section for command-response times:
https://labjack.com/support/datasheets/u6/operation/command-response
Note that resolution index 0 defaults the U6 to resolution index = 8 and the U6-Pro to resolution index = 9 in command-response mode.
So looking at your lj.getFeedBack call on average I would expect near 1.93 or 5.33 millisecond times on a U6, or 4.158 or 7.58 millisecond times on a U6-Pro. The 1.93 and 4.158 are USB high-high connection times, and 5.33 and 7.58 are USB other times.
The USB overhead on average in our tests are 0.60 or 4.0 milliseconds, and the sample time is 1.33 or 3.58 (U6-Pro) milliseconds. That is how I calculated the above times. USB delays may vary from system to system, and there may be additional overhead based on computer speed, language, etc.. The command-response page I linked to provides details.
For fastest command-response speeds set your ResolutionIndex to 1 and have a USB high-high connection which will help get average times closer to 0.65 milliseconds for your one analog input reading.
Thank you very much. That explains the results I was seeing.