LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx API - preferred way to create multiple channels and how to control can?

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:multiselect.png

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:

Different channels.png

Now we have granular control over each channel. A little more work but worth the control.

 

My questions:

 

  1. Are there other ways to define multiple channels that I have not discovered?
  2. 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?
0 Kudos
Message 1 of 5
(1,204 Views)

You can build a task in Measurement and Automation Explorer using whatever channels you need.  The call the task in your LabVIEW code.

0 Kudos
Message 2 of 5
(1,168 Views)

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

0 Kudos
Message 3 of 5
(1,152 Views)

 

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

 

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 5
(1,146 Views)

@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:multiselect.png

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:

Different channels.png

Now we have granular control over each channel. A little more work but worth the control.

 

My questions:

 

  1. Are there other ways to define multiple channels that I have not discovered?
  2. 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.

0 Kudos
Message 5 of 5
(1,138 Views)