Chronicle
Control and Computation

Motor Drivers

L298N, L293D, BTS7960, DRV8833 specifications, pinouts, connections, and how to interface with microcontrollers

Motor Drivers

Motor drivers are the interface between the microcontroller (logic level) and high-power motors (requiring much higher current). They amplify the control signal and switch motor power.

Why Motor Drivers?

The Problem

Microcontroller outputs:

Maximum current: ~40 mA
Maximum voltage: 5V

Motor needs:
Minimum current: 1-2 A
Voltage: 6-24V

Connecting directly = instant failure!

Solution: Motor driver IC

Microcontroller (5V, 40mA) → Motor driver IC → Motor (12V, 10A)
                            (amplifies signal)

Common Motor Driver ICs

Specifications:

Max current: 2A per channel (3A peak)
Voltage range: 5-35V
Logic voltage: 5V
Channels: 2 (two motors or one stepper)
Type: Dual H-bridge
Cost: ~$3-5

Pinout:

        L298N
    ┌───────────┐
    │1  GND  16│ ← Reference/ground
    │2  IN1  15│ ← Motor A direction 1
    │3  IN2  14│ ← Motor A direction 2
    │4  OUT1 13│ ← Motor A output 1 (to motor)
    │5  OUT2 12│ ← Motor A output 2 (to motor)
    │6  GND  11│ ← Ground
    │7  +5V  10│ ← Logic supply
    │8  ENA   9│ ← Motor A speed (PWM)
    │   ...
    │   INB, ENB, OUTB, etc.
    └───────────┘

Advantages: ✓ Cheap and reliable ✓ Easy to use ✓ Works with 5V logic ✓ High voltage range

Disadvantages: ✗ Only 2A per channel (limited) ✗ Heat dissipation needed ✗ Mechanical relay slow switching


L293D (Compact version)

Specifications:

Max current: 600mA per channel
Voltage range: 4.5-36V
Logic voltage: 5V
Channels: 2
Type: Quad transistor driver
Cost: ~$2-3

Uses: Small motors, educational robots

vs L298N:

  • L293D: Lower current, more compact, cheaper
  • L298N: Higher current, slightly larger

BTS7960 (High-current)

Specifications:

Max current: 43A continuous
Voltage range: 5-27V
Logic voltage: 3.3-5V
Channels: 2
Type: Integrated MOSFET
Cost: ~$15-20

For: Powerful robots, heavy-duty applications

Advantages: ✓ Very high current capability ✓ Efficient (MOSFET-based) ✓ Built-in protection ✓ Better heat dissipation

Disadvantages: ✗ More expensive ✗ Overkill for small robots ✗ Needs good PCB layout


DRV8833 (Small/ultra-compact)

Specifications:

Max current: 2A per channel
Voltage range: 2.7-10.8V
Logic voltage: 3.3V
Channels: 2
Type: Dual H-bridge
Cost: ~$5-8

For: Micro robots, low-voltage systems


L298N Wiring Example

Two DC Motors Setup

Power Supply (12V):
    ├─→ L298N +12V (pin 4, 11)
    ├─→ GND (pin 2, 13)
    └─→ Capacitor (filtering)

Motor A:
    ├─→ OUT1 (pin 2) → Motor +
    ├─→ OUT2 (pin 3) → Motor −
    └─→ Motor ground → GND

Motor B:
    ├─→ OUT3 (pin 12) → Motor +
    ├─→ OUT4 (pin 13) → Motor −
    └─→ Motor ground → GND

Microcontroller (Arduino):
    ├─→ Pin 5V → L298N +5V (pin 16)
    ├─→ Pin GND → L298N GND (pin 1)
    ├─→ Digital pin 8 → IN1 (pin 5)
    ├─→ Digital pin 9 → IN2 (pin 6)
    ├─→ PWM pin 3 → ENA (pin 9)
    ├─→ Digital pin 10 → IN3 (pin 12)
    ├─→ Digital pin 11 → IN4 (pin 13)
    └─→ PWM pin 6 → ENB (pin 8)

Truth Table (L298N)

For Motor A (IN1, IN2, ENA):

ENA (PWM)IN1IN2Motor Action
0%XXStop (coast)
50%10Forward half-speed
100%10Forward full-speed
100%01Backward full-speed
100%11Stop (brake)
100%00Stop (coast)

Arduino Code Example

Basic Motor Control

// L298N Motor A
const int motorA_IN1 = 8;
const int motorA_IN2 = 9;
const int motorA_ENA = 3;  // PWM

// L298N Motor B
const int motorB_IN1 = 10;
const int motorB_IN2 = 11;
const int motorB_ENB = 6;  // PWM

