Sunday, April 22, 2012

Voltage box

Voltage box sans labels


As described in my last blog post I decided I needed a small hand held variable voltage supply box.  The output voltage would be in multiples of 1.5V to match the various multiple AA/AAA battery combinations.  Also I would also want 3.3 and 5 volts outputs.  The entire thing would be powered by a 9V battery if possible with maybe the option of a DC input.

The basis of the design is a LM317 voltage regulator.  Since the output voltage is determined by a resistor ratio it would be simple to use a rotary switch to swap what resistor was used.  Thus the output voltage could be changed and to a fixed value.  I didn't want to use a variable resistor as I would need some kind of output screen to show what the output voltage was currently.  Originally I was going to use a single pole switch (limited to 6 positions).  However that changed later as the design evolved.

Using the LM317 was quite simple.  Following the datasheet I added the various recommended filter capacitors and protection diodes and tested the circuit on a breadboard.  Using the output voltage equation from the datasheet I determined what resistors would be needed for the output voltages of 1.5, 3, 3.3, 4.5, 5 and 6 volts.  Not all the values were "standard" values but most were available.  My aim was to be within 5% of the desired voltage.

Now that I knew the resistors needed it was time to go shopping to Jaycar.  For a case I used the remote control case (Jaycar part HB5610) as it had a battery access port built into the case.  A 9V battery fits in but is a tight fit and needs a bit of wiggling to get the battery cover on.  Although I don't normally use binding posts I wanted some on this project to future proof it.  The standard way of connecting this project will be via a 2 pin molex connector exactly the same as my previous variable resistor box was setup.  This also allows me to reuse the same cables.  I might even go back to my variable resistor box and put on binding posts there too.

While doing the breadboard design it occurred to me that having an led light up as each voltage was selected would add a nice bit of bling to the project.  Much better than just a sticky label, I would have six leds and as each voltage was selected the appropriate led would light.  To enable this I changed the rotary switch to be a 2 pole 6 way type.  The original 1 pole 12 way switch went into the parts box.  I would use a 5mm red led for the power light and 3mm green leds for the voltage selection display.  I like big obvious power lights.

Needing a way to secure the leds to the case I considered hot glue but I don't like this.  Wandering in Jaycar again I came across some 3mm and 5mm led bezels.  Very nice and they give a nice clean finish.  However when I got home I obviously had this idea previously as I already had some in the parts box.  The disadvantage of doing projects very occasionally is you forget what you have in stock at home.   

After machining the case for the components I had to fit in all the components on a prototype board.  Due to the rotary switch and binding posts I lost approx. 50% of the space in the case.  All the components fitted but were rather tight.  Also having the circuit board on the bottom of the case and the rotary switch and power switch on the top of the case made the construction harder than it needed to be.  I needed to keep the wires short so they would fit once the case was closed but long enough so I had access to solder the connecting wires.  The six green leds connecting to the rotary switch needed the most fiddling to get them to fit and not take up too much room as the leds were 10mm away from the rotary switch.

Everyone says not to do work when you are tired.  I wouldn't but I'm never not tired or sick or both.  The joys of young kids.  So as expected a few mistakes were made.  Some were simple like forgetting to connect the output terminal to a binding post.  The worst was when I connected the green led power line directly to the 9V rail, not the 2.2K current limiting resistor.  On power up the green leds were either not working, really dull or bright orange.  I switched between the 6 leds a few times before powering off.  Then I discovered what I had done.  Three out of the six leds were burnt out.  Much painful unsoldering and wiggling components out of the way resulted.  It was during this work another issue was introduced that I discovered later.  I also looped the battery cables around a screw inside the case to provide strain support in case the 9V connecter was jerked out to far.

Closing the case up however one of the green leds turned off.  Open the case, it turned back on.  There was only .5mm of difference when putting the case together between the led working or not.  So some joint was flexing and disconnecting.  This led was also one of the ones that had been swapped out earlier.  A few prods with the soldering iron fixed the dry solder joint on the led.  The tight access from the short wires made access a bit of challenge.

Finally everything was together and working.  The kids love the leds and my son keeps trying to turn off the red led by pushing it like the switches on some other household items.  A bit scary to see in a one year old the learnt response that a red led is a power switch.  I just need to make up some labels.

Enough time wasted on little projects.  Time to get back to my second mini sumo bot.


Monday, April 2, 2012

Toy debug sessions

My young children have a toy tv remote that makes various fun sounds when the numerous buttons are pressed. It also has two leds at the front that light up and/or flash in sequence. A nice simple toy that keeps them away from the real remotes. This is a good idea because baby slobber gets into anything and isn't good for electronic components. A case in point proved with the hard life this toy has had.

The toy remote had survived the various sucking attacks of my daughter and now it was my son's turn. However over the last few weeks the sound coming out of the speaker was getting quieter and sometimes there was no sound at all (the lights however continued to flash). New batteries were installed (3 x AAA) but a few days later all sound had stopped. The fixitup daddy was escalated to. To the shed...

