Reply to comment


Oct. 30, 2021, 10:20 p.m. -  rockford

PID isn't nearly as exotic as it might seem. It's quite intuitive if you are used to various feedback loops in your life. Your thermostat is the best and most simple example. It is on-off control, so not a PID, but that is a control loop in your house. I'll try to offer a simple explanation of PID, just for shits and giggles. Basic version on an e-bike PID: it takes an input (torque sensor) and compares it to a setpoint (the amount of torque you are putting in times the assist setting you are in) and drives an output (motor torque) to have the input match the setpoint. The PID part effects how much of an output based on how far away you are from the input. P = Proportional. If you are supposed to have 100 units of torque and you are only measuring 90, then you are 10 units away. Motor needs to add more jam. The P term multiplies that error (10 units) by the P gain setting to drive the motor that amount. So if P is 1, then the output would apply 10 units of torque. If it was 10, you'd get 100 units. This will create a response proportional to the error - hence the name. But it can be quite unstable if you have too much gain, and it'll oscillate - or shake like a dog shitting razor blades, as my old friend used to say. Not enough "P", and it has sluggish response and takes forever to reach the setpoint, if ever. The "I" comes in for the "if ever" scenario. I = Integral. Yes, a calculus term, but the basics are that it is a gain term that applies output over time. So in the system above, if there is 10 units of error, and that error is present for 1 second, then the "I" term will apply more output to close that gap. If that added output closes the gap, but there is still error, the "I" term will add more output again. It stops adding output when there is no error. The issue with I is that it will keep adding, and create overshoot and have to unwind itself after, one cycle at a time. So it needs to be used judiciously. D = Derivative. Another calculus term. And this one is generally the razors edge. It responds to a rate of change. So if the torque system is asking for 100 and getting 100 - happy system. P will be steady state, and I will be zero. If suddenly the torque value drops by 10, this is where D is listening and can respond. It'll see that quick drop and add output fast - before the P or I even see the error. The problem with D - if there is noise in the sensor, or in the motor output, then D sees nothing but quick errors and starts barking out orders a lot. Unless the feedback is deadly smooth, then D is typically not used. I've tuned 100's of PID's. 95%+ don't use D.

Post your comment

Please log in to leave a comment.