3.1 Ramps

The application implements acceleration and deceleration ramps for stepper motor control.

Depending on the number of steps requested and the acceleration/deceleration values, the motor may get the desired speed limit (Fig. 3.1) or not (Fig. 3.2). If the distance to reach the speed is too short, the motor will accelerate and then start decelerating without reaching the limit speed.

Figure 3-1. Acceleration Followed by Constant Speed and Deceleration

The stepper motor has time to accelerate, reach and cruise at the speed limit, followed by the deceleration period.

The distance to reach the speed is too small. The stepper motor will accelerate and then start decelerating without reaching the limit speed, as shown in the figure below.

Figure 3-2. Acceleration Followed by Deceleration

The application calls the Stepper_Move function periodically with the parameters. Initial position, steps (to go), acceleration, deceleration, speed and VBUS (BUS voltage). In this implementation, the application automatically adjusts the drive amplitude according to the power supply voltage, trying to keep the current constant through the coils. The function precalculates the acceleration and deceleration time based on the speed and the number of steps the end user wants the motor to move. After finishing the computation, the StepAdvance function is called, which controls the movement of the motor. The StepAdvance function regulates the stepper drive schema, which generates a wave of 90 electrical degrees shifted.

Figure 3-3. Stepper Move Flowchart