Part 2 of my documenting of my robot project focuses on the just completed “Smart Motor Controller”. I call it a smart controller because, unlike other motor controllers on the market, mine utilizes feedback from the motors to precisely set wheel speeds and report back how far the robot has traveled.The brain of the controller is an Arduino Pro mini, pictured in this post. The actually driver H-bridge is a Ardumoto from SparkFun.
The MCU has four outputs, PWM and direction for each channel (left and right); as well as 6 inputs. Four are from the two quadrature encoders, each encoder has two outputs. The other 2 inputs are battery voltage and current. The reason I check voltage and current is to provide data to the main MCU to calculate battery remaining, and for the motor controller to limit how much current is being drawn from the battery. If the current goes above a threshold, the motor-controller will override the speed commands sent to it, and reduce power.
I wrote my own communications protocol between the motor-controller and main MCU. Basically, the main MCU will send it 4 bytes, a header byte, a signed speed byte per wheel, and a footer byte. The motor controller will acknowledge by sending 8 bytes in return. A header/footer, as well as distance traveled since last request, voltage and current, all as two byte signed ints. If no command is given to the Motor Controller within 2 seconds, it will stop the motors as a failsafe.
As I continue with this project, the distance traveled as reported by the motor controller will be used in augmenting GPS data for more accurate localized position.
More to come! Be sure to check out pictures of the motor controller on the Photos page.
****Source Released**** motorcontroller1_0