PID and slew rate code help

Hello, y’all! I am relatively new to code, having started out as a co-coder for my middle school VRC team. This year, as a freshman, I am on a team with a few seniors and a junior. In driver control and autonomous, I’ve noticed a lot of rocking due to rapid stops. My organization’s general go-to person for tech help is busy preparing for an upcoming comp that my team will not participate in, as we are qualified for states already. Although my autonomous is pretty consistent, it rocks a lot after really hard stops throughout the program, and the same is true for driver control, so I thought that it would be a good idea to code something to prevent the rocking before states. I was told that I should research slew rate and PID controllers, but I couldn’t really find anything that would help my code. It’s not really urgent, but I feel like I’ve been putting this off for a while. Could you guys explain how I might incorporate slew rate and PIDs into my code?

Idk about slew, but for PID you basically take the proportion (distance left), integral (that is, the time integral of distance), and derivative (current speed), multiple each one by a value, add them together, and send that much power to the motor. This will cause gradual speed up and slow down that should be very effective at mitigating slip.

You may want to look into using PROS and Okapilib, or otherwise there are fantastic PID libraries such as Minipid.


This is a great resource for learning PID:


Do any of y’all know anything about slew rate? Both of the PID resources have been really helpful, but slew is slightly more of a priority for me currently.

Very Simple Very Accurate Chassis Control Code Release Take a look at this program it’s relatively simple and should accomplish everything you want it to. The rest of the thread has some good information on it as well.


Thanks! Very helpful!