# Current Limiting Stepper Driver with DRV8871

## Overview

### A Stepper&nbsp;Smörgåsbord

The Maker movement has created a growing demand for stepper motors to build into projects like 3D printers and CNC machines. &nbsp;The market has responded and now there is a huge variety of reasonably priced stepper motors&nbsp;to choose from.

But not all motors are created equal. &nbsp;Two identical&nbsp;looking motors may have the same NEMA size designation, yet have completely different electrical specifications. &nbsp;&nbsp;So it is important to choose an appropriate driver for your stepper. At best, a poor match will result in poor performance. &nbsp;At worst, a&nbsp;motor or driver may&nbsp;go up in smoke.

![](https://cdn-learn.adafruit.com/assets/assets/000/034/974/medium800/adafruit_products_IMG_4810_crop.jpg?1471807538)

### Basic&nbsp;Motor Drivers

The first generation of hobby-level motor controllers like the V1 Motor Shield were almost all based on the ubiquitous L293D chip - a very basic&nbsp;dual H-bridge chip. &nbsp;These bridge chips have&nbsp;no current limiting, so you need to apply Ohm's Law to determine a supply voltage that would not exceed the chip's maximum current rating. &nbsp;

Many high-performance steppers have a very low phase resistance so the maximum 'safe' voltage is impossibly low. &nbsp;These motors are simply not compatible with those first-generation hobbyist controllers.

The Adafruit V2 motor shield uses the more modern TB6612B dual bridge chips. &nbsp;These are more efficient and have a higher current rating. &nbsp;But the TB6612 has no current limiting either, so many high-performance motors are still off-limits for even the V2 shield.

### Choppers to the rescue!

Current limiting drivers - also known as "Chopper" drives - are capable of handling a wider range of stepper motor and power supply combinations. &nbsp;Current limiting was previously only available in expensive industrial controllers. &nbsp;But thanks largely to the increased demand from Makers, current limiting drivers are&nbsp;now becoming available at reasonable prices

Motor drivers like the DRV8871 allow you to use much higher drive voltages to get best results&nbsp;from these high performance motors. The higher drive voltage helps to overcome the inductance of the motor windings to produce more torque at the start of a step. &nbsp;But to keep current to a safe level, it 'chops' the current output when it exceeds the preset limiting level.

&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/035/009/medium800/adafruit_products_Chopping.png?1471864110)

The DRV8871 bridge chip is capable of much higher supply voltages and currents than an L293D. However,&nbsp;it is only a single bridge chip. &nbsp;We will need to combine&nbsp;two of them to drive the two phases of a typical stepper motor. In this tutorial, we'll wire up 2 DRV8871 breakout boards to drive a high-torque bipolar stepper motor.

For more information&nbsp;on how a current-limiting "chopper"&nbsp;driver interacts with the motor, please read this guide: &nbsp;[Matching the driver to the stepper](../../../all-about-stepper-motors/matching-the-driver-to-the-stepper)

