RSLogix PID Loop PLC Programming | Example of PID Control Instruction in Studio RSLogix 5000

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to this lecture on PID control loops today we're going to be programming a PID ladder logic instruction we're going to set it up accordingly we're going to also simulate this within a trends on a live PLC and we're going to look at the effects at different parameters within the PID loop instruction have on the control set point of set parameters so without any further delay let's get right into it before we get started with today's video we just wanted to quickly point out all the great content we've been releasing on the soleus plc youtube channel and this includes industrial automation plc programming as well as HMI development and if you enjoy this type of content we would really appreciate it if you could click the subscribe button as well as the notification bell in order to receive the latest and greatest content we will be posting to the channel so the get started we're going to create a new routine I'm going to go into my Advanced section and I'm going to right click head on add new routine and this is going to be a ladder logic diagram routine so I'm just going to type in the next prefix and I'm going to call it PID loop nothing extremely difficult I'm going to click OK and as you can see the new routine has been created we're going to need a couple of things in order to get the PID to work of course we are first going to use an instruction so I'm just going to pull any instructions from this bar and then rename it to PID this will bring up the PID ins instruction as you would expect with a lot of undefined parameters so we're going to start populating them at this point the PID loop first of all this is going to be the control structure which is going to be used for the PID and I'm simply going to call that PID I already used a PID underscore tutorial so I'm just going to call it PID one and here we're going to need to create some process variables so the process of a variable think of this as your input to the PID loop so we're going to just create a quote-unquote dummy rung which is going to give us some more a visual on the PID loop so here we're going to say this is some kind of a temper your sensor which is giving us a feedback from a physical device so think of this as an analog input which we're receiving into our system and this is gonna go into PID one underscore TV and this PID one underscore PV is just a real tag so that's going to be created like so and I'm going to create a new temperature sensor a real value as well this is like I said just for demonstration purposes in the real system you would have a temperature sensor which comes in on an analog card and we'll look at that in a different video so in any case that's going to be our temperature sensor at this point it's going to be zero but here the process value is going to be PID one underscore PV it's usually good practice to set these up as separate tags because you might be using a temperature sensor for different applications within your software so usually you'd want to create some kind of a move structure which allows you to output this and then the next step is going to be the tie-back this is not something that is used very frequently so I'm just going to put that in it's going to be a real tag I don't usually use the tie-back for anything so it's just kind of sits there and it calculates control value we're going to create that tag as well so PID one underscore control variable and the control value variable is essentially going to be the output of your instruction the control variable is going to be what you're going to output to the outside world in order to control the the process and here we're going to create a second move instruction so think of this as the control variable and you can use the output of the PID instruction as well so there's going to be an output in percentage there's going to be a process variable and of course the control variable is where we would like to go so let's see here this is going to be heating system and this is just going to make it easier for us to visualize what is going on I'm going to right click it click this create a new and unreal it yes next PID master loop we don't have a master this is a standalone PID but you can certainly have P IDs which depend on each other and hold in hold is going to be 0 and here we have question marks because our control value has not been initialized so I'm going to right click this head on new and this is going to be of data type PID this is a an Allen Bradley specific module so we are going to create that and that's pretty much it as far as just the basic configuration goes the other thing that we do need to look at is the parameters but actually before that let's create the timer which is going to be updating our loop so here I'm going to create a t on instruction T on and this is going to be called PID u1 underscore T we already have that tag in place and I'm going to update it every 50 milliseconds let's leave it at that and the timer is going to cycle on itself so I'm going to use a an X i/o instruction which is essentially going to be tied to my done bit so think of this as a repeating timer and then once the timer is done I want my PID loop to update and then that looks pretty good so here's what we need to configure or the critical values so of course the gains we're going to look at those in just a second but within this configuration tab there's going to be a few parameters this is going to be an independent loop the error so the control action is going to be of the set point minus the process variable that's correct derivative of PV so depending on what kind of a loop you're running you may play with those but usually the default values work pretty well the loop update timer is very important this is going to have to match the timer so this is in seconds and here the values in microseconds we're going to set that to 0.05 the limit so the high limit is going to be 100 let's set that as such the low limit is zero alarms we're not going to play with these but you can essentially create alarms for your P IDs as well in terms of scaling we need to scale our values so unscaled is going to be a thousand max at what a hundred percent is going to be let's say one thousand or actually let's make this one hundred one hundred and then e engineering units max one thousand as well here so we're going to head apply on everything and then we should be ready to essentially work with these gains no and we're going to be changing the setpoint of course I'm going to hit OK the next thing that we also need to do is we need to simulate so the loop on a PLC which is running on its own it's not going to get the values that I've described above so essentially we do need to instead of doing this I'm going to actually put on a fi here instead of doing it this which should be the way that you work with the PID instruction I'm going to create a timer which is going to sorry a compute instruction which is going to simulate which is going to simulate the PID action so let's look at that right now it's also going to update every single time that the timer is done the destination is going to be our process variable so think of this as essentially a way to trick the PID loop to show how it's running in a real-world application so this is going to be multiplied by 0.99 so essentially it's always getting closer but not quite and here we're going to add the control variable multiplied by 0.01 and we're going to save all of this let's see if we can save this without without any errors the last thing since you can tell that the rung is not energized we need to go back into our main and call this instruction essentially create a jump to subroutine so I'm going to copy one of the rungs above paste it down below and here I'm going to call the instruction routine which we've just created which is going to be underscore zero five underscore PID loop and I'm going to update this once again and I'm going to double click the PID loop and double check what is going on so since we have a zero setpoint you will notice that the process variable is going to slowly go down but I am going to put this at let's say 100 and then we haven't set any parameters so let's just give it some random values of 5 for example let's head on apply and let's hit OK so the process variable as you can see the output is currently a 100% and the process variable is trending towards the setpoint and of course if I increase this then you'll notice that the process variable is slowly going to trend in that direction I believe that we do need to adjust the scaling the process variable 1000 1000 let's see here Allah said let's set that at 1000 as well and as you will notice it overshot but then it comes back so let's create a trend which is going to demonstrate this functionality and in order to do this first of all we're going to right click on trends I already have another trend set up but I'm going to call this underscore zero to underscore a PID one I'm going to update that every single millisecond I'm going to click next here we're going to select some key tags at which we're going to look so from the drop-down menu we need to browse down to PID 1 and within this PID 1 we want to look at two different things so first of all I do want to look at the setpoint setpoint we're going to collect ad and I also want to look at the process variable so the process variable is how close we are to thee to the actual setpoint so let's see here it should be PV somewhere here sp they're not in alphabetical order so it's a little bit confusing sometimes those are going to be the two tags that we're going to look at let's click on finish and before we run I'm going to right click and go into chart properties and from here I'm going to go into my pants and instead of leaving them from 0 to 100 I'm going to type in 1000 1000 this is essentially to allow us to see the full range of both of those pens the x-axis I'm going to just change this to 10 seconds so we're going to have a span of 10 seconds within our trend I'm going to hit apply the other thing that I also want to change let's see here so this is the major gridlines here so let's just add some more gridlines so it could be a bit more apparent what's going on and then the y-axis instead of using the automatic scaling we're going to select us preset which is going to use the min and the max values that you remember we set from 0 to 1000 for both of those pens I'm going to hit apply hit this okay button and from this point I can hit the Run button and you will notice that both values are exactly the same they are currently at 300 and the reason for that is because first of all those are the values specified by the PID loop but it means essentially that the PID loop has worked as expected let's change the setpoint to 600 and then tab control tab back into the PID trend and see what happens this is the the wrong trend let me see let's um let's close a few windows I'm just going to close this apply the edits we're going to say yes and then continue closing the trend we're going to close a few trends and then I'm going to rerun just the strand and then reopen at this PID loop so let's go back and then hit run once again the PID loop is definitely running as you can see both of the values are at 600 and now let's change this value down to 200 for example and I'm going to tab back into the window and you will notice that the PID loop immediately starts to react and trend towards the setpoint which is exactly the behavior that you would expect and that you would want in a normal control system as you see here it overshot or essentially undershot below the set point then it slightly oscillates on top of it and then it comes back into the value which is the normal behavior of the loop and of course once you have set this up you can start playing with the proportional integral and derivative gains these are going to highly depend on your application and of course if you start changing them to different values you will see different results based on the gains and here the gains are going to highly depend on the values of the simulation the way we set it up but you can certainly once you implement this and get some starting points into your control loop you can figure out which values would work best for your application so let's go back and change the setpoint to 500 now that we've played with some of those values and see how it reacts this time so as you can see we have a slightly faster trend upwards but we're not quite getting into the setpoint as fast as we did last time so since I reduce the integral and the derivative gains we are certainly taking a much longer time and as you can see this would not be an ideal application for this particular loop that being said if we over increase them so for example let's put on a value of 20 let's hit on apply and then let's wait for the loop to settle down just a little bit and then we're going to put in 200 just like we did before and then we tab back to our system you will notice what happens is that the loop will typically undershoot and then oscillate for a little bit longer so it's going to oscillate then it's going to oscillate back and it's going to eventually settle but essentially it oscillates a little bit more than it did in the previous scenario and of course if we play with the proportional gain let's set it to 1 for example and then go to a set point of 500 once again then you will notice that we're trending quite a bit faster but we are overshooting a lot more in this case and this is going to be somewhat of a trial and error depending on your system it's not always a precise science there's of course some reasoning to it usually you start with a single proportional gain and then you introduce integral and derivative gains but it's not something that you could essentially reapply from system to system especially if they come if they're completely different if you're controlling flows if you're controlling temperatures it also depends on the responsiveness of your time so for example if you have a temperature sensor which takes I don't know 10 minutes to get to a real temperature because of the propagation and the delays within the insulation then of course it's going to react different than a flow meter for example which is filling a tank which reads a real-time data so there's going to be a lot of different parameters but once you set this up you can essentially start playing with the control loop that you have developed and this is a really good way to practice and see what kind of different effects these parameters have on a control loop so I highly encourage you to build this instruction just like I did and see what kind of results you get as you can see here once again this loop is not reacting fast enough and it's certainly not going to get to the setpoint as quickly as we would like but there's always trade-offs and depending on the systems it may may work for your applications thank you guys so much for watching my content if you have any questions on this topic make sure to leave them in the comment section below and if you can spend five seconds of your time liking as well as sharing that video if you've enjoyed it that would mean absolutely the world to me and if you have any suggestions for the channel what kind of hardware software I should be covering then make sure to leave that down there as well see you next time take care
Info
Channel: SolisPLC
Views: 32,912
Rating: undefined out of 5
Keywords: rslogix pid, rslogix pid instruction, plc pid, plc pid programming examples, plc pid example, plc pid control, plc pid loop, plc pid function, rslogix pid example, pid tuning, rslogix 5000 pid, rslogix 5000 pid tuning, rslogix 5000 pid tutorial, rslogix 5000 pid temperature control, pid controller tuning, pid controller, pid programming, studio 5000 pid example, pid loop, pid instruction in rslogix 5000, rslogix 5000 pid setup and tuning, rslogix 5000 pid example
Id: w_5ZIkyEqxA
Channel Id: undefined
Length: 17min 6sec (1026 seconds)
Published: Tue Jun 04 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.