Measurement Studio for VC++

Showing results for 
Search instead for 
Did you mean: 

Format of DAQmxGetDevAIVoltageRngs

When calling DAQmxGetDevAIVoltageRngs, how do you know how many voltage ranges are available?  You pass in the size of the array, but the function does not return anything but success/failure.
0 Kudos
Message 1 of 7
Hi CVilla,
Please check the following discussion forum.
Faris A
0 Kudos
Message 2 of 7
Thanks for the reply, but that is not quite what I was asking.  I know the function returns pairs of floats to describe the range, but that doesn't help to determine just how many pairs there are.  Anyway, I think I will fill my array with a clearly invalid value and use that as a sentinal value.
0 Kudos
Message 3 of 7
Here's a link that will hopefully answer your question.
If not please include your device model number.
Faris A
0 Kudos
Message 4 of 7
I'm sorry, but none of that says how to tell how many pairs of values were returned by DAQmxGetDevAIVoltageRngs.

I would like to query this in software because I am writing a software module for our customers who want to include Analog input with out software.  They will use a variety of DAQ boards - there is no single model number to give you.  Hence the desire to query the device in software.  If using a sentinal value is what I need to do, that's fine.  I just wanted to check if there is a better way to do it.

0 Kudos
Message 5 of 7
Hello Chuck,

I am unaware of any DAQmx call you could make to get how many ranges were returned, so I think that you are left processing the array yourself to decide how many ranges were returned.  Here is some code that I wrote that tells you how many ranges were returned.  I think that in the end it is going to come down to you performing a similar operation.  Let us know if you have any further questions.

#include <NIDAQmx.h>
#include <stdio.h>

int main ()
    double myDoubleArray[512] = {0};
    int i;
    double max;
    double min;
    DAQmxGetDevAIVoltageRngs ("Dev1", myDoubleArray, 512);
    for (i=0; i<512; i=i+2)
        min = myDoubleArray[i];
        max = myDoubleArray[i+1];
        if (min == max)
        printf("min is %.2f and max is %.2f\r\n", min, max);
    printf("There are %d viable ranges", i/2);
    return 0;
0 Kudos
Message 6 of 7
Thank you for your reply.

That is similar to what I planned.  I just wanted to be sure that there was not a better way.  Thanks for giving me the details!

0 Kudos
Message 7 of 7