Standalone Coffee Timer – Programming Standalone Arduino by Example

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:

Coffee machine timer based on Arduino

The Circuit

Here is an updated circuit for the standalone setup:

Coffee timer standalone based on ATMega8

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.

The circuit diagram doesn’t include a power supply unit. You can use a basic circuit like this or connect to any regulated 5V power brick (I use a USB wall charger like this or this).

Here’s a picture of the assembled circuit on a breadboard:

Standalone circuit. Things get a little crowded on a single breadboard.

The Code

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.

The Method

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:

Uploading the sketch with Arduino IDE via a programmer

Once programming completed successfully insert the chip in the target circuit. Connect it to a power source and test it.

Adding Serial Access

Troubleshooting standalone setups can be a pain. Although debugging with LED’s may work, I suggest connecting a serial console via an FTDI breakout or an FTDI cable. The connection is simple enough:

FTDI USB-RS232 connected to Arduino as basic serial console

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:

  1. Burn bootloader via programmer as shown above
  2. Revert the Arduino IDE preferences file to use bootloader as an upload method
  3. Connect a push button switch between GND and Arduino reset pin (pin #1 on the ATMega)
  4. Open the Arduino IDE and find the FTDI serial port under Tools Serial Port
  5. Load your sketch
  6. Hold the reset button and hit Upload.
  7. Release the reset button
  8. 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.

Conclusion

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.

Advertisements

Leave a comment

Filed under coffee, production

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s