Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with encoder on pins 2 and 3 #47

Open
dakoner opened this issue Dec 6, 2017 · 5 comments
Open

Issues with encoder on pins 2 and 3 #47

dakoner opened this issue Dec 6, 2017 · 5 comments

Comments

@dakoner
Copy link

dakoner commented Dec 6, 2017

Hi,
I'm using ros_arduino_bridge with the Pololu 19:1 CPR motor encoders: https://www.pololu.com/product/2822
The motors and encoders are attached to an Arduino Nano or UNO.

I am consistently seeing the encoder counts on pins 2/3 downscaled by a factor of 40 (for example, while rotating the wheel 1 full revolution, the wheel on A4/A5 reports the right value and the . I read up on the other issues (#29), and noticed that some motor boards use pins 2/3 and so there is a way to make the ISR use another pair of pins. However, I am just using an unshielded Nano or UNO. Either way, I also tried pins 3/5 with the ISR code and the #defines changed as suggested in issue 29- when I do that, I get no readings at all.

To control for variables, I've tried swapping the motors (problem remains on pins 2/3). I've inspected the encoder wave forms, everything looks correct.

Are there other options, such as using PORTB, or mechanisms to debug why the (apparently correct) encoder pin changes aren't leading ot the right encoder counts?

@dakoner
Copy link
Author

dakoner commented Dec 7, 2017

BTW, I was able to fix this by disabling servos. I guess somehow the servo code interferes with interrupts on pins 2 and 3.

@dakoner
Copy link
Author

dakoner commented Dec 7, 2017

Looking at servos.ino, it's clear the problem is that the servos want pins 3 and 4, and attach a servo instance to those pins. That overlaps pins 2/3 being used for the encoder.

@isokar
Copy link

isokar commented Oct 11, 2018

Hi,
just got the same problem. by default servo is attached to the same pin as encoder(kind of dumb).

@kindofausername
Copy link

kindofausername commented Aug 27, 2019

Sitting here two days and thinking my board library does not work! Thanks for the tip!

@Femi-Tofade
Copy link

@arminf82 did the ros_arduino_bridge work for you? cause it isnt working for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants