Saturday, October 4, 2008

Zune Project: Part 2

Last time I went over how I mounted the zune in my car. This post I'll finish up with how I connected it to my steering wheel controls.

The first thing I did was find the signal from the steering wheel button in my pathfinder. To do this I just pulled out my stereo far enough so that I could reach the wiring while it was still all plugged in. Using an alligator clip, I connected one probe of my voltmeter to the case of the stereo, which is ground. Then I checked each wire going to the back of my stereo with the other probe, and pushed the button on my steering wheel. It didn't take long before I found a wire that would jump from 0 to 5 volts when I pushed the button. This was convenient because the PIC microcontroller I was using also runs on 0 to 5V, so I could plug the steering wheel button in to the PIC without any issues.

Next I spliced a wire in to the steering wheel button wire, and also two more wires to 0V and 12V from the cigarette lighter. I ran my own wires underneath the plastic of my center console, so that it came out at the ashtray. 

With my car ready, I started on the completely different problem of storing the signals from the remote control of the zune dock, so that I could program them on to a microcontroller.

First I took the remote for the dock apart...

...and soldered a wire to the negative side of the remote's IR LED.

So each time the remote's IR LED would light up, the signal on the wire soldered to it would be pulled down to ground. By adding a 10K "pull up" resistor between that wire and the 5V supply on the PIC, the signal will be 5V when the remotes IR LED is OFF, and 0V when it is ON.

I made a circuit on a breadboard, shown in the picture below (missing the microcontroller and IR LED) . What is also not shown is that I powered the remote control with a 3V supply and hooked the ground of the 3V supply to the ground of the PIC's 5V supply. Then I connected the wire soldered to the remote to pin RD0 of the PIC.

Here is a schematic that of the circuit:
There are two ICs in the circuit. One is the PIC microcontroller, which does almost everything. The other is a MAX232 chip which converts TTL level (5V) signals to RS232 levels (12V) so that you can talk between a computer's serial port and a TTL level UART (universal asynchronous receiver/transmitter) device, such as the PIC. 

I programmed the PIC so that as soon as the IR LED on the remote starts flashing, the PIC would save the state of that pin at regular time intervals. After a certain number of samples it will stop recording, and it will "play back" the data stream as a series of ASCII 1's and 0's through the UART of the PIC. I connected a serial cable between the output of the MAX232 chip and my laptop. Then I opened up a session of HyperTerminal (every PC has this), set up the com port to the same settings as the PIC, and saved incoming the string of 1's and 0's as a text file. Then using Excel, I plotted the signal.

When I finally got the code debugged, I did a little experimenting and found out that the zune remote's LED flashes on and off at a base line frequency of 37kHz (37,000 times per second). Below is an Excel plot of a "forward skip" signal, from the remote's LED.

Zooming in on that same signal (below), you can see that the baseline frequency of 37kHz is in the "background" of a much slower signal. 

I chose the sample rate of the PIC to be 8x faster than the remote - 37kHz*8=296 kHz. This was fast enough to capture the transitions, and slow enough so that 1) the PIC could keep up with the signal and 2) I wouldn't run out of memory. With this sample rate I needed 12000 samples to describe the whole signal, which took up 1500 bytes of memory (1200 samples / 8 samples per byte). The PIC I was using had 2048 bytes of variable memory in total.

Once the sample rate and number of samples were locked down, I captured and saved the "play/pause" and the "forward skip" signals in Excel. With a few excel tricks, I generated two vectors, one for each of the two signals, each 1500 elements long, and saved them each in their own file. 

I then changed the PIC program so that it would turn on and off an IR LED of its own, at the same frequency as the remote. If the button was pushed for less than half a second, it would skip tracks. Otherwise it would pause/play. I left most of the original code in case I wanted to record more signals later on - I would just have to "un-comment" a few lines to bring it back to its original functionality. Download the pic code here.

With the new code tested, it was finally time to get the thing in to my car. I soldered together a simpler, more compact version of the breadboard circuit that didn't have the MAX232 chip. It is powered from the cigarrete lighter's 12V supply. 

Top view...


bottom view...

The circuit tucks in nicely into the ashtray.

With the ashtray closed, the IR LED is the only thing that pokes out. The finished product is below:

And that's it! Now my steering wheel button skips tracks and can play/pause my zune. It was probably more trouble than it was worth, but I had fun doing it. I left out quite a lot of details, but I can add them if there is a lot of interest in this project. 


Marc said...

I have a Pathfinder myself (and a zune). My CD changer died a few months ago and I've wanted to do something about swapping it out. However, I can't bear to lose my steering-wheel buttons - this may solve my problem!

Any hints for how to get at the head without hurting the dash? I know from my last Nissan that there may be a few secrets.

Brett_cgb said...

Since you were looking at the signals generated by the remote, did you take a few minutes to see if/where those same signals appeared in the dock? (Probably at the output of an IR detector, and possibly at the Zune connector.)

Knowing if/where those signals appear on the Zune Connector could go a long ways towards reverse engineering possible remote control commands.

spadamchrist said...

It is generally thought that the polymerization of amyloid peptides is a stepwise process, with early events leading to formation of small oligomers, followed by assembly into soluble protofibrils first and insoluble fibrils later . This process has been examined in detail for amyloid beta of Alzheimer's disease using a variety of methods to unravel the different steps of fibril formation and growth. A "dock-and-lock" model has been proposed for fibrillogenesis where Abeta binding to growing fibrils is followed by a conformational rearrangement of the bound monomer , which increases its affinity for the fibril.
Interactive Marketing

Anonymous said...

hello, I am interested in the scheme of the interface, but it is not clear. The link to the source code is not possible to obtain it. Can you send both files? Greetings.

casm369 said...

Amazing work Gabe! I still have my 30gb zune from 2006 and I think it's the best mp3 player out there. I'm going to try to do this myself. I know it's been a while, but do you still have the IR remote codes?