4/4/2012: The pcb version with variable motor speed, GOduino II, is on my blog http://techbitar.blogspot.com/2012/04/goduino-ii-motor-driver-arduino-uno.html
29/3/2012: Corrections to motor load calculations section.
14/3/2012: I have added a 100 uF electrolytic capacitor between motor power supply (pin 8 on the L293D) and GND. The Fritzing diagram shows the addition of this capacitor but the photos still don't. I have also fixed a few typos. INTRODUCTION
I have designed a few robots using the Arduino Uno and the Adafruit Motor Shield. Both are great for prototyping. But I found myself taking my robots apart every time I needed to build another robot. It's not cost effective to buy more Arduino microcontrollers and motor shields for every new robot project.
So I decided to design a low cost "run-time" GOduino robot controller that combines the Arduino Uno functionality and, to some extent, the motor shield's. For this guide, I have used a breadboard but could have as well soldered the GOduino on a PCB.
I have purchased a few ATmega328p (DIP) ICs with the Arduino boot-loader pre-burned, but you can buy the blank ATmega328 then burn the Arduino boot-loader yourself. The Arduino folks have suggested a few ways to do this: http://arduino.cc/en/Hacking/Bootloader
From now on, soon as I am done building and testing a new robot, I will replace the Arduino Uno and motor shield combo with the GOduino. Of course, the Arduino sketch should be modified to take into consideration that I am no longer using the programming library which comes with the motor shield.
Check the simple test code provided by Guilherme Martins (below) and you will see that it's not that hard to port your motor shield sketch into the GOduino environment.
To build the GOduino, I combined these two projects:
I) Building an Arduino on a Breadboard by David A. Mellishttp://arduino.cc/en/Main/Standalone
II) Control your motors with L293D and Arduino by Guilherme Martinshttp://www.instructables.com/id/Control-your-motors-with-L293D-and-Arduino
I will not repeat the above guides as the authors did a fine job with documentation and illustrations. I will provide visual instructions to help understand how the two projects are combined into the GOduino.
As for programming the ATmega328, I used the Arduino IDE 1.0 to program the microcontroller while still inserted into the Arduino Uno DIP socket. Once the IDE finished uploading my robot sketch, I simply removed the ATmega328 from the Arduino Uno then inserted into the breadboard.
So my next task is to retrofit my Faz3a II
line-following robot with the GOduino while I build another robot with the Arduino Uno and motor shield. MOTOR LOAD CALCULATIONS
The total max load (stall/peak load) for each motor should not exceed 600mA for a maximum of 1.2A for two motors. You can find the max/peak/stall current of your motor from the datasheet or by testing with a multimeter. This is what the L293D supports. The motors on my line-following robot are well within these ranges (360mA each at max/peak/stall). But there is a way to almost double the strength of the L293D.
It's possible to piggyback two L293D chips for almost doubling of their current. A single L293D can supply 1.2A for both motors. That's about 600mA per motor. Piggyback a second L293D and the combo can handle 1.2A per motor and 2.4A for both motors combined.
The SN754410 is pin compatible with the L293D and can provide 1A for each motor for a total of 2A for 2 motors. It's also possible to piggyback the SN754410 for 2A per motor and 4A for 2 motors.
The L293D has kickback-protection diodes for when the motors reverse direction, hence the D suffix but not the SN754410. It's a trade off. PARTS LIST
- ATmega328p (DIP) with the Arduino boot-loader burned for convenience
- L293D H-bridge (DIP)
- 7805 Voltage regulator
- 16 MHz clock crystal
- 220 Ohm resistor
- 10K Ohm resistor
- Capacitors: 100 uF electrolytic, 2 x 10 uF electrolytic, 2 x 0.1 uF ceramic, 2 x 22 pF ceramic
- Arduino Uno w/DIP ATmega328p (for programming only)
- Breadboards and wires
- 2 x DC motors (each < 600mA running and < 1.2A peak/stall)
- Arduino IDE 1.0
As with my other guides, feedback and corrections are most welcome.