Averaging not taking correct time | LabJack
 

Averaging not taking correct time

2 posts / 0 new
Last post
Jay
jay_coder's picture
Averaging not taking correct time

I am using LabJack T7 Pro and I want to average analog voltage for 200 ms with 5000 samples.

I initililize the registers first:

self.number_of_samples = 5000
self.sample_time = 200e-3

self.samples_per_sec = self.number_of_samples/self.sample_time

names = ["AIN0_EF_INDEX", "AIN0_EF_CONFIG_A", "AIN0_EF_CONFIG_D"]
aValues = [3, self.number_of_samples, self.samples_per_sec]
numFrames = len(names)

ljm.eWriteNames(handle, numFrames, names, aValues) 

So, if I understand correctly, the output of 5000 samples must be outputted by command:

self.analog_voltage = ljm.eReadNames(handle, numFrames, names) after 200 ms right?

But, samples in the data are at 40 to 70 ms time intervals instead of 200 ms and I am wondering what should I be doing wrong?

I also wanted to know if there is a way to command LabJack to output data at a given time (say 14:02:02.18, 14:02:02.38 instead of 14:02:02.18674, 14:02:02.36785, etc. 

 

Please let me know. Thanks in advance!

LabJack Support
labjack support's picture
To trigger the measurement

To trigger the measurement you should be reading AIN0_EF_READ_A first (returns average volts). Subsequently reading AIN0_EF_READ_B and AIN0_EF_READ_C would return the max and min volts, respectively.

Also note that 200ms is too long of a measurement period for the AIN_EF, the maximum is 180ms. You should be getting exceptions thrown from the read under your current settings. If you are not seeing any exceptions, I would recommend you check your exception handling and update firmware if you are not up to date. Current release firmware is 1.0292. Firmware can be upgraded using the device updater tab in Kipling.

I would recommend using StreamBurst for longer measurement periods:

https://github.com/labjack/labjack-ljm-python/blob/master/labjack/ljm/lj...

Unfortunately, it is not possible to directly set up the device to take a sample at a particular calendar or absolute time. We have some guidance for correlating the stream timing to a "real" time, or triggered stream a bit further down the page may be useful if you can generate a trigger at the desired start time:

https://labjack.com/support/datasheets/t-series/communication/stream-mod...