LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cycling through Multiple Channels on DAQ-mx

Solved!
Go to solution

Hello,

I am trying to use an ni 9401 to read multiple wind sensors simultaneously. From what I've read, there are only two counters on my chassis so I will need to cycle through channels. Where I need help is in figuring out how to cycle through channels at a fast rate then write all of  the readings to a row and append this row to a spreadsheet.

Can anyone provide some insight?

Thank you.

0 Kudos
Message 1 of 22
(5,174 Views)

I don't know the specifics of that device, but you should be able to read all the channels at the "same time" by configuring the DAQmx Read for Digital >> Multiple Channels >> Single Sample >> 1D Boolean. There is a tiny delay in when the hardware reads the value, but in the software it is all at the same time 🙂

0 Kudos
Message 2 of 22
(5,119 Views)

I was not specific enough; the program requires that I get frequency measurements from different sensors and the chassis I am using has only 2 counters. The issue that I am running into is that the program gives an error each time saying "use a different counter for each channel".

0 Kudos
Message 3 of 22
(5,109 Views)

Here is the code

0 Kudos
Message 4 of 22
(5,102 Views)

I've never used the counter functionality, but can you change that one to Multiple Channels / Single Sample? Then your physical channels when creating the task would be "Channel1, Channel2, etc."

 

A couple of notes: your first channel is spelled Frequecy_1 (no "n"), your last channel is Frequency_8_ (extra "_"). Are these spelled correctly? If they are, I would rename the channels to correct spelling for consistency. Sometimes a small typo can cause an error that doesn't seem very relevant.

0 Kudos
Message 5 of 22
(5,097 Views)

I tried the multiple channel -> single sample which would seem to work but still have the same issue:

 

"Possible reason(s):

There cannot be multiple counters in the same task for input operations.

Use a separate task for each counter.

Device:  cDAQ1

Task Name: Frequency_8_"

 

I understand that the names have some difference but the last one was done on purpose for troubleshooting purposes and I had trouble editing the name of the first one. 

0 Kudos
Message 6 of 22
(5,093 Views)
Solution
Accepted by topic author XeroXero7

I see. I think you are setting up the task wrong. When you create the channel, it's ok to leave the "task in" unwired. I saw an example where they set the channels using a property node.

 

Take a look at "Counter Read Pulse Width and Frequency (Continuous).vi" in the example finder and I think it will give you some ideas.

 

temp.PNG

Message 7 of 22
(5,089 Views)

In DAQmx, AI, AO, DI, and DO share a *lot* in common for capabilities, how to approach config and setup, etc.  Counters can be a little more "special."

 

As the error msg stated, each counter input channel needs its own task.  Your DAQ device has only 2 counter channels so you can only have 2 tasks active at a time.

 

Dunno how many sensors you need to query for speed, but you'll be needing to start and stop tasks as your program logic switches to sensor 3 and beyond.  There's overhead with this kind of task re-configuration which will limit the speed at which you can update all the readings.

 

I would partially configure all the possible sensor tasks upfront before the main reading loop.   Then inside the loop you'll already have task refnums to work with as you start, read from, and stop 2 tasks at a time.   It'll save you *some* of the task config overhead if you do as much as possible outside the loop.

 

 

-Kevin P

 

 

P.S. (edit)   I just had a chance to look at the code you posted.  It looks to be largely on the right track.  I'd move "DAQmx Create Channel" to happen before the reading loop, and you shouldn't need the "DAQmx Wait Until Done" right between taking your measurement and stopping the task.   You could also run 2 tasks at a time inside the loop, which should help speed through things a little faster.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 8 of 22
(5,084 Views)

Not sure how to go about configuring the channels outside the loop as I have that don inside so that the loop indexes through each. I see there are two counters though. How could I "fix" the program so that it cycles in pairs all the way through eight readings, appends that row to an array, then does the same for the next row?

0 Kudos
Message 9 of 22
(5,080 Views)

You can create the channels outside the loop (2 channels, 1 for each counter). Then inside the loop, you would use the property node to tell it which DIOs to use, so that after 4 iterations, you have data from 8 of your channels.

0 Kudos
Message 10 of 22
(5,077 Views)