How does a p-loop control the angular velocity of the flywheel?

I don’t really know how to phrase this question. I don’t know too much about how the p-loop works but I have a basic understanding of it, I just wanted to ask how I can use a p-loop to control how fast the motor spins based on the KP or the error. Or am I wrong about all of this?

Simply by summing:


power += error * kP

There are many other improvements to this such as using full PID or TBH, and commonly across both of these having a feed forward term to start with a reasonable scaled estimate of what the motor power should be to reach a desired velocity.

Sorry, I’m new to this, so would the kp be the value that needs to be changed, or the error?
As in if we want to change the angular velocity, which should we change?
EDIT: Never mind, I figured it out, thanks

kP is a constant value that you will have to fine-tune yourself, if I’m correct (I could be wrong). The error should be derived by continually subtracting your current power from your desired power.

Again, I could be completely off the mark, but that’s my understanding of PID

I dont know how correct I am but from what I’ve picked up…

kP is a constant you tune yourself, pretty sure that it has to be below 1 (so a positive decimal)
kP is used to scale down the error value

error is the difference between what you want your sensor to read and what your sensor currently reads

you have to make sure that this stuff is put into a loop so that it refreshes the error reading

No, kP doesn’t have to be below 1. For example, let’s say you have two identical robots that are coded nearly the same way, only excepting units. One of them measures the angular speed in rpm, and the other measure it in rad/s. Let’s say the rpm one finds that kP of 0.2 works really well. What does the rad/s one do then? Their units are roughly 1/10 of the size, so error will be the other’s error/10. So they’ll need 10* the other’s kP to get the same motor values out of the smaller error. They would use kP of roughly 2.

While kP does need to be tuned, it also converts units. Since those units could change to be smaller or bigger, there is no guarantee on the size of kP.

huh, posts delete in one click

but yeah, I don’t have that much actual experience with PID yet, thanks for clearing that up