Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get device information via VBA

Hi, 

 

I've written a smal Daqmx-Application for Excel in VBA. Is it possible to get device information about the connected Daq-device? I need to know how many channels the device has in order to enable or disable some functionality of my programm.

 

With kind regards,

 

Alex

0 Kudos
Message 1 of 5
(4,743 Views)

I've found the solution with DAQmxGetDevAIPhysicalChans. One more question How do I have to use the function?

At the moment I tyry the following

 

Dim tmpStr As String
Dim tmp As Integer
tmp = DAQmxGetDevAIPhysicalChans("Dev1", tmpStr, 0)

 

But I only get a 79 in tmp and an empty tmpstr. Is the something I have to do first? Is 0 for the buffersize okay? What for do I need the buffersize when I ask for physical chanels? I have a USB 6009 Card

 

Greatings,

 

Alex

0 Kudos
Message 2 of 5
(4,740 Views)

Hi Alex,

 

the command DAQmxGetDevAIPhysicalChans can be used to show all available AI channels from the device.

 

 

 

 

 

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

 

1.The first parameter of the function is a character array (string-array) where you have to transfer the devicename,e.g. "Dev1"

2. The 2nd one is the output value which is also a character array, this is array shows all AI channels

3. buffer size is an integer value, the number specifies the length of the output value array

 

 

char result[20000];

int    size = 50;

....

 

DAQmxGetDevAIPhysicalChans("Dev1", result, size);

 

Please make sure for basic testing that only one Device exist. Otherwise the function won't work, because an arry of devices is transmitted -

if this happes you need a for-loop around the function;

 

Kind regards,

 

Rupert Donauer,

NIG AE

 

0 Kudos
Message 3 of 5
(4,709 Views)

Hey Rupert,

 

Thank you for your reply.

When I use the function, the intellisens says, that the function expects device as a string, result as a string and buffer as an integer. By the way, there is no char in VBA as far as I know. So I do this:

 

Dim result as String

Dim dummy as Long

dummy = DAQmxGetDevAIPhysicalChans("Dev1", result, 50)

 

Then the result is "" (empty) and dummy is 79. I'm a bit desperate with this problem. What does 79 mean?

 

Do you have another idea?

 

Regards, Alex

0 Kudos
Message 4 of 5
(4,704 Views)

Hi Alex,

 

I carried out the functin in LabWindows CVI ( ANSI C development from NI).

I'm not involed in VBA.

 

Check if the dummy parameter  is required, in CVI the command:

 

...

DAQmxGetDevAIPhysicalChans("Dev1", result, 50);

...

was allright.

 

Kind regards,

 

Rupert

 

Rupert

0 Kudos
Message 5 of 5
(4,696 Views)