03-26-2012 12:07 PM
Is there a function to determine the number of channels on a given DAQ card?
03-27-2012 01:40 AM - edited 03-27-2012 01:41 AM
I found no native function to get this attribute; you can use DAQmxGetDeviceAttribute with DAQmx_Dev_AI_PhysicalChans attribute to get a list of available channels on a device and then parse the string counting channels. The following lines can be executed in the Interactive Execution window: provided the device name is correct they count how many input channels are present on the board:
#include <ansi_c.h>
#include <utility.h>
#include <NIDAQmx.h>
static int i;
static char msg[512];
static char *token;
DAQmxGetDeviceAttribute ("Dev1", DAQmx_Dev_AI_PhysicalChans, msg, 512);
i = 0; token = strtok (msg, ",");
while (token) {
i++;
token = strtok (NULL, ",");
}
DebugPrintf ("# of channels: %d\n", i);
The same function has equivalent attributes for analog outputs, counters and digital I/O lines / ports.