Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

dynamically adding AI channel and processing

Hi all,
    I currently hard code how many channels my DAQ program. I would like to be able to set up a way for the user to be able to add addtion channels to sample. Right now I use an XML files that contains the device settings, I know how I can expanded this files to contain any number of setting but I don't know how process it.

The things I don't know how to do programicly
1) add x additional AI channels
2) How to read the returned data.

Any help would appreciated.

Attached is a zip file with the current code I use.
0 Kudos
Message 1 of 10
(5,769 Views)
Whenever you need to change the number of channels (remove/add), you would need to re-create the task. You would dispose the existing task and basically repeat the daq configuration code you have in the FormLoad event or the ResetTask method with all the channels you want to use.

Just an FYI, to delete an existing task, you just need to call Dispose. you dont need to call Abort and unreserve. Just call the following two lines

AITask.Stop();
AITask.Dispose();

Hope this helps.

Bilal Durrani
NI
0 Kudos
Message 2 of 10
(5,762 Views)

So there is no way to remove channels without destroying the task?

0 Kudos
Message 3 of 10
(5,510 Views)

Hello Tyzach,

There are several different scenarios:

1.    If you want to add a channel to a task after the task has been started, without stopping it, then this is not possible.

2.    If you want to remove a channel from a task after the task has been started without stopping it you can do this through software.  This isn’t possible to do this explicitly, but you could do this in software by adding in some analysis to ignore the data from the channel you want to remove from the task.  Technically you’d still be acquiring from the channel, but you wouldn’t see the data in your analysis.

3.    If you want to add in channels before the task is started or after stopping it then you can do this by calling multiple DAQmx Create Channel VIs and using the “task in” input to add the new channel to the given task.

4.    If you want to remove a channel from a task before it has started or after stopping it then you basically have to create the channel over again.

I hope one of these situations covers what you want to do.  If not it would be helpful if you can describe what you’re trying to do for a more specific answer.

Have a good weekend!

Brooks
0 Kudos
Message 4 of 10
(5,493 Views)

Hi c

When refering to,measurment studio can we drop the reference to vi's as we are not using Labview.

"DAQmx Create Channel VIs".

NI should stop ramming Labview down our throats  when using other tools.

Look at the CVI help file. You would think we was using Labview.

 

Ta

Colin

 

 

 

0 Kudos
Message 5 of 10
(5,485 Views)
I am trying to be able to set up a single task (one "new" per execution) that can handle different configurations seperately.
 
Example:
 
 At one point I might want a single point read off one channel, then an continous read off multiple channels, then a continous read off a single channel or a single read off multiple channels.
 
 My idea was to create a single base task. After each operation is completed, "purge" the task, then reconfigure it before continuing. The more I think about it, the more I think that destroying/recreating the task is the best idea. Unless, of course, this is computationally/resource expensive process.
0 Kudos
Message 6 of 10
(5,468 Views)

Can you just stop the task and make changes then restart the task.

 

Colin

0 Kudos
Message 7 of 10
(5,449 Views)

Hi Colin,

You can modify the task after stopping it.  Brooks discussed it in options 2-4 of his post.  Did you have any problems when you tried it?

Regards,

Ima
Applications Engineer
National Instruments
LabVIEW Introduction Course - Six Hours
Getting Started with NI-DAQmx
0 Kudos
Message 8 of 10
(5,437 Views)
I have decided that for what I need to do, there is no real reason to add or remove channels from a task. However, it is nessacry to change "aquisition modes." IE; Go from reading n samples from n channels on a reference trigger to 1 sample from 1 channel instatly, no trigger.
 
I can't seem to get the "triggers" to "clear."
 
I've tried stoping the task, and setting the trigger to .ConfigureNone().
 
Is there something else I need to d?
 
 
0 Kudos
Message 9 of 10
(5,410 Views)

Since I was concerned with creating and deleting alot of tasks during my anaylis, (Is this a valid concern?) I decided to create two tasks - one for multi-channel/multi-sample, one for single sample reading.

Was there a better way to do this?

0 Kudos
Message 10 of 10
(5,401 Views)