This free N20 encoder motor library for Proteus adds the tiny metal N20 gear motor with an encoder to Proteus 8: the motor of small robots, line followers, robot arms and camera sliders. It simulates the common 6 V, 1:100 N20 with the values of a real one. You see the open gearbox turn, a live RPM display shows the output shaft speed, and the encoder pins C1 and C2 give real quadrature pulses that your Arduino code can read.
place the part N20 DC GEAR MOTOR, connect M1 and M2 to a battery or a motor driver, VCC and GND to 5 V, and press Play. The gears turn and C1 and C2 give 700 pulses per output turn each. Set Show RPM Box to Yes to see the output speed (300 rpm at 6 V). Swap M1 and M2 and it turns the other way.
N20 Encoder Motor Library for Proteus: Features
| Feature | N20 encoder motor model |
|---|---|
| Motor | A real analog part: back-EMF, start current, friction, gearbox efficiency and a load on the output shaft |
| Gearbox | 1:100, drawn open: the four gear stages turn while the simulation runs |
| RPM box | Live speed of the output shaft, negative when it turns backwards. Off by default: set Show RPM Box to Yes |
| Encoder | Two channels C1 and C2 in quadrature, 7 pulses per motor turn (700 per output turn), open collector with 10 kΩ pull-up |
| Drive it with | A battery, a transistor, an L298 or L293D driver, or PWM from an Arduino |
| Properties | Rated voltage, speed, no-load and stall current, time constant, gearbox efficiency, load, encoder pulses, voltage warning |
| Default values | 6 V, 300 rpm, 0.06 A no load, 0.75 A stall: the most sold N20 1:100 encoder motor |
The Motor Behind the Model: N20 Gear Motor with Encoder
The version with the little board on the back has an encoder: two Hall sensors that give pulses while the shaft turns, so an Arduino can measure the speed and count the turns. Proteus has no N20 motor and no motor with an encoder, so you can’t test your speed or position code before you build it.
The motor side is a real analog part: back-EMF, start current, friction, gearbox efficiency and a load on the output shaft. It works with a battery, a transistor, an L298 or L293D driver, or PWM from an Arduino, so your DC motor with encoder simulation in Proteus behaves like the real thing.
The default values are those of the most sold N20 encoder motor: 6 V, 1:100 gearbox, about 300 rpm, with a magnetic encoder of 7 pulses per motor turn:
| Value | Typical N20 6 V 1:100 | Model at 6 V |
|---|---|---|
| Output speed, no load | 300 rpm | 300 rpm |
| Motor speed, no load (before the gearbox) | about 30,000 rpm | 30,000 rpm |
| No-load current | 0.06 A | 0.06 A |
| Stall current | 0.75 A | 0.75 A |
| Stall torque at the output | about 0.8 kg·cm | about 0.8 kg·cm (800 g·cm) |
| Encoder | 7 pulses per motor turn, 2 channels | 7 pulses per motor turn, C1 and C2 |
| Pulses per output turn (one channel) | 700 | 700 |
Your N20 has other values? Change them in the part (see the properties below). You only need the numbers printed on its listing: rated voltage, output speed, no-load current and stall current. This version always has the 1:100 gearbox.
N20 Encoder Motor Library for Proteus: Pins
| Pin | What it is |
|---|---|
| M1 | Motor terminal, white wire. Connect it to the other side of your supply or driver |
| M2 | Motor terminal, red wire. When M2 is more positive than M1, the motor turns forward (positive rpm) |
| VCC | Encoder supply, 3.3 V to 5 V |
| GND | Encoder ground |
| C1 | Encoder channel A |
| C2 | Encoder channel B |
The red wire is M2 and the white wire is M1. Red more positive turns the motor forward and the RPM box shows a positive speed. A brushed motor has no fixed + and -: swap the wires and it turns the other way.
Do not connect the motor straight to an Arduino pin. An N20 takes up to 0.75 A when it starts, and an Arduino pin gives about 20 mA. Use a motor driver (L298N, L293D, TB6612, DRV8833) or a transistor with a diode across the motor. The encoder pins are fine on Arduino inputs.
N20 Encoder Motor Proteus Library Properties
Double-click the motor to change these:
| Property | What it does | Default |
|---|---|---|
| Rated Voltage (V) | The voltage the other values are given at | 6 |
| No-Load Output Speed at VNOM (rpm) | Speed of the output shaft with nothing on it, at the rated voltage | 300 |
| No-Load Current at VNOM (A) | Current with nothing on the shaft. Sets the motor and gearbox friction | 0.06 |
| Stall Current at VNOM (A) | Current with the shaft held. Sets the winding resistance | 0.75 |
| Mechanical Time Constant (s) | How fast it gets up to speed | 20m |
| Gearbox Efficiency (0..1) | How much of the motor torque reaches the output shaft | 0.65 |
| Load Torque on Output (g.cm) | A steady load on the output shaft. 0 = free running | 0 |
| Encoder Pulses per Motor Turn | Pulses on each channel for one turn of the motor (not the output) | 7 |
| Max Voltage Warning (V) | The log gives a warning above this voltage | 9 |
| Show RPM Box | Shows the output speed on the motor while the simulation runs | No |
The values are read when the simulation starts: stop and start it again after a change.
Speed and Current at Different Voltages
With the default values, this is what the model gives. Use it to check your own circuit:
| Voltage on the motor | Output speed (no load) | Current (no load) | Current when it starts (stall) | C1 frequency |
|---|---|---|---|---|
| 3.0 V | about 137 rpm | 0.06 A | 0.38 A | about 1,600 Hz |
| 3.3 V | about 153 rpm | 0.06 A | 0.41 A | about 1,790 Hz |
| 5.0 V | about 246 rpm | 0.06 A | 0.63 A | about 2,870 Hz |
| 6.0 V | 300 rpm | 0.06 A | 0.75 A | 3,500 Hz |
| 9.0 V | about 463 rpm | 0.06 A | 1.13 A | about 5,400 Hz |
The motor needs about 0.48 V before it starts to turn. Above that, the speed follows the voltage, and that is why PWM speed control works: a lower average voltage gives a lower speed.
Reading the Encoder: C1 and C2
The encoder board has a small magnet on the motor shaft and two Hall sensors. Each one gives a square wave, and the two waves are a quarter of a period apart (quadrature):
- Forward (red M2 more positive): C1 leads C2.
- Reverse: C2 leads C1.
- The outputs are open collector with a 10 kΩ pull-up to VCC, like the real board: high = VCC, low = 0 V.
How many counts you get for one turn of the output shaft depends on how your code counts:
| How you count | Counts per output turn |
|---|---|
| Rising edges of C1 only | 7 × 100 = 700 |
Both edges of C1 (CHANGE on one pin) | 1,400 |
| Both edges of C1 and C2 (full quadrature) | 2,800 |
So the output speed is: rpm = counts per second × 60 / counts per output turn. At 300 rpm with both edges of C1 that is 7,000 counts a second.
Example 1: N20 Motor Simulation with a Battery and an Oscilloscope
The simplest test. Place N20 DC GEAR MOTOR, a 6 V battery on M2 (+, red wire) and M1 (-, white wire) with a DC ammeter in series, a 5 V supply on VCC and GND, and an oscilloscope with channel A on C1 and channel B on C2. Double-click the motor, set Show RPM Box to Yes and press Play.
Oscilloscope settings (TREE OSCILLOSCOPE; press Default settings first):
| Setting | Value |
|---|---|
| Time/div | 100 us |
| Fine SPICE steps | On (without it the edges look sloped, about 20 us) |
| Trig mode / source / edge | Auto / A / Rising |
| Trig level (V) | 2.5 |
| Trig position | 10 % from the left |
| Channels A and B | On, 2.0 V/div, DC. Drag the B marker up so the two waves do not overlap |
| Measure | All analog channels |
- The ammeter jumps up to about 0.75 A for a moment, then falls to 0.06 A while the RPM box climbs to 300.
- The oscilloscope shows two square waves of 3,500 Hz: the measurement table reads Freq 3.50 kHz, Period 286 us, Duty 50 % and about 4.95 V high on both channels. C1 rises about 71 us (a quarter period) before C2: the motor turns forward.
- Stop, double-click the motor and set Load Torque on Output = 200. Press Play: the motor runs at about 225 rpm and takes about 0.23 A, and the pulses drop to about 2,625 Hz.
- Swap the battery wires: the RPM box shows -300 and now C2 leads C1.
| Load Torque on Output (g.cm) at 6 V | Output speed | Current |
|---|---|---|
| 0 | 300 rpm | 0.06 A |
| 100 | about 263 rpm | 0.15 A |
| 200 | about 225 rpm | 0.23 A |
| 400 | about 151 rpm | 0.40 A |
| 600 | about 76 rpm | 0.58 A |
Example 2: Arduino Encoder Motor Speed Reading
This Arduino encoder motor example drives the N20 from an Arduino UNO through our L298N motor driver module and reads the encoder to print the real output speed:
- L298N: IN1 to D7, IN2 to D8, ENA to D9 (PWM, leave the ENA jumper off). OUT1 to M2 (red), OUT2 to M1 (white). +12V to a 6 V motor supply, +5V to the UNO 5V (5V-EN jumper off: 6 V is too low for the board’s regulator), GND to the UNO GND.
- The L298 drops about 1.8 V, like the real board, so at full duty the motor gets about 4.2 V and turns at about 200 rpm. For the full 300 rpm put about 7.5 V on +12V.
- Encoder: C1 to D2, C2 to D3, VCC to 5V, GND to GND.
- Potentiometer (10 kΩ) between 5V and GND, wiper on A0: sets the speed.
- Push button from D4 to GND: changes the direction.
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
// N20 encoder motor Library for Proteus: N20_Encoder_RPM (www.electronicstree.com)
const int IN1 = 7, IN2 = 8, ENA = 9; // L298N driver module
const int ENC_C1 = 2, ENC_C2 = 3; // encoder outputs (D2 = interrupt pin)
const int BTN = 4, POT = A0;
const float COUNTS_PER_TURN = 7 * 2 * 100.0; // 7 pulses x 2 edges of C1 x gearbox 1:100
volatile long count = 0;
bool forward = true;
bool lastBtn = HIGH;
void onC1() { // runs on every edge of C1
if (digitalRead(ENC_C1) != digitalRead(ENC_C2)) count++; // C1 leads C2: forward
else count--; // C2 leads C1: reverse
}
void setup() {
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENA, OUTPUT);
pinMode(ENC_C1, INPUT); // the encoder has its own pull-ups
pinMode(ENC_C2, INPUT);
pinMode(BTN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(ENC_C1), onC1, CHANGE);
Serial.begin(9600);
}
void loop() {
bool b = digitalRead(BTN);
if (b == LOW && lastBtn == HIGH) { // button pressed: change direction
analogWrite(ENA, 0); // stop first, like on a real motor
delay(200);
forward = !forward;
}
lastBtn = b;
digitalWrite(IN1, forward ? HIGH : LOW);
digitalWrite(IN2, forward ? LOW : HIGH);
int duty = analogRead(POT) / 4; // 0..1023 -> 0..255
analogWrite(ENA, duty);
static unsigned long t = 0;
static long last = 0;
if (millis() - t >= 500) { // every half second
t = millis();
noInterrupts();
long c = count;
interrupts();
float rpm = (c - last) / COUNTS_PER_TURN * 120.0; // counts in 0.5 s -> rpm
last = c;
Serial.print("duty ");
Serial.print(duty);
Serial.print(" rpm ");
Serial.print(rpm, 1);
Serial.print(" turns ");
Serial.println(c / COUNTS_PER_TURN, 2);
}
delay(20);
}Export the .hex file from the Arduino IDE (Sketch → Export Compiled Binary), load it into the UNO and press Play. Turn the potentiometer: the RPM in the serial monitor follows the RPM box on the motor (Show RPM Box = Yes). Press the button: the motor stops, turns the other way and the RPM goes negative, while “turns” counts back down.
New to simulating an Arduino? Our Arduino UNO R3 library for Proteus shows how to load a sketch, and the virtual serial terminal shows the Serial lines.
How the Gearbox Animation Works
The N20 motor inside turns 500 times a second while the output shaft turns only 5 times. Proteus draws the screen about 16 times a second, so no drawing can show the motor at its real speed: it would jump around or seem to run backwards (the wagon-wheel effect you know from films).
So the model draws the open gearbox like your eyes see a real one:
- The four gear stages each turn at their own speed: fast near the motor, slow at the output.
- Fast gears blur into a smooth ring, like a real spinning gear.
- Slow gears near the output show their teeth moving, in the real direction.
- The output shaft turns at its real speed.
the gearbox is only a visual animation. It shows the direction and roughly how fast the motor turns, not the exact speed. For the real speed read the RPM box (output shaft, negative when it turns backwards), or count the encoder pulses. The box is off by default: set Show RPM Box to Yes to show it.
N20 Encoder Motor Library for Proteus: Troubleshooting
| What you see | Cause and fix |
|---|---|
| The motor does not turn | Less than about 0.48 V across M1 and M2, or a load bigger than about 800 g·cm. Measure the voltage on M1 and M2 |
| No pulses on C1 and C2 | VCC and GND of the encoder are not connected. Give them 3.3 V or 5 V |
| The Arduino counts double or half | The counts per turn depend on how you count: 700, 1,400 or 2,800 (see the table above) |
| The RPM is negative | The motor turns backwards: M1 (white) is more positive than M2 (red). Swap the wires or the direction pins |
| The simulation runs slower than real time | Normal at full speed: the encoder makes about 14,000 edges a second and Proteus follows every one |
| Warning “above the 9.0 V limit” | More than 9 V across the motor. Lower the supply, or raise Max Voltage Warning if your motor takes more |
| No RPM box | Show RPM Box is No (the default): set it to Yes. Or the simulation is stopped (it only shows a number while it runs) |
| Nothing changes after editing a property | The values are read at the start. Stop and start the simulation |
Download the N20 Encoder Motor Library for Proteus
The zip file of the N20 encoder motor library for Proteus holds the model MotorN20.dll, the library ElectronicsTree[MOTORN20].LIB and a Readme.
Installing it takes two minutes (see the steps right below). Looking for more parts? Browse all our free Proteus libraries.
We’re always looking to expand our library collection based on what our community needs. If you’re looking for a specific Arduino module, sensor, or component that we don’t currently offer, we’d love to hear from you!
Reach out to us at help@electronicstree.com with your requests. We prioritize new library development based on community demand, so your suggestion could be our next addition.
Join the official WhatsApp channel of ElectronicsTree to stay updated with the latest electronics tutorials, Proteus libraries, Arduino projects, and simulation resources.
How to Install the N20 Encoder Motor Library for Proteus 8
New to adding libraries? Our guide how to install a library in Proteus 8 shows where the Proteus folders are.
- Close Proteus.
- Copy the files into the Proteus data folder, normally
C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\DATA\MotorN20.dllgoes intoDATA\MODELS\ElectronicsTree[MOTORN20].LIBgoes intoDATA\LIBRARY\
Windows asks for administrator rights because the folder is underProgram Files: click Continue. - Start Proteus, open Pick Devices (press P) and search for
N20. You find the part N20 DC GEAR MOTOR.
The N20 encoder motor library for Proteus is made for Proteus 8 only; it does not work in Proteus 9. It is a library, not Proteus itself: the software comes from Labcenter Electronics, who also offer a free demo on their website.
Frequently Asked Questions
Is there an N20 motor library for Proteus?
Proteus has no N20 motor and no motor with an encoder. This free library adds the N20 gear motor with an open gearbox you can see turn, a live RPM display and a two-channel encoder on C1 and C2.
How do I read a motor encoder in Proteus?
Connect the encoder’s VCC and GND to 5 V, C1 and C2 to two Arduino pins, and count the edges of C1 in an interrupt. Read C2 in the interrupt to know the direction. Example 2 has the full sketch.
How many encoder pulses per turn does the N20 motor give?
7 pulses per motor turn on each channel. With the 1:100 gearbox that is 700 pulses per output turn, 1,400 if you count both edges of C1 and 2,800 with full quadrature.
Can I change the gear ratio?
No, this N20 always has the 1:100 gearbox. You can change the voltage, speed, currents, efficiency, load and the encoder pulses per motor turn.
Why does the gearbox look slower than the RPM box says?
No screen can show a motor at 30,000 rpm. The gears turn as fast as the eye can follow, then blur. The RPM box and the encoder always give the real speed.
Does this N20 encoder motor library work in Proteus 9?
No. This N20 encoder motor library is made for Proteus 8 only (tested in Proteus 8.17 SP2). It does not work in Proteus 9.
What is the difference to the 130 DC motor and TT motor libraries?
The 130 DC motor is a bare motor without a gearbox (about 12,000 rpm), and the TT motor is a 130 motor with a plastic 1:48 gearbox and a wheel. The N20 is much smaller, has a metal 1:100 gearbox and is the only one with an encoder, for speed and position control.
Is the N20 encoder motor Proteus library free?
Yes. Download it free from this page. The Arduino sketch from Example 2 is on this page too.
More Motor Libraries for Proteus
- 130 DC motor library for Proteus: the bare motor with a spinning gear and live RPM
- DC gear motor (TT motor) Proteus library: the 130 motor with a 1:48 gearbox and a wheel
- Rotary encoder library for Proteus: the knob encoder, same C1 / C2 style pulses
- SG90 servo motor Proteus library
- MG995 servo motor Proteus library
- Stepper motor with driver in Proteus
Conclusion
This encoder motor library for Proteus puts a real N20 gear motor on your schematic. You see the gearbox turn, read the output speed on the RPM box, and the encoder gives the same C1 and C2 pulses as the real board. That lets you write and test your Arduino speed, distance and PID code in Proteus before you build it.
Questions, or a motor you want next? Write them in the comments!