Archive for the 'Micro-controllers' Category

The Great Internet Migratory Box of Electronic Junk [TGIMBOEJ]

Friday, May 23rd, 2008
Red 7 Segment Displays

Over the weekend, I received one (1) box of electronic junk. Not just any box of electronic junk (as I have many of those, as it is), but one Great Internet Migratory Box of Electronic Junk.

As per the TGIMBOEJ rules, I took some junk treasures and replaced it with a bunch of my own junk stuff.

And, as per the rules, I took a handful of photos of some of the stuff I pulled out. Not all.

I did not take photos of the stuff I put in. That is for the next person on the list to discover fully. Some vague clues, though: I added some antique semiconductors, some power management related componentry, some completely random small bits of goodness, a working caseless gigabit switch, and a purely mechanical device that is gloriously elegant in its implementation. And some other stuff, too.

More TGIMBOEJ pr0n on the click through….

Read the rest of this entry »

Using a Vertical Stack Counter to Debounce Switches

Saturday, April 5th, 2008
3 bit counter

At left is a simple EMSL AtmegaXX8 Target Board (same board I have written about before) 3 bit up/down counter circuit.

Push the left button? Counts down. Push the right button? Counts up.

Simple.

Sort of.

The switches are fully debounced using an extremely elegant algorithm that I ran across while trying to figure out how to efficiently debounce switches with an AVR controller.

Specifically, the software uses a vertical stack count to efficiently debounce up to 8 switches in very few instructions and only 3 bytes of memory.

Read on for schematic and a description of the software…

Read the rest of this entry »

Multitasking in the AVR Microcontroller

Sunday, March 16th, 2008

Well, multitasking would be stretching it…

When writing AVR micro-controller code, you typically end up with something like this:

int main(void) {
	... initialization code ...
	while(1) {
		... main loop that never exists here ...
	}
}

The main loop spins forever and is generally the bit of code that updates various output ports based on program state. It might likely also read inputs, too. And it might contain bits of code that delays execution for a while. And it is very likely rife with conditionals that’ll cause any given pass through the loop to very in execution time.

Not a very good place to do time sensitive stuff like, say, debouncing a button press or responding to other user events.

Read the rest of this entry »

Blinking Two LEDs; Bit Manipulation Macros Oh My!

Saturday, March 15th, 2008

Before dealing with switches and debouncing switches, I wanted to add a second LED to the circuit.

Trivial:

#include <avr/io.h>
#include <util/delay.h>

int main(void) {
    DDRB = 255U; // Make all PB* -- PORT B -- pins output
    PORTB = 0x0; // turn all PB* -- PORT B -- pins off.
    
    while (1) {
        PORTB = 0x1; // B0 on, B1 off
        _delay_ms(200);
        PORTB |= 0x2; // B0 and B1 on
        _delay_ms(100);
        PORTB = 0x2; // B0 off, B1 on
        _delay_ms(200);
        PORTB = 0X0; // All off
        _delay_ms(2500); // 2.5 seconds off
    }
}

Each on/off port is represented by a single bit. So, each of the pins in PORTA, PORTB, PORTC, or PORTD — assuming they are in straight digital input/output mode and whatever AVR chip you are targeting has enough pins to have 4 port sets — will be controlled by a single bit in one of four bytes.

Clearly, some macros to toggle bits are in order. Now, it turns out that macros to toggle bits are a big source of contention amongst the AVR development community. They hide too much magic, or so they say, and, if you are going to be programming embedded systems, you ought to be comfortable with C level bit twiddling, damnit.

Read the rest of this entry »

Subversion repository for ATmegaXX8 target board hacks

Saturday, March 15th, 2008

I have created a directory in my public subversion repository for EMSL ATmegaXX8 target board code.

http://svn.red-bean.com/bbum/trunk/avr/ATmegaXX8/

AVR: Programming the EMSL Target Board from Mac OS X

Saturday, March 15th, 2008
EMSL Atmega168 Target Board

The EMSL Target Board is built around the ATmega 168 micro-controller (same controller as the Arduino — which, frankly, I couldn’t care less about other than as a source of knowledge…).

It is an extremely easy to use and surprisingly powerful micro-controller. If it weren’t so convenient, I wouldn’t be writing this.

Seriously. If you have any interest in screwing around with micro-controllers, there is little excuse not to dive in now. It is cheap, easy, and powerful.

Beyond the EMSL Target Board, you’ll also need a Lady Ada USBTinyISP programmer that has been appropriately patched (when assembled).

First, grab and install AVR Mac Pack from the fine folks at Objective Development (same source of LaunchBar and Little Snitch — both awesome products in their own right).

AVR Mac Pack has everything needed to talk to the AVR, a compiler that can target the AVR, and support for Xcode based development.


Read the rest of this entry »

AVR: Prototype Board Ready for Prototyping Pinball Flippers

Friday, March 14th, 2008
EMSL Atmel Board Populated for Prototyping Madness

Ben picked up a ton of SIP machine pin sockets from Halted recently.

I grabbed about 200 from him and populated my EMSL Atmega target board with enough to provide for both on-board prototyping and to easily break out to a bread, board when needed.

Each point accepts a 24 gauge (or so) wire quite nicely. Makes for easy prototyping while not obscuring the documentation silkscreen on the board.

Next up?

I have all the parts needed to replace an entire flipper circuit in any modern Williams/Bally pinball machine.

Thus, I should have enough parts to drive a solenoid or flash-lamp from the AVR micro-controller.

First, though, I’ll flash some LEDs in response to button presses, though. All one voltage and relatively little chance of blowing up chips, bulbs, or shocking myself.