void setup() {
  pinMode(motorA_IN1, OUTPUT);
  pinMode(motorA_IN2, OUTPUT);
  pinMode(motorA_ENA, OUTPUT);
  pinMode(motorB_IN1, OUTPUT);
  pinMode(motorB_IN2, OUTPUT);
  pinMode(motorB_ENB, OUTPUT);
}

void forward(int speed) {
  // Both motors forward
  digitalWrite(motorA_IN1, HIGH);
  digitalWrite(motorA_IN2, LOW);
  analogWrite(motorA_ENA, speed);
  
  digitalWrite(motorB_IN1, HIGH);
  digitalWrite(motorB_IN2, LOW);
  analogWrite(motorB_ENB, speed);
}

void backward(int speed) {
  // Both motors backward
  digitalWrite(motorA_IN1, LOW);
  digitalWrite(motorA_IN2, HIGH);
  analogWrite(motorA_ENA, speed);
  
  digitalWrite(motorB_IN1, LOW);
  digitalWrite(motorB_IN2, HIGH);
  analogWrite(motorB_ENB, speed);
}

void turnLeft(int speed) {
  // Left slower, right faster
  analogWrite(motorA_ENA, speed / 2);
  analogWrite(motorB_ENB, speed);
}

void stop() {
  analogWrite(motorA_ENA, 0);
  analogWrite(motorB_ENB, 0);
}

void loop() {
  forward(255);      // Full speed forward
  delay(2000);
  turnLeft(200);     // Turn left
  delay(1000);
  backward(150);     // Half speed backward
  delay(2000);
  stop();             // Stop
  delay(1000);
}

Motor Driver Selection Guide

By Robot Type

Robot TypeTypical CurrentRecommended DriverReason
Small robot (< 2kg)2-5AL293D or L298NSufficient, cheap
Medium robot (2-10kg)5-20AL298N or BTS7960Good balance
Heavy robot (> 10kg)20-50ABTS7960 or customHandles high current
Micro/aerial0.5-2ADRV8833 or L293DLightweight

By Number of Motors

MotorsL298NL293DOptions
1 DCYes (1 channel)YesUse 1 channel
2 DCYes (2 channels)YesPerfect fit
4 DCNeed 2×Need 2×Stack drivers
1 StepperYesYesNeeds 2 channels
2 ServosNoNoUse PWM direct

Protection and Reliability

Prevent Driver Damage

1. Flyback Diodes

Motors create voltage spikes when powered off:

Without diode: Spike destroys transistors!
With diode: Spike safely dissipated

Connection:
Diode cathode → Motor power
Diode anode → Motor ground
(Diode conducts on spike, shorts it safely)

2. Capacitors

Filter power supply noise:

Battery → [Fuse] → [100µF capacitor] → Motor driver
                   Smooths voltage ripple

3. Heatsink

For high-current drivers:

BTS7960 at 30A draws: P = I² × R = 30² × 0.5 = 450W heat!
Solution: Aluminum heatsink with thermal paste

Common Failures

ProblemCausePrevention
Driver diesMotor spikeAdd flyback diodes
Erratic behaviorNoise on powerAdd capacitors
Thermal shutdownContinuous high currentAdd heatsink or larger driver
Won't drive motorBad connectionCheck all solder joints
Motor jerkyPWM frequency too lowUse 5+ kHz frequency

BTS7960 (Advanced)

For high-power applications:

BTS7960 pinout:
RIN (Motor A direction from MCU)
LIN (Motor A reverse from MCU)  
RPWM (PWM signal)
LPWM (PWM signal reverse)
IS (Current sense - optional)
VS (Voltage sense - optional)
GND, +5V, +12V (to motor)

Advantages: ✓ 43A continuous current ✓ Efficient MOSFET design ✓ Built-in diagnostic outputs ✓ Better thermal characteristics


Summary

Motor Driver Quick Selection:

L298N: Best all-around (2A, cheap, popular) ✓ L293D: Compact, micro version of L298N ✓ BTS7960: High-power applications (43A) ✓ DRV8833: Ultra-compact, low-voltage

Wiring Checklist:

  • Power supply connected to motor driver
  • Motors connected to output terminals
  • Control signals from microcontroller
  • Common ground between all components
  • Flyback diodes across motors
  • Power filter capacitor added
  • Tested with low voltage first

Testing Tips:

  1. Connect with no motor first (bench test)
  2. Verify voltage at all pins (multimeter)
  3. Test with manual PWM input first
  4. Add protection (fuses, capacitors)
  5. Run thermal test under load
  6. Only then add complex control logic

How is this guide?