Single DIN carputer with WiFi
Right, so this is only my second post here... been lurking on and off for a while, and thought it was about time to let you all know what I've been up to!
I've just graduated from a 4 year computer science course at the University of Bristol (UK), and for the last 4 months or so I had my dissertation to write, based on a piece of practical work that could also be commercially exploitable.
Last summer (2004), some friends of mine went war-driving, and in the process, made the casual comment about how cool it would be to transfer mp3s to a carputer over 802.11.
Ok, so that isn't the most novel thing in the world (well, I realise that now, having read this forum a bit)... but I wanted to get this to a place where it would be commercially exploitable and as easy as possible. Thus, I set about cramming a full mp3 / wifi system into a standard DIN headunit... what follows is possibly a slightly inaccurate (and definately not chronological) account of how I went about it, and it's current status:
1) Rough Planning
Below is a rough block diagram of how I wanted the system to hook together:
- Display - 20x4 character LCD
- Radio - USB controlled D-Link unit
- Buttons - Hacked PS/2 mouse
- Wireless Bridge - provides 802.11 while still allowing WOL
The maximum internal dimersions of a DIN are 178 x 170 x 50, with a chunk taken out of one corner for the connectors, and a faction more width and height at the very front. Knowing this, it very quickly became obvious that no consumer motherboard would actually fit in the space available, let alone allow space for other components. So, I had to find me an industrial embedded motherboard to fit (and have USB, audio and ethernet inc. WOL onboard). I chose an LE-362 from Commell Systems.
I planned to lay it out roughly as below - it was gunna be tight:
2) Case & Amp
So I needed a DIN case. I figured I could rip the stock unit from my aging Vauxhall Astra (for which I didn't have the keycode) and replace with another from a breakers yard (for which I got the keycode). This plan went very nicely, until I lsot the keycode for the latter, leaving myself without music for most of the duration of the project!
So, having recieved what was actually a very user friendly case from my old stereo, I also ripped the amplifier chips out of it, and contructed a very simple 4-channel amplifier from them.
I apologise for image quality - all the pics I currently have were taken on a camera-phone, and thus very ropey!
From that test setup, I realised I'd need an eletronic form of volume control, as when hooked up to an external source at low volume, the signal-to-noise ratio was hideous (unsurprisingly).
3) Main Components
To run the system, I'd already decided on setting up an x86 PC within the head unit. I installed Gentoo GNU/Linux on it (as is my preference) and got useful things like networking and audio working.
I chose an M1-ATX for power, which initially was being power from an old PSU hanging around from my first PC. I had to destroy an ATX motherboard connector salvaged from a very old PSU to provide wiring on the PSU itself, as there was never going to be enough room to get the supplied connector to couple with the M1. This made rigging the system (expecially later on) a slightly fiddly job.
The wireless bridge was a WGE111, the warrenty on which was almost immediately invalidated as I ripped the plastic case off (which included de-soldering the aeriel from the PCB), took the switchgear off (more on that later) and destroyed the RJ45 connector, soldering a custom 1" cable to it, to fit directly onto the motherboard's ethernet header.
A word of warning regarding the WGE111 - it will only ever recognise one IP on the wired network and refuses to provide connectivity to any other wired device
The HDD is a 40Gb Seagate Momentus, with a 40-44pin laptop IDE adaptor. Unfortunately, these adaptors are designed to plug into a pre-existing IDE cable, not directly into the motherboard, and refused to work. It took every single one of the 40 data channels to be swapped on the disk-drive's end before it would work!
4) LCD Nightmare
So, I was going to integrate an HD44780 based LCD display into the stereo. That's nice and easy, as the HD44780 is very common and there are 4 different Linux drivers for it! Well, it was easy... eventually!
The problem was (as I found out on a few occasions), the motherboard was labelled incorrectly. Not only that, the manual was also incorrect, but in a different way! So, when taking my one and only 26pin parallel port connector (the motherboard has 2mm pitch headers, rather than the standard 2.5mm), I was happily getting pin 2 swapped with pin 13, pin 3 with pin 2 etc... I was using a very understanding eBayer for my supply of LCD units, and sent the first one back as defective (having tried three of the four linux drivers, with no success). Figured it out on the second unit, but by the time I had it work it had been soldered onto so much that I was having to solder directly onto lines in the PCB... which broke very shortly afterwards, prompting a desperate plea for help (with the project deadline rapidly drawing in), and a very fast displatch of a third LCD.
But, it works! I use the LCD-Linux kernel driver, allowing my custom written program to write to a character device (/dev/lcd) as if it were a terminal, and the text appearing on the screen.
I'm sure there are more graceful ways of doing this, but I decided to rip apart a cheap PS/2 mouse to use for the control interface. I got hold of the chip from inside (a Topro TP3388ap), looked up the spec and built a new "mouse" on a breadboard. I matrixed 6 buttons onto the three available on the chip, leaving one combination for null and one for an error condition. I also took the switchgear from the scrollwheel and used it on the Y-axis to act as a jog-dial for the front panel.
The wireless bridge also needed some control - both power and access point / ad-hoc modes needed physical controls. These were achieved via two DPDT push switches, thus allowing a tri-colour LED to indicate if the power was off (red), or the wireless was on in access point (green) or ad-hoc (orange) mode. The LED and bridge were both powered from the 5V STBY line from the M1, with diodes in place to allow it to draw from teh standard 5V when the system is powered on.
Finally, an analogue potentiometer was used to control the volume of the audio provided to the amplifier.
6) Building into the case
By good planning (or good luck), everything more-or-less fitted!
I hacked together supports for various components from balsa wood or acrylic sheet, which a number of components held in place my foam. Therefore, teh force of the case shutting would hold everything in place in an almost completely screwless design. The disk-drive in particular was held in purely by foam to try and provide some shock insulation. It's only at this point that things actually start to look promising...
I custom wrote the software myself (mainly because I was doing a software based degree and I wanted to get some marks). Initially I tried using ALSA for my audio output, but for some reason it wouldn't play properly, despite the code working perfectly on my desktop. I resorted to using the OSS emulation layer on ALSA, which works just fine.
The mp3 decoding is achieved using libmad, and the control events are gathered by directly reading /dev/psaux. Using FFTW, I created a spectrum analyser for the LCD display. I also started putting an sqlite backend on the system, to allow fairly intelligent playback schemes, when...