It’s very messy and my not be of much use, but here it is:
Here are the pin mappings for my Digital IO on my Arduino:
5 & 6 are PWM waves to a dual channel MC33926 motor driver carrier (also by pololu ) for rightside motor.
10 & 11 are also PWM waves to the motor driver carrier (IE: the other motor) for leftside motor.
Rightside motor’s yellow encoder wire is connected to digital IO pin 2. Rightside motor’s white encoder wire is connected to digital IO pin 3.
Leftside motor’s yellow encoder wire is connected to digital IO pin 13. Leftside motor’s white encoder wire is connected to digital IO pin 12.
The above set up works (in the sense that turning the wheel one way or another increases/decreases the count) for the RIGHTSIDE motor.
Using the PololuWheelEncoder class I write a quick test program as:
#include <PololuWheelEncoders.h>
PololuWheelEncoders encoders;
int count;
void setup(){
Serial.begin(9600);
count = 0;
encoders.init(2,3,255,255);
encoders.getCountsAndResetM1();
}
void loop(){
if(encoders.checkErrorM1())
{
Serial.print("ERROR");
}
count = encoders.getCountsM1();
delay(100);
// Serial.print(count);
Serial.print(count);
//Newline serial write
Serial.write(10);
Serial.write(13);
delay(500);
}
However, while the RIGHTSIDE motor’s encoder works well in the above specific setup, the LEFTSIDE motor’s encoder returns 0 and -1 and ERRORS (using the checkErrorM2())
I think it’s something to do with the changed Interrupt Services provided in the Arduino Uno Rev.3 that has the interrupt->pin mappings declared incorrectly in the PololuWheelEncoders.cpp file. Any useful documentation on how to rewrite it?
Funny things I noticed…
If I swap the LEFTSIDE motor’s yellow and white encoder wires (IE: Now yellow->12 and white ->13) my RIGHTSIDE motor’s encoder stops working.
Switching my RIGHTSIDE (working) yellow and white encoder wires from (2,3) to (4,7) also has the RIGHTSIDE motor encoder working. Of course, you need to change the encoder object initialization to encoders.init(4,7,255,255) instead of encoders.init(2,3,255,255).
When testing both encoders together I’ve also tried instantiating another encoder object.
IE: instead of
encoders.init(2,3,13,12)
I have
encoders.init(2,3,255,255)
encoders.init(13,12,255,255)
No luck however…
In all above mentioned examples I checked and double checked that I’m using the right pairs corresponding to getCountsM1() and getCountsM2() in getting my counts.
IE: In scenario “encoders.init(2,3,13,12)” I use getCountsM1() for pair (2,3) and getCountsM2() for pair(13,12).
If its important, I’m using the Arduino AVR ISP mkII programmer. I tried different programmers available in the Arduino 1.0 IDE as well (AVR ISP, Arduino ISP) but no such luck.
Any advice/comments/ideas on stuff I could try would be well appreciated. Sorry for the lengthy post.