[Matching the Driver to the Stepper](https://learn.adafruit.com/all-about-stepper-motors/matching-the-driver-to-the-stepper)
![](https://cdn-learn.adafruit.com/assets/assets/000/035/011/medium800/adafruit_products_3190_iso_ORIG.jpg?1471864453)

# Current Limiting Stepper Driver with DRV8871

## Materials

For this tutorial you will need the following:

## 2x DRV8871 Breakout Boards

Each DRV8871 breakout board contains a single H-bridge. &nbsp;Since the stepper motor has 2 sets of windings, we will need two of them: &nbsp;One&nbsp;DRV8871 for each winding.

![adafruit_products_3190_iso_ORIG.jpg](https://cdn-learn.adafruit.com/assets/assets/000/034/961/medium640/adafruit_products_3190_iso_ORIG.jpg?1471799956)

## A Microcontroller

We are using an Arduino UNO R3. &nbsp;But most Arduino compatibles will work as well.

![adafruit_products_50-06.jpg](https://cdn-learn.adafruit.com/assets/assets/000/034/962/medium640/adafruit_products_50-06.jpg?1471800003)

## Breadboard

We are using a full-size board here. &nbsp;But the circuit would fit on a half-size breadboard just as well.

![adafruit_products_239-05.jpg](https://cdn-learn.adafruit.com/assets/assets/000/034/963/medium640/adafruit_products_239-05.jpg?1471800199)

## Hookup Wire or Jumpers
![adafruit_products_1311-00.jpg](https://cdn-learn.adafruit.com/assets/assets/000/034/964/medium640/adafruit_products_1311-00.jpg?1471800274)

## A Stepper Motor

In the example circuit, we are using a bipolar stepper with the following specs:

- NEMA 17
- Torque: 76 oz-in -&nbsp;5.47 kg-cm
- Step Angle: 1.8
- Winding Resistance: 1.8 Ohms/Phase
- DC 2&nbsp;A/Phase
- 12-24VDC (Recommended)

But this tutorial will work with many&nbsp;NEMA-17 and NEMA-23&nbsp;bipolar stepper motors -including the&nbsp;[NEMA-17 motor](https://www.adafruit.com/products/324)&nbsp;from our store.

![adafruit_products_IMG_4796_crop.jpg](https://cdn-learn.adafruit.com/assets/assets/000/034/965/medium640/adafruit_products_IMG_4796_crop.jpg?1471800433)

Danger: 

## A Power Supply

We are using a 12v/5A supply in our example circuit.

Using our example motor with a 1.8 ohm phase resistance, this would draw 6.7A per phase and would quickly burn out a V1 or V2 motor shield. &nbsp;

But the DRV8871 breakout is configured to automatically limit the current to a maximum of 2A. &nbsp;This is a safe level for both the motor and the driver.

![adafruit_products_352-03.jpg](https://cdn-learn.adafruit.com/assets/assets/000/034/966/medium640/adafruit_products_352-03.jpg?1471800810)

Warning: 

# Current Limiting Stepper Driver with DRV8871

## Wiring

![](https://cdn-learn.adafruit.com/assets/assets/000/034/972/medium800/adafruit_products_Untitled_Sketch_bb.png?1471806685)

Wiring up the 2 DRV8871s is farly straightforward:

First assemble the DRV8871 breakouts as instructed [in this tutorial](../../../../adafruit-drv8871-brushed-dc-motor-driver-breakout/assembly):

From the Arduino to the DRV8871 Breakouts (we'll call them "A" and "B"), make the following connections:

- GND -\> (both breakouts)
- Pin 2 -\> IN1 (breakout A)
- Pin 3 -\> IN2 (breakout A)
- Pin 4 -\> IN1 (breakout B)
- Pin 5 -\> IN2 (breakout B)

![](https://cdn-learn.adafruit.com/assets/assets/000/034/971/medium800/adafruit_products_234A1553.jpg?1471804552)

On the motor side:

- Connect one pair of motor leads to the MOTOR terminal block on breakout A.
- Connect the other pair of motor leads to the MOTOR terminal block on breakout B.
- Connect the power supply ground to the "-" terminal of the POWER terminal block on both breakouts.
- Connect the power supply positive wire to the "+" terminal of the POWER terminal block on both breakouts.

![](https://cdn-learn.adafruit.com/assets/assets/000/034/970/medium800/adafruit_products_234A1549.jpg?1471804490)

# Current Limiting Stepper Driver with DRV8871

## Testing

To test out our current limiting stepper driver, we'll use the standard Arduino Stepper library. &nbsp;This is included with the Arduino IDE, so no additional libraries need to be installed.

&nbsp;Copy the code below and upload it to your Arduino.

```auto
#include <Stepper.h>

// A 200-step motor connected on pins 2-5
Stepper stepper(200, 2,3,4,5);

void setup() 
{
  // Rotate at 20 rpm:
  stepper.setSpeed(20);

  Serial.begin(9600);
  Serial.println("Stepper Test!");
}

void loop() 
{
  // Step forward 1000 steps
  Serial.println("forward");
  stepper.step(1000);

  // Step in reverse 1000 steps
  Serial.println("backward");
  stepper.step(-1000);
}
```

The motor should start turning back and forth - 1000 steps at a time.

![](https://cdn-learn.adafruit.com/assets/assets/000/035/008/medium800/adafruit_products_234A1554.jpg?1471862495)


## Related Guides

- [Adafruit QT Py Activity Timer and Hydration Reminder](https://learn.adafruit.com/qt-py-activity-timer-and-hydration-reminder.md)
- [LoRa and LoRaWAN Radio for Raspberry Pi](https://learn.adafruit.com/lora-and-lorawan-radio-for-raspberry-pi.md)
- [LED Neon Selfie Spot](https://learn.adafruit.com/led-neon-selfie-spot.md)
- [No-Code Room Occupancy Status ](https://learn.adafruit.com/no-code-room-occupancy-status.md)
- [CircuitPython Essentials](https://learn.adafruit.com/circuitpython-essentials.md)
- [Improve Brushed DC Motor Performance](https://learn.adafruit.com/improve-brushed-dc-motor-performance.md)
- [Fog Machine with Motion Sensor and Adafruit IO](https://learn.adafruit.com/fog-machine-remote-trigger.md)
- [NES Emulator for RP2040 & RP2350 DVI Boards](https://learn.adafruit.com/nes-emulator-for-rp2040-dvi-boards.md)
- [Raspberry Pi E-Ink Event Calendar using Python](https://learn.adafruit.com/raspberry-pi-e-ink-desk-calendar-using-python.md)
- [Raspberry Pi E-Ink Weather Station using Python](https://learn.adafruit.com/raspberry-pi-e-ink-weather-station-using-python.md)
- [Scrambled Number Security Keypad](https://learn.adafruit.com/scrambled-number-security-keypad.md)
- [Quickstart - Raspberry Pi RP2040 with BLE and CircuitPython](https://learn.adafruit.com/quickstart-raspberry-pi-rp2040-with-ble-and-circuitpython.md)
- [reef-pi Guide 5: Light Controller](https://learn.adafruit.com/reef-pi-lighting-controller.md)
- [Breakbeat Breadboard](https://learn.adafruit.com/breakbeat-breadboard.md)
- [Breadboards for Beginners](https://learn.adafruit.com/breadboards-for-beginners.md)
