Background
Why, why, why isn't there an AUX input on my car stereo from 2007?Yes 2007 was before the big era of smartphones, but everyone owned a couple of dirt cheap mp3 players and iPod was a big thing.
The HU that my car is fitted with has two super retro 8-pin DIN-connections on the back. One of which is for connecting a CD-changer "CD-CHGR" that you could have installed in the boot of the car - but who uses CDs these days?
It didn't take allot of research to find out there is already a product out there that lets you add an AUX to you HU-xxxx. The only drawback is that it sets you back $80 and most of all: It doesn't come with the awesome feeling that you get when you have hacked the stereo yourself.
Research
It wasn't an easy thing finding information on how to hack the HU, but after allot of research I finally found some really good pages that made the hack easy peasy.This is how it works:
- The source knob on the HU lacks the ability to choose the CD-CHGR until you connect the CD-changer.
- To trick the HU that you have a connected a CD-CHGR is not as easy as to shorten two of the pins on the DIN-connector, but it has to be done in code via a protocol named MELBUS
- MELBUS is a protocol that utilizes a clock pin and a single bi directional data line to transfer the data between the units and the HU.
- MELBUS uses three lines: Clock, Data and Busy see blue lines on picture below: ("Run" is just 12V from battery)
Picture source |
- In the picture above you can also see the Left and Right Audio signals that I tapped into for the AUX-input (Red).
- Focus on the left DIN-Socket (female) on the picture, that's the back female socket on the HU.
Hardware
- Arduino Nano (clone) with USB-cable - $2.5
- 8-Pin DIN male plug (pins exactly like the pic above) - $1
- 0.5m network cable - free
- 1m 3.5 mm audio cable - free (who doesn't have a drawer full of them?)
Hacking together some code
Edit 2016-11-04
A guy named Sebastian has modified my code and his version is more stable, and it also works on Mitsubishi HU and supports displaying track numbers! -Here's a link to his code!
A guy named Sebastian has modified my code and his version is more stable, and it also works on Mitsubishi HU and supports displaying track numbers! -Here's a link to his code!
Finally some programming!
I found this awesome write-up that contained almost everything I needed to fool the HU that the Arduino is a CD-CHGR. I will talk you through the process:
- Set BUSY to low for 1000 ms to make the HU run its initialization routine
- The HU init routine starts by sending three bytes: 0x07 0x1A 0xEE
- Then two bytes per optional connection device (~30 of them), the first byte being the predefined ID of the device (ex. CD-CHGR = 0x8E), followed by either an empty byte 0xFF, if the device is not connected, or the answering ID of the device (CD-CHGR = 0xEE)
Example: External CD-CHGR: ID = 0x8E and its return ID is 0xEE
Example: Internal CD-player: ID = 0x80 and its return ID is 0x86
See list of predefined addresses and returns on bottom of this site. - I.e. to simulate a connected CD-CHGR we have to:
- Trigger the HU init routine
- Wait until HU is sending out our ID (0x8E)
- Respond to that by sending back 0xEE
- Now the HU has registered that we have a CD-CHGR and it is now available through the source-knob, and will listen to the Left and Right Audio pins on the DIN-plug.
- Every time the car ignition is turned on, the HU will automatically run a secondary initialization routine:
- Starting by sending four bytes: 0x00 0x00 0x1C 0xED
- Then two bytes per already registered connection devices from the first init routine, the two bytes follows the same pattern as in the first init routine, first ID, than expecting the same answering byte as before.
- If the HU won't get an answer from the CD-CHGR, the device will be removed, and we have to set BUSY low again to call the first init-routine.
As a bonus the 12V is only active when the ignition is turned on => no extra load on battery caused by the arduino when car is not used)
The code I wrote (below) is well documented and fairly easy to understand...
I had a hard time getting the function "SendByteToMelbus(uint8_t byteToSend)" to work.
It turned out that the Arduino functions: digitalWrite(MELBUS_DATA, HIGH); and LOW are too slow for this code, (MELBUS runs at 10-12MHz) and CLK had returned to high state before Databit was changed.
To solve this, I had to go back to the old AVR-GCC technique and use
PORTD |= (1<<MELBUS_DATA); and
PORTD &= ~(1<<MELBUS_DATA);
in place of the Arduino functions.
I tried this setup without any form of ground-loop isolation and it works like a charm! Even when the engine is running and my smartphone is charging through the cigaret-socket the sound is crisp and no disturbing noise (alternator suppose to cause ground noise)
I guess one could buy an external Ground Loop Isolator ($5) to be on the safe side....
I had a hard time getting the function "SendByteToMelbus(uint8_t byteToSend)" to work.
It turned out that the Arduino functions: digitalWrite(MELBUS_DATA, HIGH); and LOW are too slow for this code, (MELBUS runs at 10-12MHz) and CLK had returned to high state before Databit was changed.
To solve this, I had to go back to the old AVR-GCC technique and use
PORTD |= (1<<MELBUS_DATA); and
PORTD &= ~(1<<MELBUS_DATA);
in place of the Arduino functions.
I tried this setup without any form of ground-loop isolation and it works like a charm! Even when the engine is running and my smartphone is charging through the cigaret-socket the sound is crisp and no disturbing noise (alternator suppose to cause ground noise)
I guess one could buy an external Ground Loop Isolator ($5) to be on the safe side....