Sunday 25 November 2012

Toothbrush time...

It's been a while since I've had time to post, in between working on Sunrise and full-time work, but I thought I'd post a few shots from a teardown of my Oral-B toothbrush, as it was badly in need of a new battery.


 The toothbrush in question was the top of the line one - I believe later versions are a bit fancier now, but it was pretty expensive, and after a few years use, the battery life had dropped from 4-5 days or so down to about 1-2 days between charges.

The battery is a NiMH tabbed cell, soldered in.  The choice appeared to be between approx. 55 quid for a refurbished brush, or £8.30 inc. P&P for a new cell.  I decided to take the latter option... despite Braun's warnings that doing it yourself will knacker the water seals.  Frankly, for less than a tenner, you're not going to lose much even if the brush does suffer from water ingress at a later point.

Getting the thing open wasn't too hard - there are tutorials on Youtube, but the internal plastic retaining clips were a little more fiddly than anticipated... thankfully didn't snap the induction coil wire when it gave way!


Under the LCD screen, there was lurking an MSP430, which was slightly surprising, as I'd have thought they'd be using a more cut-down controller for something like this.  Certainly in the lower cost brushes, I seem to recall seeing an unknown uC.

In any case, even an MSP430 cannot run off 1.2V so there must be a boost converter  on there... probably that little SOT package just below, as there's a chunky-ish inductor just above it.  I presume that the motor runs directly off the battery via. a MOSFET under control of the MSP430, as the boost converter is unlikely to be that efficient at this low a voltage.


The charging circuit looks pretty simple.  I haven't traced it out, but noticed that it's a pretty slow charge, so probably nothing exotic.


Here's the old battery in place, with the retaining spring removed between the motor and the battery.  Note that there's actually quite a lot of spare length in the chassis - the original battery is 42mm long, but you could probably fit another 10mm or so in there.  Such a shame that it wasn't ever so slightly longer to take a regular AA.

They've also decided that a 0.1uF cap across the motor terminals was necessary... wonder if this is for RFI or whether it was adversely affecting the microcontroller in some way.



New battery in place.  The cell is rated 2000mAh, and is allegedly a Sanyo, so of decent quality.  The terminal strips were a little wider than the original but are easily cut down with scissors as the metal is so thin.

And then, put it all back together again... still charging, but seems to be fine so far... :)


Monday 14 May 2012

JLH gets regulated (temporarily)...

Over the weekend, I tried to get modify some of the high efficiency DC/DC converter boards to output 26V for the JLH, by replacing most of the passive components with different values suggested by TI's design software, but not a great deal of joy was had - while they will happily do 26V into no load, the under voltage lockout/ramping doesn't appear to be right as they only output around 3.3V when connected up to the amp... ah well.

So why not try plugging into the linear bench supply?  If memory serves (I built it a few years ago), this is LT1084 based, so capable of decent grunt with the die cast aluminium case acting as a heatsink.  The outputs have been configured for a voltage of around 33V.

First results are promising with an 8 ohm load - modulation is now down to almost nothing, and the noise floor is much flatter... but there's a lot of high order harmonics present that weren't seen before in the unregulated supply.  Let's try reintroducing that hand-wound 2mH 0.03 ohm choke between the supply and the JLH... hey presto, much cleaner!

(Note: signals are still being normalised to 0dBFS)

It's important to remember that most linear regulator ICs are not good at suppressing higher frequency noise... that said, it is surprising just how big an effect the choke is having.  The performance is now very impressive indeed for a simple circuit, and fully satisfies a basic objective criteria for a "clean watt".

Let's go further and try it with a 15 ohm load again, this time comparing to the measurement reference DAC being used as a source in these tests.  The DAC is based around an old WM8740 evaluation board whose heart has been replaced by an AK4396 in the name of better objective measurements... here's what it looks like inside...


All the mains circuitry in the picture is purely for charging - when in use, the design is disconnected from the mains and the DAC runs fully off battery power, with digital input coming via. optical for electrical isolation - this eliminates the possibility of annoying ground loops at the input end.

The measurement reference DAC is driven with a 24-bit 96kHz test signal, captured by a modified LynxTWO-B board with AK5394 A/D conversion... this is as high as the board will take in its current form via. S/PDIF, and appears to give good results... while it is certainly possible to achieve lower distortion than this (the simplest means being high order filtering around the test tones), the results are plenty good enough for a basic check point.


