LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create DAQmx Channels consecutively

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?

 

Quiztus2_0-1722622574358.png

 

DAQmx FP.png

Actor Framework
0 Kudos
Message 1 of 19
(860 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 19
(846 Views)

I need to be able to read the single channels in my real code.

Actor Framework
0 Kudos
Message 3 of 19
(838 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 19
(832 Views)

My HAL design unfortunately doesn't support that.
Could I create 2 seperate tasks, running in parallel on the same device instead?

Actor Framework
0 Kudos
Message 5 of 19
(824 Views)

@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.

0 Kudos
Message 6 of 19
(821 Views)

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

Message 7 of 19
(797 Views)

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.

Actor Framework
0 Kudos
Message 8 of 19
(797 Views)

@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.

0 Kudos
Message 9 of 19
(784 Views)

Mimic single channel read.png

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.

Actor Framework
0 Kudos
Message 10 of 19
(760 Views)