05-06-2020 08:34 PM
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!
Solved! Go to Solution.
05-06-2020 08:51 PM
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.
05-06-2020 09:30 PM - edited 05-06-2020 09:44 PM
Thank you! I was able to get it to work 🙂
05-06-2020 09:46 PM
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.
05-07-2020 02:23 AM
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!
05-07-2020 11:32 AM
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.
05-07-2020 11:34 AM
@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.
05-07-2020 12:17 PM
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
05-07-2020 12:36 PM
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/
05-07-2020 01:57 PM
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