

The ENCODER N20 is a rotary encoder designed to convert the angular position or motion of a shaft into an electrical signal. This component is widely used in robotics, automation systems, and motor control applications where precise position feedback is required. Its compact size and compatibility with small DC motors make it an ideal choice for projects requiring accurate rotational measurements.








The ENCODER N20 is typically paired with an N20 DC motor and provides incremental position feedback. Below are its key technical details:
| Parameter | Value |
|---|---|
| Operating Voltage | 3.3V to 5V |
| Output Signal Type | Quadrature (A and B channels) |
| Resolution | 11 pulses per revolution (PPR) |
| Maximum Speed | 10,000 RPM |
| Operating Temperature | -20°C to 85°C |
| Dimensions | 12mm x 10mm x 10mm |
The ENCODER N20 typically has four output pins. The table below describes each pin:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | VCC | Power supply input (3.3V to 5V) |
| 2 | GND | Ground connection |
| 3 | A | Channel A output signal (quadrature signal) |
| 4 | B | Channel B output signal (quadrature signal) |
Below is an example Arduino sketch to read the ENCODER N20 signals and calculate the position:
// ENCODER N20 Example Code for Arduino UNO
// This code reads the quadrature signals from the encoder and calculates position.
#define ENCODER_PIN_A 2 // Connect to encoder pin A
#define ENCODER_PIN_B 3 // Connect to encoder pin B
volatile int position = 0; // Variable to store the encoder position
void setup() {
pinMode(ENCODER_PIN_A, INPUT); // Set pin A as input
pinMode(ENCODER_PIN_B, INPUT); // Set pin B as input
// Attach interrupts to handle encoder signals
attachInterrupt(digitalPinToInterrupt(ENCODER_PIN_A), encoderISR, CHANGE);
Serial.begin(9600); // Initialize serial communication
}
void loop() {
// Print the current position to the Serial Monitor
Serial.print("Position: ");
Serial.println(position);
delay(100); // Delay for readability
}
// Interrupt Service Routine (ISR) for encoder
void encoderISR() {
// Read the state of pin A and pin B
int stateA = digitalRead(ENCODER_PIN_A);
int stateB = digitalRead(ENCODER_PIN_B);
// Determine direction based on the state of A and B
if (stateA == stateB) {
position++; // Clockwise rotation
} else {
position--; // Counterclockwise rotation
}
}
No Signal Output:
Incorrect Position Readings:
Missed Pulses at High Speeds:
Q: Can the ENCODER N20 be used with a 12V motor?
A: Yes, the encoder can be used with a 12V motor, but the encoder itself must be powered with 3.3V to 5V.
Q: How do I calculate the RPM of the motor using the encoder?
A: Count the number of pulses in one second, divide by the encoder's PPR (11), and multiply by 60 to get RPM.
Q: Do I need external pull-up resistors?
A: It depends on the encoder's output type. If the outputs are open-drain, you will need pull-up resistors.
By following this documentation, you can effectively integrate the ENCODER N20 into your projects for precise position and motion control.