Go Down

Topic: 30rpm d.c geared motor encoder error (Read 717 times) previous topic - next topic

Paul_Dbz1

Recently, I brought a N20 6V 30rpm pololu dc geared motor from here-

https://robu.in/product/n20-6v-30rpm-micro-metal-gear-motor-with-encoder/


And to test the encoder I used the code from this link of the same website.

https://robu.in/run-rotary-encoder-arduino-code/


The issue is, the encoder value just keeps oscillating between 0 & 1 . It neither decreases or increases in response to manually rotating the encoder wheel or programatically rotating the motor.

I have warped around this issue for days now. Am I missing any detail here?

vinceherman

Don't make us go look for your code.  Post it here.  Use code tags.

How do you have the encoder wired up?  Can you draw a picture of your wiring and post it here?
When the encoder is turned, you should be getting changes on 2 of the wires.  It sounds like you only receive changes on one wire.
I would want to confirm that you have both data wires from the encoder connected properly to 2 pins on the arduino.

cattledog

Quote
I would want to confirm that you have both data wires from the encoder connected properly to 2 pins on the arduino.
Run this simple test code while slowly turning the encoder to check your wiring. You should see a repeating sequence like;

11
10
00
01
11

Or the reverse, depending which direction the encoder is turned. You are likely to see repeats of the same value, but the pattern should be clear.

Code: [Select]

#define encoderPinA 2
#define encoderPinB 3

void setup() {
 Serial.begin (115200);

 pinMode(encoderPinA, INPUT_PULLUP);
 pinMode(encoderPinB, INPUT_PULLUP);

}

void loop() {
 byte a = digitalRead(encoderPinA);
 byte b = digitalRead(encoderPinB);
 if (a == 1)
   Serial.print("1");
 else
   Serial.print("0");
 if (b == 1)
   Serial.print("1");
 else
   Serial.print("0");
 Serial.println();
}

TomGeorge

#3
Aug 25, 2019, 03:19 pm Last Edit: Aug 25, 2019, 03:19 pm by TomGeorge
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :)


Everything runs on smoke, let the smoke out, it stops running....

Go Up