Wednesday, July 8, 2009

Solar powered fairy lights

  
Yes, I'm going through a solar powered phase right now. I'll have used up the parts I bought from allelectronics.com soon enough & will have to move onto pastures new.

My lovely lady suggested it'd be nice to have some twinkling fairy lights in the kitchen; ideally, ones that didn't need to be plugged in to the mains. The simplest solution would have been to use a battery pack, but our kitchen gets a fair bit of light &, like I said, I'm in a solar powered gadgetry phase right now...

My ebay habit has brought me some colour changing LEDs (before I knew exactly what they did). These look like normal LEDs (two leads) but cycle through a few colours over the course of 15 seconds or so. I figured these would be perfect for the project, so I dug out 4 working ones (using the LED tester I posted about previously).

There are very few components for this (if you count the solar-panel/charger as a single component): 1 solar charging circuit, 4 colour changing LEDs, an Altoids tin, some wire and I used a couple of neodymium magnets to secure the tin onto the curtain rail in our kitchen.

The first thing to do is to cut the LED leads from the solar-charging circuit, this is where we'll attach the wires for our own lights. I also cut down the plastic 'pins' which hold the circuit board in place; this was to make the assembly fit nicer in the tin (and as an excuse for me to try out some new cutting disks for the Proxxon).

I then cut two strands of wire (about 1 1/2' each of red and black), marked where I wanted to place the LEDs/lights on the wires and striped away the insulation around these points. I ended up melting the insulation away with a soldering iron and then using a knife to scrape off the excess plastic. There must be a much better way of doing it.

Soldering the LEDs onto the wires was a little awkward, especially since I cut the LED leads down to about 1/3 cm to keep them close the the wires. I'm glad I decided to only put on 4 for this prototype! Hmmm... thinking about it now, I should have left the leads on and bent them around the other wires to hold them in place whilst soldering them, doh!

After soldering the LEDs, I drilled a couple of small holes in the Altoids tin, threaded in the two wires and soldered them onto the solar charging unit.
Slide everything into place and there we go:


My better half has been making lots of playdough for some lovely projects (see: Dinosaur Island and playdough rain table) as a result, we've used up a lot of food colouring. It turns out the bottles make quite good LED diffusers. The picture below shows the Fairy Lights in front of our kitchen window. I used two magnets to make the tin secure (the magnets are on the inside of the tin). I also ended up taking the lid off the tin and securing the solar panels in-place with a couple of elastic bands.


Saturday, July 4, 2009

Personal empowerment through skill acquisition (or how I fixed a Vtech Tote 'n Go)

Phew, what a poncy title! Well, that's me through and through :) But what I wanted to post about was how empowering learning something pretty simple like soldering has been for me.

The kids have been playing with various incarnations of Vtech laptops (ones that play 'learning' games to do with letters and numbers). Their first laptop, the Vtech Tote 'n Go, broke about 6 months ago, the speaker stopped working as did the mouse button. Normally, that'd mean landfill for this big bit of plastic, but, having learned a little bit of electronics, I took it apart to see if I could figure out what was wrong.

It turns out that the speaker wires had broken off and the small push button inside the mouse had broken completely. I got the speaker wire soldered back in place the same day, but the button fix had to wait a while. I was tempted to hack together some Frankenstein creation using the huge push buttons I bought ages ago, but decided against it (I'm sure the kids would have loved it though).

I recently found allelectronics.com (see the solar power upgrade to the fireflies) and, as part of the initial order, I bought some small push buttons which were exact matches for the one in the kids laptop. So I took a second stab at fixing it. I couldn't successfully de-solder the original button, so I just clipped it off, trimmed the leads of the replacement and soldered it in place.

All very simple stuff. I left the laptop out somewhere I knew the kids would find it and the next morning I hear our youngest waking up our oldest by crying "Carys! Carys! Come see! Come see! The monkey laptop! It's working!". It was lovely.

The shocking part of this is that our friends have the same laptop and it's mouse button has stopped working as well. I'll fix that one too, but it must mean that loads of these things become landfill just because a single button breaks...

LED tester


I have to be honest, I've not been very er... meticulous when it comes to keeping my LEDs in check. Let's be frank, I have a big mess of them and I've no idea which ones work or what colour they are. I'm about to start on a solar powered fairy lights project and realised I'd be spending a lot of time working out which LEDs were the ones I wanted (hence the subject of this post).

To date, I've been using a torn down dollar store hand fan for testing; I'll take a picture to show you what I mean:

It's not the easiest to use, but it outputs ~3V, has a switch and two leads (not obvious which one is positive and which one is ground though since they're both red). I ended up getting frustrated whilst holding the ends of the wires onto the LEDs and then switching over wondering if the batteries were dead, the LED was dead or if I was just crap at getting a decent connection between the leads.

Anyway, what all this blathering is getting to is that I wanted something simpler and more reliable to use. You know, something that doesn't make me want to throw it against the wall in frustration... I'd been messing with 8 pin IC sockets and perf board for other projects and realised that they are perfect for this as well. So I got together the old battery pack from the JarOFireflies prototype (which is why it has a magnet still glued on top), a small bit of perfboard, an 8 pin IC socket and 4, 330 ohm, resistors.

I soldered the resistors and socket onto the board at the same time.

I used the wires from the last resistor to solder all the connections on each side together forming two rails (positive and ground):

Then I soldered in the wires from the battery pack, connecting one to each rail, and voila!

The nice thing about this is that it's easy to check a single led without messing much with it's leads (since there's 4 holes a side, there's plenty of room) and it'll also accommodate, up to, 4 LEDs at a time:


This took about 20 mins to put together including frequent interruptions from the kids wondering what I was doing by myself in the garage.

UPDATE (2009-09-19): The resistor set-up I created is obviously crazy, I'm not sure what I was thinking (or not) at this point... The resistors should be separating pins 1 - 4 from the positive rail.

Wednesday, June 17, 2009

Solar powered fireflies

I've been wanting to make something solar powered for some time & figured the firefly kit would be perfect to upgrade to solar power.

I just came across some cheap, second hand, solar powered light fixtures from allelectronics, which is a great place to pick up bits and bats for your electronic projects. Here's the actual solar lights I bought - solar-cell w/charging circuit. As the description says, they come with two solar panels, an LDR, a charging circuit (including - old - batteries) and some LEDs (one LED with this particular one and three with a different product).



As you can see from the pictures, all the components are easily acessible; these seemed perfect for hacking.

My first attempt was pretty simple, I just de-soldered the battery wires from my old JarOFireflies project, snipped the leads to the LED on the solar light kit and soldered the two kits together (the leads to the LED actually have a + and - designation printed on the board).


The LED wires are solid core and quite thick so there's no worry about them snapping under the strain and it made positioning the firefly board easier too. Speaking of which, I cut down the board to a more reasonable size for this project.

I didn't know if the batteries on the solar kit were duff so I left the hybrid out in the sunshine for a full day to charge then brought it indoors to see if it works:


And it does! What a pleasant surprise for something to work first time!

I think I'll cut a hole in the original jar's lid and place the kit in it more securely. Might be nice just to put it out in the garden to confuse the next door neighbours cats who seem to prefer our back yard to their own...

Saturday, June 6, 2009

555 noisemaker

When I started off on the electronics journey I bought the solar powered theramin kit (heliophone) from the makershed I thought it'd be a fun thing for the kids and would be a good starting point for learning to solder. The heliophone uses a solar panel to generate power and produces a clicking noise (the frequency of clicks varies with the intensity of ambient light).

The noisemaker I wanted to make sounds pretty similar but runs off a battery and uses a 555 timer to generate pulses which drive the speaker. Like with the heliophone kit, we alter the frequency of the 'clicks' with changes in ambient light intensity. In this case, it uses the standard "astable" set-up for the 555 and switches R1 for an LDR.

This is a pretty simple set-up and it makes a horrendously annoying noise; so it's perfect for the kids :) My inspiration for this came from this hack-a-day post on tiny-optical-theramins.

I'd already bought a few 555s and LDRs (again due to my eBay issues) so it seemed daft not to make something out of them, especially if the kids were likely to enjoy it.



Here's the final kit. I still want to house it in an interesting way, but I'll have to employ my lady's creative talent to produce something attractive. Maybe I'll paint an alien face on the tin with the LDR sticking through as it's mouth and get the kids to 'feed' it light.


Here's a little test run I did with Ffion, she got distracted pretty quickly by stuff going on in the next room...

Monday, May 18, 2009

ATtiny header board


I've been programming my AVRs using the SparkFun set-up since I started. This is fine for the odd bit of tinkering, but it's a pain having all those wires poked into the programming cable and getting in the way on the breadboard. With an 8-pin dip, there's not a lot of room around the chip for my fat fingers to add wires.


I'd seen these breadboard headers over at Tinkerlog.com and fancied having a go at making my own using the components I'd got lying around (well, ok, I bough the male/female header pins from eBay).

First a rough idea of how I thought it should look:

Then I tried to figure out where the wires should go based on my original set-up (pic of wire mess above) and the ATtiny13 datashet.

Finally I gave a little thought as to where the physical wires were going to go on the perfboard. I decided to swap the position of the 6-pin programming header to make the wiring a little easier. I'm sure there's a better solution, but I was impatient and wanted to get on with it.


Then it was a matter of soldering everything together. I am not an accomplished solderer - this is only my 3rd real soldering project and I'm sure most people wouldn't even consider the ones I've done so far 'projects'.

First off I soldered the headers, push switch (cannibalized from a broken kids toy) and IC socket. This is pretty much how the finished project looks from the top.

Then I realise that I could bridge pins 1 and 8 using the 10K resisitor and have the resistor out of the way of the rest of the wires by having it on the front of the board.

After that it all got a little messy... I need to give myself more time to figure out wiring/routing! I guess this is all a learning experience :)




I kept the insulation on the long wires to prevent short circuits, unfortunately I also ended up melting a lot of the plastic which caused a few issues around pin 5 of the IC socket hence the blackened mess and excess solder around there... I think I managed to sort out my technique a bit better after than and the remaining solder bridges are ok (tips on creating these gratefully received!).

Here it is in action (note that I have to bring in power from the breadboard with my particular programmer).

Saturday, May 9, 2009

Basic AVR IO

I found this very confusing when I started to program my ATtiny13. I read a bunch of different sites/blogs/datasheets to get a feel for it (and am still slightly confused tbh). So, I thought I'd give a brief overview of the basics in a way that makes sense to me. I'm not going to cover input here, just output; but it's a good start.

Here's the key concepts:
  1. AVR uCs are 8-bit devices.
  2. Every AVR has at least some pins which can act as either Input or Output (I/O) devices.
  3. The voltage on the pins can be sensed or controlled via software.
  4. Because of 1. physical pins are logically grouped in sets of 8 as I/O ports. For my ATtiny13 there is only one port (port B) as there are only 8 pins.
  5. Each I/O port has 3 registers associated with it: DDRx, PINx and PORTx (more on this later), where x represents the port (in my case there's only BBRB, PINB and PORTB available).
  6. I/O pins exists as registers inside the processor. It's the software controlled contents of these registers that controls the state and operation of the I/O ports and pins.
  7. The registers are 8-bits in size. Each bit in the register determines the operation of the corresponding number pin (0-7).
DDRx
This register the direction (input/output) of the pins on port x. Again, for the ATtiny13 there is only a port B so we only have DDRB available but on other AVRs there can be many ports (e.g. the atmega168 has 3 ports B, C and D controlling 23 programmable I/O pins) .

A '0' bit makes that port pin act as input.
A '1' bit makes that port pin act as output.

PORTx
This register contains the output state of the pins on port x.

A '0' bit is considered LOW (~0V)
A '1' bit is considered HIGH (~Vcc)

PINx
This register contains the input state of the pins on port x.

A '0' bit indicates that the port pin is LOW (~0V).
A '1' bit indicates that the port pin is HIGH (~Vcc).

So let's take a quick look at the simple code I posted in "Starting with the AVR uC":

1:  #include 
2: #include
3:
4: //LED is wired into pin 7 (PB2)
5: #define LED PB2
6:
7: int main(void){
8: //set data direction register for pin 7 to output
9: DDRB |= _BV(DDB2);
10:
11: //infinite loop
12: while (1) {
13: //turn on the LED
14: PORTB |= _BV(LED);
15: //wait for 1/4 of a second
16: _delay_ms(250);
17: //turn off the LED
18: PORTB &= ~_BV(LED);
19: //wait for 1/4 second
20: _delay_ms(250);
21: }
22: }
5: define LED as PB2. This is just a convenience to allow us to refer to pin 7 as the variable LED. I have the LED wired into pin 7 and this pin is called PB2 according to my datasheet (this can be different for different uCs). PB2 is actually another variable which has been defined thanks to the avr/io.h import statement. I could have used the number 7 instead but I decided to use the name of the pin from the datasheet.

9: This sets bit 7 of DDRB to '1' without affecting any of the other bits in the register. This is the data direction register (DDR), setting a pin in this register to a '1' makes that pin act as an output. I think I should have used the LED variable (defined earlier) rather than DDR2, just for clarity. Ok, next time.

14: Here we manipulate the bits in the PORTB register. This statement sets bit 7 to '1' without affecting any of the other bits in the register. Assigning a '1' to bit 7 of PORTB sets pin 7 to HIGH (~Vcc). This allows current to flow through our LED, lighting it up (or burning it out if you've not added a resistor in serial with it).

18: This statement sets bit 7 of the PORTB register to '0' without affecting any of the other bits. Pin 7 is now LOW, no current flows through the LED (so we've turned it off).

Now, here's a little nugget of info that didn't click until my trip to Noisebridge and a chat with Mitch Altman: I/O pins, by their very nature, are ambivalent towards the direction of current flow. Let me say that again as it's something I didn't realise to begin with and it has an impact on programming LEDs with the AVR. I/O pins don't care which way current flows through them. So, if you have an LED attached to an I/O port (via a resistor) then it can be orientated in either direction (i.e. connected to ground or Vcc, it doesn't matter), the only difference will be whether or not a '1' or a '0' on the corresponding PORTB pin switches it on or off. If the LED is connected to ground, then a '1' in the PORTB register will turn it on; on the other hand, if it's connected to Vcc, then a '0' will switch the LED on.

I know I laboured that last point, but it was non-obvious to me (as a beginner) so I wanted to share. It also meant that those common cathode RGB LEDs I bought aren't as useless as I thought - I was under the wrong impression that I'd only be able to program them using 3 transistors attached to the AVR as switches, because I thought you could only turn on LEDs [with an AVR] by placing a '1' in the PORTB register... doh!