Someone at work asked me why I put two separate motor controller boards on the robot. Well, it would have been very easy to do so. And in my original prototype, I had done exactly that, using an Arduino UNO and the fantastic Adafruit Motor Shield. My motor controller boards use the same H-bridge chip as Adafruit’s motor shield, but that’s where the similarities end.
The core of the Dual Motor Controller is the ATMEGA328P microcontroller. Among this chip’s many talents: six of the pins can output a PWM signal. But two of them are special. Two of them can go ultrasonic without messing up the other timers!
It’s those two, in the middle, highlighted in bright red.
These two can run a PWM frequency around 32kHz, which is well within spec for the TB6612FNG motor driver, but it’s conveniently outside the hearing range for most humans. You know that “hum” you sometimes get when electric motors aren’t going at full speed? This gets rid of that! It’ll annoy all the neighbourhood dogs, though.
But there’s more!
Having a separate board for the front and rear motors made it possible to mount the optical encoders directly to the same board as the controller. A slotted disc on each wheel passes through an infrared break-beam detector, and results in a number of pulses that the microcontroller can count, which correlates to the speed of the wheel. (I can only measure speed and distance with these sensors. I’m only able to infer the direction.)
Building two separate boards also saved me a little bit of money on the PCB. OSH Park does a great job of manufacturing PCBs for me, but custom PCBs are certainly not the cheapest things in the world. At $5.00 US per square inch, they’re about the only thing more expensive than Vancouver real estate. But you get three boards for that price. So having a need for more than one board certainly makes sense to me!