Thursday, May 28, 2009

Tripping Up?

About two years ago one of my best friends (I’ve known him since the 9th grade in school, and we were in JHC, A-Div together) gifted me a Griffin iTrip. He had just recently bought (been gifted?) an iPod video, and the iTrip 4014 was not compatible with it. Not wanting to throw the iTrip out, he very sweetly gave it to me (thanks bro!).

Incidentally, I happened to be the second in our ‘gang’ to own an iPod, after another one of my best friends (c’mon, I can have more than one best friend! As a matter of fact I happen to have 15 at this moment). He had a silver Mini, and we would take turns listening to it in the electronics lab, while we soldered away at a 7447 and a 7490 counter-with-display circuit.

I take a teensy moment now to salute my alma mater – Jai Hind College. JHC, was an oasis in a concrete jungle, ‘figuratively’ speaking (wink, wink :-)). Just off Marine Drive in Bombay, JHC was where I did my junior college. I studied Electronics as a vocational subject and was taught Sam’s Laws, by none other than Prof. Samel, who also taught us other important things, such as the reason Darlington pairs are named so (Note to reader: if you are opening your eyes in bewilderment – ‘what is he talking about?’ – you are pardoned; this is an internal joke). Coutinho, Rane and Bai were the ‘awesomest’ of teachers!

Right. Back to the topic at hand. I used the iTrip with my iPod Mini a couple of times before keeping the iTrip aside in disgust because it used to drain my already weak battery super quick. Earlier iPod batteries had notoriously short run times – only 4 hours for a new Mini; these days, play times of over 20 hours are not unheard of! One mod I made to my Mini was swapping out the Hitachi Microdrive, and replacing it with a CF card. By the time my iPod got ‘old’ enough for me to gather the courage to disassemble it, my Li-Ion battery was too far gone to make any real judgment about the modded performance. However, in all fairness I must say that I did notice marginally improved battery life (the CF card has no moving parts as opposed to the spinning platters in a Microdrive, so battery juice lasts longer), but nothing that merits boasting.

I am, at some later date, planning to strip down a Nokia BL5C and replace the original Mini battery. Why go through all of this trouble when I can simply buy a new Mini battery online? Well, for one, at the time of writing this replacement batteries (USD 30) are horrendously expensive compared to a BL5C (INR 125; ~USD 3); Apple charges a bomb (USD 75) to replace the batteries themselves; and lastly, I’m doing it just BECAUSE I CAN :-)

The iTrip 4014 is an FM transmitter that is capable of transmitting from 76 MHz to 108 MHz. Based on the BH1415F from ROHM, it also has a PIC12F626. The frequency at which the iTrip broadcasts is set by the '629. Small sound clips (provided by Griffin) are to be played by the iPod to change the frequency. The clips contain codes which tell the '629 which frequency to set.

Sadly, the iTrip 4014 can only be used by an iPod, and that too, only from its remote control port. Naturally, I did not like this forced restriction. So I decided to see if I could mod the iTrip to play from any old source with a 3.5mm jack.

I trawled the net for pinouts and specs, and came across several tutorials to increase the transmission range, but none that told me how to make the desired modification. This site came close, but a different iTrip was used. Anyway, I took apart the iTrip with a sharp craft blade. You can see the scuff marks at the bottom – these are the only visible signs of damage to the case (which I plan to discard anyway).


After a bit of poking around and with some intuitive guesswork I figured out which wire went where and did what. The images are marked with the relevant data incase you decide to take your iTrip apart. The image on the right has the microcontroller (a PIC12F629) and the one on the left has the FM chip (BH1415F). Click on the image for a better view.






I rigged a rough setup to power the iTrip externally. In the image below, my trusty PICKit2 is providing 3.3v to the iTrip. Also visible is the connector which plugs into the remote control port at the top of the iPod. The image to the right is a close up of the connections.






The audio jack was connected to my laptop, and audio was broadcast to my radio. It worked perfect. The ultimate aim is to make this into a standalone FM transmitter, therefore to change channels I would need some way to provide the audio control commands to the iTrip.

The audio commands are extremely simple – they follow an ASK-like format. A command is 19 bits long, and is transmitted LSB first to the Audio L wire (it’s the tip on the 3.5mm jack). A sample audio command clip being analyzed in Goldwave is shown below.

5