Once that works, I’ll wire up higher voltage / current drivers. I figure I ought to be able to both replace the flipper drivers with a much more maintainable system while also adding some automatic diagnostics that will light some LEDs inside the pinball when the flippers need to be rebuilt or maintained.

AVR Microcontroller Prototype Board

Sunday, March 9th, 2008
XX8_complete

The folks at Evil Mad Scientist Laboratories whipped up an elegant little kit that includes an ATmega168 AVR Micro-controller, 4 or 5 discrete components, and a circuit board.

The Atmel AVR micro-controllers are awesome. They cross three particular barriers to entry that I arbitrarily chose prior to screwing around with micro-controllers.

Specifically:

  • Price: $10 per useful part The Atmel series ranges from less than $1/part to a bit north of $10/part for the über-deluxe controllers. The ATmega168 in this kit can be had for less than $5/each and includes 23 I/O lines (6 of which can be used for ADC), 16K of program memory, and can run up at speeds up to 20MHZ.
  • USB based Programmer less than $50 LadyAda sells a simple USB programmer (based on the Atmel chips — it implements a USB stack in software!) for $22. It works great, once you fix this particular bug (which involves replacing two resistors with wires; not hard).
  • Easy & Powerful Programmability (on a Mac) Code for the Atmel series of chips is written in C and compiled quite easily via gcc. The ObDev folks have made an easy to install package available. It just works. Better, the chips support in system programming (without sacrificing pins for I/O!) and, thus, “build and run” in Xcode re-loads the code on the target chip without having to either power down the board or remove the chip from the circuit. Edit-compile-run is very very fast.

    The code, itself, is pretty straightforward. The header files provide all the #defines needed to deal with all the random I/O based hardware functionality quite straightforward. The chips, themselves, are exceptionally flexible, with the ability to reconfigure what pins do what in software.

    The hardest part is remembering which pin maps to what random #define’d symbol.

    Mooninites & Lemur

    The Atmel chips are, in fact, the same chips (almost the same exact chip — the proto boards use a slightly less expensive part in that it doesn’t have quite as many I/O ports) used in the Peggy Board (also from EMSL). I picked up the ladyada programmer and grabbed the source from EMSL.

    I had simple animation up and running within a couple of hours, most of that time being consumed by dealing with the now fixed USBTiny programmer bug. Not much longer after that and I had a pretty neat line based animation.

    Jamie over at Noise Land Arcade else has grabbed the code and made a neat animated pacman sign (video here).

Which brings me to this kit: This credit card sized board is designed quite specifically for prototyping ATmega168 (and several others) based projects. Beyond including a bit of room for adding a couple of 8-pin DIPs (or other random components), the silk screen fully documents the various mnemonics associated with each pin.

First project?

I’m going to build modern style flipper replacement for ’80s and early ’90s Williams/Bally pinball machines. The old school flippers require more maintenance and tend to fail gracelessly, taking out other discrete components upon failure.

This board is total overkill. I really only need an 8 pin Atmel controller per flipper; maybe one chip for both flippers, if I optimize.

But at $9/each for the board, controller and discrete components (including shipping and CA tax) in lots of 10, I might just stick with building it out on the EMSL prototype board.

As with many EMSL projects, everything is open source. The board is single sided and easy to etch, but silk screening on the various documentation bits would be difficult.

Aqua Teen Day — January 31st, 2007: Never Forget.

Wednesday, January 30th, 2008

Update:

Evil Mad Scientists Laboratory has made the foundation of this build available as The Peggy for $80.

In typical EMSL fashion, that link includes tons and tons of information, including full details, board design, source, and loads of implementation notes.


So, apparently, it is being called Aqua Teen Day. Good enough.

Better yet, though, is that the fine folks of boston — the level headed public that makes the city such a great place — are celebrating the first annual “Aqua Teen Day” by decorating the city with LED art.


Mooninites & Lemur

On January 31st, 2007, the authorities in Boston completely lost their minds. It wasn’t the first time, but this particular date was heavily reported and even the most head-in-the-sand die-hard “OMGWTFBINLADENFTChildren!!!one!!!” fear mongers found it ridiculous.

I am, of course, referring to the Aqua Teen Hunger Force “Hoax Device” bomb scare.

I could go on a political rant about fear based leadership and the general stupidity of the security theater played out in our cities and airports.

But that is boring.

Lemur in Blue

I’d rather remind people of the jackassery that has happened and, once again, laugh at it. Then vote appropriately.

To that end, I purchased memorial kits from the fine folks at Evil Mad Scientist Laboratories and put them together over the last few days.

The results are just stunning. And effective. I brought the boards into work on Monday and, on the way home, stopped for a beer with boards in hand. Several folks asked about them and, upon explaining the history of the boards, they became just a touch more enlightened as to the stupidity of certain leadership and just a slight bit more inclined to learn more and vote accordingly.

MooniniteMooninite

Mission accomplished. With laughter included.

(The kits were a special edition from EMSL — you’ll have to contact them for availability. The LED “peg board” is generic; you can lay out the LEDs anyway you want to make any kind of similar display, including a “charlieplexed” mode that allows simple animations. I believe EMSL will be offering the generic form of the kit sometime soon.)

MMm…. the smell of hot solder in the evening.

Monday, January 28th, 2008
Lots of Soldering to Look Forward To!

I spent a chunk of the evenings this weekend soldering together the aforementioned kits from Evil Mad Scientist Laboratories.

As I said before, truly awesome kits.

While assembling the kits, I whipped out the camera and took a few random photos.

The kits are done, but I’m holding on the final photos until tomorrow.

So, for now, click on through for a bit of macro electronic assembly pr0n.

Read the rest of this entry »