Putting to one side the second and third order harmonic, the JLH closely mirrors the distortion and noise of the input signal... in fact, if anything, you could say that the JLH appears to have "cleaned" the signal up a bit - this suggests that the output of the DAC probably would benefit from a little bit more filtering.

This is pretty good performance and suggests I should build up some linear regulators as soon as possible for the JLH so I can go back and listen to them again!  While a discrete regulator would be interesting to play with, I've ordered some LT1083 to do an initial first run with, as the design seems to work so well with even a traditional series regulator.

Friday 11 May 2012

Class A contender no.1 - JLH 1969

When it comes to audio, in my opinion, quite often simple is good, sometimes best.  It's very easy to overcomplicate designs and introduce additional problems, only having to add additional parts to ameliorate basic flaws.

A perfect amplifier, as someone once said, is a piece of straight wire with gain.  While there are plenty of line level ICs such as opamps capable of vanishingly small levels of measurable distortion, achieving the same with much higher levels of current and voltage is much more taxing.

As has been said, running in Class A gives a head start in terms of low distortion, as it avoids the problem of crossover distortion in Class B amplifiers, where the amplifier switches fully from sourcing to sinking current, or vice versa.  To lessen the problem, Class B amplifiers are often offset biased to become a Class AB, so that the amplifier operates effectively in Class A for a fraction of its rated power.  This is very effective at reducing crossover distortion, but as Class AB amplifiers tend to be designed for much higher powers (and therefore, typically run on higher rail voltages), the bias amount tends to be fairly small to keep consumption down.

For the sake of a single clean audio watt, I believe that (with mains power at least!) Class A is probably the best way of achieving the goal... as an added benefit, Class A circuitry tends to be simpler which means from my perspective, less componentry to sully the sound.  An excellent reference on the subject of Class A amplifiers is the Class A amplifier site, run by Geoff Moss.  The site focuses on variations of an amplifier developed by John Linsley Hood, or JLH as he is often referred to.

JLH came up with quite a brilliant little Class A design which was the subject of a Wireless World article back in 1969, and is still a reference today.  It uses just four transistors, one input level PNP, a mid powered NPN for phase splitting and two beefy NPN power transistors for the output.  As was common for the time, this is a single rail non-complementary design which means you can really go to town on just one rail of power supply and not worry about how complementary your output pair really is.


One of the reasons why the design needs so few active parts and can run single rail is due to the simplistic biasing and that both the input and output are AC coupled (so coupling capacitors in the signal path).  Some audio enthusiasts run a mile at the thought of capacitors in the signal path, but I am not one of them.  Providing the cap is of high quality, I'll happily take one over a far less linear active device which will leave a much bigger sonic imprint (to my ears, anyway).  They also provide a degree of safety over that inevitable time when then the bias "wanders" and there is an unpleasant amount of DC going where it is not desired...

I won't go into the circuit operation in detail as far wiser heads than me have debated it in great detail over the years, but it can be read as a simple three stage amplifier.  While I've grown to have a fondness for FETs over the past few years, the sound of a JLH amplifier has always stuck with me, so thought it was an excellent bipolar-based design to start with.

As someone who's designed a few bits of audio kit in their time (and still do, when time permits!), it feels a little lazy to use someone elses' PCB, but you have to value your time when it comes to these things... there is often little point in reinventing the wheel, particularly when going after a fairly faithful recreation.

I decided to start with the first iteration of the JLH design, as this is the simplest (and you could argue, purest) form of a bipolar Class A that you could wish for.  I found a seller on eBay that does what appeared to be authentic looking 1969-design PCBs with the added bonus of supporting more modern component pinouts if you wanted to try different parts.

On the whole, I was keen to stick close to the original transistors, with the exception of the output transistors... by all accounts, the OnSemi MJE15003 are considerably superior to the originals in this design and so could be used without hesitation.  TO-3 packages are a pain to mount compared to the more modern TO-247/TO-3P as they usually need an angle bracket when using with a PCB... this is then thermally coupled to the primary heatsink.


For extra security against misalignment, I put PTFE sleeving around the TO-3 pins... this ensures even if the TO-3 packages somehow wiggle their way to making contact with the metal, no shorting should occur.  Fancy alumina ceramic shims (about 1.5mm thick or so) were used to thermally couple but electrically isolate the TO-3s from the heatsink, with liberal use of good quality thermal paste in the sandwich. This naturally gives a bit more lead inductance but reduces stray capacitance.

