NokiMo
Pybricks
Pybricks

patreon


How to change PID values with blocks

The default motor controls work fine for a typical small drivebase. But sometimes you want to spice things up a little, especially if you build a heavy drivebase.

One way to do that is to increase the KP value of the PID controllers. This is quite easy to do in Python, but did you know you can do it with blocks too?

Here's how to do it for a single motor. The meaning of the values is given here. In this example we only set the first 3 values. The rest remains unchanged:

You can see the original values and the new ones printed at the bottom.

For a drivebase you can change the controls for the distance and heading:

To make these examples work, create an additional Python file called pid_python with the following contents. You can download it below so you don't have to type everything!

You won't have to change anything in this program. This file just makes the functions available to your block program. You can play with the numbers there.

Which values do you choose? It's often a good idea to start with the original values, and explore from there. To make it more aggressive, for example, you could make the original KP value about 50% bigger, or even double it.

How to change PID values with blocks

Comments

You can find more about that here: https://github.com/orgs/pybricks/discussions/2380#discussioncomment-14637517

Laurens Valk

What is the range of values for PID parameters, especially Kp, Kd & Ki ?

Shebin


Related Creators