Author Topic: Motor control PID again  (Read 2021 times)

0 Members and 1 Guest are viewing this topic.

Offline perdrixTopic starter

  • Frequent Contributor
  • **
  • Posts: 751
  • Country: gb
Motor control PID again
« on: February 16, 2022, 04:07:02 pm »
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





 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1351
  • Country: es
    • Picuino website
Re: Motor control PID again
« Reply #1 on: February 16, 2022, 04:34:53 pm »
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)
« Last Edit: February 16, 2022, 04:36:42 pm by Picuino »
 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1351
  • Country: es
    • Picuino website
Re: Motor control PID again
« Reply #2 on: February 16, 2022, 04:42:52 pm »
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.

 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1351
  • Country: es
    • Picuino website
Re: Motor control PID again
« Reply #3 on: February 16, 2022, 05:15:39 pm »
The system schematic should be something like this. Although it does not have a PID (only Kp), it usually works fine.
 

Offline nigelwright7557

  • Frequent Contributor
  • **
  • Posts: 717
  • Country: gb
    • Electronic controls
Re: Motor control PID again
« Reply #4 on: February 16, 2022, 06:31:59 pm »
Sounds like the gain of the PID is out.
Overshoot from too much gain or undershoot from too little gain.
 

Offline perdrixTopic starter

  • Frequent Contributor
  • **
  • Posts: 751
  • Country: gb
Re: Motor control PID again
« Reply #5 on: February 17, 2022, 12:28:22 pm »
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.

Speed 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.
 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1351
  • Country: es
    • Picuino website
Re: Motor control PID again
« Reply #6 on: February 17, 2022, 02:21:28 pm »
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 setpoint
Is 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.
 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1351
  • Country: es
    • Picuino website
Re: Motor control PID again
« Reply #7 on: February 17, 2022, 08:17:47 pm »
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
 

Offline perdrixTopic starter

  • Frequent Contributor
  • **
  • Posts: 751
  • Country: gb
Re: Motor control PID again
« Reply #8 on: February 18, 2022, 02:31:33 pm »
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

No 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.
 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1351
  • Country: es
    • Picuino website
Re: Motor control PID again
« Reply #9 on: February 18, 2022, 04:19:31 pm »
Then I apologize.
I had misunderstood the difference.
 

Online H.O

  • Frequent Contributor
  • **
  • Posts: 924
  • Country: se
Re: Motor control PID again
« Reply #10 on: February 18, 2022, 06:55:22 pm »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf