is using a 3 stage elevator arm this year, and we have had success using a profiled pid controller to bring it to preset positions based on potentiometer(I attached the command). The only problem has been that once the setpoint has been reached, the arm slowly sags back in due to gravity. In addition, our mechanical team just decreased the gearing of the extension, so this saving should increase even more. Does anyone have suggestions on how to keep the extension in place once the pid has brought it to a setpoint? I considered maybe never-ending the pid loop, to keep feeding the arm output to keep it in place, but this method didn’t seem to work very well(I think our pid values weren’t tuned very well then though). Thoughts?
PID doesn’t account for gravity always pulling down on the elevator. So, you need to add a feedforward that accounts for gravity. Basically, always give the motor a little power upwards to counteract the force of gravity so it will hold and the PID will react better.
Just add a little power to the output (start with 5% but don’t go too high).
Robot.arm.extend(output + 0.05); // if you're controlling the motor with percent output [0,1]
Robot.arm.extend(output + 0.6); // if you're controlling with voltage output [0,12]
I agree with Vyo – try a small constant feedforward term, preferably in a perpetually-running PID controller.
Check out this example project that has the PIDcontroller in the subsystem:
Since the elevator itself changes angle, the feedforward term is also going to need to change based on that. For example, if the elevator is pointed forward and down (e.g., ground pickup), then switches to being pointed forward and up (e.g., score on upper node), you’ll not only need different feedforward terms, but they’ll need to be of opposite sign. In the first case, the elevator would tend to extend due to gravity and in the second, it would tend to retract.
If the motion is so bad you notice it during a match, your mechanical team needs to learn how to counterbalance and/or lighten the extension. Fighting the force gravity of a very unbalanced system will only burn out your motors/strip your gears.