ROSANNAPAPINI.IT ≡ Accessories Circuitoimpreso Kits Educativos Amplifier
  • Motor

  • N20 DC Motor with Magnetic Encoder — 6V 530 RPM

N20 DC Motor with Magnetic Encoder — 6V 530 RPM

$67.5 $108.68
The first step in a robot­ics project is to get a motor spin­ning. Once you’ve done that you quick­ly learn that not all motors go the same speed, even if they are the same part num­ber! There are always vari­a­tions that relate to volt­age, envi­ron­ment, and man­u­fac­tur­ing changes. So, the sec­ond step is to fig­ure out how fast it’s going! Turns out that’s not so easy, but the best way to get start­ed is to add an encoder wheel and an opti­cal or mag­net­ic counter. As the motor turns, the attached encoder wheel spins, caus­ing the counter to detect each pass­ing spoke and that lets your micro­con­troller count and deter­mine speed.If you want to do one bet­ter, add a sec­ond counter, and now you can tell direc­tion as well as speed! All this wiring is kind of a pain, so that’s why this motor is real­ly nice! It has a mag­net­ic wheel and two hall effect sen­sors already attached. Using this motor is a breeze, and it’s a nice small motor as well, in the ‘stan­dard’ N20 size.Pro­vide 4.5 to 6V DC (nom­i­nal) to the white and red wires — these con­nect to your motor dri­ver, and can be PWM’d for speed adjust­ment and direc­tion by using an H‑bridge.Con­nect the black wire to your micro­con­troller ground pin, and the blue wire to 3–5V DC (we tried both, works fine) use whichev­er volt­age your micro­con­troller uses. Then you can read the hall effect out­puts on the yel­low and green wires. We have an exam­ple sketch here for Arduino, it can be adapt­ed to oth­er lan­guages — basi­cal­ly you just want to inter­rupt on one of the encoder pins, use count the time since the last inter­rupt, and mul­ti­ply the count time by 14-counts-per-rev­o­lu­tion and the gear ratio.This par­tic­u­lar DC motor comes with 1:150 gear ratio, uses 6V nom­i­nal pow­er for the motor and draws about 100mA (200mA when stalled). The gear ratio will not affect the cur­rent draw but does change the torque and RPM. See below for the no load/rated/stall cur­rent, RPM and torque for a range of ratios!TECHNICAL DETAILS:Dimen­sions (exclud­ing shaft): 30.5mm x 18.5mmWire Length: ~150mm longLink:DatasheetGear Ratio Com­par­i­son TableArduino Code:below is the arduino code for Con­trol­ling N20 Micro Gear Encoder Motor with arduinoArduino #define MotFwd 3 // Motor Forward pin #define MotRev 5 // Motor Reverse pin int encoderPin1 = 2; //Encoder Output 'A' must connected with intreput pin of arduino. int encoderPin2 = 3; //Encoder Otput 'B' must connected with intreput pin of arduino. volatile int lastEncoded = 0; // Here updated value of encoder store. volatile long encoderValue = 0; // Raw encoder value void setup() { pinMode(MotFwd, OUTPUT); pinMode(MotRev, OUTPUT); Serial.begin(9600); //initialize serial comunication pinMode(encoderPin1, INPUT_PULLUP); pinMode(encoderPin2, INPUT_PULLUP); digitalWrite(encoderPin1, HIGH); //turn pullup resistor on digitalWrite(encoderPin2, HIGH); //turn pullup resistor on //call updateEncoder() when any high/low changed seen //on interrupt 0 (pin 2), or interrupt 1 (pin 3) attachInterrupt(0, updateEncoder, CHANGE); attachInterrupt(1, updateEncoder, CHANGE); } void loop() { for (int i = 0; i <= 500; i ){ digitalWrite(MotFwd, LOW); digitalWrite(MotRev, HIGH); Serial.print("Forward "); Serial.println(encoderValue); } delay(1000); for (int i = 0; i <= 500; i ){ digitalWrite(MotFwd, HIGH); digitalWrite(MotRev, LOW); Serial.print("Reverse "); Serial.println(encoderValue); } delay(1000); } void updateEncoder(){ int MSB = digitalRead(encoderPin1); //MSB = most significant bit int LSB = digitalRead(encoderPin2); //LSB = least significant bit int encoded = (MSB << 1) |LSB; //converting the 2 pin value to single number int sum = (lastEncoded << 2) | encoded; //adding it to the previous encoded value if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderValue --; if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderValue ; lastEncoded = encoded; //store this value for next time }12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364#define Mot­Fwd  3  // Motor For­ward pin#define MotRev  5 // Motor Reverse pin int encoderPin1 = 2; //Encoder Out­put ‘A’ must con­nect­ed with intreput pin of arduino.int encoderPin2 = 3; //Encoder Otput ‘B’ must con­nect­ed with intreput pin of arduino.volatile int las­tEn­cod­ed = 0; // Here updat­ed val­ue of encoder store.volatile long encoder­Val­ue = 0; // Raw encoder val­ue  void set­up() {   pin­Mode(Mot­Fwd, OUTPUT);   pin­Mode(MotRev, OUTPUT);   Ser­i­al.begin(9600); //initialize ser­i­al comu­ni­ca­tion    pin­Mode(encoderPin1, INPUT_PULLUP);   pin­Mode(encoderPin2, INPUT_PULLUP);   dig­i­tal­Write(encoderPin1, HIGH); //turn pullup resis­tor on  dig­i­tal­Write(encoderPin2, HIGH); //turn pullup resis­tor on   //call upda­teEn­coder() when any high/low changed seen  //on inter­rupt 0 (pin 2), or inter­rupt 1 (pin 3)   attach­In­ter­rupt(0, upda­teEn­coder, CHANGE);   attach­In­ter­rupt(1, upda­teEn­coder, CHANGE);  } void loop() { for (int i = 0; i <= 500; i ){dig­i­tal­Write(Mot­Fwd, LOW); dig­i­tal­Write(MotRev, HIGH); Ser­i­al.print(“For­ward  ”); Ser­i­al.print­ln(encoder­Val­ue);} delay(1000); for (int i = 0; i <= 500; i ){dig­i­tal­Write(Mot­Fwd, HIGH); dig­i­tal­Write(MotRev, LOW); Ser­i­al.print(“Reverse  ”); Ser­i­al.print­ln(encoder­Val­ue);} delay(1000); }  void upda­teEn­coder(){  int MSB = dig­i­tal­Read(encoderPin1); //MSB = most sig­nif­i­cant bit  int LSB = dig­i­tal­Read(encoderPin2); //LSB = least sig­nif­i­cant bit   int encod­ed = (MSB « 1) |LSB; //converting the 2 pin val­ue to sin­gle num­ber  int sum  = (las­tEn­cod­ed « 2) | encod­ed; //adding it to the pre­vi­ous encod­ed val­ue   if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoder­Val­ue –;  if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoder­Val­ue ;   las­tEn­cod­ed = encod­ed; //store this val­ue for next time }  Some expla­na­tion about the code. This code will run motor in For­ward direc­tion for some time and then run in Reverse direc­tion mean­while we can get the encoder val­ue at our Ser­i­al Mon­i­tor. When motor moves in for­ward direc­tion encoder val­ue will incre­ment and if motor moves in reverse direc­tion the encoder val­ue will decrease. This is very basic code just to get idea how we can get encoder val­ue from the encoder. In next post we will se how we can per­form posi­tion con­trol using PID on N20 motor. Encoder val­ue cal­cu­la­tion Encoder pulse per rev­o­lu­tion = 28 so one rota­tion of out­put shaft = Encoder pulse per rev­o­lu­tion X Gear Ratio So pulse per one rota­tion = 28 X 100 = 2800 Pulse per rev­o­lu­tion.
Motor

