Sub topic 9
Powering the motor and logic: shared ground and decoupling
This chapter assumes you know Ohm's law, have wired a breadboard, and understand how an H-bridge switches a motor (covered in earlier chapters). It covers how to power a driver and an Arduino together without resets, noise, or damaged pins.
Two supplies, two jobs
A motor driver circuit has two separate power needs.
- Logic power runs the Arduino and the driver's control circuitry. It is usually 5 V or 3.3 V and draws tens of milliamps.
- Motor power runs the motor through the H-bridge. It might be 6 V to 12 V or higher, and it can draw amps, especially at start-up and stall.
These loads behave very differently. A motor is an inductor with brushes that spark and switch. It makes electrical noise and pulls sudden current. A microcontroller needs a steady voltage and fails in odd ways when its supply dips. Most power problems in motor projects come from letting the motor disturb the logic supply.
Common driver modules handle this in different ways. The table lists the ones you are most likely to meet.
| Module | Motor supply pin | Logic supply | Notes |
|---|---|---|---|
| L298N board | +12V (VS) | 5V pin | A jumper enables an onboard 5 V regulator. Remove it when the motor supply exceeds about 12 V. |
| L293D | VS (pin 8) | VSS (pin 16) | Two separate supply pins. VSS must be 5 V. |
| TB6612FNG board | VM | VCC | Logic accepts 2.7 V to 5.5 V. Motor supply is separate. |
| DRV8833 board | VM | None (logic powered from VM) | Logic inputs accept 3.3 V or 5 V signals. |
Check your module's datasheet before connecting anything. Pin names and jumper behavior vary between manufacturers.
The common ground
The Arduino's output pins send a voltage, but a voltage is only meaningful relative to some reference. When the Arduino drives IN1 high, the driver reads that pin as "high" by comparing it against its own ground pin. If the driver's ground and the Arduino's ground are not connected, the driver has no shared reference. The input may read as noise, flicker, or never register at all.
The rule is: every ground in the system must connect together. That means the Arduino GND, the driver's logic GND, and the negative terminal of the motor supply.
A single shared node is the clean way to think about it. In practice, wire the motor supply ground to the driver GND, then run a second wire from the driver GND to the Arduino GND.
Where to join the grounds
Motor current is large, and it returns to the supply through the ground wire. Wires and breadboard traces have a small resistance. A 2 A current through 0.1 Ω of ground wire creates a 0.2 V difference between the two ends. If the Arduino's ground connects at the far end of that wire, the Arduino sees a ground that moves every time the motor current changes.
To limit this:
- Keep the high-current return path short and thick: motor supply negative to driver GND.
- Branch the Arduino's ground off at the driver GND terminal. The motor current does not flow through that branch.
- Avoid sharing breadboard power rails between the motor current and the logic.
This arrangement is sometimes called a star ground, because the grounds meet at one point instead of being daisy-chained.
Can one supply do both jobs?
Sometimes. Suppose a 9 V battery pack feeds the driver's motor pin. You can also feed the same pack into the Arduino's VIN or barrel jack, and the Arduino regulates it down to 5 V. This saves a battery and gives a common ground automatically.
The risk is that motor noise and voltage sag reach the Arduino's regulator input. A weak battery or long wires makes this worse. If you see resets only when the motor starts, give the Arduino its own supply, or add the filtering described below.
If the Arduino has USB power and the motor has its own supply, the grounds must still be tied together. Do not connect the two positive rails together. Two supplies at slightly different voltages joined at their positive terminals fight each other, and one can be damaged.
Why decoupling matters
A motor does not draw steady current. When the motor starts, or when the PWM signal switches the bridge on, the current rises quickly. The supply wires have inductance and resistance, so the voltage at the driver dips for a moment. When the bridge turns off, the motor's inductance pushes current back, and the voltage spikes above the supply.
A decoupling capacitor (also called a bypass capacitor) sits across the supply near the load. It acts as a small local energy store. When the load suddenly demands current, the capacitor supplies it for a few microseconds, before the distant supply can respond. When a spike arrives, the capacitor absorbs part of it.
There are two roles, and you normally need both.
- Bulk capacitor. An electrolytic capacitor, typically 100 µF to 1000 µF, across the motor supply at the driver. It handles the slower swings: start-up current and PWM cycles. Its voltage rating must exceed the supply, and a common rule is at least 1.5 times the supply voltage. Mind the polarity, because a reversed electrolytic can fail violently.
- High-frequency capacitor. A ceramic capacitor, typically 100 nF (0.1 µF), across the same supply pins as close to the driver as possible. It handles fast spikes that the electrolytic is too slow to catch.
You can also place a 100 nF ceramic capacitor directly across the motor terminals. Brushed motors create sparks at the commutator that radiate noise. A capacitor soldered across the terminals, with short leads, suppresses much of it.
Capacitor placement
Placement matters as much as value. A capacitor with 15 cm of wire to the driver has the wire's inductance in series, which makes it nearly useless against fast spikes. Place capacitors:
- directly across the driver's VM and GND pins, with leads as short as possible;
- on the Arduino side, near the 5 V and GND pins, if the Arduino shares a supply with the motor;
- on the motor terminals themselves for noise suppression.
Voltage drop inside the driver
The driver does not pass the full supply voltage to the motor. A bipolar driver such as the L298N drops about 1.8 V to 3 V across its output transistors, so a 9 V supply gives the motor roughly 6 V to 7 V. MOSFET drivers such as the TB6612FNG drop far less, usually well under 0.5 V at moderate current. When you pick a supply voltage, add the driver's drop to the motor's rated voltage. Chapter material on current and thermal limits covers the heat this drop produces.
Brownouts and how to spot them
A brownout happens when the supply voltage dips below what the Arduino needs. The board does not necessarily power off. It resets, or it freezes, or it behaves strangely. Typical signs:
- The Arduino resets each time the motor starts.
- The serial monitor shows repeated start-up messages.
- The on-board LED flickers when the motor runs.
- Behavior is fine with the motor disconnected.
You can test for resets with a short sketch that prints a message at start-up and then drives the motor. If the message appears more than once, the board is resetting.
const uint8_t IN1 = 7;
const uint8_t IN2 = 8;
const uint8_t EN = 9;
void setup() {
Serial.begin(9600);
Serial.println("Boot"); // appears again after every reset
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(EN, OUTPUT);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
}
void loop() {
analogWrite(EN, 255); // full speed gives the largest start-up surge
delay(1000);
analogWrite(EN, 0);
delay(1000);
}If "Boot" prints repeatedly, work through the fixes in order: confirm the motor has its own supply, confirm the grounds are joined, add the bulk and ceramic capacitors, shorten and thicken the supply wires, and finally move the Arduino to a separate supply.
Wiring checklist
- Motor supply positive goes to the driver's motor pin. Check the polarity twice.
- Motor supply negative goes to the driver GND.
- Driver GND goes to the Arduino GND.
- The logic supply for the driver (if it has a separate pin) goes to the correct voltage.
- A bulk electrolytic and a 100 nF ceramic capacitor sit across the driver's motor supply.
- Optionally, a 100 nF ceramic capacitor sits across the motor terminals.
- Turn on the motor supply and Arduino, and test with the motor at low speed first.
Common errors
- Missing common ground. The motor does not respond, or responds randomly. Add the ground wire.
- Motor powered from the Arduino 5 V pin. The board resets or the regulator overheats.
- Wrong jumper on an L298N board. With the 5 V regulator jumper left in place above the supported voltage, the regulator can overheat. With the jumper removed, the board needs an external 5 V logic supply.
- Reversed capacitor. An electrolytic capacitor has a marked negative side. Match it to ground.
- Capacitors placed far from the driver. The wire inductance defeats them.
Exercise
Your Arduino resets every time the motor starts. The motor is powered by a separate 9 V pack, and the driver's IN1 and IN2 inputs respond correctly otherwise. Name three changes you would try, in order, and explain why each one helps.
Show answer
First, check that the driver GND, motor supply negative, and Arduino GND all join, and that the Arduino ground branches off at the driver GND instead of sharing the high-current path, because a moving ground reference can reset the board. Second, add a bulk electrolytic capacitor (for example 470 µF) and a 100 nF ceramic capacitor across the driver's motor supply, placed close to the driver, so the start-up surge is supplied locally and the voltage does not sag. Third, if the Arduino takes power from the same 9 V pack, give it its own supply (such as USB) or add filtering, so the motor's voltage dips and noise cannot reach the Arduino's regulator.
Exercise
A 6 V motor is connected to an L298N module running from a 6 V supply, and the motor turns slowly with little torque. The supply voltage measures a steady 6 V at the module. What is the likely cause, and what is the fix?
Show answer
The L298N's bipolar output transistors drop roughly 1.8 V to 3 V, so the motor receives only about 3 V to 4 V. Raise the supply voltage to the motor's rating plus the driver's drop (about 8 V to 9 V here, and make sure the motor tolerates the PWM duty you use), or switch to a MOSFET driver such as the TB6612FNG, whose voltage drop is much smaller.