Switching from PWM to I²C

     As I wrote a few weeks ago, I built a videogame-style controller for my robot, Rocky. At its most basic level of operation, Rocky can be controlled with just three analog voltages, corresponding to the velocities of its three motors. I generated these voltages using an Arduino that output three PWM signals that were then RC filtered to rough analog signals. It's a very simple circuit and it fits a 2"x3" board, but unfortunately it didn't mesh well with my motor controllers. The Arduino PWM frequency is 1KHz while the motor controllers are reading input at somewhere above 1MHz, which means that even when well filtered, the "analog" signals were still extremely rough from the motor controller's perspective. The motor controllers expressed their disapproval quite loudly, and the motors were heating up much too quickly for my comfort. I decided to replace the PWM/RC signal with a true analog voltage source, so I got a DAC chip with an I²C interface. I had no idea how easy this was and I wish I had done it to start.

     I²C is a wonderful serial interface that can connect all kinds of different digital circuits together using two wires. This allows you to control potentially hundreds of different devices with two output pins. There's also a library built into Arduino, so it's easy to implement. The hardest part is going to an individual IC's datasheet and figuring out what messages to send it, but even that isn't too difficult (at least not in this case). My new jacobian function is about fifteen lines longer than the original. Now the controller's working beautifully, my motor controllers are happy, and my motors aren't burning up. Wonderful.