AVR Basics: Reading (and writing) flash contents

Programming on a target board

From our forums comes this interesting question:

   ”Is it possible to download the contents of an ATmega168/328, essentially backing it up so that it can somehow be restored later?

For example: Let’s say I have lost the source code to a very useful program currently residing on a 328, but I need to flash it with a different sketch temporarily, then restore that original sketch. This would be useful in the case that the chip was soldered directly onto a board – a big mess to try to replace.
Is this possible in some way, perhaps by altering an ISP programmer?”

The answer is that yes indeed, it is possible– with a couple of exceptions that are worth mentioning. And on occasion, it’s even very useful. Continue reading

More cool electronics tools

Cable tie tool 1

What is it? Hint: your life depends on tools like these.

Some time ago we wrote about five relatively obscuretools for doing electronics. But, five tools barely scratches the surface of the stuff out there, and here are a few more of our favorites. In this roundup we’ve collected some handy–and even important –tools along that you might not have seen before, along with some best-of-breed versions of everyday electronics tools.

Continue reading

Tricks of the trade: Twisting wire bundles

Wire Twisting - 23

A common problem that you may come across when building “a box” to do something– whether a one-off gizmo or bona fide scientific instrument –is the rats nest of wires. A similar problem occurs when you need to run a bunch of basic wires out from your box to other devices. Unless there’s a standard cable lying around that does exactly what you need, you can end up with messy tangles of wires outside of your box as well.

There are many well-known solutions of course, as varied as elegantly laced wiring harnesses, cable tiesand teflon spaghetti sleeving, heat shrink tubing and cold shrink tape, and (possibly for the brave and/or insane) duct tape and paperclips.

Wire Twisting - 25

One of the other basic methods– well known to many people who build electronics –is to twist wire bundles with a hand drill and a friend. This is a quick and awesome trick that makes durable cables, short or long, exactly to your specifications, and shockingly fast.
Continue reading

Basics: Serial communication with AVR microcontrollers

Serial Port Added

One of the distinguishing characteristics of beginner-friendly microcontroller platforms– Arduino, PICAXE, and a few dozen others– is that they neatly wrap up and hide the nuts-and-bolts details of interfacing with the hardware.

Like everything else, it’s a blessing and a curse. The benefits are clear: A new user who has just acquired an Arduino can plug it in, blink an LED, and have a working demonstration of two-way serial communication in just a few minutes.

The drawbacks are a little harder to see. When you just use one line of initialization that calls a “library,” it’s easy to overlook exactly what’s involved: how many lines of code have invisibly been added to your program? What memory structures have been allocated? What interrupts are now going to disrupt program flow and timing? There’s also a portability issue. We often hear from people who got started with Arduino but now want to explore other AVR microcontroller systems, and don’t know how or where to start the migration process.

In what follows we discuss a minimal setup for serial communication with AVR microcontrollers, and give two example implementations, on an ATmega168 and on an ATtiny2313. While this fundamental “AVR 101″ stuff, we’re approaching the problem (this time) from the migration standpoint. Suppose that you had an Arduino based project, where you relied on serial communication– using the library functions–between that hardware and your computer. From there, how would you migrate to a stand-alone AVR microcontroller with similar functionality, or even to a different microcontroller?
Continue reading

Soft Circuit Merit Badge

Soft Circuit Merit Badge15
The proliferation of spoof, nerd, science, and electronics merit badges has demonstrated that geeks like to show off their skills and accomplishments. One skill is particularly appropriate for the format: soft circuitry. By building your own soft circuit onto an actual badge you can demonstrate your mastery.

Soft Circuit Merit Badge14
The size of the badge is just right for a simple circuit with a battery, a switch and an LED. The crowning touch is that the stitched circuitry can form the circuit diagram as well.

Continue reading

Five Electronics Tools You Might Not Know About

resistor bendersuction toolchip inserterusing the crimperchip remover

You’ve got your wire strippers and your soldering iron…now what? You probably know that there is a standard set of essential tools that you need on your electronics workbench. You can find helpful lists of these tools at Lady Ada’s site and Dan’s Data.

However, real tool junkies always want just the right tool for the job. Here are five electronics tools you may not know you were missing. These esoteric tools go a bit beyond the basics that everyone should have.

Continue reading

Using AVR microcontrollers: Minimalist target boards

USBtinyISP and simple target

This is a quick how-to guide on making ultra-simple development boards for programming AVR microcontrollers. Most recent-vintage AVRs can be programmed through an ISP (in-system programmer) connection; all that is really needed is a place for the chip to sit and a way to connect to the programmer.

That’s where these minimalist AVR “target boards” come in. These little boards cost only about $2 and take only a few minutes to make.

It turns out that I build a lot of these because asking “how do you make a circuit to program the AVR?” is really the same as asking how you can program an AVR that is in a circuit. And, we might as well start with a simple circuit.
Continue reading