LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic control of AI input range for 8 AI channels.

Solved!
Go to solution

Hi everyone!

I am trying to sample voltage on 8 AI channels using NI-9205. All the channels are connected differentially and all are sampling "at the same time".

The challenge is to be able to change the AI input range in some channels to either i) gain resolution or ii) avoid oversaturating the ADC at a certain point in time.

 

I have been able to achieve this by using the attached VI, but I think this slows down the rate of data sampling. Is there a more efficient way to dynamically set the AI range on multiple channels? At 30k sampling rate with 100 samples per channel to collect, each loop should take approx 27ms (8 channels x 100 samples)/30000kHz = 0.027sec. Unfortunately, with the way my VI is arranged, it takes about 100ms

Is there a way to speed it up?

 

Channel AI range.jpg

Cheers!

0 Kudos
Message 1 of 5
(2,962 Views)

Hi retro,

 

at 30kHz samplerate I would expect a loop iteration time of 100 samples/30kS/s = 1/300s ~= 3.3ms…

 

Is there a way to speed it up?

No.

Creating a new task, setting up all channels, setting sample rate, starting the task, doing the reading and stopping the task will take its time…

 

Your example is quite bad: you constantly create a new task, but you don't clean up that task! This is a NO-GO!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(2,958 Views)

Indeed, this was the only way that I could find to change the AI input range of each channel automatically.

Is there a better way to change the AI range of each channel without Starting and stopping the task? 

Also, what do you mean by clening it up?

 

Many thanks! 

0 Kudos
Message 3 of 5
(2,944 Views)
Solution
Accepted by topic author retrothis

Hi retro,

 

Is there a better way to change the AI range of each channel without Starting and stopping the task?

No.

 

Also, what do you mean by clening it up?

In each iteration of the loop you create a new task, do some work and stop the task. But you don't call DAQmxClearTask…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(2,939 Views)

Ok, many thanks, Gerd! 

0 Kudos
Message 5 of 5
(2,935 Views)