Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the correct channel name

Hello,

 

I'm using text based API and a NI 9201. I'm trying to get voltage samples. I found that the DAQmxReadAnalogF64() function always takes a lot of time. So I did a bit of research and decided to use function DAQmxSetAIADCTimingMode(). 

 

However, I don't know the name of the channel. The name of the chassis is "NI-DAQ". There are 4 C modules. The name of the physical channel for the measurement is "NI-DAQMod4/ai0". 

I called function like this error |= DAQmxSetAIADCTimingMode(*task, "NI-DAQMod4\ai0", DAQmx_Val_HighSpeed);


But I the status bit returns an error. What is the correct channel name?

0 Kudos
Message 1 of 5
(871 Views)

Just add more information, calling DAQmxSetAIADCTimingMode() with NI 9201, returns status -200458. It seems NI 9201 does not support this API. What are my options to improve execution time of DAQmxReadAnalogF64()?

0 Kudos
Message 2 of 5
(844 Views)

It is difficult to help/guide without seeing what you've created and how instruments appear in your NI MAX. As a starting point, please share the code that you created and a snippet of how your C-series modules appear in NI MAX.

 

On the other hand, have you looked at the examples that ship with DAQmx drivers?

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 3 of 5
(836 Views)

I'm on Linux, so I cannot use NI MAX. 

 

Using command nilsdev, there is one NI DAQ chassis with 4 DAQmx C modules.
NI-DAQ
NI-DAQMod4
NI-DAQMod3
NI-DAQMod1
NI-DAQMod2

I'm using NI-DAQMod4, which is a NI 9201 to measure analog input of voltage.

 

The code is below:

error = DAQmxCreateTask("", task);

// value of 'chan' is "NI-DAQMod4/ai0".
error |= DAQmxCreateAIVoltageChan(*task, chan, "", DAQmx_Val_Cfg_Default, 0.0, 5.0, DAQmx_Val_Volts, NULL);

// value of 'buf' is "".
// value of 'KDAQNI::config.rate_ms' is 25. 
error = DAQmxCfgSampClkTiming(*task, buf, (1000.0 / (float64)KDAQNI::config.rate_ms), DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1);

 
There is a thread running which read the analog input:

while (KDAQ_TASK_STATE_RUNNING == io->state)
    {
        result = DAQmxReadAnalogF64(io->task, 1, 0.025, 
             DAQmx_Val_GroupByChannel, values, 1, &samples, NULL);

        // Handle errors
        if (result < 0)
        {
            LOG_DEBUG(LOG_KDAQ, "AI failed read within 0.5s [result=%d]", 
                 result);
        }
        else
        {
            for (i=0; i<num_io; i++)
            {
                *io->io[i].register_ptr = ((float64)io->io[i].scale_factor) * 
                    (values[i] - (float64)io->io[i].offset);
            }
        }
    }

 

DAQmxReadAnalogF64(io->task, 1, 0.025,
DAQmx_Val_GroupByChannel, values, 1, &samples, NULL) function takes long time to run, about 15 - 25 ms.

0 Kudos
Message 4 of 5
(823 Views)

Update: I'm measuring a counter input and an analog input at the same time. Counter input is measured using a NI 9421. Analog input is measured using a NI 9201. 

 

After some experiments, DAQmxReadAnalogF64() function is also interfering the counter input measurement.

 

Without DAQmxReadAnalogF64() function, counter input measurement is good and accurate. 

 

But with DAQmxReadAnalogF64() function running in a thread every 25ms, counter input measurement is wrong and very inconsistent. 

I understand that DAQmxReadAnalogF64() is a blocking function, but I do not expect it interfering with other measurements.

0 Kudos
Message 5 of 5
(813 Views)