I chose to keep the original 2N3906 PNP (using a Magnatec part which should be very close as a second source to the original Motorola version) for the input transistor, though for the NPN splitter, I ended up going with a 2N1711 branded part with lovely-looking gold plated leads - the 2N1711 was endorsed by JLH as a superior replacement so feels authentic enough.  All transistors were tightly Hfe matched, across both pairs and channels.  I would have preferred higher Hfe parts but out of 16 power transistors, the "best" were around 50ish, with a lot of them much lower.

There didn't seem much point to throw exotica at this first attempt, so you won't see any teflon capacitors or tantalum resistors here - the input cap is a salvaged WIMA Polypropylene from an amplifier refresh, and the output capacitors are effectively "no name" Forever-branded units of basic merit.  The decoupling capacitors are good quality Rubycons, bought in for the job


 I socketed R5 in the picture so that I could tune the output to be half the rail voltage as JLH recommends, but the fixed 100K was so close to half rail already that I took the trimmer pot out and put the 100K back in.

For the sake of getting things up and running quickly, I wanted to skip the regulated supply and try one of the many simple unregulated supplies floating around here of many voltages - unfortunately never quite the *right* voltages, it seems!  Commandeering a set of 2x25V 160VA toroids from Antrim, back when Maplin used to sell more interesting componentry, I put the secondaries in parallel, rigged up a simple full wave rectifier and threw a big Elna Cerafine on the output.  Hm... a bit high... off-load DC voltage was something like 45V!

This design is meant to run off 27V for 8 ohm loads... more could certainly be tolerated by the parts in question, but that it going to get properly toasty at that, never mind being worried about the health of the some of the parts from a voltage point of view.  A bit of thought, and I remembered that there were a couple of 100VA toroid cores spare which I'd intended to wind chokes with... a spool of 30A wire and a patient Anna resulted in two simple chokes of approximately 2mH each, and very low DCR.  These were put in series with the rectifier, and kept well away from the mains toroid in use.


As the angle brackets were rather oversized for the job, it was thought that it would function as a basic heatsink for now - after all, it should be only 30W or so per channel.

Both amplifiers were gingerly powered up, and gladly showed signs of sane biasing the first time around, rail being between approximately 32 and 35V.  The bias starts off fairly low and stabilises at a considerably higher point, being similar for both channels... the bias appears to be very sensitive indeed to temperature - just grabbing the heatsink with your hand is enough to affect the bias to a significant degree, which does sound like an element of the design that will benefit from slightly more complexity!

Ok... enough of this faffing about, let's get them into the main system and see how they sound.  First night impressions were very positive indeed... while I wouldn't call the resulting sound "airy", it certainly came across as more beguiling and of fine definition.  I've experimented with many amplifiers over the years but have usually come back to my humble Arcam Alpha 8Ps... a quite traditional (and relatively complex) Class AB amplifier with a complementary MOSFET output stage - the JLH was certainly bringing something new, though quite hard to define.

Let's see what some measurements show.  For sake of brevity, I'm just going to show some normalised 24/96 65536-point FFTs of a 1kHz input... load is a 25W wirewound power resistor of either 8.2 or 15 ohms.  This lets you see the harmonic spectrum, and give a great deal more information that any single THD figure will.  While these traditional measurements only give, IMO, a small insight into the sound quality of a device, the order and shape of the harmonics can be quite revealing.  There have been alternative tests proposed for quite some years, but this a reasonable starting point.

Let's start with a 15 ohm load first.  This was done at considerably less than a watt as the MF+HF units will rarely get anywhere near a full watt... if they do for any length of time, I'll probably have my fingers in my ears, and perhaps the neighbours might want a word...

The first thing that is immediately obvious is that the JLH output is being modulated, probably from mains harmonics... at a relatively low level, but nevertheless impacting on the sound.  This is likely to be a combination of the very primitive unregulated supply and the primitive biasing arrangement.

