Motor control PID again - Page 1
Forum section: electronics / projects

author: perdrix
author_rank: Frequent Contributor
timestamp: February 16, 2022, 04:07:02 pm
content: I've now got my speed limited autonomous slews nicely under control.Now I want to turn to the non-autonomous slews. This is managed by the controller that talks to the motor controller sending "STEP" signals to the motor controller to increment the setpoint. Sending the "STEP" signals faster increases the setpoint faster and so moves the motor faster... This allows the motor to be accelerated at a well controlled rate to the target speed and decelerated when the desired target position is reached. There are two sets of PID coefficients involved but for everything except *very* slow movement the so called "High Speed" set (HsKp, HsKi, HsKd) are used. I believe this is the "traditional" means of controlling small brushed DC motors.Now the questions start!I attach a pdf showing a plot of the motor position, error value and PID output value against time and a second plot of the motor speed against time.As you can see there are oscillations in the PID output value as the PID chases the moving setpoint and these reflect as variations in the motor speed which I'd like to eliminate if possible.Any thoughts on how best to handle this? Pushing Kd higher just slows everything down and can make the oscillation worse ...David

author: Picuino
author_rank: Super Contributor
timestamp: February 16, 2022, 04:34:53 pm
content: It seems the PID is poorly adjusted. Note that if the mass moving the motor is relatively large, this can add non-linearity to the plant. Is the driver saturating?If the mass moved by the motors changes over time, the PID will go out of adjustment.Could you post a schematic of the system?A genetic advice to adjust a PID:1º Increase Kp until the system starts to oscillate.2º Increase Kd to reduce oscillation.3º Increase Ki to reduce the position error (In this case you should not need it)

author: Picuino
author_rank: Super Contributor
timestamp: February 16, 2022, 04:42:52 pm
content: How do you generate the speed reference? It should be a straight line, instead of a parabola. The speed should increase linearly so that the motor driver does not saturate.

author: Picuino
author_rank: Super Contributor
timestamp: February 16, 2022, 05:15:39 pm
content: The system schematic should be something like this. Although it does not have a PID (only Kp), it usually works fine.

author: nigelwright7557
author_rank: Frequent Contributor
timestamp: February 16, 2022, 06:31:59 pm
content: Sounds like the gain of the PID is out.Overshoot from too much gain or undershoot from too little gain.

author: perdrix
author_rank: Frequent Contributor
timestamp: February 17, 2022, 12:28:22 pm
content: Quote from: Picuino on February 16, 2022, 04:42:52 pmSpeed plot is simply from the sensor on the motor. Remember this isn't a step change in setpoint, it is being changed continuously by the other processor incrementing the setpoint every few ms.D.

author: Picuino
author_rank: Super Contributor
timestamp: February 17, 2022, 02:21:28 pm
content: So, you have 2 control loops.The inner control loop controls the speed of the motor.The outer control loop acts on the inner one and controls the position.So you have two PID controllers, one for inner control and one for the outer control, and two setpoints: Position setpoint and speed setpointIs that how i explained it?Without a schematic or a control program it is difficult to get an idea of ​​how it works.You should still tune the internal PID first, and once the speed control is working properly, try to tune the external PID.It seems that you comment that the internal speed control already works correctly, but the graphs show the opposite.

author: Picuino
author_rank: Super Contributor
timestamp: February 17, 2022, 08:17:47 pm
content: For moderators: this thread should be merged with this other thread, which started the topic:https://www.eevblog.com/forum/projects/pid-motor-control/msg3934289/#msg3934289

author: perdrix
author_rank: Frequent Contributor
timestamp: February 18, 2022, 02:31:33 pm
content: Quote from: Picuino on February 17, 2022, 08:17:47 pmNo it should not - that was concerned with the autonomous slews which did use two nested PIDs and use a completely different set of parameters.This is concerned with ONLY a position control PID where the setpoint is being driven by another processor that is sending STEP signal to change the setpoint, and doesn't (AFAIK) use a PID at all.D.

author: Picuino
author_rank: Super Contributor
timestamp: February 18, 2022, 04:19:31 pm
content: Then I apologize.I had misunderstood the difference.

author: H.O
author_rank: Frequent Contributor
timestamp: February 18, 2022, 06:55:22 pm
content: My first thought was motor control loop bandwidth - the higher the velocity is the larger the oscillation is. But then, it seems like, when the velocity is high but constant the oscillaation just stops and the control loop is stable.In the other thread it was suggested you'd implement feed forward. Did you do that and if so, did you do it for velocity, for acceleration or for both? It really does make a big difference (for the better) but if it IS implemented perhaps the acceleration feedforward is TOO aggressive.