0

I am having trouble trying to read interleaved data using a NI-USB 6353 device. I’ve looked through the Python nidaqmx API documentation to see if there is a way to do that, but there is no mention of that. Is there a way to read interleaved data through the Python API?

Darth_Yoda
  • 37
  • 3

1 Answers1

0

when you are reading from multiple channels at once, the data is returned in an interleaved format by default.

Here's an example of how to read from multiple channels with the NI-DAQmx Python API:

import nidaqmx
from nidaqmx.constants import TerminalConfiguration

with nidaqmx.Task() as task:
    # Assume that you have 2 analog input channels.
    task.ai_channels.add_ai_voltage_chan("Dev1/ai0:1", terminal_config=TerminalConfiguration.RSE)

    data = task.read(number_of_samples_per_channel=1000)

In this code, "Dev1/ai0:1" specifies that you want to read from channels ai0 and ai1 on device Dev1. The task.read() call then returns a 2D list of samples. If you specified two channels as in this example, the list would look like this:

[[channel0_sample0, channel1_sample0], [channel0_sample1, channel1_sample1], ...]

This is interleaved data: the samples from the two channels are alternated in the list.

If you specifically want to deinterleave the data (i.e., separate the data from the different channels), you can do this:

channel0_data, channel1_data = zip(*data)

This uses the zip function to transpose the list of lists, giving you separate lists for each channel's data.

  • Unless I didn’t configure something correctly, it’s returning non-interleaved data. `[[channel_0_sample0, channel0_sample1, …], [channel1_sample0, channel1_sample1, …]]` – Darth_Yoda Jun 05 '23 at 16:29