Five self tapping screws held the case together. All the buttons were on a single rubber piece that came off to reveal the pcb. However to get to the component I had to unsolder the battery terminals from the pcb so the board could come free. Straight away I noticed the large amount of corrosion at the front (where the leds were located and a prime sucking point) of the pcb. The legs of one of the leds were brown and the board was discoloured. So my first thought was that baby slime had made it to the speaker and broken/dissolved it.

I cleaned all the board is isopropyl alcohol to remove the goo. Then I unsoldered the speaker to test it. However when a voltage was applied across it's contacts crackling could be heard. So the speaker was ok. Put that part back in. I replaced the corroded led (even though it still worked, that much corrosion is just bad). At this point I was focused on some passive component having failed. Doing various tests on the surface mount resistors all checked out ok. A diode test on the transistors seemed fine. I then considered the large (compared to the surface mount ones) electrolytic capacitor. It was a 100uf 6.3v. Old capacitor, baby slime - maybe faulty? Testing the resistance across it - 500ohms. That shouldn't be so time to replace that part. Given the small space in the toy I used a recycled 6.3v capacitor from an old computer mouse. Applying power and everything worked! Another of life problems solved by replacing a capacitor.

The next day however, failure. The sound from the remote was dead again. Back to the shed.

I replaced the second hand capacitor with a new one thinking this would be a quick fix. I didn't have any 6.3V caps so I substituted a 16V one. This took a bit of lead bending to make it fit in the space available. However that didn't solve the issue. So either something else had broken overnight (unlikely) or the capacitor wasn't the real cause of the issue. Back to more circuit tracing.

The pcb was dual sided. The heart of the toy was a microcontroller hidden under the standard black glob. So working in reverse for each part of the circuit I traced backwards to the controller. There were three main parts each driven off a separate pin of the microcontroller:

* the speaker driver consisting of what looked like a transistor and a few resistors and capacitors
* two identical led drivers circuits consisting of again what looked like a transistor and a few few resistors and capacitors.

Luckily all the transistors were the same model. The two on the led circuits were working so I could use their behaviour to compare to the behaviour of the transistor on the speaker circuit. Again I checked all the end points between components (use the continuity tester on my multimeter) and tested the values of all the components. All looked fine. Next I powered the circuit and checked the voltages at various points. Again all looked fine.

Concentrating on the transistors I tested the behaviour of the led transistors. Testing the base pin on the transistor I found out it went from 0v to 0.7v when the led was turned on. The collector pin went from 4v (ish) to 0v. Ie the transistor was turned on. Now to test the speaker transistor. When sound was meant to occur 0.7v was seen on the base pin. However the collector pin stayed at 4v. A dead transistor perhaps. I bypassed the transistor by bridging the base pin to the collector. Sound was heard, but it was very soft. So the transistor should be acting as an amplifier as expected, but it was not working currently. I unsoldered/destroyed the broken transistor so I could replace it. I don't have any surface mount components so I used a generic NPN transistor in a TO92 package and held the transistor onto the appropriate pins. Sound was back and it was loud. Not as loud as originally but that was ok as the sound level before was too high.

The original transistor was a SOT-23 package so a TO92 wasn't going to fit. Also the transistor was directly under the speaker so there was no room for a through hole component. However like a lot of consumer toy there were various components on the silk screen that weren't present. Perhaps they are used in other designs or revisions? One available spot was next to the leds which was for an electrolytic capacitor. Plenty of room for a TO92 part. The leads were a bit long but all fitted. The only mar on the whole job was when I slipped and slightly burnt the speak wire.

Putting everything back together the sounds are working and there is one happy little boy who isn't trying to grab the tivo remote as much as before.

Looking back I spent a lot of time (3-4 hours) fussing around on a $15 toy. On the hourly rate test it was a failure (I like to work out based on my hourly rate how much something would take to do before deciding to do it myself or get someone else to do it or buy a replacement) but from a learning aspect it was great success which is why I persevered. Or the obsessive compulsive aspect of me kicked in and refused to be beaten.

Things learnt:

* not having a computer in the shed to look up datasheets slowed things down. I had to use trial and error to work out which pins on the TO92 transistor were what for example. I need to test if the wireless network makes it down there. Or waste time walking back to the house.
* surface mount bits are hard to unsolder. With the normal tip on my soldering iron I couldn't get solder sucker in fast enough after I moved my soldering iron out of the way.
* my guilt on having lots of components that I didn't buy for any real reason is reduced by projects like this.

The final thought now is to build a hand held portable battery powered voltage supply. I'm thinking of LM317 run off a 9V battery and a rotary switch to determine what voltage. Voltages would be in multiples of 1.5V to fix what is seen in toys with maybe 3.3V and 5V added in for good luck.