Just a very quick note about this.
I upgraded my laptop to 64-bit Windows 7 a week or so ago and have just gotten round to setting it up for AVR programming. I thought for a while that I'd never get my USB programmer to work (AVRStudio couldn't auto detect my AVR ISP even after installing/reinstalling). After a little bit of searching I found this thread on avrfreaks.net. I followed the directions, allowed windows to discover the correct drivers at the end of the process and, badabing-badaboom, everything now works fine (other than the fact that I installed a 32 bit Eclipse that isn't happy...).
Sunday, November 22, 2009
Tuesday, November 3, 2009
LED Tester Mark II
Ok, so the last one I made had a serious flaw... it'd burn out any LED that couldn't take 3V... Oops! I recently bought a new soldering iron (variable temp, xytronics from allelectronics.com) and wanted to play with it, so I thought it was time to replace the LED burner with an LED tester.
Basic ingredients: wire, some resistors, an 8 pin DIP socket, a pushbutton and some perfboard. I treated myself to an automatic wire stripper the other day ($8 from Fry's), it's great! I've been using it quite a lot. No need for it in this project really, but I like to show off my toys.
Here's the basic wiring and soldering for the resistors and socket (this is what I messed up in the first iteration):
At midnight I ended up with the following "finished" product (I should have learned by now not to start late at night...):
The problem was that I'd completely wired the push button wrong. In the above wiring, the power lines are connected to the positive and negative rails on the DIP socket, which meant the LEDs lit up as soon as they came in contact with the DIP. On pushing the switch the LEDs would turn off because the positive and negative leads from the battery holder were shorted... bah!
A few days later, I came back and repaired it (button connects and disconnects +ve terminal, -ve terminal is wired directly):
A view from the top.
Single LED test. You can see the multi-LED test picture at the top of this post.


The soldering iron is much better than the Weller I'd bought (it was a bottom of the line weller min you). It heats up fast and the tip is noticeably better quality. The power cord, however, is very thick and reduced the maneuverability of the iron.
The soldering iron is much better than the Weller I'd bought (it was a bottom of the line weller min you). It heats up fast and the tip is noticeably better quality. The power cord, however, is very thick and reduced the maneuverability of the iron.
Sunday, November 1, 2009
Flashing Bat Eyes
Very simple project. You just need a 555 timer a couple of resistors, a capacitor, a couple of LEDs and a talented wife to provide a bat ;) I think she'll be adding a post on making the Halloween bats so I'll link to it once it's up.
I used the following online calculator to work out the values for R1, R2 and C1 for the standard astable 555 set up. I ended up with: R1 = 3K Ohm, R2 = 570 Ohm and C1 = 100uF (mainly because that was the combination of components that I had lying around and that gave an acceptable output wave). I didn't bother adding a switch to this one, I'm not sure why as it'd be very easy... here's the fully wired up project:
Did you notice the 9V battery clip onto an 2xAA holder? Weird eh? Useful though. I think I picked up the battery case at radioshack. You'll also have noticed that I decided to try a free-form (no perf-board) approach. It was a bit fiddly, but worked out ok. I still haven't found a combination of 3rd hand/clamp/foot/nose that works for me for these fiddly soldering projects...
Here's a couple of close-ups of the soldered 555 itself:
Most of the time I had the 555 held with a crocodile clip (on the 3rd hand). Unfortunately, I bought a really cheap 3rd hand from a market and the crocodile clips are not stable so everything kept moving around whilst I was trying to work on it... bah. At points I ended up jamming the chip into a corner of the 3rd hand base whilst pushing at it with the soldering iron. Not very elegant or skilled... any advice is greatly welcomed!
Labels:
555,
For the kids,
general electronics
Saturday, October 31, 2009
ATmega programming board
Recently I've been playing with some projects that required more IO pins than the ATtiny has to offer. I bought a few ATmega8's from ebay and have about 3 of them installed in various breadboards at the moment. All the wiring was getting very frustrating, so I decided to make another programming board to reduce the clutter and to make my life a bit easier.
The process was almost identical to that for the ATtiny header board. There are only two real differences: 1) this is a board designed to fit the ATmega8 AVR chip so it has a 28 pin DIP socket and 2) I used a bad purchase (wide 28 pin dip socket) as the female headers for wiring up to the breadboard projects.
The wiring is practically the same as the ATtiny board. If you've ever wired an ATmega to a breadboard (or to anything else) you'll easily be able to work this out. There's more room to maneuver with the larger 28 pin board as well, which was nice.
Here's the 'bad purchase':
I mistakenly bought a few of these wide 28 pin sockets (as part of another allelectronics purchase). These have been sitting in a drawer all but forgotten. I noticed them whilst retrieving the narrow 28-pin socket for this board and figured these would be useful as female header rows if I just chopped them in half. It turns out they fit really well & look pretty good too.
Saturday, September 12, 2009
LED Cube
I've wanted to create one of these for ages. There are a ton of instructables out there for how to make various versions of these from 2x2x2 cubes to 8x8x8 monsters. I wanted to make something reasonable for a first attempt, but fun enough to look at. I figured a 3x3x3 is a good start.
There's also been quite a buzz the last few months around using LEDs as both light emitters and light detectors. I wondered if the LED cube could be made more interesting by also making it detect changes in ambient light. Perhaps that's a little too ambitious for the first iteration, but I can at least plan for this feature as a software (rather than a hardware) update later on. It turns out that there's nothing extra needed, hardware wise, for light detection with LEDs (check out this post on spritemods, which is a great example: minimalism; Jeroen also posts the source code, which I'm going to "borrow" from rather liberally when I get round to trying the light detection part). Don't expect any of the light detection fangling in this post - I'm only going to describe making and testing a 3x3x3 LED cube. I mention the light detection stuff because it's cool and I wanted to pressure myself into getting round to doing it by publicly announcing my intent :)
Anyway, first things first, lets get a working cube soldered and tested.
For the initial test set up I used the following: 9 LEDs (I chose all blue), an ATmega8, 12 breadboard jumper cables, 3 alligator clips (for the cathodes), a couple of breadboards and my regular USB AVR programer and associated paraphernalia.
To make the soldering process easier I created a jig from a plastic box in the recycling bin. I made a 3x3x3 grid of holes, spaced 25mm apart (just a little less than the length of the LED cathode leads). I marked out the holes with a sharpie and then blasphemed by melting the holes with my soldering iron...
I pushed in the LEDs into each hole with the anodes (long leads) facing outwards - we're going to be soldering all the anodes in a column together later on and it seemed sensible to have them on the outside of the cube, where they'll be easier to get at. Then I bent the cathodes down 90o so that they touched the cathode of one of their neighbours.
Here's the jig with the first set of LEDs in place, ready to solder:

