Optimizing PID-Loop

We’ve recently deployed a PAC-R1 system using one PID-Loop as its main control algorithm to maintain a target level (set point) of dissolved ozone (O3) in a large tank of water. In this application, an ORP sensor is used to measure the ORP level (in mV) in the water being supplied from a large water tank, which in turn will drive an analog output to an ozone generator to control how much ozone to generate and inject into the water circulating back to the tank (Output is in the range of 0% to 100% Power). Now that this Ozone system has been installed and commissioned (in Europe), it is quite apparent that PID fine-tuning is required to stabilize and further optimize this system (as was expected).
I was hoping someone with more PID experience can quickly look at my output graphs and determine my next step. At initial startup of this machine when the water started being circulated through the ozone generator and back into the tank, the system was able to somewhat maintain the setpoint, but the Output% was oscillating between 0% and 100% in order to do that (not good), which was no surprise at this point. After watching some PID videos, etc., I decided the quickest way to fine-tune this system was using “Guess” as my fine-tuning method (3rd option from Beno’s PID video). I’ve spent several days monitoring and tweaking the loop, and could easily do much more of this to keep improving the system but was hoping for someone’s experience to guide me and point me in the right direction.
The system is very slow in terms of response, with a 5-minute “dead loop” time, so I’ve finalized on using a 100-second scan rate, and now that the system seems to be able to stabilize and maintain the set point, it seems that it is way too slow, taking up to half an hour to stabilize… I’d like to be able to get to the setpoint quicker, even over-shoot if necessary. I’m wondering if my “D” parameter is causing the system to be “too jumpy” at times. Please see my attached graphs using the handy PAC Strategy PID tuning tool:

  • Capture1_unstable was one of the first initial plots, where output oscillates from 0 to 100.
  • Capture 1_2024-04-13 was improved, but notice how the output dropped from 100% to 0% just after started, then gradually increased back to 100%. This is unexplained to me as the Input was way below the setpoint and should have remained at 100% output.
  • Capture 4 shows a more stable system but slowly approaching the setpoint (very gradual output increases).

Sorry for the lengthy email… if there’s a better way to analyze this and review, please let me know (phone call?). Thanks in advance… Andre.



0 the tune d, it isn’t going to help you.
I don’t like really long scan times, I would shorten that to maybe 10 seconds. Long scan times add to your response delay. Short scan times don’t hurt anything. Note that this does affect the other tuning parameters, look at the formulas to see how. Also your input range and output range also affect the tuning. Best to have all those figured out and then leave them alone.

I typically set the I tune to a very small number like .00001 and then try to find the gain that is stable, or just begins to oscillate. Then decrease the gain by about half and then start increasing the I tune to get rid of “offset” in an acceptable amount of time.

Slow response loops take a lot of patience. Yours responds in about 200 seconds, not quite 5 minutes.

Good luck!

1 Like

Im wondering how you measured the dead loop time?

Have you tried using the PID tuner on the website?
https://www.opto22.com/support/resources-tools/demos/pid-reaction-curve-tuning-for-interactive-pid-alg

Your D term is too large. It should typically be 1 or less. With it up around 50 its going to be hard to tune.
I think you need some D, but crank it down a lot from what you currently have.

Keep in mind that the scan rate is the time between doing the PID math, so at 100 seconds, you are going to be doing nothing at all for those 100 seconds.
I agree with @philip in that doing it a bit faster is usually better, his suggestion of 10 seconds sounds reasonable. I would not go below that.

Is your ORP input using a wider than required span? ie, don’t just accept the whole range of the probe, but set the input to be the required range of the large water tank. ie, set it for reality, what you want and expect and just a little wider to allow for some under/over sensing.

The output of 0 to 100 sounds about right, so that should be left as is.

Does the water tank ozone ever get turned off?
In other words, do you need a ‘start up’ phase before the PID is turned on?
Or is the process running 24 * 7 * 365?
If it just runs all the time, then tuning the PID will be the main goal. But if you turn the system off, say nightly then having a start up chart might be in order and we can talk about if its the case.

1 Like

I found the information at https://controlguru.com/ to be pretty helpful with tuning. The website prescribes to the IMC method witch has very good setpoint tracking but could be a little sluggish for slow processes.

PID Tuner Controller | FREE Software is a free tool where you can import your step response data and fit a differential equation model to it. From there, you can try out different values on the model.

1 Like

Thanks for your feedback! Much appreciated…
The dead loop might even be greater than I expected. See attached graph from this morning. The blue trend is the flow rate, and the pump is scheduled to turn on at 3 a.m… and it appears that about 8-9 minutes later, the ORP started to rise (even though I see another minor transition after 3 mins). I used this to calculate the dead loop last time, but before when I calculated it, it took about 5 minutes to start rising (going from 0% to 100% output in both cases).
ORP input will likely use the entire range, at least from about 200-1000 mV (20%-100%), and possibly lower if they use RO water.
The system sits idle and is triggered by a set schedule. See attached “full day” graph from today. They have it scheduled to “RUN” twice a day. Which I’m amazed how well the PID loop seems to be working, but there’s still a lot to learn here, as many other factors come into play (they transfer “dirty” (or leachate) water to this tank which might initially have a lot of organic matter and be difficult to increase ORP).
And I agree, a 5-minute start-up phase would probably stabilize the tank before turning on the PID loop (good point).
(I’m off to catch a plane to Europe and will likely have time to monitor further today).

Thanks again!