

The ENCODER N20 is a small, high-precision rotary encoder designed to measure the position or rotation of a shaft. Its compact design makes it ideal for applications where space is limited. This encoder is commonly used in robotics, automation systems, and various electronic projects requiring accurate rotational feedback. It is often paired with DC motors to provide precise control over motor position and speed.








The ENCODER N20 is designed to provide reliable and accurate feedback in a small form factor. 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 RPM | 10,000 RPM |
| Output Signal Voltage | Same as input voltage |
| Operating Temperature | -20°C to 85°C |
| Dimensions | 12mm x 10mm x 10mm |
The ENCODER N20 typically has four pins for interfacing. 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) |
The ENCODER N20 is straightforward to use in a circuit. Below are the steps and considerations for integrating it into your project:
Below is an example of how to connect the ENCODER N20 to an Arduino UNO:
The following code demonstrates how to read the encoder's 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 // Channel A connected to digital pin 2
#define ENCODER_PIN_B 3 // Channel B connected to digital pin 3
volatile int encoderPosition = 0; // Variable to store the encoder position
volatile int lastEncoded = 0; // Last encoded value
void setup() {
pinMode(ENCODER_PIN_A, INPUT); // Set pin A as input
pinMode(ENCODER_PIN_B, INPUT); // Set pin B as input
// Enable interrupts for pin A and pin B
attachInterrupt(digitalPinToInterrupt(ENCODER_PIN_A), updateEncoder, CHANGE);
attachInterrupt(digitalPinToInterrupt(ENCODER_PIN_B), updateEncoder, CHANGE);
Serial.begin(9600); // Initialize serial communication
}
void loop() {
// Print the encoder position to the Serial Monitor
Serial.print("Encoder Position: ");
Serial.println(encoderPosition);
delay(100); // Delay for readability
}
void updateEncoder() {
// Read the current state of the encoder pins
int MSB = digitalRead(ENCODER_PIN_A); // Most significant bit
int LSB = digitalRead(ENCODER_PIN_B); // Least significant bit
int encoded = (MSB << 1) | LSB; // Combine the two bits into a single value
int sum = (lastEncoded << 2) | encoded; // Combine with the last encoded value
// Determine the direction of rotation
if (sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) {
encoderPosition++; // Clockwise rotation
} else if (sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) {
encoderPosition--; // Counterclockwise rotation
}
lastEncoded = encoded; // Update the last encoded value
}
No Output Signal:
Inconsistent Readings:
Incorrect Direction Detection:
Position Drift:
Q1: Can the ENCODER N20 be used with a 3.3V microcontroller?
Yes, the ENCODER N20 operates within a voltage range of 3.3V to 5V, making it compatible with 3.3V microcontrollers.
Q2: What is the purpose of the quadrature signals?
Quadrature signals allow the encoder to determine both the position and direction of rotation.
Q3: How do I calculate the resolution in degrees?
The resolution in degrees is calculated as ( \text{Resolution} = \frac{360}{\text{PPR}} ). For the ENCODER N20, this is approximately 32.73° per pulse.
Q4: Can I use the ENCODER N20 for speed measurement?
Yes, by measuring the frequency of the pulses, you can calculate the rotational speed of the shaft.
This concludes the documentation for the ENCODER N20.