From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using PID inside a while loop used for timing

Solved!
Go to solution

I am trying to impliment a PID controller in my data acquisition code. I am currently using a producer/comsumer model to collect data and store/display it. Inside the consumer loop, I have a while loop that collects data from multiple sources at a set rate and adds them to a queue. I am trying to impliment the PID controller inside this while loop. I have the process variables in a shift register so they are being fed back to the PID block every loop iteration. However the timing is not working how I expected. I would like this PID to update only every 60s so I added a constant to the "dt (s)" port in the PID block. But it is updating every loop iteration. I am unclear how to fix this as I still want the pid block be receiving data during those 60s (for the integral action) but I only want the control output to update every 60s. How do I fix this? Am I even approaching this in the correct way?

 

I have attached my code but there are alot of subvis I couldn't include so it won't run but hopefully will give a good idea of the structure. 

0 Kudos
Message 1 of 2
(693 Views)
Solution
Accepted by topic author akb427

Hi akb,

 

wiring an arbitrary dt value to your PID function makes the PID calculate wrong output values...

 

When you want to change the output value only once per minute you should use ElapsedTime with a case structure. Inside the elapsed case you can update your output.

IMHO it seems silly to update the output only once per minute when you read process values much more often!

Best regards,
GerdW


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