There are no photos yet, as I've not actually done most of this - but as I progress through it, I'll add the pics and add more information as and where it's needed.
Basically, what I want to be able to do is plug my iPhone/iPod into a docking cable in my car, and have it work.
These are my requirements:
- Be able to hear music on the stereo
- Be able to charge the iDevice
- Be able to see which track is playing on the Radio LCD
- Be able to skip forward / back on the current track
- Be able to skip tracks forward / back
- Be able to utilize the MFSW for the above
- NOT loose use of the CD changer
So how am I planning to achieve this? That's the million dollar question I guess
First things first..
step 1: getting to the same state I have now (aux connection), but with charging and using the apple connector
building the dock
I've previously built a fair few aux connectors for the Z4.. it's pretty straightforward, and only costs around a fiver.
But the drawbacks to this are two fold:
- It doesn't charge the device
- It means having a dangly aux cable loitering around in the car
Well, it turns out those cables have the smallest connectors in the world and they are an absolute beast to (de)solder.
A bit of googling and research found me a product called "PodBreakout".
Here's the one I bought from Amazon for £6.59:
http://www.amazon.co.uk/gp/product/B007 ... UTF8&psc=1
This little device makes it so much easier to solder wires to the connector - solving that headache instantly.
Next I needed to figure out how to charge the device using the connector.
I knew that you could charge from both USB and from other docking devices (the apple wall plug is effectively USB, so not including that), but I wasn't sure if the docking devices were just sending +5v ala USB, or if they were able to provide more voltage on different pins.
Eventually, I found this little pinout guide, which clearly shows a couple of "firewire" pins, that run on +12v - handy!
http://pinouts.ru/CellularPhones-A-N/iP ... nout.shtml
A bit of testing and I was then able to get an iDevice to charge using the firewire pins - that's the incar charging sorted!
So now I need to fabricate a dock.
Looking at similar, commercially available units (StarDock for example), I decided to go for the ashtray as the home for the dock.
I did a bit of playing around, as I didn't want to not be able to operate the center console buttons when the device was docked and I was able to reach all but the passenger seat heating control without issue (I could reach it, but had to "go around" the device).
I found a load of these on eBay and other places. Whilst I wasn't bothered about the actual dock, what I wanted was the plastic adapters that come with it:
http://www.ebay.co.uk/itm/iPod-Universa ... 4611b2986d
Taking one of these, and my current ashtray, I intend to fiberglass the PodBreakout into an adapter plate, and then the unit as a whole into the the top of the ashtray, so it fits flush.
I'd then drill a hole in the side of the ashtray to allow me to feed the cables from the PodBreakout.
The idea being that this unit can slot directly into the ashtray hole, and when fitted, will sit flush next to the cigarette lighter and look as "OEM" as possible.
Providing the power
Simple job this.. as the dock is located adjacent to the cigarette lighter, which conveniently provides a +12v and a ground, simply bind into these and feed pins 19,20 (+12) & 29,30 (gnd) on the podBreakout PCB.
Getting the audio
Again pretty easy. Take a wire from pins 2 (gnd) 3 & 4 (audio) to the back of the stereo unit ala aux cable (need the resistor inbetween the two cables to enable the audio - see my DIY for more info)
The final step is to tell the device to play audio via the lineout, which is achieved by attaching a 68KOhm resistor between pins 15 and 21, then connecting pin 11 to pin 15 with a loop wire.
---------------------------------------------------------------------------------------------
Huzzah.. At this stage, you should have a working iDevice dock that will play audio and charge the device.
But that's not where the story ends. I am content with the device using the aux connection for audio, but I now want to be able to change track on the device.
This is where it gets a bit more involved!
Step 2: IBus integration
IBus background information
Ok heads up - this is going to get technical. I'm going to explain how the IBus works and what it can do for us.
If you're just wanting to follow the howto (as it were), you can probably skip this bit. However, it does contain all the information (hopefully) we would need!
The IBus in our cars is effectively a single long cable that connects to many things (MFSW, cd changer, radio, headlights, fog lamps, etc - basically the "secondary" electronic devices in the car).
It carries a 12v digitial signal that allows those "many things" to communicate with each other.
It is effectively identical to the KBus (the thing that connects all the ECU's and "primary" electronic devices in the car).
Data is transmitted along it in binary form, grouped together in packets. The binary values are as follows: +12v = "0", 0v = "1".
Therefore, if you are getting a +12v feed on the line, there is either no data being transmitted, or you are receiving a binary zero.
The data is transmitted at 9600bps. Each individual block of data is 8 bits long, followed by a single parity bit and then a stop bit.
This probably wont mean much to you non-geeks, so here's an example:
Lets pretend we haven't received ANY data so far (just getting a constant +12v) and then we receive this: 1010000111
Taking this apart, we have the data bits "10100001", the parity bit "1", and finally the stop bit "1".
So what can we do with this information?
Well, as I say above, the devices in your car are already talking to each other using the IBus.. so lets take a look at what they're sending!
If I press "previous track" on my MFSW, the following binary data is sent along the IBus:
10100000100000110010110100011111100000100000100110110100011010010000100010100011100000001
converting that to hex using the rules above, we have the following:
50 06 68 F0 04 68 48 10 C4
doing a bit of investigation, I've discovered that the first hex digit is the identification number for the device sending the data.
The second digit is the length of the data being sent. The third digit is the identification number for the device that should receive the data
And the remaining digits are the data being sent between the two devices.
After a bit more testing with various units, I've discovered the following "identifications"
18 = CD Changer
50 = MFSW
68 = Radio
6A = Carver amp
00 = Broadcast (only used as a destination, and can be picked up by more than one device)
So what does this mean? Well, we now know what to look for on the bus for next and previous tracks as well as skipping forward and backward.
The data being sent by the MFSW for these is as follows:
F0 04 68 48 10 C4 = previous track
F0 04 68 48 00 D4 = next track
F0 04 68 48 50 84 = skip back
F0 04 68 48 40 94= skip forward
(conveniently, this same data is sent by the headunit when using the track buttons on it!)
iDevice background information
Again, you can probably skip this bit.. it's just information on how to control the iDevice remotely
So now that we know what to listen out for on the IBus, we now need to work out how we can get the iDevice to do what the IBus wants it to do.
Luckily, this information is pretty well spread on the internet, so after a bif of googling, I found the following info:
Communication to iDevices is done via a serial data connection, using pins #12 (transmit) & #13 (recieve) on the iDevice connector
Again, the data is transmitted using the standard "RS232 8N1".
What this means is that there are 8 data bits, with no parity, and one stop bit. So, every byte looks like: "101010101"
Simples
Now, onto the data we need to send to the iDevice in order to get it to do what we want!
Firstly, we need to switch the device into "AIR" mode (not airplane mode! just the mode they go into when you plug them into a dock etc).
To do that, we need to send the following data:
FF 55 03 00 01 04 F8
(just FYI, the codes are made up as follows, the first two bytes have to always be "FF" then "55". The next byte indicates the number of data bits included in the command. Then you have the data bytes. Followed by a checksum byte, which is calculated by adding up the values of all the data bytes, then taking them away from 0x100)
So, now we have the iDevice in "AIR" mode, we can then send the commands we want:
"FF 55 03 00 29 01 D6" = play/pause
"FF 55 03 00 29 02 D5" = stop
"FF 55 03 00 29 03 D4" = next track
"FF 55 03 00 29 04 D3" = previous track
"FF 55 03 00 29 05 D2" = fast forward
"FF 55 03 00 29 06 D1" = fast rewind
Awesome.. that's the basic background information in place. Once we get this bit to work, we'll return to this and look at how to get data (trackname etc) from the iDevice and display that on the radio.
---------------------------------------------------------------------------------------------
So. how are we going to achieve this?
Step 3 - Building the interface
So now we know what to listen for and what to send, we need to build something that will actually do this.
My initial plan was to use a Rasberry Pi for this, as they're very cheap, have loads of ports and run linux.
However, I then remembered the Arduino board. It's about half the price of the RPi, has tonnes of IO ports, runs of 12v (bonus!) and is pretty easy to code, so I've decided to go down that route.
I will come back to this bit and fill in how to connect it all up precisely, but for now I will give some general gumf on it.
The only cables we need to connect to the Arduino are the iDevice's serial cables and the IBus. We will also be adding a couple of relays off the board so that we can do clever things (such as "cut out" the CD Changer, and control power to the dock), but we will be looking at that a little later on in this post.
Once we have the cables connected, we then need to code the arduino to listen out for the relevant codes on the IBUS, and then issue commands to the iDevice.
Luckily, I've tonnes of experience coding (tis my job after all) and I've messed with Arduino many times in the past (automated home lighting, electronic gates, etc)
Now, I realize writing code like this will be beyond most of the people reading this, so once I've written it myself, I'll make it available here for everyone to use as they wish. I'll also put a bit of tutorial in on how to load it on your own arduino.
Next, we need a power supply for the arduino. It's requires 12v, but we need it to be "switched", so as to not keep the device running whilst the car is off.
Handily, there's one of these hooked into the back of the stereo, so we'll just hook into that
Whilst were there, we can also hook into the IBus connector on the back of the stereo
Again - I'll fill this section out much more once my Arduino actually arrives!
---------------------------------------------------------------------------------------------
So.. where are we at?
Well, at this point, we've got an iDevice sat in a dock, that is able to play it's music via the aux connection on the back of the stereo, and also listens to and responds to the MFSW and radio controls for next/previous track as well as fast forward and rewind!
But we're not all the way there yet... we still have to address the problem that the audio is of lower quality when using the aux connection, and that we're not displaying the track names on the radio screen. (which becomes quite important when you can no longer see the track name on the front of the iDevice now that it's in "AIR" mode!)
I've again ran out of time, so I'll update again a bit later with info on how we're going to do that