I'd previously written about the poor performance of my AlphaBot Alpha Rover - Out of Control and how I was surprised that the wheel optical encoders had not been incorporated into the AlphaBot library. fmilburn had written a blog post about implementing encoder feedback using a PID controller Simple Arduino DC Motor Control with Encoder, Part 2 .
I decided that before trying to implement a PID controller that I'd just try some first order feedback trying to balance the encoder counts between the two wheels. I was amazed that the performance got worse. So, I did a simple open loop test where I swept the PWM value to both motors and measured the equivalent RPM at each step. The Blue trace is the step count (0-255). The Red trace is the Left motor and the Green trace is the Right motor. Two things are apparent - the Right motor takes more voltage to start and there is a huge difference between the two motors in terms of RPM. At first glance, I suspected that I had a bad motor.
Then I checked the output of the optical encoder. Ch1 is the Left motor and Ch2 is the Right motor.
So, besides any issues with motor mismatch, I'm also having encoder issues - most of the apparent RPM mismatch is probably due to this. It would explain why trying to add feedback would make things worse.
The encoder is pretty simple. A slotted disk interrupts the light path between a photo diode and a photo detector. And the signal gets cleaned up by an inverting buffer.
Looking at the output of the photo detector shows the problem - some of the output pulses are not reaching 3V and the spec on the buffer is 0.7 x VCC = 3.5 (VCC is 5V). So, the output is intermittent.
Unfortunately this could be a number of issues - maybe even mechanical alignment. It probably will require taking things apart and verifying everything. The Left wheel sensor looks similar, I think that buffer might have a bit more input margin.
Anyway, I barely had time to try to finish the Alpha Rover if there hadn't been any issues. So, I won't get done for the AttackoftheDrones contest, but I'll finish this off when I get the other projects out of the way. And maybe the Arduino RP2040 Connect will be available by then...
Good luck to all the participants! I'm sure I'll learn stuff from your projects that I can use .
Top Comments