08-27-2013 11:06 AM
Hi
How can I query how many inputs and outputs are available on a given devicevia the Ni-Daq C API? Do I need to hardcode the IO specs to a given device ID?
Thanks
Nirvtek
Solved! Go to Solution.
08-27-2013 11:11 AM
Hi Nirvtek-
You can find functions to query the specific channels available to various devices in the system, and you can also query the specifics of what those channels support (for example, measurement types, ranges, sample rates, and many others).
I would recommend consulting the DAQmx C Reference Help and browsing mxcprop.chm for the "Device Properties" and "Physical Channel Properties" sections.
Hopefully this helps-
08-27-2013 11:59 AM - edited 08-27-2013 11:59 AM
The documentation is hard to follow. There's no section which lists how to query devices and inputs and outputs. All the examples in both the docs and the examples involve specifying which channels are already there. There's nothing to indicate which specific functions to call to query inputs/outputs.
There was a series of posts on this forum on how to query the available devices and get friendly devices names. Without that I don't think the documentation or the examples would've shown how to query devices.
Thanks for your quick response though.
08-27-2013 12:23 PM
Hi nirvtek-
I agree that the help file can seem a bit fragmented, but it provides function prototypes to describe how to do a lot of things programmatically. For example:
int32 __CFUNC DAQmxGetSysDevNames(char *data, uInt32 bufferSize);
DAQmxGetSysDevNames gets the Device Names property.
Using each device name, you can do things like these:
int32 __CFUNC DAQmxGetDevChassisModuleDevNames(const char device[], char *data, uInt32 bufferSize);
DAQmxGetDevChassisModuleDevNames gets the Chassis >> Module Device Names property.
int32 __CFUNC DAQmxGetDevAIPhysicalChans(const char device[], char *data, uInt32 bufferSize);
DAQmxGetDevAIPhysicalChans gets the I/O Type >> Analog Input >> Physical Channels property.
Using each physical channel, you can get things like these:
int32 __CFUNC DAQmxGetPhysicalChanAISupportedMeasTypes(const char physicalChannel[], int32 *data, uInt32 arraySizeInElements);
DAQmxGetPhysicalChanAISupportedMeasTypes gets the Analog Input >> Measurement Types property.
int32 __CFUNC DAQmxGetDevAISampModes(const char device[], int32 *data, uInt32 arraySizeInElements);
DAQmxGetDevAISampModes gets the I/O Type >> Analog Input >> Timing >> Sample Modes property.
And there are many others that you can use to get a programmatic view of what devices are in your system and what types of operations they support.
08-27-2013 01:32 PM
That's a useful list of functions.
If I use this with an emulated device: result = DAQmxGetPhysicalChanAIInputSrcs( "Dev2", buff, BUFF_MAX );
buff is populated with :_external_channel (this is with an emulated device).
I was expecting ai0, ai1, ai2 and so on.
I'd like to code so that any NI device can be used instead of assuming that a USB-9234 has four inputs and coding appropriately.
08-27-2013 01:57 PM
Hi nirvtek-
It sounds like what you actually want is:
int32 __CFUNC DAQmxGetDevAIPhysicalChans(const char device[], char *data, uInt32 bufferSize);
I tried this on a simulated cDAQ chassis with 9233 (where device[] = "cDAQ2Mod1"), and it returned a list of channels that included "cDAQ2Mod1/ai0, ..., cDAQ2Mod1/ai3"
08-27-2013 11:49 PM
Thanks! That answers my question. If I have any more I'll post here.
08-28-2013 02:14 AM
One more question, when creating a task, is it possible to assign channels from multiple devices in a single task. (DAQmxAddGlobalChansToTask)
08-28-2013 03:09 AM
Actually nm. It looks like independent devices can't be added to a single task.
08-28-2013 04:00 AM
How do you query the range of values (say for voltage) that allowed on a specific device?