In the previous video, we got the PLC setup for PID.
In this video, we will use the Do-more’s built-in Auto-Tune feature to create the coefficients
and sample time we need for PID to do its thing and then we'll run some tests to see how well
it worked!
To run Auto-Tune, we need to bring our system up close to the 110-degree temperature we
want PID to hold for us.
But how much heater power do we apply to get to 110 degrees?
Well, we could play with it for a couple hours until we found something that works, or we
can do it the easy way.
We can just get it that from the chart we created in the Hardware Video.
To get the box to 110 degrees, looks like we need to be at around 38 percent heater
power.
Easy!
Now you know why we spent so much time learning about our system.
It removes all the guesswork and saves us time.
I could bring up a dataview and enter the heater power there but look at this: Do-more
PLCs have a built-in PID viewing tool, which is a dataview and a trend view that has everything
we need to know about PID in one convenient place.
We need to manually set the PWM controller to 38% so let’s make sure the PID is in manual
mode and then enter the power we want here.
When I click this button to write that to the PLC, we see the Green PID output signal
jump to 38%.
Let’s change the setpoint to 110 degrees – it’s not doing anything – I’m just
using it to mark where we want the temperature to be.
It will take a while for the box to heat up, so while we wait I’m going to change the
scale to cover our temperature range, close the toolbox and shrink this window to make
more room, and I’ll go ahead and fast forward the video.
Ok, it took about 40 minutes for the heater running at 38% power to get the box up to
temperature without PID.
And we ended up pretty close to the 110 we wanted inside the box which we can see both
here in the dataview and here in the trend view.
Cool.
Click on Auto-Tune.
We’ll start with a PI controller and a Closed Loop Algorithm.
We’ll do open loop example in the video on manual tuning.
The default deadband is fine. We’ll go into more detail on that in a later video
too.
When we actually hit the start button, it should take the PID output to 100% and then
wait until the process variable crosses the setpoint.
It will do that two more times and then based on how the process variable responds, the
Auto-Tune algorithm will calculate all the coefficients and the optimum sample time.
Since it is going to run three cycles, we expect this to take several minutes to heat everything
everything up and cool everything down a couple times, right?
Let’s see what happens.
I’ll hit Start. uh-oh.
What happened?
Auto-Tune is done but we didn’t see three cycles and it finished way too fast.
What happened?
Well, the issue is noise.
I’ll right-click and adjust the Y-Axis, so we can get a closeup view of the signal.
Look at this messy signal!
So, the NOISE crossed the setpoint three times very rapidly.
Auto-Tune saw three crossings and assumed it was done.
Bummer.
Something else happened here too.
Did you notice the setpoint changed at the start of Auto-Tune?
Why did it do that?
Well, we told it to.
In the PID instruction, we told it to move the setpoint to whatever the process variable
is at the start of the PID process.
Auto-Tune uses the PID process, so it moved the setpoint to whatever the process variable
was when we kicked off Auto-Tune.
Auto-Tune takes that into account, so you don’t need to worry about it.
But you DO need to worry about that noisy signal!
To fix the noisy signal, we’ll just add a filter here to get rid of the noise before
we do our PID calculations.
So, let’s add the filter instruction right before the PID instruction.
Our RTD sensor has a 1 second response time, so we can filter anything that changes faster
than that.
I experimented a bit and found that a quarter second filter time was more than enough.
We want to filter our noisy process variable in RX0 and we’ll put the result in R1 which
I already named Process Variable Filtered.
I can’t emphasize enough how incredibly important it is to get a clean process variable
going into the Auto-Tune algorithm.
A noisy process variable is one really quick way to mess up Auto-Tune.
Of course, we need to go into the PID instruction and tell it to use the new filtered process variable.
Accept, save, write it to the PLC.
Ok, I got the system back to the 38% heater power and corresponding temperature.
Again, we expect Auto-Tune to raise the output to 100%.
That will raise the temperature until the process variable crosses the setpoint and
repeat that two more times and then calculate the coefficients.
Let’s try it.
I’ll speed up the video.
Ok, that took about a minute.
I’ll zoom in so we can see it better.
Look at what we got. That is a proper Auto-Tune cycle!
We got some reasonable coefficients and the sample time is also reasonable.
Now before we do anything, we need to put those coefficients in our ladder code so the
PID algorithm will load them into the OvenPID structure each time we start the PLC.
Let’s do that in the dedicated first scan system task using the PIDINIT instruction.
I’ll just copy the coefficients from here … and put them in here.
If you want to, you can enter the coefficients directly into the OvenPID structure yourself,
but I like this PIDINIT instruction because it makes sure I don’t miss anything.
We need to turn on C0 to give the PID instruction control of the output so I’ll bring up a
dataview so we can do that.
When we did that, PID automatically moved the setpoint to whatever the current process
variable was, so let’s move the setpoint back to 110 degrees and wait for things to
settle out.
I had to run off to a meeting, so I let PID run while I was gone.
Looks like it held our 110 degree setpoint to within a fraction of a degree!
Cool!
Let’s do some experiments to see how well it performs.
I’ll change the setpoint to 115 degrees.
Fast forward and sure enough, PID automatically raised the box temperature and settled out
right at 115 degrees.
And look at that response!
If I was tuning this manually, that’s pretty much what I would be trying to accomplish.
A little overshoot and then quickly settling out at the new setpoint.
We can also see how PID went to full power until it got close to the setpoint, then started
to back off and adjust things for a nice smooth landing.
Perfect.
That was going to a higher temperature, what about drops in temperature setpoints?
Let’s drop all the way down to 100 degrees.
Fast forward.
Again the PLC automatically went to 100 degrees with a nice clean transition simply because
we asked it to!
Let’s go back to our baseline of 110 degrees.
Write that to the PLC.
Fast forward.
And again, another nice clean transition.
Remember – that was a PI tuning.
Let’s try a PID tuning.
I’ll click on Auto-Tune, switch to PID mode and hit start.
Fast forward.
I’ll zoom in so we can see the result. Yep, there are the three cycles we expect to see
for a proper closed loop Auto-Tune.
I’ll zoom back out and fast forward while I step through the exact same setpoint steps.
So, this is the PI tuning results as we changed the setpoint, this is the PI and D Auto-Tune
we ran, and this is the results of the PID tuning.
Very similar but the PID definitely settles out quicker, doesn’t it?
And you will find that in general for temperature applications that PI and D will usually give
better results, where most other industrial processes only need PI.
But it’s so easy to do, just try both and see which you prefer!
Ok, that was how it responded to us changing the setpoint.
How does it respond to disturbances?
Suppose our enclosure has a filter on the inlet and it gets clogged.
That would reduce airflow, so the box would get hotter – right?
Will PID compensate?
Let’s find out.
I covered most of the air inlet holes. Fast forward and sure enough, PID saw the temperature
rising and automatically lowered the heater power to compensate.
If I replace the air filter with a clean one – or in our example simply open the holes
back up – and fast forward, again, PID automatically compensated by increasing the
heater power.
Exactly what we expected.
And all we did was made sure we fully understood our system and what it is capable of, entered
one PID instruction, made sure the process variable was a nice and clean signal, manually
raised the heater power until the process was near the temperature we wanted, ran Auto-Tune,
and tried it.
We also stored the PID coefficients using the PIDINIT instruction.
Not bad at all.
Now we did gloss over quite a few things and didn’t cover all the options or even all
the cool tools Do-more designer has to help you do this PID stuff.
We’ll cover those in the next several videos.
In the next video, we’ll learn how to use the built-in PID process simulator.
That way you can get all of this setup and tested before you take your system offline.
Very cool.
Click here to see all the videos in this series.
Click here to learn about AutomationDirect’s Free award-winning tech support options and
click here to subscribe to our YouTube channel so you will be notified when we publish new
videos.