LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Determine number of channels on a DAQ card

Is there a function to determine the number of channels on a given DAQ card?

0 Kudos
Message 1 of 2
(2,951 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(2,941 Views)