To switch frequencies the user plays a command file (which sounds like random beeps), pauses it after the ‘random’ beeps, waits for a few seconds till the iTrip automatically locks the frequency, and then resumes playing audio. The first string of blips is the actual command to switch to 107.7 MHz. The three blips towards the end mean ‘Ignore the previously issued command’. This is to prevent inadvertent frequency switching incase this file is played when the player is in ‘shuffle’ mode. In case the file is played by mistake, the iTrip will receive the command beeps, try to lock the new frequency, then receive the ‘ignore’ beeps (since the user would not have paused midway) and not lock to the new frequency.

6

7






The 19-bit command is (LSB first) ‘1010 10101100001 1001’. A command is framed by ‘1010’ to the left, and ‘1001’ to the right. The actual command word itself – ‘10101100001’, if read right to left is ‘10000110101’, which happens to be 1077 in decimal. Divide that by 10, and you get the FM frequency, 107.7. The ignore command is just ‘10101’. Each ‘1’ is 20ms of a 1000Hz sine wave. Thus each ‘1’ consists of 20 peaks and 20 troughs. A ‘0’ is just 20ms of silence. The commands are fed to the PIC, which decodes them, and sets the desired frequency.

Some commands are given below:

Freq.

Decoded Audio

Frame

Data (LSB first)

Frame

Data (MSB first)

Data in decimal

76.0

1010000111110101001

1010

00011111010

1001

01011111000

760

76.1

1010100111110101001

1010

10011111010

1001

01011111001

761

76.2

1010010111110101001

1010

01011111010

1001

01011111010

762

76.3

1010110111110101001

1010

11011111010

1001

01011111011

763

76.4

1010001111110101001

1010

00111111010

1001

01011111100

764

76.5

1010101111110101001

1010

10111111010

1001

01011111101

765

76.6

1010011111110101001

1010

01111111010

1001

01011111110

766

76.7

1010111111110101001

1010

11111111010

1001

01011111111

767

76.8

1010000000001101001

1010

00000000110

1001

01100000000

768

76.9

1010100000001101001

1010

10000000110

1001

01100000001

769

77.0

1010010000001101001

1010

01000000110

1001

01100000010

770

93.0

1010010001011101001

1010

01000101110

1001

01110100010

930

96.6

1010011000111101001

1010

01100011110

1001

01111000110

966

105.6

1010000001000011001

1010

00000100001

1001

10000100000

1056

108.0

1010000111000011001

1010

00011100001

1001

10000111000

1080

To figure this scheme out I had to open multiple files and compare the data. Here’s a shot of my desk. Notice the dual screens :-). iTrip open heart surgery is in session.

8

So this got me thinking – more likely than not, the PIC was simply ignoring the fact that the signal was a sine. It could work just as well with a square wave. And I could provide a square very easily with another microcontroller.

As a proof-of-concept experiment I generated the square wave in Goldwave (image-left), and created an audio clip similar to the command file (image-right).

9 10






I played this to the iTrip, and it switched frequencies like a charm. I can easily program a PIC to poll a couple of buttons, provide the requisite string of square waves when a button is pressed, and display the changed frequency on an LCD/numeric LED, thereby giving me a standalone FM transmitter.

Sites that were useful / will be useful:
http://badacetechshow.com/psp_itrip.htm
http://www.maushammer.com/systems/ipod-remote/ipod-remote.html
http://stud3.tuwien.ac.at/~e0026607/ipod_remote/ipod_ap.html
http://nuxx.net/wiki/Apple_Accessory_Protocol
http://www.petertyser.com/2005/04/28/motion-based-ipod-remote-control/

Future plans:
1. Make it into a standalone transmitter with button-selectable frequencies.
2. Provide power from a tiny rechargeable Li-poly. This would entail making a charger circuit (for recharging), and a buck regulator (to provide 3.3 volts to the hacked iTrip).
3. Make a nice enclosure.
4. Boost range/power.

Stay ‘tuned’ for future updates! :-)

1 comment:

  1. nice blog...seems like PIC's are everywhere, though my loyalty lies with AVR. i did contemplate on migrating to PIC but i got too involved with AVR's in robocon. i think next shot would be ARM or maybe higher series of AVR.
    yes..i was "gifted" the ipod video (still working great though...great battery life even after 4 years..gives me 6 hrs with just audio playback).
    i remember listening to nikhils pod while doing our pracs in the lab...what peace...what peace!! and yes our college was an oasis...after being stuck in the desert for 4 years (with just one palm tree (wink ;-)) i can vouch for that statement!!

    ReplyDelete

Visitors