Motor

  • 23HS Series Mounting Bracket M...
    $14.06 $26.15
  • Metal Wheel 65mm for Soccer/RC Car
    $61.88 $95.3
  • 12V N20 Metal Gear Motor 300RPM
    $67.59 $125.04
  • DC Motor 37GA Mounting Bracket...
    $18.29 $34.75
  • DC 12V 4L/Min Microw Diagram High Pressure Water Pump
    $42.5 $84.15
  • A4988 Step Stick Stepper Motor...
    $27.97 $48.95
  • Servo Motor Micro SG90 360 Degree Continuous Rotation
    $46.02 $87.9
  • Cooling Fans 12VDC for CPU Hea...
    $20.73 $36.28
  • 12VDC 80W Micro Electric Diaph...
    $13.5 $17.55
  • 17HS Series Mounting Bracket M...
    $10.68 $21.04
  • DC Motor 130 Mounting Bracket ...
    $31.5 $55.76
  • BTS7960 Motor Driver 43A Modul...
    $28.03 $54.66
  • DC Motor 390 Mounting Bracket ...
    $27.5 $54.18
  • 37GB 12V High Torque Gear Motor – 500 RPM
    $38.33 $55.58
  • 12V DC Motor 2000 RPM
    $60.19 $76.44
  • DC Motor 360 and 365 Mounting ...
    $22.84 $34.26

© 2026 - ROSANNAPAPINI.IT