The second thing that struck me is how much (relatively speaking) high order harmonic distortion the Arcam has.  While this amplifier will no doubt measure very well in terms of a THD figure, the harmonics of this single test tone are spread across the whole frequency range.  Second order harmonic distortion in my experience is fairly benign and is generally overwhelmed by the speaker contribution, so isn't worth worrying about unless of a very high quantity... third order is a bit more concerning, and I'll generally like to see it below -80dB on the reproduction front, and fifth and above odd harmonics preferably below the noise floor.

A high noise floor is evident on the Arcam, possibly down in part due to the high gain that this amplifier offers, considerably higher than that of the JLH - I suspect when the JLH is given a better power supply and better biasing, the noise floor will drop further to go with the lower modulation.

Let's have a look at an 8.2 ohm load now, at close to a watt - this is considerably harder than I'm putting on the amplifier at the moment due to a resistive attenuator network for gain matching, but is interesting for comparison purposes.

Note that with the more difficult (albeit still only mostly resistive) load, the modulation on the JLH output has dropped considerably.  The JLH second harmonic is quite high (which would lend a rather poor THD score, for what that's worth - not very much) and slightly higher on third harmonic, but aside from a few odd glitches, higher harmonics are pretty much absent.  Odd order harmonics on the Arcam are visible all the way up the 15th, and this isn't even with extra averaging.

So the Arcam isn't very good objectively at low power levels... consistent, yes, but not particularly low in even basic distortion tests.  The JLH is already sounding good, although these results do suggest that the modulation will be impacting on the sound - hard to know if this is being perceived positively or negatively at the moment.

In any case, there is more work to do on the JLH... whether I will attempt to modify the existing boards or start afresh, I'm not sure, but it's certainly worth some more listening hours!  :)

Wednesday 9 May 2012

The perfect watt...

And so we move neatly to the subject of amplification.  The amplifier in a system is generally dictated by the speakers, as different speakers have different requirements.

Broadly speaking, the majority of modern commercial speakers are in the region of 86-90dB/W/m, which is what I'd class as "mid efficiency" units.  These can be driven to modest levels by almost any amplifier, but ideally 20 watts or more, depending on how wild the impedance curve is.

Heading into the realm of drive units designed for high SPLs (a typical example would be for PA use) are units in region of 95-100dB/W/m... I class these as "high efficiency" drive units, which typically have very powerful magnet systems and lighter diaphragms.  There is a penalty (other than the typically high price) in that the lighter cones often lack the critical damping of lower efficiency units, which can lead to considerable colouration in the sound... however, the gains can be worth it.

Once you are beyond 100dB/W/m, you are in "super high efficiency" territory.  While even a 100dB drive unit may only be technically a few percent efficient in terms of converting electrical power into sound, these units are vastly more efficient than a conventional unit due to the log scaling.  The use of horns in particular can allow (given enough space!) very high SPLs from only a handful of watts.  If you are prepared to spend serious money, then 110dB/w is feasible!  At this point, an amplifier is practically unnecessary - a liability, even.

Back in the real world, we have limited resources, and without the space for large horns (or wanting to deal with their own set of issues), "high" efficiency is a reasonable goal.

My own speakers are essentially divided into two.  A bass driver operating essentially in free air, which is very inefficient, and a midrange and HF unit of relatively high efficiency.  While the bass driver requires a powerful amp, ideally of at least 100-200W in power handling, the midrange and HF unit are never likely to see more than a watt in typical use.

You can further lower the workload on the MF+HF amplifier by taking advantage of the fact that there tends to be more musical energy at the low frequencies than the high.  By moving the high pass filter from the speaker crossover to before the amplifier input, you can reduce the load by 3dB or more, depending on the music.  Do note that this is fine for a midrange like the TD15M Apollo which has insane (>500W) power handling as even if the amplifier goes DC, the speaker won't care, but it's a really bad idea to DC couple any kind of high frequency driver without suitable protection in place.  Be warned that it can be an expensive lesson...

The high power demands of the bass driver realistically limit choices to a Class AB or a Class D solid state amplifier, which aren't very interesting from a purist point of view, and this drive unit is only covering a few hundred Hz with fairly quick rolloff, so let's not concern ourselves with that for now.  What is interesting is the watt for the MF+HF, which covers roughly 250Hz onwards... the bulk of the sonic spectrum.

So we want a good watt... how to get it?  The immediate answer is Class A operation... whether it be a single output device or a push pull pair, "always on" operation yields the lowest distortion, but unfortunately also the lowest efficiency.  For a single clean watt, we can sacrifice efficiency and still keep power consumption within manageable limits.

