![]() |
Alternative Method for calculating I term in PID
Recently, I was doing a little work tuning PID constants. I couldn't get my I constant just right depending on my starting distance from the target. I always found that if I was a large starting distance from the target, the I term would grow large quickly, and it would overshoot the target. Also, with very short starting distances from the target, the I term would be too small, and it would take along time to reach the target.
After thinking about my problem for some time, I decided to change the way I was calculating the I term. Rather than calculating I as the traditional sum of the P term, I instead calculated it as the sum of the reciprocal of the D term. So, when D is large, ie moving quickly towards the target, my I term grows very slowly. Where as when D is small, ie close to the target, but not making progress towards it, I grows quickly, pushing towards the target. This caused the I term to remain small until it slowed, approaching the target. I found that this eliminated the problems I was having finding a constant that worked well with large and small starting distances from the desired target. Im no expert on PID loops, so I thought I would put the idea out there for some of the others around who have had more experience with PID than myself. Im probably not the first one to think of this, so I would like to get some others thoughts on the idea. Questions, comments and advice would be greatly appreciated. |
Re: Alternative Method for calculating I term in PID
I've no experience with that kind of calculation, but I thought I'd comment based on a rough analysis. Basically, it's an interesting idea. I don't want to think about the transfer function or any other formal controls definition of it this time of night, but I'd be concerned about how this would interact with any noise in your sensors. If you have a noisy sensor with no filtering, your D term would probably fluctuate enough to render the I term ineffective, or randomly effective. This probably isn't a concern in FIRST applications where we're measuring position with encoders, but it might crop up with pots. Also, I'm assuming you're using the absolute value of the reciprocal of the D term, correct? If you're using the straight value, you'd end up with a negative I term after you overshoot, and that could end up being very bad for your system in rare cases.
Just FYI, the standard solution to this is called integral anti-windup. You basically put a cap on the I term so it can only grow so large. You still end up with overshoot, but not so much as to be a problem. The plus of this method as compared to yours is that you'd have a stable, predictable I term. |
Re: Alternative Method for calculating I term in PID
its not clear what signals you are referring to. In a feedback system you normally have:
command: the signal that is telling the system what the operator wants: ie, desired distance from point of origin, or desired speed control: the signal that is coming out of the PID controller, telling the motor or heater or actuator what to do at this instant feedback: a sensor that is measuring what the system is doing at this instant - it could represent distance, speed, acceleration, torque, angle... depending on the type of sensor used error: the error signal is the difference between the command and the feedback, what the operator is telling the system to do, and what the system is actually doing at this instant. Its very easy to get confused, and to look at the distance sensor when you should really be looking at the error signal, or to take a velocity command input and compare it to a distance sensor feed back signal. The best first step is to check all your units. Make sure you have velocity when you are working with velocity. If you start inverting signals you have changed the units. The 2nd step is to make sure the polarity of your signals is correct. If you have negative feedback on a sensor the system goes berserk. The third step is to realize the P I and D are all inter-related. You cant tweak the P to get the best response, then start adding I, then D. When you add I the P must also be tweaked, when you add D the P and I must be tweaked. The best way I have seen this done empirically is to hit the system open loop with a step function (square waves), and measure the response. Then you can characterize the system and calculate the constants. Turning the system on and twiddling the 'knobs' for P I and D will drive you crazy :^) All that math stuff: the bode plots, the pole/zero diagrams... it really is necessary unless you have a control system that can characterize the open loop response of the system by hitting it with step functions. |
Re: Alternative Method for calculating I term in PID
Well what do you do when the arm is not moving (D=0) i'm assuming just put a really big number in ????
This is a really interesting idea, i'm not sure but i think one of programming mentors had this idea last year. |
Re: Alternative Method for calculating I term in PID
Quote:
Thats one flaw with this method. In my case, I made sure the absolute value of "D", was greater than or equal to 1. This just limits how fast the "I" term can grow with this method. |
Re: Alternative Method for calculating I term in PID
Quote:
|
Re: Alternative Method for calculating I term in PID
Im not saying you cant get a PID control system to work without first characterising the system, and working out the equations
but if you want it to work as well as possible, you need to either do the math, or have an automatic control system that will do the math for you. There are several variables in a PID system, and you have to pick which ones you want to optimize. Lets say you are controlling the position of a robot arm, an elbow that can bend from 10 to 180 degrees. what are you trying to accomplish? do you want the arm to move as fast as possible? do you want it to move smoothly? do you want it to stop at the commanded position within 1/10th of a degree? is overshoot allowable? do you want the same response with the arm fully loaded and with no load (no weight on the arm)? Does it have to work while the robot is moving, or while the elbow (shoulder?) below it is also moving, or the wrist above it? Do you want the arm to resist if another robot trys to move it? To resist or to RESIST! ? dont get me wrong, a PID controlled drive system is far better than running open loop, even if its not tuned for optimum performance - if you can get it to point where you want the arm to point thats great. But if you start adding other requirements (speed, load variation....) it can take a lot of work (math) to get it tuned. |
Re: Alternative Method for calculating I term in PID
Can anyone introduce me to the involved mathematics to calculate the gains in a PID loop?
|
Re: Alternative Method for calculating I term in PID
As an alternative, consider turning on the I term once the P
and D terms have brought the system within some reasonable distance to the target, zeroing the integral and turning it on to zero out the error in the control system that would otherwise remain. Eugene Quote:
|
Re: Alternative Method for calculating I term in PID
Quote:
|
Re: Alternative Method for calculating I term in PID
Quote:
Quote:
|
Re: Alternative Method for calculating I term in PID
Quote:
So I guess what I was really saying is that, you can develop an intuitive sense of what a PID control system does, and what each component of the P I D does and you can get a closed loop feedback control system to work more or less like you want it to but to really be able to optimize a feedback system, you gotta take that Signals and Systems course (and the pre-req math courses). I hate to leave this hanging like an end of season cliff hanger, or an engineering teaser. Feedback control system design is one of those things where you can dip your toe in the water and experience something new and incredible and you can dive down 5 miles deep, and find new things that you didnt see when you were only 4 miles deep. Its something you can dabble in now and its something to look forward to in college. |
Re: Alternative Method for calculating I term in PID
I believe what Ken was referring to by applying a step function to the system and watching the response means instantly creating a point for the system to reach, then watching the general behavior, acceleration, overshoot, etc, and adjusting the PID terms with the (entered value vs. system reaction) graph as a reference.
I have no idea what a Bode plot or pole whatchamacallit is... ![]() PID without a PhD |
Re: Alternative Method for calculating I term in PID
Quote:
for example, if you are trying to control wheel speed, you hit the motors with a step from 0 to 6V, and you record the speed of the wheel. It will speed up, kinda like your graph is showing, and at some point it will level off at some constant speed. That response is due to several factors: the torque the motor can produce, the static and dynamic friction present in the drivetrain, the inertia of the components (motor, gears, chains, wheels) and how much load is present (is the wheel free spinning, on a tile floor, on a carpet, going up hill....) the graph shown is in the time domain, the x axis is time in seconds. If you perform a Fourier transform on the response of the system you get the frequency domain response. Its much easier to work with control systems and feedback in the frequency domain (I know I am losing most readers here). So going back to an intuitive perspective, once you have measured the inertia and torque output and friction and load.... of the system, you have characterized it. You can also do this with the spec sheet for the motor, the gears, the chain, the wheels, calculate the friction of the bearings.... and characterize the system that way. Then you can do some real magic with the math and S (frequency) domain equations. This is how you do PID control design on most systems. If you are designing the flight control system for a 777, you dont fly the plane around, then turn up the I gain 3% then fly it around some more to see how it responds, you analysis the systems first, and design the control system to make the aircraft fly the way you want it to. |
Re: Alternative Method for calculating I term in PID
There's a decent general description of PID principles on Control Technology Corp's site which discusses the technique, bode plots, etc. in broad terms.
This, and articles like PID without a Phd are good places to learn why it's needed and enough to play around with them, but like Ken said, "its something to look forward to in college" if you really want to understand and apply them scientifically (as opposed to going by the seat of the pants). |
| All times are GMT -5. The time now is 03:37. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi