Part 2 of this video series left us with a PLC that used the TIMEPROP instruction to
create a PWM output on Y0.
The PWM signal controlled a solid-state relay which modulated the power input to a 500-Watt
heater which heated an enclosure that had room temperature air being pulled through
it.
We have an RTD sensor in the box which produces a 4-20 mA signal, so we can send it directly
into WX0.
This is our process ... an enclosure heater.
I’m not showing the 24-Volt power supplies or the extra digital panel meters in this
diagram just to keep things simple.
Great.
Now we take that digitized signal which ranges from 0 to 32767 and scale it to degrees Fahrenheit.
That’s our Process Variable. It tells us what the current status of our process
is.
Why degrees Fahrenheit?
Because we want to specify the desired temperature in degrees Fahrenheit.
We call that the Set Point, which we will just manually set for this demo.
Now that they are both in degrees Fahrenheit, we can subtract them to see how far apart
they are.
We call that the error.
We then do the PID math which outputs a 0-100% range.
Normally we would scale that to whatever the process needs, but our process happens to
need 0-100%, so do we need scaling?
Nope!
This looks kind scary but guess what.
All of this is done by a single instruction!
The PID instruction.
Once again, the Do-more engine does all the heavy lifting for us.
So all we need to do is: Make sure the analog input is scaled correctly, add a PID instruction,
and add a TIMEPROP instruction to generate the PWM output.
Here we go … To set up the analog input, go to the dashboard
and configure analog inputs.
We’re using a 4-20 mA sensor and we do want to scale it here for 4-20 mA.
The RTD sensor we are using goes from 0 to 300 degrees Fahrenheit, so we put that
here.
Notice that Do-more designer has already taken the 4 mA offset into account.
That is, 4 mA corresponds to this digital value.
I love that I don’t have to remember how to do that.
And the final scaled temperature data is in RX0.
We still have the room temperature sensor connected and the BRX PLC will complain if
we don’t configure it, so I’ll go ahead and set that up so we can monitor the room
temperature if we want to.
Now we just put a PID instruction in our ladder code.
Fill it out. We’ll need a new PID Structure – let’s call it OvenPID.
This is a position PID. We’re monitoring the amount of heat, not how fast it’s
changing.
Be careful here. If you are measuring a motors speed, for example, do you choose
position or velocity?
Well, if you are measuring the amount of speed, not how fast it’s changing, then it
is still a position algorithm. That does trip up a lot of people so be careful about
which one you choose here.
This tells PID that when it first starts, it should to set the setpoint at whatever
level the process is currently at.
That’s to prevent sudden changes when PID starts.
In our temperature example that won’t be a big deal, so we’ll come back to this initialization
stuff in other videos.
We already scaled the process variable in the analog input dialog, but I am going to
do it here again anyway, just so I can specify that I want the process variable to come from
RX0.
Otherwise, we would have to transfer RX0 to the process variable ourselves in the ladder
code, right?
We’ve already scaled it to 0 to 300 degrees, so we’ll scale it to that, which is no
scaling.
The beauty of using this scaling, even though we don’t need it, is that we can type the
units in right here.
Now going forward, everything we display about PID will be in degrees Fahrenheit and we don’t
have to fool with raw data values.
This is a forward acting process. That is if we increase the output, the temperature
increases.
A reverse acting process would be like a cooling system where as our control output increases,
the process temperature decreases.
PID needs to know that to get the math to work out.
We’ll cover these options in the Loose Ends video.
And as we saw on our block diagram, we don’t need to scale the output. The 0 to 100%
that PID naturally sends out is exactly what we need to drive our PWM output.
And since the PID output will be controlling the PWM signal, let’s go to the TIMEPROP
instruction, fill him out like we did in the previous video, and make sure he gets his
input from the OvenPID structure’s output.
And let’s add some contacts to enable the various instructions.
We need to turn on the exhaust fan, so let’s go to the dedicated First Scan system task
and enable the fan so it runs continuously.
Accept all of that.
Send it to the PLC and put the PLC in RUN Mode.
Nothing is happening because PID is in manual mode, which means we are controlling the
PID output, not the PID instruction.
And that’s a key point.
Once the instruction is in place, PID is always running.
The Auto Manual selection just decides if PID is automatically controlling the output
of the instruction or if we are manually controlling the output of the instruction.
Great, we now have our raw temperature data which is scaled to 0 to 300 degrees Fahrenheit
for us in the analog input setup.
The PID instruction takes that, does its math, then passes a 0 to 100% to the TIMEPROP
instruction which creates the PWM signal to control the solid-state relay and ultimately
the average heater power.
We also enabled the exhaust fan.
OK!
The PLC is set up.
Join me in the next video where we will tune the PID algorithm and then run some live demos
to see how well it works!
Click here to go directly to that video.
Click here to lean about our Free tech support options.
And click here to subscribe to our YouTube channel so you will be notified when we publish
new videos.