Skip to content

Understanding PIDF and gains

santiago-gutierrez edited this page Feb 10, 2018 · 1 revision

Say you’re a runner and you want to run a mile. You have a goal of running 100 yards in 5 seconds.

You start the race, and run 100 yards in 7 seconds - you’re not going fast enough and as time passes. Those 2 seconds will add up for every 100 yards you run at that pace, leaving you further and further behind the other runners.

F is how fast you want to go before you even start the race. It’s the pace you’re aiming for, in this case 100 yards in 5 seconds.

The I term represents the total amount of time you’re off the mark, adding up as you go. At 200 yards, you will be 4 seconds behind. At 300, 6 seconds behind.

P is the difference you’re off between two intervals. For example, you’re off by 2 seconds in between 0 and 100 yards.

Say you speed up to 100 yards in 6 seconds between 300 and 400 yards. D is the difference between the current error and the previous error. In this case, you were off 2 seconds between 200 and 300 yards, but only 1 second off between 300 and 400 yards.

Now say you’re driving a car, so you’re measuring feet/seconds. When you accelerate to go faster, you go from 0 to 100% throttle. However, the motor measures speed in feet per seconds, not 0 to 1 (the throttle). Gains are the number that you multiply feet/second to get a vase between 0 and 1.

If you’re going to slow, you need to floor the accelerator, so the value is closer to 0, because you’re getting closer to the finish line.

Say the motor has a voltage input of 12V, and you measure it in 500 encoder counts per second. You’re currently at 200 encoder counts, so 300 short. You multiply 200 by a gain to figure out how far behind you are compared to 1V.

Clone this wiki locally