Hi, I'm a new user and I'm using your streamTest example, but I don't understand how to get all the samples instead of having average per number of request.
The application I need should basically set 10 channels,with a sampling frequency of 1.25 kHz, and return 75000 samples per channel, which would be the equivalent of 6 seconds... or MAX_REQUESTS=6.25?
and I read what this page says https://labjack.com/support/datasheets/u3/operation/stream-mode, but not managed to understand how to configure the stream for what I need
Thanks for the help :)
You can access individual samples with the index. r["AIN0"] and r["AIN1"] in the example are lists. For example, the first index to get the first returned sample for AIN0 is:
r["AIN0"][0]
The last sample is:
lastIndex = len(r["AIN0"]) - 1
r["AIN0"][lastIndex]
Configuration for ten channels (AIN0-AIN9 for demonstration) at 1.25kHz would look like:
# Configure FIO0-FIO7 (AIN0-AIN7), and EIO0-EIO1 (AIN8-AIN9) as analog inputs.
d.configIO(FIOAnalog=0xFF, EIOAnalog=0x03) # 0xFF = b11111111, 0x03 = b00000011
# Configure stream mode
SCAN_FREQUENCY = 1250 # 1250 samples/second
pchans = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] # Postive channels are AIN0-AIN9
nchans = [31]*10 # Setting all negative channels to 31 (single-ended)
res = 3 # Resolution 2 (20kHz max) or 3 (50kHz max) would work.
d.streamConfig(NumChannels=10, PChannels=pchans, NChannels=nchans, Resolution=res, ScanFrequency=SCAN_FREQUENCY)
The returned samples are in the lists r["AIN0"], r["AIN1"], ..., r["AIN9"].
Note that 75000 samples per channel with a 1250 Hz scan rate would be 60 seconds of data. Consider counting your read samples in the loop to determine when you have 750000 samples total, instead of stopping the loop with "if dataCount >= MAX_REQUESTS".