2.1.21. Exercise: A4988 Stepper Motor Driver Objective

Control a stepper motor using a driver module.

A stepper motor uses a toothed rotor and multiple drive coils to create motion in discrete steps. The fundamental angular size of the steps is determined by the physical spacing of the internal magnetic teeth. Steppers motors are open-loop since there is no sensor involved in controlling position, the driver simply cycles the coil currents and assumes the motor moves synchronously. If the motor encounters too high a torque, the magnetic forces can be overcome and the rotor will slip to a different position. The microcontroller has no means of detecting this error.

This exercise uses a stepper motor driver module which takes care of cycling the currents appropriately through the two coils of a bipolar stepper motor. The primary inputs to the driver are direction and step. Each pulse on step moves the motor one unit in the direction specified by the direction input. The additional inputs control the unit subdivision of the physical steps (fractional stepping) and the overall driver power state.

As a simple one-in one-out demonstration, the exercise uses a potentiometer as an input to vary properties of a motion sequence.

../../../_images/stepper-motor.png Steps and observations

  1. Use a DMM to measure the winding resistance of the stepper motor. A bipolar stepper motor will have two independent windings which should be clearly observable as a low resistance between two separate wire pairs.

  2. The lab stocks several different kinds of stepper motors and stepper motor drivers. Please check the motor type; it should have a rated voltage lower than your supply voltage. These drivers control the current by chopping the power supply, so the supply voltage can be higher than the motor rating.

    If the supply voltage is between 8-35V (e.g. 12V as shown), you should use the A4988 stepper motor driver,

    If the chosen supply voltage is between 2.5-8V (e.g. 5V), you will need to use the low-voltage DRV8834 stepper motor driver. The module has a pinout compatible with the A4988.

  3. You will need to set the current limiting potentiometer on the driver board to the correct level for the particular stepper motor type. To set it, you will need to use a thin piece of plastic or small screwdriver to rotate the surface-mount potentiometer while measuring the voltage at the wiper pin with a DMM. The module will need power applied during this measurement (logic power for the A4988, motor power for the DRV8834).

    For the A4988, the reference voltage is \(V_{ref} = I_{limit}/2.5\). So for example, if using the NEMA14 SY35ST28-0504A stepper with 0.5A/Phase rating, the current limit reference voltage should be 0.2V, and for the NEMA14 SY35ST36-1004A with a 1.0A/phase rating, the voltage should be 0.4V.

    For the DRV8834 the voltage is \(V_{ref} = I_{limit}/2.0\), and the correct reference voltages will be 25% higher than for the A4988.

  4. Load and run the StepperSweep sketch.

  5. Observe the stepper motor motion and compare against the code. In the last stage, the code moves at speeds determined by the control wired to A0. Try varying the map() parameters to control over the full speed range of the motor.

  6. Try adding a 10K pull-up resistor between MS1 and 5V and observing the resulting change in step rate. The driver is capable of microstepping in which the coils can be driven using PWM rather simply on or off in order to divide the fundamental step into smaller angles.

  7. Read the data sheet for the driver and configure the driver for even finer steps. Comments

Stepper motors can move relatively fast but at too high a rate can lose count.

The schematic for the A4988 shows that the driver module is mostly a breakout board for the surface-mount driver chip, but includes the current reference pot, current-sensing resistors, pullup resistors, pulldown resistors, charge-pump capacitors, and decoupling capacitors which filter the power. Arduino Code

  1. Documentation: StepperSweep Arduino Sketch
  2. Sketch Folder: StepperSweep Other Files

  1. EAGLE file: stepper-motor.sch