LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Select analog channels by custom names

Solved!
Go to solution

Hello Forum Friends,

 

My stuff:

LabView 2009 SP1

Windows 7

 

I'm rewriting LabView code from LV7 with the 2009 version.  The old code has a vi called "ai waveform scan.vi" and it allows the user to specify the DAQ device and also select the channels by simply listing them as numbers (0,1,2,5,6 etc.) in a channel input box from the front panel.  I've figured out how to do something similar with 2009 using daqmx create channel, but I have to list the channels like this: dev1\ai1,dev1\ai2, etc.  Is there a way to select them with numbers like in LV7?  From what I've read I think there is, but I've been unable to make it work.  Thanks.

 

dZack

0 Kudos
Message 1 of 7
(2,871 Views)
Why do you want to change the default behavior of the channel selection control? The default control will automatically update the list of channels when you change hardware. Will yours?
Message 2 of 7
(2,866 Views)

Dennis,

 

Thanks for the quick reply.

 

I don't think what I'm trying to do is that complicated.  Let me retry explaining it.

 

The person I'm doing the LabView work for asked if it is possible to be able to select the channels from the front panel by simply listing numbers that correspond to physical channels.  For example, we have a LabView program that can be used for a variety of experiments that involve taking pressure and sound measurements at different times during a run.  These are wind tunnel experiments using with mixed gases, so once one gas line is opened, we take a pressure measurement.  Then, a second gas line is opened and another round of pressure measurements are taken.  After that, microphones used to take sound measurements, followed by another round of pressure measurements.  At each one of these acquisitions (3 pressures and 1 microphone), the channels selected may vary as the initial pressure measurements may only need data from 2 of the transducers (2 channels), but the pressure measurements at the end of the run may need to acquire from 5 transducers (5 channels).  One option is to create specific tasks for each acquisition using MAX and selecting the specific task from the front panel.  That's not bad, but to be able to just enter the channels from the front panel would be much easier, and it would make my boss happy.  

 

Is it clear as to what I'm trying to do?  As I said in the previous post, I can partially accomplish my goal using the daqmx create task vi and connecting a control box to the physical channels node on the vi.  The only problem is that it isn't a simple 1,2,3, but rather, dev1/ai1,dev1/ai3, etc.   Also, I noticed the help talks about giving new names to the channels.  It uses, as examples, names like "foo" and "b", resulting in new channel names: foo1,foo2 and b1,b2, respectively.  Names like b1,b2 would also be fine.  If it's not possible to do this in 2009, the dev1/ai1 method will have to suffice.

 

Thanks again.

 

0 Kudos
Message 3 of 7
(2,856 Views)
Solution
Accepted by topic author dZack
I understood your question but what I don't understand why a list with ai0, ai1, ai2, etc., is so hard to understand. In any case, its easy to convert the plain numerics to actual channel names. The format into string function seems suitable. You would create an array of channel numbers. A string is an acceptable input to the DAQmx Create Channel function.
Message 4 of 7
(2,846 Views)

Ah, ok.  It's just the device part (dev1) that I would like to refrain from writing out.  Having 5 channels that aren't in numerical succession will make the input box rather large with the device designation.

0 Kudos
Message 5 of 7
(2,840 Views)

I figured it out.  Thanks again.

0 Kudos
Message 6 of 7
(2,802 Views)

The attached VI shows what I did, for anyone else wondering.

 

The input box takes a string in the form 'a1,a2,a4'.  This designates analog channels 1, 2, and 4.  The a is necessary.  The Search and Replace String VI searches for the a's and replaces them with Dev1/ai.  The resulting string is Dev1/ai1,Dev1/ai2,Dev1/ai4.  Be sure to set the Replace All to True, otherwise it will only replace the first instance.  Wire the Resulting String node to the Physical Channels node on the DAQmx Create Channel VI, which in this case is AI Voltage.

 

This Dev1/ai1 is specific to this machine; it may be different if there are multiple DAQ boards installed in the machine.  You can check the device designations of the different boards from MAX (Tools Menu).  All that will change is the number following Dev.

 

For digital channels, the designation is different.  It is Dev1/port0/line0.  The input box could be something like 'd1,d2,d3'.  And the Search and Replace String VI would search for d's and replace them with 'Dev1/port0/line' resulting with 'Dev1/port0/line1,Dev1/port0/line2,Dev1/port0/line3'. 

 

I hope this helps.

 

0 Kudos
Message 7 of 7
(2,742 Views)