Skip to content

Slew Rate Control

Jeffrey Shen edited this page Jul 24, 2017 · 2 revisions

Adding a slew rate control to each motor means that instead of switching between two voltages really quickly, it gradually ramps up until it reaches the desired voltage. This is much better for the overall motor health and prevents motor burnout in rounds.

Setup

In config.c: #define USE_SLEW 1 An integer array MOTOR_SLEW[] must also be defined to tell the library how to apply the slew rate control to each motor. This array needs to have exactly the same number of elements as the robot has motors. The nth MOTOR_SLEW[] element controls how much the nth motor's voltage will change in each unit of time. So for example, if MOTOR_SLEW[0] was equal to 40, that means that the first motor's voltage will increment in units of 40.

  • If you wanted to disable the slew rate control on a motor, set it to a number greater than or equal to 255.
  • Make the number bigger if you want less of a slew rate control (this is faster but worse for the motors)
  • Make the number smaller for more of a slew rate control
    A recommended setting if you want to apply the slew rate control to a motor is 40.

Example

#define USE_SLEW  1 //Disable if slew interferes with move functions or slows robot down
int MOTOR_SLEW[MOTOR_NUM] = {255, 40, 40, 40, 40, 255, 255, 255, 255, 255};

Usage

When calling motor values, use motorReq[MOTOR_NAME] instead of motor[MOTOR_NAME] otherwise the slew rate will not be applied.