Component · Actuator
N20 Encoder Gearmotor
The N20 is a small metal-gearbox motor with a built-in magnetic encoder, the usual drive choice for balancing robots that need torque and wheel position.
What it is
The N20 is the small metal-gearbox motor that shows up wherever a robot needs real torque in very little space. The bare motor is about the size of an AA battery; the gearbox on the front trades its very high speed for usable torque, and on the encoder version a magnetic disc on the rear shaft reports how far it has turned.
That last part is what earns it a place in a balancing robot. Without wheel feedback, a balancing robot can stay upright but has no idea where it is — it will hold vertical beautifully while wandering across the room. The encoder closes that gap.
Why the metal gearbox matters here
A plastic-gearbox motor like the TT gearmotor is perfectly good for a line follower, which mostly drives forwards. A balancing robot is a different load: it reverses direction continuously, hundreds of times a second, in small increments.
Every gearbox has backlash — a small dead zone where the gears have disengaged and the output does not move until the teeth meet again on the other side. In a plastic gearbox that dead zone is large, and in a balancing robot it lands exactly where the correction matters most: at the moment of reversal, when the robot needs the wheels to respond now. The result is a robot that oscillates around vertical and never quite settles, no matter how carefully the gains are tuned.
Metal gears do not remove backlash but reduce it enough that the loop can do its job.
Reading the encoder
The encoder produces two square waves 90° out of phase — standard quadrature. The phase relationship tells you direction; counting edges tells you distance.
| Wire (typical) | Connects to | Notes |
|---|---|---|
M1, M2 |
Motor driver outputs | The motor itself; polarity sets direction |
VCC |
3.3 V or 5 V | Encoder supply, not the motor supply |
GND |
Ground | Common with the controller |
C1 |
Interrupt-capable pin | Encoder channel A |
C2 |
Any digital pin | Encoder channel B |
Wire colours vary between suppliers, so check the listing rather than assuming. The one that catches people out is powering the encoder from the motor rail: the encoder wants a clean logic supply, and feeding it the motor voltage will either destroy it or fill your counts with noise every time the motor switches.
Put channel A on a pin that can raise an interrupt. Polling an encoder from loop() on a balancing robot will drop counts, and dropped counts mean the outer loop slowly loses track of where the robot is.
Choosing a ratio
The gear ratio sets the trade between torque and speed, and a balancing robot needs both:
- Too high a ratio (1:250 and up) gives ample torque but the wheels cannot spin up fast enough to get back under a falling body.
- Too low a ratio (1:30 and below) spins quickly but cannot move the robot’s mass with authority.
Around 1:100 at 12 V — roughly 200 RPM — is a reliable starting point for a small robot. If yours catches itself from small disturbances but loses bigger ones, you likely need more speed, not more gain.
Driving it
Pair the N20 with a TB6612FNG rather than an L298N. The reason is dropout: the L298N loses roughly 2 V across its output stage, so a large part of your battery never reaches the motor, and small correction commands fall below the voltage at which the motor moves at all. On a balancing robot that dead zone sits right where the fine corrections live.
Power it from a battery pack that can supply the stall current of both motors at once without its voltage sagging — a sagging rail resets the microcontroller mid-correction, and the robot falls over for reasons that have nothing to do with your control loop.
Used in
- Self-balancing robot — the drive motors, with the encoders feeding the outer position loop
Explore the graph
Used in these builds
Projects, learning paths, and simulators that include the N20 Encoder Gearmotor.
Compare
Alternatives
Questions
N20 Encoder Gearmotor FAQ
What is an N20 encoder motor?
An N20 is a micro gearmotor about 12 by 10 by 26 mm with a metal gearbox, and the encoder version adds a small magnetic disc and sensor on the rear of the motor shaft. The gearbox gives it far more torque than its size suggests, and the encoder reports how far the shaft has actually turned rather than how far you asked it to turn.
Why do balancing robots use N20 motors instead of TT motors?
Two reasons. The metal gearbox has much less backlash than the plastic gearbox in a TT motor, and backlash is poison to a balancing robot—every time the motor reverses, a loose gearbox wastes the first few degrees of correction doing nothing. The encoder also gives the outer control loop real wheel position, which is what lets the robot hold a spot instead of drifting.
How many encoder counts does an N20 give per wheel revolution?
Multiply the motor-shaft pulses by the gear ratio. A typical encoder gives 7 pulses per motor revolution per channel; on a 1:100 gearbox that is 700 pulses per output revolution, or 2800 counts if you decode all four quadrature edges. Always confirm the figure for your specific motor, because both the pulse count and the exact ratio vary between suppliers.
Can I drive an N20 straight from an Arduino pin?
No. An N20 draws several hundred milliamps running and around 700 mA stalled, well beyond what a pin can supply, and the inductive kickback will damage it. Use a motor driver such as the TB6612FNG, which also has a low enough voltage drop that small correction commands still actually move the motor.
What gear ratio should I pick for a balancing robot?
Something in the 1:50 to 1:150 range is the usual compromise. Too high a ratio gives plenty of torque but the wheels cannot accelerate quickly enough to catch a fall; too low and the motor lacks the torque to move the robot's mass at all. Around 1:100 at 12 V, giving roughly 200 RPM, suits a typical small balancing robot.
Further reading