[Dprglist] Power vs Velocity for PID controllers

Murray Altheim murray18 at altheim.com
Tue Apr 21 14:05:51 PDT 2020


No, Doug, unless you got something wrong your description is very helpful, one
of the more helpful descriptions of the P, PI, PD, and PID variations, and why
one might use each. Indeed, in all the descriptions I've found online this
was one of the more helpful, nice, straightforward, and with enough detail to
actually help out on the variations, thanks!

What I did last night was resurrect the controller I'd written that uses a
value I'd mistakenly called "power" (in the code as well) when I meant the
value sent to the motor controller. It now acts as a PID controller for what
I'm assuming is actually voltage.

In some ways that was largely successful. I was tweaking the P, I and D
constants (as one does) but I think it was mostly functional. I was using
the value from GetMotor() to set SetMotor(). Probably voltage. Maybe power,
I don't know the guts of the ThunderBorg firmware, but a value between 0.0
and 1.0.

I think David A. in his video mentioned that there wasn't a direct relationship
between voltage and velocity, but between torque and velocity. You can see his
explanation (in describing the PWM of an H-bridge controller) at 20:15:

    https://www.youtube.com/watch?v=8CXReb7f0Eo

"the speed of the motors is not really proportional to the voltage, it's actually
the torque of the DC motors is proportional to the current."

To clarify my difficulty, what I think I'm doing wrong is that my current PID
controller takes the value I'm sending the robot (I think voltage) as the input,
does its PID computation, then sets the output (again, as I think voltage),
whatever is sent to SetMotor().

What I am not able to do is figure out how to change the input to the *velocity*
I'm getting from the encoders. Yes, I can certainly use the velocity measurement
as input (I have a function for that), but because I can't "set velocity", only
the value I sent to SetMotor(), which I think is voltage or some surrogate, I
can't figure out what the relationship is between velocity and voltage in the
code. It's not a direct relationship.

So what I've done (so far, last night) is take my "voltage"-based PID controller
and wrap it with a velocity-based PID controller. I'm not sure if that's either
necessary or sensible, but that's where I'm at right now.

This will (very likely) be easier to deal with in a conversation, so I'm
looking forward to today's/this evening's video conference.

Cheers,

Murray

On 22/04/20 3:58 am, secretary at dprg.org wrote:
[...]
> Now take this scenario, your robot with encoder feedback is moving on a > level floor at a given speed set by your PID (or P, or PI, or PD) controller,
> then it comes to the ramp. If you have a P controller the speed will change
> to a certain level as the controller increases the voltage (and thus the 
> current and torque) to some value that is lower than your level speed but
> higher than it would be without any feedback. The reason that it doesn't
> maintain perfect speed control is because the feedback value comes close to > the desired (reference) value, a P controller loses its ability to change
> the output, in a sense it runs out of steam the closer it gets. So for a P
> controller there will always have an offset from the desired speed set by
> your reference signal. Often this is all you need. If you have a PI 
> controller, the I portion of the controller will allow your output to match
> your reference setting at the expense of adding more instability (however,
> it maintains response even as speed approaches reference). For most robots
> this is usually all you need. Adding a D component (i.e., PID vs PI) can
> add response with reduced oscillations in output if done right, but it adds
> a level of trickiness to the tuning.  I often use only a P, or PI controller,
> in my robot depending on what I am doing. I often wrap a velocity PI inside
> of a heading P controller. In the case of a line following robot, a PD > controller is often used. What the D does is add response to rapid changes.
> The robot will not run at the reference setting with PD, for that can only
> be done with an I component in the controller. Note that both I and D have
> a dt component, you must keep loop time constant or adjust for varying it.
> Also, please note that the above is somewhat general, people with more
> knowledge may have a better understanding than me.  I hope others will 
> jump in and correct me where I have gone off base.
...........................................................................
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