The middle LED only makes one connection, which makes it a weak point in the layer. I was tempted to add a couple of extra connections from it to make it more stable, but I figured that, after soldering the layers together it should be stable enough. I just added a bit more solder to that particular connection in order to strengthen it.
I tried to come up with the simplest test I could imagine whilst ensuring I was addressing each LED correctly. So my first test just powered up each individual LED in order, one layer at a time.

I've included the code below for those interested. Just bear in mind that this was specific to the way I wired up the cube. It's a shame 9 columns have to be used for this as it means using multiple registers for the LEDs, which means we have to specify which columns are on which registers. Maybe someone out there can show me a better way to do it?
Here's the jig with the first set of LEDs in place, ready to solder:
The middle LED only makes one connection, which makes it a weak point in the layer. I was tempted to add a couple of extra connections from it to make it more stable, but I figured that, after soldering the layers together it should be stable enough. I just added a bit more solder to that particular connection in order to strengthen it.
After soldering all the leads together, you gently pull each LED out of their hole. You can then pull the whole assembly away and marvel at your soldering skill ;). Then it's time to start over again...
Here's the full set of 3 layers all soldered nicely (still separate though):
Here's the full set of 3 layers all soldered nicely (still separate though):
The final step in creating the cube is to solder the layers together. There must be a better way than what I tried, but here it is: I placed one layer back in the jig, cut off a few small strips of sellotape, positioned the next layer on top so that the anodes from the lower layer overlapped enough to solder to the next layer and then secured the two layers together with the sellotape (synonym:scotch tape). I soldered the corners first to give some amount of stability to the emerging structure.
Whilst soldering the third layer I worked out that the best method was to position the lower anode lead on the outside of the upper LED, then bend about 2mm of the lower lead 90o towards the upper lead and then solder them together. The bottome left LED column in the second picture below shows what I mean:
Whilst soldering the third layer I worked out that the best method was to position the lower anode lead on the outside of the upper LED, then bend about 2mm of the lower lead 90o towards the upper lead and then solder them together. The bottome left LED column in the second picture below shows what I mean:
And here's the completed cube:
I'd not actually programmed an ATmega8 before, but it was fairly straight forward to modify my ATtiny setup. I just had to work out which pins to attach the programmer to (by looking at the atmega8 datasheet). The trickiest part ended up being getting the cube securely placed into the breadboards (I wish I'd given into a previous whim to buy one of the bigger boards now). The picture below shows my test current set-up with the cube installed.
I tried to come up with the simplest test I could imagine whilst ensuring I was addressing each LED correctly. So my first test just powered up each individual LED in order, one layer at a time.
Here's a video of it in action:
I've included the code below for those interested. Just bear in mind that this was specific to the way I wired up the cube. It's a shame 9 columns have to be used for this as it means using multiple registers for the LEDs, which means we have to specify which columns are on which registers. Maybe someone out there can show me a better way to do it?
/*
* led_cube.c
*
* Created on: September 6th, 2009
* Author: Paul
*/
#include <avr/io.h>
#include <avr/delay.h>
//define the cathode pins
//I just happened to connect them to these pins
#define LAYER1 PD1
#define LAYER2 PD0
#define LAYER3 PD2
//define which pin each column (anode) is connected to
uint8_t kColumnConfig[] = {PD3, PB7, PB3, PD4, PD6, PB2, PB6, PD7, PB1};
//store the layers in an array as well
uint8_t kLayerConfig[] = {LAYER1, LAYER2, LAYER3};
//this function switches a column on or off
//we have to know which port the column is a part of
//hence the switch statment:
// PORTD pins are at indices 0,3,4,7 in the kColumnConfig array
// PORTB pins are at indices 1,2,5,6,8 in the kColumnConfig array
void setColumn(uint8_t pVal, uint8_t pCol)
{
switch(pCol)
{
//portD pins
case 0:
case 3:
case 4:
case 7:
if(pVal)
{
PORTD |= (1 << kColumnConfig[pCol]);
}
else
{
PORTD &= ~(1 << kColumnConfig[pCol]);
}
break;
case 1:
case 2:
case 5:
case 6:
case 8:
// portB pins
if(pVal)
{
PORTB |= (1 << kColumnConfig[pCol]);
}
else
{
PORTB &= ~(1 << kColumnConfig[pCol]);
}
break;
}
}
int main(void)
{
uint8_t i = 0;
uint8_t j = 0;
DDRB = 0xFF; // all set to output
DDRD = 0xFF; // all set to output
//swich off all layers by applying voltage to the cathode pins thereby preventing current flow
PORTD |= (1 << LAYER1) | (1 << LAYER2) | (1 << LAYER3);
while(1)
{
//loop through each layer
for(i = 0; i < 3; i++)
{
//set the output value for this cathode layer to '0'
//this allows current to flow in this layer
PORTD &= ~(1 << kLayerConfig[i]);
for(j = 0;j < 9; j++)
{
//turn on the LED in column j
setColumn(1, j);
_delay_ms(250);
//trun off the LED in column j
setColumn(0, j);
}
//set the output value for this cathode layer to '1'
//this prevents current flow for this layer
PORTD |= (1 << kLayerConfig[i]);
}
}
return 1;
}
Monday, September 7, 2009
PVC Pipe Marshmallow gun
This post is a bit of a diversion from the normal electronic fangling, but it's such an easy and fun project that I wanted to share.
I was flicking through a recent purchase, "The best of instructables (volume 1)" , and I landed on page 232 - "The marshmallow shooter". It's labour day (sorry: "labor day") which means that we were having a lazy Monday at home so we decided to take a trip to Lowes to pick up the necessary bits to make a few shooters.
That's all you need (and some marshmallows). The pipe is 1/2" schedule 40 PVC, it was 89c for about 5 feet of the stuff (enough for 3 shooters). I also picked up a few different fittings: three way junctions, four way junctions, elbows (with different angles), caps and some couplings (to use as mouthpieces). I also picked up a pipe cutter; I've experienced the "joy" of using a hacksaw for cutting pipes (those ones get a brief mention on filthwizardry: music tree) . This time I decided on an easier option.
First off we cut up the pipe into various lengths, short pipe for the handles and longer ones for the main body. We washed all the bits thoroughly.
Here's all the parts that went into our first three guns:
Next up I showed the girls how all the parts fit together. I helped to tighten the parts, but that was all the intervention necessary. It's all very easy and simple. I think I'm going to get a load more of the piping and fittings and just let the kids play with it free-style sometime soon.
After getting all the parts together, they decided their creations needed to be decorated before we could use them :) We had a strange coincidence here: before heading to Lowes we popped into the local Savers (they were having a labor day sale) and what did we find in the book section? A book on making marshmallow guns (here's the Amazon link)! Very weird! Being from Savers, it didn't come with any of the piping, but it did have most of the stickers left (not anymore though!).
Time to try out the beautified guns on Lin.
They had a great time blasting (and eating) the mini marshmallows. The great thing about using marshmallows is that, strangely, there was no mess to clean up afterwards...
Labels:
For the kids,
no electronics required
Sunday, August 30, 2009
Toy Traffic Lights
This is something I've been meaning to make for ages. My kids love toy cars (ok, lets face it, all kids love toy cars!). There's been lots of car related fun in our household (some of which has been documented on filthwizardry: "Toy cars and trucks from recycling", "shower curtain village playmat" and "home made toy carwash") and one of the kids favourite pastimes in the car is to shout "RED means STOP!" and "GREEN: GO!" (as loudly as humanly possible). I figured it was about time I used this as an excuse to spend some time in the garage making something with flashing LEDs :)
Between Lin and myself we've managed to amass quite a bit of cheap 'junk' that can be hacked together for something like this. I was going to make something flimsy using a battery pack and a drinking straw, but I was persuaded to make something a bit more kid-proof using a dollar store wooden box, an Altoids tin and the tube from a black felt-tip pen. Here's a picture of all the bits (there are three 150 ohm resistors are missing):
The plastic domes are the discarded remnants of 25c kids toys purchased from a vending machine in our local Taqueria, they looked like they'd make good LED covers (and they were used as wheels in another crafty distraction: "Toy cars and trucks from recycling"). The chip is an ATtiny13.
First up was to drill some holes: two in the box, one on the side for the switch and one on the top for the pen tube; one in the base of the altoids tin (again, for the pen tube) and three in the back of the tin for the LEDs.
Then I painted it black.
The wiring for the base/box is pretty simple, just an AA battery pack wired to a switch with the main wires threaded out of the hole in the top of the box. I stuck the pen casing in at this point and threaded the wires through to the top.
Now it's time for the wiring.
First off, I hot glued the base to the Altoids tin. Then I glued the LEDs into their holes with the cathodes all facing in one direction so I could solder them together to form a ground rail.
I soldered on three, 150 ohm, resistors to an 8-pin dip socket (pins 5, 6 and 7), soldered the positive lead from the base to pin 8 on the socket. Then I connected the LEDs to the resistors and finally connected the ground pin (pin 4) to the ground rail. That's it!
When I was writing the code I didn't think ahead about which pins were going to be connected where in the final project and ended up with the red and green pins mixed up (in software), so the initial sequence was backwards; but then that's why I used a socket rather than directly soldering the uC ;). Easy to fix with a quick software update.
Here's the final working project (yes, the yellow works too, I just didn't take a picture of it):
I've included the code below. As always, it's pretty simple:
### code starts here ###
(I found a nice way of displaying code in blogger. I talk about setting it up here)
/*
* trafflic_lights.c
*
* Created on: Aug 29, 2009
* Author: Paul
*/
#include <avr/io.h>
#include <avr/delay.h>
#define RED_LED PB2
#define YELLOW_LED PB1
#define GREEN_LED PB0
#define RED_DELAY 10
#define YELLOW_DELAY 3
#define GREEN_DELAY 15
uint8_t i = 0;
uint8_t j = 0;
void delay_seconds(uint8_t pSecs)
{
for(i = 0; i < pSecs; i++)
{
for(j = 0; j < 4; j++)
_delay_ms(250);
}
}
int main(void)
{
DDRB = 0xFF;//set all to output
//start traffic light sequence
while(1)
{
PORTB = (1 << RED_LED);
delay_seconds(RED_DELAY);
PORTB = (1 << YELLOW_LED);
delay_seconds(YELLOW_DELAY);
PORTB = (1 << GREEN_LED);
delay_seconds(GREEN_DELAY);
}
}
Subscribe to:
Posts (Atom)
