# Which part handles the acceleration of stepper motors?

I am learning about stepper motors. I am especially interested in them in CNC machines and 3D printers but also in general.

I learned already that stepper motors need signals to accelerate and decelerate them correctly. What I like to find out is which "part" handles the smooth acceleration and deceleration.

I think at least the following parts are involved when stepper motors are used in CNC machines: CAM software, postprocessor, controller, stepper motor driver (sometimes they are part of the controller board, sometimes separate), stepper motor.

When the CNC machine positions the spindle to machine something, which software or hardware manages the acceleration and deceleration?

The short answer is all components in the chain you described have some effect on the acceleration.

The CAM software defines the waypoint through which the tool center point passes. (Let us ignore the setting when it outputs the contact trajectory). When the waypoints are defined and the feeds and speed for the segments are set this already imposes some limits on the accelerations. One such limitation comes from segments with different speeds, obviously there is an acceleration needed between these. A second limitation comes from the curvature on which the waypoints are situated. Even if the feedrate is constant, the curve will determine the acceleration of the different axes.

The CNC gets the waypoints and feed from the GCode. The CNC rounds sharp corners, adds in between waypoints based on a linear/circular/spline interpolation. Furthermore, and most importantly, the CNC adds the „time component“, it plans the velocity and acceleration profiles. The waypoints together with the velocity and acceleration profiles form the trajectory.

The trajectory is then sent each cycle (interpolation cycles can be as low as 2 ms) to the axis controllers. Each controller is responsible for executing the trajectory as precisely as they can. Usually the trajectory planner in the CNC is aware of the dynamical limits of the system and plans only executable trajectories. A stepper motor driver is a simplistic case, which has its inherent limitations in terms of smoothness (the first/second/third order continuity of the trajectory). High end CNC machines use PMSM motors.

In modern (probably since the 90s) CNC machine there are no HW components actively participating in the acceleration profile planning or execution (if we disregard the inherent limitations of stepper motors).

The main element responsible for the planning of the acceleration profile is the trajectory planner in the CNC. However this planner is limited by the waypoints it gets from the CAM tool and by the dynamical limits of the machine.

On my experience working with stepper motor and CNC shield V3 with DRV8255 motor driver, acceleration and decelaration happen on software side.

So I have simple trajectory planner and PD controller to handle the error which produce control signal in form of acceleration, then I simply integral and get the velocity at that time. The acquired velocity then send to microcontroller.

On microcontroller side, I use motor stepper controller library in here. The code on microcontroller would be something like this

#include <AccelStepper.h>
AccelStepper mtr(AccelStepper::DRIVER, stepPin[0], dirPin[0]); //Class creation
// After receiving data from computer
mtr.setSpeed(data)
mtr.runSpeed()
`