Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

nidaq

Solved!
Go to solution

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

0 Kudos
Message 1 of 17
(4,068 Views)

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-

Tom W
National Instruments
0 Kudos
Message 2 of 17
(4,067 Views)

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.

 

 

0 Kudos
Message 3 of 17
(4,060 Views)

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:

 

Get/Set/Reset Sys_DevNames

int32 __CFUNC DAQmxGetSysDevNames(char *data, uInt32 bufferSize);

 

Purpose

DAQmxGetSysDevNames gets the Device Names property.

 

 

 

Using each device name, you can do things like these:

Get/Set/Reset Dev_Chassis_ModuleDevNames

int32 __CFUNC DAQmxGetDevChassisModuleDevNames(const char device[], char *data, uInt32 bufferSize);

 

Purpose

DAQmxGetDevChassisModuleDevNames gets the Chassis >> Module Device Names property.

Get/Set/Reset Dev_AI_PhysicalChans

int32 __CFUNC DAQmxGetDevAIPhysicalChans(const char device[], char *data, uInt32 bufferSize);

 

Purpose

DAQmxGetDevAIPhysicalChans gets the I/O Type >> Analog Input >> Physical Channels property.

 

 

Using each physical channel, you can get things like these:

Get/Set/Reset PhysicalChan_AI_SupportedMeasTypes

int32 __CFUNC DAQmxGetPhysicalChanAISupportedMeasTypes(const char physicalChannel[], int32 *data, uInt32 arraySizeInElements);

 

Purpose

DAQmxGetPhysicalChanAISupportedMeasTypes gets the Analog Input >> Measurement Types property.

Get/Set/Reset Dev_AI_SampModes

int32 __CFUNC DAQmxGetDevAISampModes(const char device[], int32 *data, uInt32 arraySizeInElements);

 

Purpose

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.

 

 

Tom W
National Instruments
0 Kudos
Message 4 of 17
(4,054 Views)

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.

0 Kudos
Message 5 of 17
(4,047 Views)
Solution
Accepted by topic author nirvtek

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"

Tom W
National Instruments
Message 6 of 17
(4,041 Views)

Thanks! That answers my question. If I have any more I'll post here.

0 Kudos
Message 7 of 17
(4,024 Views)

One more question, when creating a task, is it possible to assign channels from multiple devices in a single task. (DAQmxAddGlobalChansToTask)

0 Kudos
Message 8 of 17
(4,016 Views)

Actually nm. It looks like independent devices can't be added to a single task.

0 Kudos
Message 9 of 17
(4,012 Views)

How do you query the range of values (say for voltage) that allowed on a specific device?

0 Kudos
Message 10 of 17
(4,008 Views)