|
Re: PID help
Things to consider:
The comment says the loop runs at 20 hertz, but it is actually programmed to go 200 hz.
The loop is reading the encoders and limit switches directly, but is only setting a variable for the output. Things will get wonky if the other loop doesn't update the motor very often or in phase with this loop. It won't matter if the controller is primarily proportional, but this will mess with integral and derivative terms. I'd recommend updating the motor in this loop and doing the necessary logic to get rid of the other location.
The fact that the limit switches modify the encoder or substitute a value could cause issues if the switches and encoder aren't well calibrated. It seems like this discontinuity would be confusing when leaving the limits to travel in between. I am by no means an expert, but it seems like it may be preferable to have limit transitions read the encoder and modify the setpoint.
Greg McKaskle
|