The Texas Instruments DRV8871 is a 3.6A brushed DC motor driver with internal current sense / pulse with modulation control. This device is suitable use for printers, industrial equipment’s, mechatronics, appliances, etc. This device as 2 logic input to control the H-Bridge driver, which is it has four N-Channel MOSFET’s that can control the motors bidirectional up to 3.6A peak current. The inputs can be PWM (Pulse with Modulation) to control the motor speed using a choice of current –decay modes.
The DRV8871 device has advance current regulation circuitry that does not use an analog voltage reference or external sense resistor. This solution uses a standard low power resistor to set the current threshold the capability to limit the current to a known level can significantly reduce the system power requirements and bulk capacitance needed to main stable voltage particularly on motor startup and stall conditions. This device has integrated protection from faults and short circuits, including under voltage, over current and over temperature. When the fault condition is removed this device automatically resumes to normal tasks or operations. The DRV887 can handle 2 motors or 1 stepper. For further readings please refer to this link.
On this example we will going to wire the DRV887 manually without using a prebuilt module were going illustrate the device using standard electronic components. See below diagram.
Required Components
- Arduino IDE | Atmel Studio | Energia
- Microcontroller – Arduino, NodeMCU, Teensy Board, TeensyDuino, ESP8266 12, 12E, ESP32, LinkItOne, ESP8266 NodeMCU, ESPDuino, ATMEGA328 16/12, ATMEGA32u4 16/8/ MHz, ESP8266, TI Evaluation Bord C2000, CC3200, MSP430 ,ATMEGA250 16 MHz, ATSAM3x8E, ATSAM21D, ATTINY85 16/8 MHz Note: The Diagram below is using NANO. (please refer to each MCU’s respective pin-outs)
- DRV8871 Brushed Motor Driver IC / Module
- Capacitors
- Resistors
- Solder Less Breadboard
- Jumper Wire
- Prototyping Board (Optional)
Wiring Guide
Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
#define MOTOR_AIN1 5 //This pin is set for Arduino Pin 5 (See chosen MCU respective pin mapping) #define MOTOR_AIN2 6 //This pin is set for Arduino Pin 6 (See chosen MCU respective pin mapping) #define MOTOR_BIN1 9 //This pin is set for Arduino Pin 9 (See chosen MCU respective pin mapping) #define MOTOR_BIN2 10 //This pin is set for Arduino Pin 10 (See chosen MCU respective pin mapping) void setup() { Serial.begin(9600); Serial.println("14CORE | DRV8871 TEST CODE"); delay(1000); Serial.println("Initializing.............."); Delay(4000); pinMode(MOTOR_AIN1, OUTPUT); pinMode(MOTOR_AIN2, OUTPUT); pinMode(MOTOR_BIN1, OUTPUT); pinMode(MOTOR_BIN2, OUTPUT); } void loop() { /* MOTOR A*/ // Set Motor A Forward Up digitalWrite(MOTOR_AIN1, LOW); for (int i=0; i<255; i++) { analogWrite(MOTOR_AIN2, i); delay(10); } delay(1000); // Set Motor A Down Forward for (int i=255; i>=0; i--) { analogWrite(MOTOR_AIN2, i); delay(10); } //Set Motor A Up Backward digitalWrite(MOTOR_AIN2, LOW); for (int i=0; i<255; i++) { analogWrite(MOTOR_AIN1, i); delay(10); } delay(1000); //Set Motor A Down Backward for (int i=255; i>=0; i--) { analogWrite(MOTOR_AIN1, i); delay(10); } /* MOTOR B*/ // Set Motor B Up Forward digitalWrite(MOTOR_BIN1, LOW); for (int i=0; i<255; i++) { analogWrite(MOTOR_BIN2, i); delay(10); } delay(1000); //Set Motor B Down Forward for (int i=255; i>=0; i--) { analogWrite(MOTOR_BIN2, i); delay(10); } //Set Motor B Up Backward digitalWrite(MOTOR_BIN2, LOW); for (int i=0; i<255; i++) { analogWrite(MOTOR_BIN1, i); delay(10); } delay(1000); //Set Motor B Down Backward for (int i=255; i>=0; i--) { analogWrite(MOTOR_BIN1, i); delay(10); } } |
Downloads
Download DRV8871 Brushed Motor Driver Datasheet | PDF