Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the available analog input channel names in NI DAQmx by using c API provided by NI.

Hi,

I am using C API provided by the NI. My device name PCI-6251.
1. Is there any speacial function to get the names of available physical channels (ex: i need to see all analog inputs ie from ai0 to ai15)?
2. While creating virtual analog input channel, is there any possibility to create with some different name(other than actual name). or after i create is there any possibilty to changethe name?

Looking forward for your reply.
0 Kudos
Message 1 of 11
(4,827 Views)
Dear amlu,
Thansk for asking this question because I was planning to ask the same one today. I have the same requirements for getting available analog channels plus I also need to be able to get external counter/timer channels, if available.

For some parameters such as for available gains, you can attempt to set the parameter when you attempt to create a channel such as by calling DAQmxCreateAIVoltageChan(...) and then check to see what the value of the parameter parameter was actually set. Unfortunately, if you try to set a non-existent channel, you get an error returned and the executable or, in my case, the dll crashes. At least, it does so in the shipping examples that I've tried and in my own dlls.

If your program uses a graphic interface and if it is intended for interactive use only, you can use NIDAQmx_NewPhysChanAICtrl(...) followed by setting filter properties using SetPhysChanCtrlAttrib(...) to limit the list displayed in the pull-down list in the special text box that the channel control uses to get the list of available channels. Unfortunately, I haven't found a way to programatically get the list or the number of items in the list. In my case, I mostly want my dll to return an error and perhaps display a message with crashing. Fortunately, getting a list of available devices ort checking to see if a particular device is real and/or active is simple but I haven't found a way to do the same thing for available channels.

Message Edited by duncan carter on 06-06-2005 11:05 AM

0 Kudos
Message 2 of 11
(4,823 Views)
I tried to answer the first part of your question but forgot the second. You could select another available channel name if you are using an interactive channel control which would be one of my possible options. As far as I know, there is no option for creating your own channel names, except perhaps in MAX which I haven't tried because it's not useful for me.

Duncan
0 Kudos
Message 3 of 11
(4,816 Views)
Dear Duncan ,

Thank you very much for reply.
But i could't under stand properly.
1. I would like show all channels in my GUI like in MAX. ie i would like to show Dev1/ai0......Dev1/ai15 in a list. My question is is there any special function to get this list or we have do it manually by adding strings or something?.

2. I used DAQmxCreateAIVoltageChan(TaskHandle taskHandle, const char physicalChannel[], const char nameToAssignToChannel[], int32 terminalConfig, float64 minVal, float64 maxVal, int32 units, const char customScaleName[]) to create virtual channel.
In this i passed "physicalChannel" parameter as "Dev1/ai0", "nameToAssignToChannel" parameter as "". Actually i did't under stand what is "nameToAssignToChannel" parameter. Here i tried to give some name like "blabla", but it was not accepted.
My aim is to do same like in MAX, i want create the channel name with some user friendly name like "Achannel1". Is it possible to do while creating channel or after channel was created?
I found one function DAQmxSetChanDescr(TaskHandle taskHandle, const char channel[], const char *data), but by using this function i have to set some description first and then i have to get it? Is it right way?

Thanks
0 Kudos
Message 4 of 11
(4,808 Views)
Are you using Labwindows/CVI? I ask this because the code that I ahve uses CVI. If not, what are you programming?

Channels for DAQmxCreateAIVoltageChan(...) must be correct for and limited to devices and channels that NIMAX recognizes. NIDAQMXNewPhysicalChanAICtrl will give you a pull down list in a text box of channels that NIMAX and the NI hardware interface will recognize and accept.
0 Kudos
Message 5 of 11
(4,801 Views)
Are you using Labwindows/CVI? I ask this because the code that I have uses CVI. If not, what are you programming with?

Channels for DAQmxCreateAIVoltageChan(...) must be correct for and limited to devices and channels that NIMAX recognizes. NIDAQMXNewPhysicalChanAICtrl will give you a pull down list in a text box of channels that NIMAX and the NI hardware interface will recognize and accept.

I've never tried to use DAQmxSetChanDescr(...).

Message Edited by duncan carter on 06-06-2005 01:05 PM

0 Kudos
Message 6 of 11
(4,804 Views)
Thank you for your reply.
I am not using Labwindows/CVI. I am writing program(interface) in c++ by using C API functions provided by NI.
For user interface i am using Visual c++(MFC). I am trying to show all channels(Dev1/ai0.....Dev1/ai15) in user interface as a list.

Looking forward for your reply.
0 Kudos
Message 7 of 11
(4,792 Views)
Does you C API have NIDAQmx_NewPhysChanAICtrl(...)? IF so, this is the main function that you want to use to create a text box with a list of available channels. It's available in CVI on my system which has NIDAQ 7.4; I don't know if it's in earlier versions of NIDAQ.
0 Kudos
Message 8 of 11
(4,789 Views)
Sorry i dont have that function. all of my functions starts with "DAQmx" not with NIDAQmx. I dont know what is the difference..

Looking forward for your reply.
0 Kudos
Message 9 of 11
(4,787 Views)
It's in a library supplied with LabWindows/CVI named daqmxioctrl.fp and listed in daqmxioctrl.h. I don't see anything comparable in NIDAQmx.h.

Sorry.
0 Kudos
Message 10 of 11
(4,772 Views)