LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx choose channel to display on different waveforms

Solved!
Go to solution

Hi NI Community,

 

I've been using LabVIEW to do some data acquisition with DAQ Assistant. In my example, you can see that I choose different channel from Dynamic Data (DDT) and display on different waveform screens. 

 

How can I do similar task but with DAQmx? 

 

Thank you!ask NI.PNG

0 Kudos
Message 1 of 19
(2,645 Views)
Solution
Accepted by topic author victor55

Good job moving away from the DAQ Assistant!

 

Look in the example finder (Help -> Find Examples -> Hardware input and output -> DAQmx) for a multi-channel example to help.

 

Basically you'll use "Read multiple inputs/multiple samples (1D Array of Waveform)" and it'll return an array of waveforms. Next use Index Array to get the first 3 of them. That will work exactly the same as your DAQ Assistant as far as data handling goes.

 

Do note that you will need to configure the task, set the timing, then start it outside of your loop. The only function you need within the loop is a DAQmx Read. Stop and clear your task outside of the loop. This will be in the example as well, but I want to point it out.

0 Kudos
Message 2 of 19
(2,632 Views)

Thank you! I was able to get it to work 🙂

0 Kudos
Message 3 of 19
(2,611 Views)

I have a quick question - How would I index through array if there were 2 analog input modules? For example Slot 5 and Slot 6 on PXI both have 8 channels. 

0 Kudos
Message 4 of 19
(2,595 Views)

Hi Victor,

 


@victor55 wrote:

I have a quick question - How would I index through array if there were 2 analog input modules? For example Slot 5 and Slot 6 on PXI both have 8 channels. 


So you want to have 16 different waveform graphs on your frontpanel? And 16 shift registers to store the data???

There are better ways to handle data…

 

But to answer your question: learn about using (FOR) loops and the autoindexing feature of loop tunnels!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 19
(2,548 Views)

Awesome! I will check that out. But for indexing through 2 different modules, is it like PXI Slot 5 (a0-a7) and PXI Slot 6 (a8-a15) ? Is that the index numbers for the second module? I want to be able to have monitor 16 channels visually but the data will get saved for actual data processing later.

0 Kudos
Message 6 of 19
(2,494 Views)

@victor55 wrote:

I have a quick question - How would I index through array if there were 2 analog input modules? For example Slot 5 and Slot 6 on PXI both have 8 channels. 


The waveforms appear in the same order as you configure them in Create Virtual Channel. For example, if your channels were dev1\ao0:7:dev2\ao0:7 then the array would have 16 elements. The first 8 would be dev1 and the second would be dev2.

0 Kudos
Message 7 of 19
(2,493 Views)

I see. So for example the index array will go from 0-7 for the first module then 0-7 again for the second module?

 

Index array: 

- 0 (module 1)

- 1

- 2

- ....

- 7 

 

- 0 (module 2)

- 1

- 2

- ...

- 7

0 Kudos
Message 8 of 19
(2,477 Views)

Yep, you got it.

 

Keep in mind it's not the module number that determines the order- it's the order you wire them into Create Channel. Theoretically you could do module 0/ai0, module 1/ai0, module 0/ai1, module 1/ai1, module 0/ai2, module 1/ai2, etc.

 

An additional way to keep track of them is to use Waveform Attributes. When you create the virtual channel you can optionally wire in the Name parameter, which assigns a name to the NI_ChannelName attribute. Use a comma-separated list to specify multiple names. If you don't wire the input, it defaults to the terminal name (like Dev0/ai1). If you wire 1 name to the list, it'll use that to name the first channel and auto-generate the rest.

 

Use "Get Waveform Attribute" with the "Name" input set to "NI_ChannelName" and it'll return the name of the virtual channel that made the waveform.

 

For further reading:

https://zone.ni.com/reference/en-XX/help/371361R-01/lvwave/get_waveform_attribute/

 

0 Kudos
Message 9 of 19
(2,471 Views)

Thank you very much! I have another question. If 2 of the modules have different sampling rate due to hardware specifications, is it possible to create 2 different settings in the same DAQmx Create Channel ?

 

I have 

Create Channel -> Timing -> Start Task -> Read -> Close

0 Kudos
Message 10 of 19
(2,462 Views)