10-01-2020 01:54 PM
I am learning how to initialize my DAQ and start collecting data using the API method rather than the task created by the system designer. I found single channel examples but have not found multiple channel examples. There are two way I have found so far.
1) Multiple select on the physical channels:
The advantage is adding more channels easily. The disadvantage is if you need different minimum or maximum values or input terminal then you have to define separate channels.
2) The second I have discovered is defining multiple channels as so:
Now we have granular control over each channel. A little more work but worth the control.
My questions:
10-01-2020 07:50 PM
You can build a task in Measurement and Automation Explorer using whatever channels you need. The call the task in your LabVIEW code.
10-02-2020 08:52 AM
@RavensFan wrote:
You can build a task in Measurement and Automation Explorer using whatever channels you need. The call the task in your LabVIEW code.
Yep! That is what I did at first. The NI tutorials teach you that method as well. The tutorials go on to teach the method of using the "Create Channel -> Timing -> Start Task" as the better method with more control. THat is whay I am trying to learn this method instead.
10-02-2020 10:14 AM
- Are there other ways to define multiple channels that I have not discovered?
Not really. Sometimes method 2 is performed in a loop to save block diagram space, but it's still the same sequence of calls that add uniquely-configured channels to the task.
2. When I define the channels using the second method above the channel data seems to be in the waveform table in random order.
Channel order should not be random -- it follows the order in which the channels were added to the task. Channel data will follow the same order. Double-check, I'll bet you'll find it isn't really random after all.
-Kevin P
10-02-2020 10:26 AM - edited 10-02-2020 10:33 AM
@flycast wrote:
I am learning how to initialize my DAQ and start collecting data using the API method rather than the task created by the system designer. I found single channel examples but have not found multiple channel examples. There are two way I have found so far.
1) Multiple select on the physical channels:
The advantage is adding more channels easily. The disadvantage is if you need different minimum or maximum values or input terminal then you have to define separate channels.
2) The second I have discovered is defining multiple channels as so:
Now we have granular control over each channel. A little more work but worth the control.
My questions:
- Are there other ways to define multiple channels that I have not discovered?
- When I define the channels using the second method above the channel data seems to be in the waveform table in random order. I have payed around a bit but have not discovered what drives the data placement in column order. When I want to get a single column of data from the waveform how do I do so if I cannot rely on a specific channel being in a specific column?
I often use a variation of your second method. Instead of having individual calls for each channel I put the call within a FOR loop and make an array of the physical channel and other attributes. If I'm using mixed AI types (Voltage and Current, for example) I also have a case structure that selects the correct DAQmx call. Your issue with the channels being randomly ordered is odd. Perhaps that is a quirk with LabVIEW NXG. I've still not done a project with NXG.
Edited to Add: I use this method to save space and to make adding/taking away channels easier (no rewiring of the program just to add a channel to the task). I know many prefer to create the task in MAX, but I personally prefer this approach as I can quickly see in the program all of the parameters that I need. A disadvantage is that I can't test the task the way that I can in MAX.