[Dprglist] Power vs Velocity for PID controllers
Murray Altheim
murray18 at altheim.com
Mon Apr 20 21:27:18 PDT 2020
Hi all,
Over the past week I've spent many an hour working on my Python-
based PID controller, which is using a ThunderBorg motor controller
under the hood to drive a quartet (left-right pairs) of OSEPP motors.
I've kinda got something working, at least the PD part of it seems
functional, but there's a big gaping hole where a certain part of
the implementation is concerned: prior to PID I was "successfully"
driving the robot based on an encoder-based velocity measurement,
but there was no PID, and my recent attempts to create a PID
controller using velocity have failed.
I believe this is due to the fact that I was attempting to use the
velocity measurement as the PID input to set the motor power. As I
think David noted in his YouTube video, there isn't a direct relationship
between motor power and velocity so this was bound to fail. I like
fail as much as the next person, but success is nice too.
So with that in mind I've gone back to a power-based PID controller,
knowing I still have a certain mountain to climb.
The question I now have is: how to add a velocity-based control to
my robot? Do I come up with some mathematical relationship between
velocity and motor power, or do I create a velocity-based PID
controller **over top** of the power-based PID controller, i.e.,
two layers of PID control?
Much-simplified pseudo-code:
KP = some_constant
KI = some_constant
KD = some_constant
target_power = 0.5
while True:
current_power = motor.get_power()
error = target_power - current_power
k_diff = KP * error
i_diff = KI * sum_errors
d_diff = KD * last_error
output = k_diff + i_diff + d_diff
slewed_output = slew(output)
new_power = current_power + slewed_output
set_motor_power(new_power)
last_error = error
sum_errors += error
So would I incorporate velocity into the above somehow, or build
Yet Another PID controller for velocity (using roughly the same
structure as above, but solely dealing with velocity) that calls
the above power-based PID controller?
I thought perhaps we could discuss this in tomorrow's Robot Builders
Night Virtual get together... but an email discuss is also welcome,
thanks!
Cheers,
Murray
...........................................................................
Murray Altheim <murray18 at altheim dot com> = = ===
http://www.altheim.com/murray/ === ===
= = ===
In the evening
The rice leaves in the garden
Rustle in the autumn wind
That blows through my reed hut.
-- Minamoto no Tsunenobu
More information about the DPRGlist
mailing list