Tuesday 28 February 2012

Building a better 12V supply

I've recently been on a bit of an efficiency drive, replacing more light bulbs with LEDs in an attempt to reduce the ever-growing electricity bill, and it occurred to me that one of the most important things to focus on is appliances which are on 24/7.

We're generally pretty good at switching stuff off, as I've put "kill switches" on all the main groups of stuff like the telly and computers, but the cable modem and router tend to be left on all the time.  I'd never bothered to check what kind of power they were using, but saw that they were linear-style "wall warts" and as a result probably not very efficient.

Measuring the two together with the little "Energy Monitor" block brought a figure of 12W (16VA, 0.61PF)... which isn't awful although could probably be a lot better.  As they both use 12V,  I thought I'd try a few of the switching supplies I had lying around to see if any could do better, only to find they had a horrid power factor and were not much better at around 9W.

So I decided it was time to have a go at building my own.  A fully switched supply can be efficient and operate at a near 1.0 Power Factor with suitable correction, but they are not commonly (yet) efficient at lowish powers, as the cheap adapters I tried demonstrated, though are likely to become so in the next few years.  A good compromise is to use a fat toroid (a house staple!) and high efficiency rectifier bridge followed by a DC/DC converter.

Looking on eBay, I chanced across this unit here.  It's a wide input range (16-40V) buck converter board with good efficiency that looked ideal for the job... so for less than eleven quid, I bought one.  When it arrived, I was slightly disappointed at the lack of the shown Oscons but nevertheless worked fine when I added a wodge of input decoupling.  With a test load of 726mA and trimmed to 12V, I calculated an efficiency of 96.4% for the unit for an input of around 17V, which is very impressive!

The unit is based around a TI TPS40057 synchronous buck controller driving a pair of Toshiba TPCA8016 60V 25A N MOSFETs... good quality parts... you'd struggle to build it yourself for the UK parts cost alone.

Building the supply

So with the converter in place, I needed to pull the other items together.  Main thing I was missing was a case, which was dutifully purchased so it could be put into something!  First thing to be installed was the toroid which is an encapsulated 2x6V 50VA unit... ideally go as big as you reasonably can for this kind of thing as power as wasted in the copper resistance, but for the low drain on the supply, this wasn't a major issue.

For the rectifier bridge, I went with a favourite choice of mine, NXP PMEG3050 - these are very efficient, very small 30V 5A rated Schottky diodes which have a commendably low voltage drop at an amp or two.  They were mounted to a little piece of vero board using copper tape, and screwed to the top.

As I wanted the unit to be able to power at least four 12V items, I went for four sockets on the back, all individually polyfused.  The appropriate LEDs on the front will dim if a fuse trips, indicating a problem - there are far more sophisticated things you can do but this would be enough to stop one device turning off the whole lot.  Even though the LEDs only run at ~1mA, they are plenty bright!

I added a few ferrite clamps to suppress some of the inevitable switching noise, and with some additional decoupling I was pretty much there, short of a few hours with the hand drill cutting out the holes!

And ended up with this...


The module looks so small in comparison to everything else!  In retrospect, I really should have put the toroid further over to the right as it would have freed up some more space for decoupling but too much on the input will hurt the power factor.

Here it is in situ, next to the cable modem and router..


The LED lights are a lot brighter than it looks here!  I think blue LEDs are a bit noughties now, but I had a bunch doing nothing, so why not... to prevent them from being eye-piercingly bright and to not stick out, they were sawn down and sanded to near-flat to give a more diffuse effect. 

Any good?

So... the point was to save some power - did all this work pay off?  Well, the consumption of the new 12V supply running the same gear came out at 7W (9VA, 0.76PF) which is a saving of 5 watts.  Not bad!  I could have increased the PF to around 0.8 by fitting a choke but couldn't find a satisfactory way to mount it... maybe at a later point.

Bigger gains will be had when more equipment is added to the supply - in particular a NAS is likely to feature at some point... have yet to decide which one best suits our requirements although the Silverstone DC01 is looking strong for good performance and low power consumption.

Probably time to consider a Gb router too... :)

Monday 27 February 2012

Bus tracker lives!

And so for the first project on here...

Here in Edinburgh we have these wonderful posts with LCDs on them that tell you when the next bus is coming.  On a Sunday, the buses are less frequent as you'd expect, so it's handy to judge your leaving time with reasonable accuracy... there is a web site but we don't always have a computer on (hard to believe, I know!) so I decided to make my own equivalent for the house!

The basic ingredients are a computer with ethernet, some form of display, and a button to change what is being displayed.  Plan was then to put it all inside a cheap canvas frame which could be painted up to look a bit like a bus...

