08-02-2024 01:17 PM
I am struggling to define from which channel to read temperature correctly.
How do I define to read first from channel ai0 and then with a second read from ai1?
08-02-2024 01:50 PM
Why not just read both at the same time? Use the Multiple Channels, Multiple Samples Waveform mode for the DAQmx Read and the output will be a 1D array of waveforms. You can then use Index Array to separate the two waveforms and do whatever with them.
08-02-2024 02:13 PM
I need to be able to read the single channels in my real code.
08-02-2024 02:25 PM
@Quiztus2 wrote:
I need to be able to read the single channels in my real code.
Yes. You read them together and then pass the channel data you actually need.
08-02-2024 02:37 PM
My HAL design unfortunately doesn't support that.
Could I create 2 seperate tasks, running in parallel on the same device instead?
08-02-2024 02:44 PM - edited 08-02-2024 03:31 PM
@Quiztus2 wrote:
My HAL design unfortunately doesn't support that.
Could I create 2 seperate tasks, running in parallel on the same device instead?
No. Only 1 AI hardware timed task per device.
EDIT: This won't help your problem, but you should specify the number of points to read per call instead of waiting 1 s like in your example.
08-02-2024 03:32 PM
I do this all the time. You appear to have a Thermo device that has two (simultaneous?) outputs. There's a DAQmx Device function that takes your Active Device (the Thermocouple) and lets you output AI.PhysicalChans. Use Array Subset to get the first two of these (your AI0 and AI1). Now, when you use that Device wire, you request Analog NChan NSamples, you'll get a 2D Array, which you can break up (using Index Array) into the two separate 1D Arrays that you need. Your code doesn't seem to give a reason why you can't Sample (both) Once, split them, then Process Twice, each going to a separate Chart/Graph.
You mentioned a HAL. If your HAL instance only allows a Temperature device that supports a single channel, it may be time to add a module to the HAL for your hardware that seems to support multiple channels.
Bob Schor
08-02-2024 03:34 PM - edited 08-02-2024 03:43 PM
Could I then readjust the Read Pointer during the readings?
Edit: My motivation for this question was that reading a single channel is no issue using NI-Scope. I am not experienced with DAQmx, so here we are.
08-02-2024 04:57 PM
@Quiztus2 wrote:
Could I then readjust the Read Pointer during the readings?
Edit: My motivation for this question was that reading a single channel is no issue using NI-Scope. I am not experienced with DAQmx, so here we are.
NI-Scope and NI-DAQmx are two different beasts. In some ways scope is better, in others DAQmx really outperforms NI-Scope. For example, there is direct to disk logging for DAQmx, for Scope you need to write your own logger. The DAQmx properties allow you to find out just about everything you need to know about the card attached; Scope does not have that feature, its properties are more limited.
It's not easy to abstract the two cases/classes as there are significant differences as you have found.
08-03-2024 05:25 AM - edited 08-03-2024 05:32 AM
I didn't test this, but the idea is to have a map containing queues for every channel. If the desired channel's queue is empty, I read all channels and write the different channels' data into their buffers for later use.
This looks maybe weird, but this would keep my HAL design easy. My application should know nothing about single or multi channel devices. It just wants some temperature or voltage scalar/waveform at some points.