Drive a stepper motor with acceleration and deceleration using an Allegro driver on ATmega8

Drive a stepper motor

The stepper motor is an electromagnetic device that converts digital pulses into mechanical shaft rotation.

 Drive a stepper motor

Most common types of stepper motor can be bipolar or unipolar, depending on the winding.

 Wire connection diagram Drive a stepper motor

To make a stepper motor move, motor windings must be loaded in the correct order.
A stepper motor move at steps, it’s accuracy is usually expressed as degree per step. Microstepping is a method by witch motor accuracy can be increased at the expense of the motor torque.
Stepper motor can be driven using straight dual H-bridge driver. However there is a family of IC expressily built to drive stepper motor, they incorporate microstepping technique and are driven by a built-in translator, so that each received pulse is translated to a motor step.
Allegro MicroSystems offers a wide range of bipolar stepper motor driver.
This library drive a stepper motor using the Allegro A3967 (EasyDriver) on ATmega8. It will also work on the Allegro a4988, and other type of motor driver controlled by the number of pulse received.
It features:

  • direction changing
  • speed changing
  • acceleration and deceleration
  • multiple motor driving
  • stop spinning after number of step, or continuos spinning mode
It would be easly portable on other microprocessor.
To rotate a motor at constant speed, pulses must be generated at a steady rate. Otherwise it must be implemented a acceleration or deceleration ramp.
Suppose the function for calculating the next pulse is called with frequency f.
The time to next pulse t, depends on the counter c.

Leave a Comment

Your email address will not be published. Required fields are marked *