LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog Write On Damand - has a time lag

The application is a simple DC motor controller using only proportional gain (i.e. P-controller).  I'm simulating low sampling rates (<1613Hz) by balancing a combination of actual sampling rate and setting the Number of Samples read per iteration in a For-Loop;  each iteration the mean values yields a single data point.   In general, this algorithm works fine.   However, we've noticed a time lag with the analog write which is dependent on the actual sampling rate.   The Analog Write is presumably On-Demand but not performing as such.   To simulate 299Hz,  the actual sampling rate is set to 50kHz and the Number of Samples is set to 167, which is used to calculate a single data point.   The Analog Write immediately outputs a voltage command to the motor - as it should.   For some reason, there's a lag of several iterations before the analog outputs issues a voltage command when simulating 298Hz  (actual sampling rate: 1786 - Number of Samples: 6).    I don't understand the source of this delay.    If anything, I would expect the performance at 299Hz to totally suck but that's not the case.   What am I missing?

 

I'm using: NI-9178 cDAQ chassis with NI-9229 (Analog Input) and NI-9263 (Analog Output), LabView 2014 with the latest mxDAQ.   Attached are two pictures to illustrate the time lag to output a voltage command (yellow plot).   Also, I've attached a basic, single-vi program to demonstrate how the channels are being configured.

0 Kudos
Message 1 of 6
(3,302 Views)

Hi Joshu,

 

Is the 298Hz case the only one that lags? What do you mean there is a lag of several iterations before the device writes? It looks like that delay time is from all the processing going on before your write the data.

0 Kudos
Message 2 of 6
(3,199 Views)

No, the lag varies across all frequencies up to 1kHz (max setting for this application).  This is just an extreme example to demonstrate the issue.   The Analog Write - On Demand is not performing ON-DEMAND.   The output value is correct but there's no voltage output from the NI-9263 for several iterations - with reference to indices in the For-Loop.   Each point on the graph is one iteration in the for-loop.

0 Kudos
Message 3 of 6
(3,157 Views)

Hi Joshu,

 

what happens when you only include ai2 in your AI task? (It's the Tachometer voltage you need in your calculation.)

What happens when you separate AI and AO in two loops using a producer-consumer scheme?

Can you check the real sampling rate of your AI task by reading the DAQmx properties after right before starting the task?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(3,149 Views)

Have you tried graphing VControl? I should just be Vout/7 but if you verify what voltage you are sending to the AO task, it  would limit the problem area.

0 Kudos
Message 5 of 6
(3,131 Views)

SteveD:

The "Command Voltage" (White) curve is Vcontrol, which jumps to 20V as you'd expect.

 

GerdW:

I have tried setting the output voltage to a constant - eliminating all the controls, but witnessed the same delay.   I'll try a producer consumer loop with a queued control voltage tomorrow.

 

Thanks for the help!!!

Joshu

0 Kudos
Message 6 of 6
(3,127 Views)