Saturday, May 19, 2012

High Sleeper cabin bed lights - Driving the LED chain

In previous posts (part one and part two), I've been talking about running 5m of LED strip light under a child's cabin bed to illuminate the play area. Here we are going to talk about how we are driving the full LED chain from our little microprocessor.

For testing purposes, in the previous circuit, we only included a single LED. This single LED was setup to only draw around 1.5 mA, as this was all it needed. The output pins of the microprocessor are rated to around 20mA - anymore than this and you are going to destroy the chip and have to throw it away. The 5m LED string draws around 2A - about 100x the pin rating - so we need to find another way to connect it to the microprocessor.

The way to do this is very straight forward - you use a transistor. In this case I have chosen a "metal oxide semiconductor field effect transistor" or MOSFET. These are a good choice for this circuit for a couple of reasons. Firstly, they have a nice high current rating (often into the 10's if not 100's of amperes) and, secondly, they can be driven from the logic level output of the microprocessor without the need for an interface circuit.

So, here's our plan

MOSFET LED Switch

The rest of the circuit from previous has not changed apart from replacing the LED and resistor.

The three pins of the MOSFET are called the Gate (the one on the left), the Source at the bottom, and the Drain at the top.

In our case, we are using the MOSFET as a switch, so it can be in one of two states. When the OC0A pin is low it is open, it does not allow current to flow between Drain and Source. Conversely, when the OC0A is high the switch is closed and it allows all of the current to flow between Drain and Source.

The resistance from the gate to either the drain or the source is so high (to the order of 10MOhms) that it needs a pull down resistor to the source, otherwise we would get unpredictable results when the output pin is not driven. Here I've chosen a 1k resistor, but any value between that and 10k is fine. Without this you might see the LEDs flash on at power up while the microprocessor starts up before it pulls the output pin low.

 While the gate to source resistance is very high, it can also be thought of as a small capacitor somewhere in the 1000's of picofarads. The upshot of this is that, when the OC0A pin is set high, it would effectively be shorted to ground while the capacitor charged up. Therefore we add the 10R resistor to limit the inrush current this would cause. This also has the effect of creating an RC damper circuit, so it will slightly reduce the switching speed, but not by an amount that will affect us.

I could probably leave out the 10R resistor, as not having it will not detrimentally affect the action of the circuit.

Electrify your mind

A few weeks ago a colleague sent me this link, partly as a joke. So, in return - again, partly as a joke - I thought I'd make him one.

Transcerebral Direct Current Stimulation is one of those scary phrases that conjures up images of white tiled Victorian hospitals with an overpowering smell of bleach, but apparently it's all the rage. In the last few months there has been an article in New Scientist and a couple of posts to Boing Boing so it's not going to be instantly fatal.








tDCS Stripboard Photo

The circuit itself is simply a LM317 configured as a constant current source set to 1mA, with a LED battery test function. By choosing a 1k ohm current limiting resistor for the test LED I was hoping that it would be a helpful feature, but, unfortunately, it still lights reasonably brightly even when Vbatt is down at 3v. This means that it's not very useful as a battery test, meh.

tDCS Circuit Diagram
(Order of SW1, R1 and D1 may vary, but it doesn't matter)

A more useful battery test feature would be to turn on the LED when Vout approaches (Vbatt - Vdo), as this would be the point that the battery is no longer providing enough voltage to maintain 1mA through the probes.

Measuring the output current using the internal resistance (tiny) of my multimeter it was reading 1.02mA - and a very low resistance load is a worst case for compliance, so I'm happy that it is to specification.

So, Mr S. if you do actually try using this, please don't turn yourself into either a superhero or a vegetable, I'll never hear the end of it.

High Sleeper cabin bed lights - The LEDs

So when we got a high sleeper cabin bed in our house a few months ago, it turned out to be a bit dark underneath. So what does a good honest electronics geek of a dad do? Install LEDs of course.

I found, on the delightful treasure trove that is ebay, whole strings of surface mount LEDs on self-adhesive strips. Like these


At five metres long, this is good enough to go around the two long sides and one short side of a standard bed frame, underneath the highbed lighting up the play area underneath. Included on the strip with the LEDs are the right resistors to act as the current limiting element. This means that you can wire this up directly with a standard 12v PSU. To run the whole 5 metre length you need 24W PSU (capable of delivering 2A @12v ... P=VI, remember?)



If you don't want to use the whole length of the strip, or can't fit it into the space you need, it has marked cut points every 40mm (or 3 LEDs) along the whole length. Below you can see two sections with the cut mark in the middle.


Because we now have 300 individual LEDs spread out evenly, the light underneath is beautifully flat and shadow free. It's almost like florescent light, without the annoying flicker and breakable tubes.


Now, the next obvious step is to hook this up to an arduino and build a dimming control.

Monday, January 30, 2012

High Sleeper cabin bed lights - The Circuit mk1

This post in the continuation of a series, starting with part 1.

When you're starting something new, especially in electronics, it is always a good idea for your mark 1 version to be as simple as possible. This is especially true when working with a new tool chain, new programmer, and you don't have any debugger at all [1]. Consequently, this version does not have any input controls and it only drives one 5mm LED, rather than the full strip shown previously.

So, here's are mark 1 circuit:

Circuit Diagram for The Circuit Mk1

Saturday, January 28, 2012

Hand soldering SMT packages to stripboard

Prototyping a new design can be tricky enough, but it can get even more so when the part you want to use is not available in a through-hole version. I needed a p-channel FET to run the high side switching of an LED matrix and they did not exist in a sensible package, so I made one.

Now this makes me proud - i fear no package!

Hand soldered SMD transistor package on stripboard

This is a Rohm P-channel MOSFET (RTQ030P02) in a TSMT6 package. The black package body is 2.9mm by 1.6mm.

The process to make this little guy is pretty straight forward, although kinda fiddly.

Friday, January 27, 2012

LED encapsulated in hot melt glue

In a future project that I'm working on right now, I need to fix some standard 5mm LEDs into 6mm holes through an 18mm thick sheet of MDF. The final idea is to drill the holes all the way through the MDF and then cover the front with a 0.6mm birch wood veneer, sliding the LED all the way through from the back and fixing it in place with a hot glue gun.

Now, this got me thinking. How are the LED packages, which are rated for 100-125 degrees centigrade, going to handle the 200 degrees of hot glue? An experiment was in order.

5mm LED encapsulated in hot glue pt1

5mm LED encapsulated in hot glue pt2
It lives!

Right, that's enough work displacement for the moment - now I've got to get back to working out why my AVRISPmkII refuses to talk to my ATtiny44v.

Thursday, January 26, 2012

First contact with an MSF receiver

Back in May last year I wanted to play with an MSF receiver, so I went and bought one from PV Electronics. This first video is just powering it up for the first time after connecting the wiring loom and antenna. The LED shows the raw MSF datastream that is being received. (The TO-220 package you see at the beginning is a good old faithful 7805 voltage regulator.)


A few weeks later, I was prototyping it out and hooking it up to an Arduino UNO. I had a TLC5916 LED driver chip hooked up and running an 8 bit binary count on the LEDs you can see. If you look at the indicator LED on the receiver board, you can see that something isn't quite right.



Something is generating RF noise in the 60kHz band (which is perfetly acheivable by the components on the board). You can see that, depending on the orientation of the ferrite antenna with respect to the breadboard, the noise comes and goes.

I'm not sure whether this was because of the the long curving wires from the Arduino Uno to the breadboard acting as an antenna; or if it is because of switching noise from the TLC5916 as it drives it's output FETs with the PWM train.

In those infamous scientist words, "More research is required"