LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

The elapsed time of PID vi does not match with true time

Solved!
Go to solution

Dear all,

 

I am trying to do motion control of a hydraulic cylinder using PID vi. The hardware I used includes NI 9220 for LVDT voltage input, NI 9269 for voltage output, and NI 9213 for temperature input.

 

The problem is that when I acqusite extra temperature data from NI 9213, the elapsed time of PID vi becomes extremely slow, leading to failure of PID control due to the low loop frequency.

 

Does anyone encounter similar problem?

 

Attached please find the programme used.

 

Best Regards,

Roy

0 Kudos
Message 1 of 5
(841 Views)

Hi Roy,

 

without looking at your VI I can recommend to place the DAQmx task handling the NI9213 into a separate loop so it will not slow down the other DAQmx tasks...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(804 Views)
Solution
Accepted by Roy19

Hi Roy,

 

now I had a chance to look into your VI…

@Roy19 wrote:

The problem is that when I acqusite extra temperature data from NI 9213, the elapsed time of PID vi becomes extremely slow, leading to failure of PID control due to the low loop frequency.


That's not a problem of the PID functions, but of your data acquisition!

 

Recommendations:

  • Don't use the DAQAssistent ExpressVI when it comes to more accurate timing. Use plain DAQmx functions instead, as explained here and in all those DAQmx example VIs… (This applies to both DAQAssistents in your VI!)
  • When you need accurate timing in a DAQ loop then you should use the timing options provided by DAQmx in favor of any wait function in the loop! Set a samplerate of 20S/s when you need a sample each 50ms for your AI task (channels Voltage, Voltage_0)!
  • Create a 2nd DAQmx task to read your thermocouple from module2. The NI9213 is really slow with just 75 S/s for all it's input channels! Read that 2nd task in a parallel loop (as said before)!
  • You don't need to wire the "dt" input of the PID functions, they will determine that value internally on their own…
  • To improve iteration time of your loop you also should replace the WriteMeasurement ExpressVI by "plain" file functions (like WriteTextFile)! Open the file once before the loop, write the data inside the loop, close once after the loop…
  • Are you sure you should use PID gains of [10.0, 0.01, 0.001]? How did you determine them?
  • When the profile should repeat automatically you could use a shift register and the "profile complete" output of the PIDProfile function instead of the boolean button…
Best regards,
GerdW


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

Dear GerdW,

 

Thanks for all your comments. They really help a lot!

 

Regarding the PID gains, because I modified the programme from the PID example, so the PID gains would always recover to its default values of [10.0, 0.01, 0.001]. This also happens for the PID profile. Save the file doesnot help at all. Is there any method to solve this so that I do not need to reinput all the gains and profiles again. 

 

Best Regards,

Roy

0 Kudos
Message 4 of 5
(759 Views)

Hi Roy,

 


@Roy19 wrote:

Is there any method to solve this so that I do not need to reinput all the gains and profiles again. 


You need to set new default values, either by right-clicking the controls (->Data->set as default) or by using the edit menu -> set as default…

Best regards,
GerdW


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