In the previous videos, we configured the CLICK PLC for PID and got our first look at this
PID monitor.
It's time to start doing stuff.
We need to know three things about our system before doing an autotune:
What is the smallest and largest possible process variable, is our process linear, and
is our process repeatable?
Our minimum process variable is when the output is zero.
Our output is currently at zero and we see the process variable is at room temperature.
Remember, these guys are always in whatever units you’re using. For us, that is degrees
Fahrenheit.
Let’s go to the Display tab and change the vertical axis to show the full range of
our zero to 300 degree sensor to give us some perspective.
I’m going to turn the dots off to give us a cleaner display.
Let’s go to the PID Control tab and change the setpoint to 110 degrees where ultimately
want our system to be at.
It’s not doing anything right now because we are in manual mode - we are just using it as a
marker.
To measure the maximum process variable, make sure we are in manual mode where we control
the PID output, make sure the PLC is running, and then manually force the PID output to
100% and see what happens.
It’s going to take a while for the enclosure to heat up so I’m going to fast forward
the video and adjust the time axis, so we can see everything.
We see the max temperature is well within our sensor's range, so I’m going to zoom
the Y-Axis to only show our operating range.
We see that our max temperature is just under 170 degrees,
which means we have about 60 degrees of headroom for PID to operate.
That is, PID can shoot for 170 degrees and then at the last minute back off to settle
out right at 110 degrees to get the fastest possible transition time.
Step 1 is done. We now know our min and max process variable, so let’s close the monitor
and bring up the setup dialog.
I’ll read the current PID configuration to preserve any changes we might have made,
modify the min and max process variable entries that we skipped earlier and then write everything
back to the PLC.
We could also have done that via a dataview using the addresses shown here.
What if you can’t get your system to zero or 100%?
Maybe it will stress your system or its not practical, or it creates a safety hazard.
That’s not a problem, but, the answer will make more sense after we answer question number
2 – is the system linear?
The more linear your system is, the better PID will work.
So let’s see what ours looks like.
Let’s close the setup dialog and go back to the PID monitor.
I’ll lower the output to 80%, wait for it to level off and measure that level.
Then lower the output to 60%, wait for it to settle, and measure that level.
Same thing for 40% and 20%.
If we plot the output levels vs the temperature values we read at each level, we see we have
a reasonably linear system.
I’ll add a trend line, so we can see what a perfectly linear system would look like.
Knowing our system is linear gives us confidence that PID will be stable and reliable.
Ok, let’s go back to the question – what if you can’t run your system up to 100%
or down to zero percent?
Again, maybe it will stress the system too much or create a safety hazard.
Easy, just gather a few points over the range you CAN measure and use that to extrapolate
the end points.
In fact, this is actually the preferred way to do it because many systems aren’t linear
at the extreme ends of their range.
And at the end of the day, choosing whatever values provide the best linear match
to your operating range is what will give you the best possible PID results.
Ok, so we determined our min and max process variable and adjusted those to give us the best
linear match to our system.
Finally, we need to make sure our system is repeatable.
That is, when we go away from a temperature and then come back, do we get the same answer.
Sure enough ours returned to the original value.
If your system doesn’t get back to within a few percent of the original value, you need
to do some work on your system, because a system that isn’t repeatable is really difficult
for PID to deal with.
Great! We now have confidence our system is PID ready, so let’s do it.
Here are the steps: Start in manual mode and bring the process
up close to the level you intend to operate at, within a few percent.
Just make sure the process variable isn’t changing and is stable.
For our demo that’s somewhere near the 110 degrees which we marked with the red setpoint
trace.
How do we know how much output power to apply to get the enclosure to a 110 degrees?
You can do it via trial and error, but since we did our homework, we can do it the easy
way!
We just pull it off our chart.
Looks like we need around 38% output power to get the system near 110 degrees.
I could enter that here but that will take a while.
Instead, I’m going to enter 100% output power, fast forward and then when the process
variable gets close to the 110, I’ll switch to 38% to finish it off.
That will get the process variable – our enclosure temperature - there a lot quicker.
The key is make sure the process gets to a stable value near your desired setpoint before
doing autotune.
Next, we want to preset the tuning parameters to these values.
That just forces PID into a lethargic state, so things don’t go nuts when we switch over
to auto mode.
Make sure you are in bumpless mode 2.
We don’t want the setpoint moving when we start autotune.
We did that when we configured the system, but let’s bring up the dataview and make sure.
Yep, bumpless mode is on.
If it wasn’t, we could simply change it here instead of going back to the PID setup.
To do an autotune, we just switch to auto mode and as a quick check, none of these
should change, if we did everything right.
They didn’t so we are good to go.
Select the algorithm type we want – we’ll start with PI.
Set the hysteresis to something reasonable for your system.
Hysteresis is a percentage of the setpoint.
If we choose a 1 percent hysteresis then that puts a 1 percent or 1.1 degree band around
the 110 degree setpoint we have.
When tuning starts the output will go to its max allowed value.
Autotune will wait for the process variable to cross the setpoint plus the hysteresis.
The output will then go to its min value and wait for the process variable to cross the
setpoint minus the hysteresis.
It will repeat that two more times and based on the way the system responds, the autotune
algorithm will calculate the PID coefficients and sample time we need!
Let’s try it.
This will take several minutes, so I’ll fast forward and zoom the display so we can
see it better.
Now that’s what a proper autotune cycle should look like!
When it hit the setpoint plus the hysteresis it went the other way until it hit the setpoint
minus the hysteresis and repeated it two more times times.
Perfect.
We see the autotune complete message and the new coefficients loaded into
the PLC ready to go.
Now that's important.
The coefficients are in the PLC but not the project.
If these are your final coefficients, then don't forget to hit this button to copy them to the project.
Now I know I'm going to be messing with these in the next video, so I didn't do that here.
If you're not sure what the current project settings are, then click this button to read them into these slots.
They won't go into the PLC until you hit the individual write buttons or the global write button
which writes all the parameters in all 3 tabs to the PLC.
You want to keep the hysteresis as small as possible but larger than any noise you have
on the process variable.
If your tuning cycle finished too fast, then it’s probably because the noise on the process
variable crossed the hysteresis, so try increasing the hysteresis to get your proper autotune
cycle.
Or you could increase process variable filtering.
We’ll do an example of that in the next video.
Ok, well, let’s try it out!
I’m going to modify the vertical axis so we can see the results of the test we are
about to run.
Let’s bump the setpoint up 5 degrees.
Fast forward and sure enough PID automatically moved the oven temperature to the new setpoint
for us via a smooth efficient transition!
Nice!
Let’s bump the setpoint down to 100 degrees.
Fast forward and PID automatically takes our system to that temperature.
I’ll bump it back up to our original 110 and once again autotune automatically adjusts
the output to get us there.
Very cool.
And what did we do to make this happen?
Before starting autotune we found our expected min and max process variable, saw that our
system had plenty of head room for PID to do its thing, the system was linear, and it
was repeatable.
Once were confident our system was PID ready, we then put it in manual mode, put our setpoint
at the level we wanted to be at, manually drove the output to get the process variable
close to that level – we knew how much power to apply from our linearity chart - and waited
for the process variable to stabilize.
While we waited, we made sure we were in bumpless mode 2 and populated the PID coefficients
with known stable values.
To do autotune we switched to auto mode, selected the algorithm we wanted and hit start.
Those are the basics to getting a successful autotune.
Join me in the second part of this video where we will: Do a PID autotune, learn how to deal
with noisy process variables which can really mess up an autotune, and run several examples
to give you a better feel for how CLICK PID works and just to get you more comfortable
with PID in general.
Click here to see all the videos in this CLICK PID series.
Click here to learn more about AutomationDirect’s free technical support options and click here
to subscribe to our YouTube channel so you will be notified when we publish new videos.