2

I am writing code for a robotic slide lift. I can accurately get the position of of the lift but I would like to be able to keep the position of lift with little to no oscillation (small high frequency oscillations should be fine). I am using a PID control loop and I have spent a lot of time trying to tune it. However, since gravity is helping the thing down but slowing it when its trying to go up, it is impossible to tune the PIDs very well. Right now when it is trying to hold its position it slowly goes up to the target position then once it reaches it and just barely overshoots the next update it falls back down then repeats the process again.

I was thinking of getting the raw power value that the PID calculates and simply add some constant to it to compensate for gravity but I don't have access to the PID calculations so I would have to write the PID code myself.

Would this modified PID loop work or is there another control loop that will help to compensate for this asymmetric situation?

For reference, I control the lift using a joystick. I apply to move the lift up then whenever I stop giving power (the joystick is at the 0 position), the PID kicks in to try to keep the position at that time.

Jonas
  • 121,568
  • 97
  • 310
  • 388
Dylan Siegler
  • 742
  • 8
  • 23

2 Answers2

3

This is a classic example of where you may want to use a feed-forward term in your control loop.

Simple feedforward PID system

In the model above, the Feedback compensator is your PID loop, which converts your error signal into an actuator command. The Feedforward compensator is a calculation that converts your desired angle, r in this example, to an actuator command.

Because you know the force of gravity acting on your system, you can estimate the amount of torque needed from your actuator to cancel this force. This is called gravity compensation.

The gravity compensating torque needed from your actuator will be Torque = Force * Distance. (Make sure your units are correct for this calculation!).

Force is the weight of your element, or mass*gravity.

Be careful with your distance calculation though! Because the force is a vector pointing in the direction of gravity, the distance needed is only the horizontal distance from your actuator center. This distance will be dependent on the current angle of your slide. This calculation will be something like Distance = cos(theta) * x.

Assuming that the output to your actuator is in terms of torque (or possibly current), this calculation will now be Output = Perror + I(integrated error) + D*(velocity error) + Feed-Forward.

You want your PID feedback to merely cancel out the errors. This way when your slide is at the set position, the feed-forward term will hold it in place and the PID loop will correct any errors. If your feed-forward model is exactly correct, your PID gains could all be set to zero and it would work (but the model won't be correct, and that's why feedback is necessary).

By the way, this question is better suited for the robotics stack exchange. You may find more answers to your question over there.

jekso
  • 81
  • 8
-1

If you set a too high Integrative term, you will get more overshoot... To dampen the oscillations you should carefully set the Derivative term without putting too much of it. (Daunting, isn't it?)

Try starting from P = 0, I = 0, D = 0. Raise P until you have your system oscillating. Then put some D term to dampen those oscillations. Then put some I term to get a 0 steady state error.

To get the best out of tuning with your gravity issue, I would suggest using a Gain Scheduling approach, thus tuning and using one PID just to go up, and another PID just to go down.

If not satisfied, you could try with some adaptive control technique such as Model-Reference Adaptive Control.

NitroHxC
  • 21
  • 3