Learn how to setup and tune a PID loop ion a GS4 Variable Frequency Drive (VFD). Part 1: Setup and System Test; Part 2: Sensor signal filtering and Trial and Error tuning; Part 3: System Linearization and Formula method for tuning; Part 4: Loose ends
where we back up and cover things we glossed over in the previous three videos.
In the first video we setup the drive with these parameters and we learned about our system. In this video we'll setup PID using the Trial and Error method. Parameter 7.0 enables PID. We know from the last video that we have a Forward acting system, and let's make PID active in either remote or local modes so we don't have to worry about which mode we are in while we are testing. Parameter 7.02 is a read only parameter that tells us where the PID Setpoint is coming from. This is telling us the drive will use keypad entry for the setpoint, which is what we want so no changes are required. Where would we change that if we want the setpoint to come from a remote PLC for example? In parameters 4.0 and 4.1, just like we do for normal drive operations. That's where we always setup our analog input source — doesn't matter what mode we are in. Now that PID is enabled, Forward Acting is specified and the setpoint source is setup, we can finally setup PID. To do that, go to parameter 7.25 and set it to a 1. That selects this PID mode: the independent or parallel PID mode. We'll explain the difference between the two diagrams in the loose ends video. I love this chart because it shows me everything I need to know about PID at a glance. This is the setpoint stuff we just did. This is supposed to look like a switch. When PID is off, the setpoint is the drive frequency in Hz and that goes straight out to the motor. When PID is enabled it takes the feedback from the sensor via whichever source we select, compares it to the setpoint number we told the drive to try and maintain — that would be the 6 psi number we used in the previous video - and uses the difference or error to modify the frequency that goes out. It's really important to understand that when PID is enabled the setpoint we enter - and is shown on the LCD - is now a percentage number so we can subtract it from the sensor reading — or Process Variable - which is also in percent. We enter the Setpoint via the keypad where we would normally put the drive frequency, but again, we have to remember, this is a setpoint percentage number now — not a drive frequency. We want our system to maintain 6psi which is 40% of the sensors full scale. So here, where the drive frequency would normally be, we need to put 40%. But this is in still entered in Hz, so we enter 40% of the drives max frequency of 60Hz, which is 24 Hz. I know that's confusing. Just remember this isn't drive frequency when we do PID — it represents a 40% of the drive’s full scale output. And look at this … you always can check that you got it right by looking at parameter 7.05. It shows you the current setpoint in percent. Yep 40%. Perfect! Remember – while our setpoint is coming from the keypad, you could have it come from an analog input or even a remote PLC. So, this is a great way to verify the Setpoint is what you think it should be. If we set Parameter 8.0 to a 10, we can monitor the feedback signal right on the LCD display. That's almost the same thing as the analog input we were monitoring in the first video, but this shows us the feedback signal we selected for use with PID. Which is great, because we know analog input 1 is working from the first video, so if we don't see it working here we immediately know we selected the wrong function for Analog Input 1 in parameter 4.02. Yep, Analog input 1 is definitely the source of our feedback signal – which we also call the Process Variable. Great, We’ve Enable PID, Setup the Setpoint, Selected the PID mode and we verified we setup the feedback signal in the first video. We can finally tune the PID loop. That's this stuff. And for this video, we don't need any of this. We will cover all of that stuff in the loose ends video. We know from the last video our system needs to run around this frequency range so why not just tell the drive to go hang out there and then just have PID make minor corrections around that as the load changes? Well, that's exactly what this is for. It selects where the offset is coming from — we want a fixed offset to generate that 6 psi which comes from parameter 7.04. You can also have a dynamic offset via an analog input. Again, this is a percent value, not Hz. Everything we do in PID is in percent. We know from the first video the drive needs to be around 31.2 Hz to get the system to 6psi with one valve open. That's 52% of the drives 60Hz. So, if even if all of this is zero, the drive is still going run at this offset frequency of 52% of the 60Hz. Which is 31.2 Hz And now all this PID stuff has to do is just make minor corrections around that offset, which will require smaller gains, which means it will be easier to setup a stable PID system. Let's try it. Let's go to parameter 7.13 to set P to zero, Parameter 7.14 to set I to zero ... and parameter 7.15 to make sure D is zero so now only the offset should affect the drives output. I'm going to bring up the GSoft2 Application, connect to the drive, and open up the scope so we can watch all of this graphically, We'll make Green be the setpoint we want the drive to maintain in percent — that's this guy. Yellow the sensor feedback also in percent- this guy. Red is the difference between the two — this error signal - and we’ll make light blue will be the actual frequency command being sent out, this guy. If we start the scope and run the drive and then open each valve ... and then close each valve ... and pause the scope, and zoom in on that - we can see that these boxes show the values at the current cursor location. Sure enough, the setpoint is at 40%. The feedback from the pressure sensor settles at about 40% with one valve open, and changes as we open more valves. The drive frequency is fixed at the 31Hz offset we entered as 51.8% of full scale. The error is the difference between green and yellow and it settles out around zero for one valve and increases for each additional valve. Perfect. Exactly what we expect. So, this scope trace is just a graphical view of what we did in the first video, right? As we open each valve the system pressure drops. Well, let's turn on the PID parameters and see what happens. We'll leave I and D zero and just work on P first. How is P used? We take where we want to be — the Setpoint - and subtract the feedback signal that tells us where we actually are to get the difference, or error between the two. Multiply it by P and add it to the offset. The bigger the difference, the more we change the offset. So, we’re modifying the offset by an amount that is proportional to the difference between where we want to be and where we actually are. That makes sense. So, P is just a proportionality constant or you can think of it as a gain value that determines how much this difference affects the drives frequency. So how do we figure out how big P should be? We know from the first video that on average the pressure drop between valve openings was around 4.2% on average, and that the corresponding frequency increase we needed to overcome that was around 4.4% on average. So ... what do we need to multiply this pressure drop by to get this increase in speed? 1.05. That's P. It just scales this difference to give us the additional frequency we need to maintain the pressure. Let’s re-scale the scope display so it’s easier to see the traces in the next test we run. Let's go to parameter 7.13 and enter 1.1 as our starting point for P. I and D are still zero. Hit enter and .. uh oh ... what happened? The drive went berserk and shut itself down. All we did was add a little more frequency output — right? It's like the drive is trying too hard to compensate. Do we have too much gain? Was P too big? Let's cut P in half and try again. Startup looks a little messy, let’s open and close the valves. Still getting a lot of messy oscillation. So, what's going on here? The issue is … noise in the feedback signal. If we set P back to zero and re-run the open loop test and zoom in, look how big the noise is compared to the pressure drop we are trying to measure. We told the drive to compensate based on this difference, but the noise from the sensor is adding and subtracting this much to that at random, so the drive is going nuts trying to keep up. We'll take a closer look at why the pressure signal is so noisy in this system and what we can do about it in the loose ends video, but for now assume we are stuck with this noisy signal and we just have to deal with it. The good news is the GS4 has an easy fix for us: we simply go to parameter 4.13 and add some filtering to analog input 1. If I zoom way in on the noise signal, we see some fast-moving noise and a slower undulation that is around a couple tenths of a second. So let’s set the filter time to something just a little bit longer than that – how about a quarter second? Before I hit enter, let’s get the scope running so we can see the unfiltered noise, then I’ll hit enter. Wow, What a difference! And in the big picture the noise is almost gone. Much Better! We could tweak the filtering value even more, but for now this will be fine. We'll cover filtering do's and don'ts in the loose ends video. Ok, the analog signal looks a LOT better now so let's put P back to our original 1.1. Let's open the valves ... and close the valves. Now that's more like it. And look! We can now see the drive is automatically adjusting the frequency to try and compensate for the pressure drop. Looks like we have nearly a 5 percent error between the setpoint and the feedback signal so it's time to get more aggressive with P. I like to double P until things go haywire. Open the valves ... and close the valves. Looking better - we now have a 3% error. Let's double P again. Uh-oh ... the system is starting to oscillate. That means P is too big and the drive is trying too hard to compensate. Let’s spilt the difference. How about 3.0? Great. The oscillation stopped – that’s good. Open the valves ... close the valves, that looks pretty good. We got a little overshoot then settles our pretty quickly. And the error is down to a little over 2%. I ran one more test with P set at 3.5 and as you can see the oscillations are starting up again, so we’ll stick with P set at 3.0 for. As you can see, we could play with this all day to get just a value for P we are comfortable with. That's why we call it the Trial and Error method. But, P didn't get us quite there, did it? It never did get the sensor feedback value back to the set point we wanted, did it? We still have some error and we want that error to be as close to zero as possible. So ... it's time to enable l. I just sums the error values over some length of time and uses that to adjust the output frequency. Different systems use different kinds of integration equations. This drive uses an I that gets more aggressive as it gets SMALLER. Looking at our data, if we sum the error over this entire duration the result will be heavily impacted by all of this stuff. I'm going to say that by the time I get here I would like to have a stable sum. I don't want this stuff to impact it, so maybe we'll make our duration about this long. We’ll call that a tenth of a second. So go to parameter 7.14 and enter that for I. If I re-start the scope and run the drive, we immediately see the impact the I value has on the system. It is helping but it is taking way too long around 7 seconds to get the pressure back to 6 psi. That's way too slow so let's cut the I value in half. Restart the scope, open some valves. Ok, now our error gets to zero in about 3 seconds. Cut it in half again … it settles quicker. And let’s cut I in half one more time. So look at this … the drive is now automatically adjusting the frequency when the pressure changes in less than three quarters of a second to automatically maintain system pressure regardless of how many valves are open. That’s pretty good! And we only needed P and I to do it. Which will be the case most of the time – it will be rare that you actually need D. We’ll talk about the D parameter and these other blocks we didn’t use in the loose ends video. Could we continue to tweak this and make it better? Sure! It just takes time and patience. Which is a big problem with this approach - right? Time. Shutting down an operation while you take the time to go through this trial and error process can be very costly. And at the end of the day, the results are still just a guesstimate that depending on how much time and effort you put into it may or may not be optimal or super stable. Also, with this trial and error method you usually push your system into oscillation to gauge where you are. In our pressure demo here, there was no harm in doing that. BUT many systems can’t handle that kind of abuse or might even cause catastrophic failure. So … Is there a way to find the PID constants that doesn’t take the system down for long periods of time and doesn’t go into oscillation? Yep. And we'll do that in the next video. Click here to learn more about the GS4 Variable Frequency Drive. Click here to learn about AutomationDirect's free support options. And click here to subscribe to AutomationDirect's YouTube Channel so you will be notified when we publish new videos.