The Computer

There are a number of small computer-y things lying about the house, but I eventually settled on a Bifferboard as I had a couple of them spare from an audio design that didn't quite suit.  This a little 486-compatible SoC with USB and 100Mbit ethernet that typically runs OpenWRT... the handful of GPIO ports made it ideal for the job.

 
It took a little while to get OpenWRT set up correctly and flashing a useful image, but once finally done, that's it!  When building an image from scratch, you *really* appreciate having quad cores in your dev machine... it takes a little while.

The Display

My immediate reaction was to go for a 20x4 LCD as it's similar to size used on the actual bus trackers, and also have familiarity with HD44780 displays from my work on the Zero One Ti48 transport.  It needed to be large so as to be visible from a distance - most are far too small for this kind of application.  Rapid came good with the Winstar WH2004L unit which isn't too expensive and is nice and large.


I was tempted to go with the white on blue a la the Ti48 but figured it was nicer to have black on green as it's what the real bus trackers use.  As HD44780 displays are parallel, conventionally they need quite a lot of pins to drive, which is a shame as the Biffer doesn't have a huge amount available.  You could use a USB to Parallel port converter and drive it that way, but I thought it'd be simpler to use a simple HC595 serial to parallel chip to do the job off the Biffer GPIO.  So I thought...

I came across this website which seemed to have done most of the work already.  However, I found the LCD to be very unreliable (particularly initialisation) and the positioning code was missing.  In the end, I rewrote all of the code and wired the '595 latch to Enable which avoids unnecessary state transitions on the output pins, which seemed to make the LCD happier.  Other than that, the wiring is essentially the same. 

The Button (ooh!)

The Bifferboard already has a button on the front of it, but it's likely to wear out in short fashion if used day in, day out.  A cheap minature switch from Maplin was procured and wired in parallel with the Biffer's button.  Due to the sloping internal sides of the frame it wasn't very feasible to mount on the outside without glueing, so instead ended up screwing it into the inside and dropping in a shaft extender in the shape of an M3 hex spacer - hack-tastic!


The Inside

So here's what it looks like in the inside the frame.  You can see the metal L brackets used to mount the internal sheet to the wooden frame - the sheet itself is a kind of foam commonly used for advertising boards... the great thing about it is that you can cut pieces out with a scalpel, yet it is still strong enough to support the electronics.  At the top there's the biffer board with a lead going down to the shifter unit piggybacking on the LCD display.


The white plastic block is a budget-style "passive" Power Over Ethernet converter... purpose of this is ultimately to run the unit off ethernet power, but my main PoE power source is 12V so needs to be converted down to 5V before this can happen - for now, it just runs off the original 5V supply.

The Code

The code was pretty straightforward - it's a C++ application using standard POSIX calls, no special libs required as all it needs to do is pull down an XML file over HTTP, parse out the bits it wants, and display it.  It took far longer to get the OpenWRT image right than it did to actually write the app itself!  To learn where to get the XML from, I took a look at the Android Bus Tracker application, and the parameters to send were very self-explanatory.

For brevity, the parser is only *just* sophisticated enough to get the job done... rather than employ a heavyweight XML library, the code relies on certain strings being in the right place.  If they ever change the format, it will probably break the app, but that shouldn't be too hard to fix.

Power

For those power geeks out there, according to my Fluke, power on peaks at around 450mA (2.25W) and it typically sits at around 326mA (1.63W).  This is about double what my "Energy Monitor" told me, so need to take it with a big pinch of salt in future when it comes to really low power stuff!  The screen is probably taking around 80mA, most of which will be in the backlight - this could be tuned down a bit, but the unit doesn't run off batteries so not so critical

"Finished" Product

And here it is...


Thanks to Anna for doing the artwork - I think it looks friendly and a bit silly, which is exactly how I like it!  Seems to work fine - the canvas was velcro'd to the wall with some small squares of the stuff... the adhesive seems strong enough to hold a light frame like this, which is handy!

The display updates every two seconds with a new page - you can speed it up with a quick tap of the button.  Hold down the button for a second or so for a different bus stop.

Pleased to have it completed to a point where it can be used every day... projects like this tend to start with such enthusiasm but then little problems crop up here and there and it starts to drag a little - starts to feel like work!  But it's generally worth it when you're done - certainly was in this case.  :)

Time for a blog...

Hello world!  I'm Tom... a self-confessed audio geek and software engineer with an enthusiasm for electronics.  For years I've kept notes on paper of my various designs... perhaps now is a good time to start putting it on the big cloudy thing.  Maybe I'll even be able to find things now and again.  :)