Slew Rate + PID Control for Drive Train

I’m working on developing some more accurate autonomous programs for Worlds and I was curious how you guys structure your control algorithms. I know slew rate controllers are essential for preventing wheel slippage but I have a few questions I was hoping someone could help me with.

Should each side of the drive train (assuming a tank drive) have an independent slew rate controller? Or would it be better to tie them together so that they are always exactly the same speed (opposite speeds during turns)?

What slew rate is best to prevent wheel slippage without making the drive too sluggish?

In my experience, PID becomes impossible to stabilize with a slew rate controller slowing its output. How are you guys tuning PID controllers on your drive train while slewing their output?

Also, what is the advantage of using the gyro to measure turns instead of encoders? I’ve struggled with drift producing inaccurate turns.

I would appreciate any answers to these questions. If I’m missing something altogether I would love to hear what it is. I’m mystified by those of you that have accurate, repeatable autonomous programs.


Yes, each motor or motor combo typically has its own slew rate. You can use this effectively in PID as well.

Slew rate code from here: [

You tune the PID with the slew in place. We have generally settled on 15 PWM steps per 20 milliseconds. It does not give maximum protection but gives reasonable response.

See the attached for a four wheel drive robot with 4 IME’s forward direction PID that does a rotation PID as well from a gyro named Gyro1. It uses the slew rate on it as it has motorReq] instead of motor] calls. You turn on the rotate and forward PID via global variables. I apologize for my daughter’s horrible spelling. Luckily compilers don’t care.

Thank you for the info and code. I will definitely look through it and let you know if I have any other questions.