(Do note that I've seen a Class D amplifier that idles at over 20 watts, so it can be dangerous to make assumptions purely based on topology!)

There are some very well known Class A designs that put out a few nice watts, and I've been endeavouring to build them up to try with the speakers... time to build, listen and measure... in that order.  :)

Tuesday 8 May 2012

Speaking plainly...

Audio is difficult.  This is the conclusion I've managed to come to after a decade or so of practising in the art.  Many systems are good at one or two things, but to cover all the bases is incredibly hard.  Being pragmatic is to decide what particular aspects are most important to you, and to focus on achieving those primarily.

Take my speakers, for example.  I'm certainly not a speaker designer by trade, but I know what's most important to me... low distortion and an even tonality with no undue emphasis, particularly in the upper midrange.  I also hate cabinet colouration, which led me to come up with a speaker with no cabinet, or baffle for that matter.  Throwing away these things greatly hurts efficiency and creates potential nulls in bass response, but that is the price that needs to be paid for a small, relatively light footprint which doesn't suffer from the usual smearing of sound as the cabinet resonates.

Losing efficiency in one area of the design like this requires high efficiency, high power handling units to compensate for the shortfall.  I've long since used Lambda Acoustics TD15M Apollo for mid/bass duty (a big 15" unit with stupendous power handling and a curvilinear cone for wide frequency response) but the thought occurred to me that it could be used for a pure midrange.  With the Raal ribbons on top, that is potentially a 95dB/W midrange upwards block, which could be driven by its own small amplifier.  No baffle step compensation should be necessary here, as that can be incorporated into the bass driver crossover, which will have to be driven relatively hard to achieve any bass.



I had been mulling over the idea of a baffle-less speaker for a while, but this created a problem... how to support the drive units?  A bit of a discussion was had with a talented carpenter called Russell who's turned some of my (rather poorly drawn) ideas into reality before, and eventually settled on the idea of a V shape as a support.  This had a potentially interesting property of dividing the rear wave energy, which may help ameliorate nulling problems to a degree.  He builds out of thick birch plywood, which is an excellent material acoustically - a light year away from the typical MDF used in most speakers.


The magnets of the drive units neatly slot into the supporting holes.  The idea was to bolt the drive units together, but in an attempt to reduce transferral of energy through the front baskets, oil-based clay was used to cement the units into the mounting holes - this proved sturdy enough to support the drivers, with some sorbothane spacers keeping things at the right height.

I haven't said much about the 15" bass drivers so far, which are high Q units similar in design to the TD15Ms... I had a bit of a trial with them, discovering that one unit had a cracked basket long after I'd purchased them - the speaker company in question was not particularly helpful in the matter, but thankfully I was able to epoxy the basket to what appears to be adequate strength, and distortion performance appears unaffected.

As said, the nature of the design means that the bass drivers need to be heavily equalised in order to produce any reasonable bass.  In the case of these drivers, a low pass filter was pretty much all that was needed to bring things into line, after attenuating the midrange+HF suitably.

The attenuation of midrange+HF to get a decent bass response worked out to approximately 12dB, which really isn't too bad, although does mean the effective efficiency of the bass driver has been reduced to roughly 78dB/W!  With roughly 200W power handling, that is enough to play reasonably loud, but it won't blow the house down... that was not on the requirements list.  :)

The crossover is relatively simple... second order on the bass driver, first (high pass only) on the midrange, and the tweeter is effectively fourth order, if memory serves.  Response looks something like this, about 15-20 degrees off axis...


It's a fairly even response with mainly dips rather than peaks, and a gentle roll off at the top end unless you're sitting bang on axis... the limited vertical dispersion of the ribbon is a bit of a price to pay for the excellent sound quality it provides, though this could be ameliorated with an "ambience tweeter"... something I've been meaning to try for over a year now but haven't got around to!

Once the crossover was gotten into a reasonable shape, I stopped messing with them and just started to listen to music... which is how it should be, really!  They have their limitations (primarily the small sweet spot), but perform well with a wide range of musical genres.

The big gap in efficiency between bass and midrange+HF suggests biamping would be an excellent idea - perhaps a high efficiency Class D driving the bass, and a high quality small Class A driving the midrange+HF.  Now there's a thought...

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.  :)