January 24, 2014

Fun With Encoders

Time to play with some microcontrollers!

For now I'm starting out using the mbed platform.  Think Arduino but faster and fancier.  I spent a lot of time using these in the lab over the summer, so that's what I'm using to get things up and running.  Eventually, I'd like to switch over to a BeagleBone Black, but there's a fairly large learning curve there that I'm not going to jump into just yet.

To sample the encoders, I first used the convenient QEI library.  Testing with this quickly showed me that one of the stock encoders was borked.  Upon opening it up, I could see a chip out of the encoder's glass optical disc.  Disassembling it revealed even more sadness on the surface of the disc.


Fortunately, I had a pile of fancy encoders scavenged from a lab cleanout over the summer, so I grabbed one of those.  The stock case and connector were extremely bulky, so I 3D-printed a new shell.

Stock:


Modified:


The new encoder is coupled to the motor by a timing belt from the motor's back shaft, and is held in place by some pieces of laser cut Delrin.


Adding this new encoder made another problem apparent.  The new encoder has 2,500 lines per revolution, over the stock encoder's 500, giving a resolution of 10,000 steps per revolution in quadrature mode.  The QEI software library just couldn't handle the pulse rate.  I could manually wave the robot arm around and get the microcontroller to lose track of the encoder's location

Fortunately, it turns out that the processor on the mbed has a built in hardware quadrature encoder interface.  However, on the mbed the pins corresponding to the interface are used up by indicator LEDs.  Some clever guy figured out how to use them anyway, by soldering wires to tiny pads on the bottom of the PCB, and wrote a driver as well.  Each board only has one such interface, so I'll need to use two of them to drive the motors.  To sync everything, they will eventually communicate with each other over SPI.    The hardware QEI seems to have solved the speed problem.  I can wave the arm around as fast as I want manually without it skipping a step.

I also assembled some boards to interface all the electronic components together.  From top left, clockwise are terminals for power supply and motors, a pair of motor drivers with added heatsinks, two mbeds, and two encoder breakouts.


Up next:  writing some kind of control loop so the robot can actually do things.

No comments:

Post a Comment