This is a follow-up post on Programming Arduino with Arduino. I’ll show an example of the process based on the Coffee Machine timer. Just to recap the original setup, when connected to Arduino it looked something like:
Here is an updated circuit for the standalone setup:
The .sch file can be found here.
You may notice that the new circuit is almost identical to the original. The only significant changes are I/O pin assignments for easier wiring. The IC that drives the circuit is an ATMega8. I chose it since I had a few lying around but it can be replaced with ATMega168 or similar. Note that the footprint here uses Arduino pin annotations. This simplifies identification for software usage. You can get the part from here.
Note: Although not explicitly shown, the 74HC165N shift register should have pin 8 connected to GND and pin 16 to VCC.
Here’s a picture of the assembled circuit on a breadboard:
The CoffeMan.pde sketch was updated to the latest version of Arduino which makes the LiquidCrystal patch redundant. I/O pins are reassigned to match the circuit above.
First, setup a programming station as described here and place the standalone ATMega chip in the programmer. Alternatively, you can connect your Arduino directly to the standalone by following the ISP pin assignments. If you’re using a new chip, upload the bootloader as explained in step #3. Next, follow steps #4-#7 to set up Arduio IDE to upload sketches via the programmer. Open the CoffeeMan.pde sketch and hit the upload button:
Once programming completed successfully insert the chip in the target circuit. Connect it to a power source and test it.
Adding Serial Access
The FTDI USB-RS232 header is cross connected to the Arduino chip. This means the FTDI TXO (pin 4) is connected to Aruino RX (pin 2). The FTDI RXI (pin 5) is connected to Arduino TX pin (pin 3).
Note: The FTDI Pin 3 can be used as a 5v supply pin. Do not connect it to input voltage.
When connecting the FTDI cable/breakout to a USB port, a new serial port will be registered. You can start it from sketches with standard Serial.begin(…) command and communicate normally as you would with Arduino.
An added bonus is the ability to upload sketches to the chip via the bootloader directly from the Arduino IDE. To accomplish that you’ll need to follow some steps:
- Burn bootloader via programmer as shown above
- Revert the Arduino IDE preferences file to use bootloader as an upload method
- Connect a push button switch between GND and Arduino reset pin (pin #1 on the ATMega)
- Open the Arduino IDE and find the FTDI serial port under Tools → Serial Port
- Load your sketch
- Hold the reset button and hit Upload.
- Release the reset button
- Hope for the best…
The manual reset procedure can be quite annoying. From Sparkfun’s product page on the FTDI breakout, the DTR pin (pin 6) on the FTDI breakout can be used to auto-reset the chip for sketch upload. I didn’t get it quite working, but I’ll post an update if I’m successful.
This post meant to show some handy methods to convert an Arduino based projects to a standalone setup, while maintaining Arduino compatibility for programming and debugging. The method can be used as a step in the life-cycle of a project from concept to production.