Fred’s new brain is built on the Sparkfun Arduino ProtoShield Kit, though other protoshields would work too. It would make a good basis for other animatronic or robot projects as it is designed to be plug-in.
Wired onto this are
- four I2C connectors, with terminating pullup resistors.
- Two connectors for controlling separate L298N motor controllers
- Connectors for stop switches for the L298N controllers
- Connector for eye position indicator.
I have a WiiChuck connected into its standard position in A5-A2 via a short extension to a male header so it can mount on the front of the case.
The I2C connector pins are configured -,SDA,+,SCL with the ground pin to the left where the board has a row of ground holes. I chose this pattern as I read that it is good to separate the SDA and SCL lines when using ribbon cables for I2C. As I ended up using Cat5 ethernet cable for my I2C wiring, I could have matched the pinout to one of the other standards. When using Cat5 for I2C, I trim off the brown pair, connect all the stripe wires to ground and allocate the three remaining solid color wires to +, SDA and SCL. This twists each signal and power wire with a ground wire to reduce interference. This works for me.
4.7k pullup resistors tie the SCL and SDA line to +
The I2C connectors are used to plug in the dome and eye position sensors, which are absolute position encoders and a 12 button keypad – all of which use the MCP23008 I/O expander. I have one port spare which was going to take the head sensor, but that ended up on the headset instead connecting via the WiiChuck.
The motor control ports are simple 6-pin male headers designed to connect to these L298N controller modules via a 6-way jumper wire. The L298N is a dual motor controller – actually it is a chip with four half H-bridges. While the normal way to use it is to drive two motors, I am connecting it in its parallel mode for twice the load capacity as the wiper motors are pretty beefy. You could use other controller but these ones are cheap on eBay ($6) and plug in easily, giving access to all 6 control pins. Some modules reduce the pin-count by two by adding an inverter giving you forward and back modes only. This uses less Arduino pins but you lose the braking modes. When configuring the L298N in parallel all the pins need to be paired with their mirror counterpart. On this module this means connecting the middle pins together, the outer pins together and the other pins together, and soldering a pair of wires across the back between the outputs. The motor control ports are adjacent to pins 9 and 10. These pins were chosen as they are controlled by Timer 1 which can be adjusted without impacting other functions in the arduino. The enable pins (outer pins) are connected to the arduino pwm pin and pulled up with a 4.7k resistor to the row of 5V holes. The next two arduino pins on either side are connected to the other motor control pins with 10K resistors. These resistors allow the stop switches to pull down the signal without pulling too much current from the arduino pins. The stop switch connectors have the two middle pins grounded and the two outer pins connected to the motor control inputs. This is easier said with a schematic. Using these cheap external controller is a good alternative to the more expensive integrated shields, particularly if you are operating higher power motors that might fry the controller.
The eye position indicator connector is a straightforward breakout of the +5V and digital pins 3, 4 and 5. This connects to a little board with three LEDs and resistors on it which are programmed to indicate to the operator if the eye is too high, too low or just right, as it is hard to judge from inside.