HMLiberator

From nuxx.net
Jump to: navigation, search
Current state of the HMLiberator: First Device Assembled

About

The Honda Music Link, as detailed elsewhere, is very difficult to use, mostly because of it's insistance that the iPod be kept in Advanced Remote / AiR / Mode 4, which locks out the controls on the iPod itself.

In order to work around this I'm developing the HMLiberator, a device which sits between the Honda Music Link and the iPod. The device emulates an iPod in its responses to the Mode 4 commands, prompting the HML to allow audio to pass through. Additionally, the HMLiberator will occasionally send Mode 2, or normal iPod remote commands to the connected iPod. These commands will be sent in response to the reception of various events which are the result of pressing various controls on the head unit / steering wheel.

All information used in developing the HMLiberator has been acquired from publicly available sources on the internet, or discovered by capturing communications between the Honda Music Link and my iPod. My primary external source of information on the dock connector and Apple Accessory Protocol was the iPodLinux project's documentation section. I have mirrored the pages most useful to me on this site because I've found the iPodLinux site to be rather unreliable.


Development Tools

Honda Music Link and Sniffer

Honda Music Link Sniffer

To make it possible to watch communications between the Honda Music Link and the iPod, I built a simple level converter and connected it to the iPod TX/RX pins on the bottom of the HML. This device is a reference implementation of a MAX232 level shifter on strip board, with the two inputs connected to the TX and RX pins, and the outputs connected to DB9 headers (Top View, Bottom View). These DB9 headers were then connected to two serial ports on a PC, and serial port monitoring software was used to observe the communications.

Typically software such as Eltima Serial Port Monitor worked very well for most of the sniffing needs, but at US$70 I found the software a bit expensive for this limited hobby-like use so after the trial period I ceased using it. In the end I found myself mostly using Look RS232 for observing communications while the HML was running, and AGGsoftware's Advanced Serial Port Monitor for testing commands and responses from the HMLiberator while developing it.

Serialterm appears to be another useful capture / logging device, but it's lack of support for higher serial ports (such as COM14, which my USB serial adapter appears as) kept me from using it. The biggest issue I ran into when investigating free (or lower cost) serial port monitoring applications was the need to send specific strings of data in hex. This was needed in order to send commands to the HMLiberator and test responses to ensure that the application on the PIC was doing what I expected. It seems that most serial port monitoring applications don't support sending data this way.


Compiling a version of the HMLiberator software in mikroBasic.

EasyPIC4 and mikroBasic

A mikroElektronika EasyPIC4 and an EasyConnect header (along with some custom cabling) was used as the development and testing environment for the HMLiberator.

To make the test wiring harness a MiniDIN 8 header and socket were connected using some spare 8-wire stranded cable, just as they would be in the Honda Music Link cable which runs between the Honda Music Link itself and the iPod. This cable was then cut open, and the serial TX, serial RX, and GND lines were connected to the EasyConnect. Eventually a toggle switch was added in the middle of the 3.3V line, as it is used by the HML as a sense line to determine if an iPod was connected. This allowed for simulating connecting and disconnecting an iPod without actually taking the time to plug / unplug it.

Initially the HMLiberator was developed on a PIC16F88, which mikroBasic and the EasyPIC4 support for easy in-circuit debugging (ICD). Upon moving to the PIC16F688 (which was selected for its lower pin count and faster speed) I was able to wholly emulate the final HMLiberator, albeit without ICD support.

After receiving the initial run of PCBs I've moved away from using the EasyPIC4, instead using one of the production boards and an in-line serial sniffer.


Programming an HMLiberator

PICkit2

The HMLiberator is programmed using the Microchip PICkit2 programmer via the ICSP connector. This programmer is a convenient, low-cost, small programmer from Microchip. It doesn't support all Microchip products, but for those which it does, it is a good alternative to a full debugger / programmer such as the ICD 2.

While I don't use MPLAB for writing the HMLiberator software, I'm still able to use the programmer by giving it the outputted .HEX file from mikroBasic. Programming is very simple, with the PICkit2 software providing simple feedback as to whether or not programming was successful.


Firmware

The firmware for the HMLiberator is being developed in mikroElektronika's mikroBasic on both an EasyPIC4 development board and the final PCB. Custom procedures were written for easily defining new iPod commands and sending them to either the HML or the iPod.

A periodically updated version of the firmware is available for reading here. Note that it is still under heavy development and may change drastically at any time. It is also currently not completely functional.

In order to have an FIFO filled based on an interrupt triggered by the presence of data on the hardware EUSART I used some code taken from this discussion at the mikroElektronia forums. My FIFO is heavily based on the irq_usart module listed there, but I've removed a few things I didn't need (delimiter, TX FIFO, count of <CR><LF>s in RX FIFO, etc) and added some others (dumping of incoming data if the FIFO is full, bugfixes, etc).


Some quick work-in-progress notes about the HMLiberator's iPod response emulation:

  • iPod name (playlist 0) is 'HMLiberator', playlist 1 (the first and only playlist) is 'Frees Your iPod'.
  • 99 Tracks in both playlists, meaning 99 tracks on the whole device, all of them in the one playlist.
  • Turning polling mode on sends a polling announcement every 500ms indicating that the song is 23 seconds into the song.
  • App starts at track 1 (0x01) upon reset.
  • App starts indicating iPod is paused.


Hardware

Overview

The HMLiberator hardware is a PIC16F688 running at 20MHz and LM78L05-based power supply. The LM78L05 taps into the +12V intended for charging the iPod. The PIC16F688 has its hardware EUSART connected to the HML. Two additional pins are used as a software UART and connected to the iPod.

It would be ideal to run the PIC at 19.968MHz, but crystals of that value do not seem to be available in small quantities. With a 20MHz crystal the baud rate from both the EUSART and software UART is 9615 bps; an error of 0.16% from the desired rate. In testing this slight variance does not seem to affect communications with either the iPod or Honda Music Link.

The 3.3VDC line coming from the iPod is passed through the HMLiberator and on to the HML, as it is used as a sense line by the HML to detect the presence of an iPod. Upon detecting the presence of an iPod the HML begins communicating with the iPod. Audio lines (Left, Right, Common) are also passed directly through the HMLiberator.


First Assembled HMLiberator PCB

PCB

The PCB design for the HMLiberator is a 25mm x 50mm PCB, with all connectors and circuitry fitting within a 25mm x 37mm space. The additional 13mm has three 4mm holes drilled into it so that the cables for connecting to the HML and iPod can be mechanically tied down, providing strain relief.

The PCB and schematic layout was done using CadSoft EAGLE v4.6r1, a wonderful low-cost PCB CAD tool package. Prototype PCBs have been ordered from Advanced Circuits, and the EAGLE and Gerber files (including Excellon drill files) are available in one zip file here: HMLiberator_pcb_1_0.zip

A 300dpi PNG of the schematic is also available, along with a 600dpi PNG export of the PCB layout (without groundplanes) from EAGLE.

The first run of 12 PCBs were ordered from Advanced Circuits on 07-May-2007. I tried quoting a quantity of five to twelve PCBs, and throughout this entire range the per-part cost times the number of parts was always right around US$220. After this point the total price jumped up a bit. While this is technically a prototype run, it is expected that the board layout for a production run would be the same. So any spare PCBs should be usable for production boards, should I decide to sell the HMLiberator.

The PCBs were received on 16-May-2007 and look very good. They came wrapped in a small stack, packed with a t-shirt, sticky notes, and a bag of microwavable popcorn. The quality of the boards is very good, as can be seen in 600dpi scans of the top and bottom of a board. Assembly of the first board went very smoothly, leading me to realize that I could probably have made the board even more compact.

Here is output from running the HMLiberator PCB v1.0 through Advanced Circuit's FreeDFM tool prior to submitting the order:


Bill of Materials

Part Name on PCB Value Part Number Quantity Catalog Description
C1, C4, C6 .1μF 77-VJ12Y50V104K 3 Vishay/Vitramon 1206 Ceramic Chip Capacitors 1206 0.1uF 50volts X7R 10%
C2, C3 27pF 77-VJ12A100V270J 2 Vishay/Vitramon 1206 Ceramic Chip Capacitors 1206 27pF 100volts C0G 5%
C5 .33μF 77-VJ12Y25V334K 1 Vishay/Vitramon 1206 Ceramic Chip Capacitors 1206 0.33uF 25volts X7R 10%
IC1 PIC16F688-I/SL 579-PIC16F688-I/SL 1 Microchip PICmicro - PIC16Fxxx Flash MCU's 7KB 256 RAM 12 I/O
IC2 L78L05ABUTR 511-L78L05ABU 1 STMicroelectronics Voltage Regulators 5.0V 0.1A Positive
ICSP (optional)   571-1032396 1 AMP AMPMODU Breakaway Headers 6 P HEADER GOLD 30u, single row
Q1 20MHz 695-HCM49-20-U 1 Citizen HCM49 SMD Crystals 20 MHZ 18pF HC49S SMD
R1 470Ω 71-CRCW1206-470-E3 1 Vishay/Dale 1206 Thick Film Chip Resistors 1/4watt 470ohms 1%
R2-R6 10KΩ 695-HCM49-20-U 5 Vishay/Dale 1206 Thick Film Chip Resistors 1/4watt 10Kohms 1%
    161-2608 1 Kobiconn Mini-DIN Jacks 8 PIN IN-LINE MINI
    806-KMDLAX-8P 1 Kycon Mini-DIN Connectors 8P SNAP N LOCK PLUG ASSEMBLY

The two 8-pin Mini-DIN connectors are used to connect to the Honda Music Link and the cable which leads to the iPod. The snap lock plug connector (806-KMDLAX-8P) is the same type of connector used by the Honda Music Link OEM connectors and is used to ensure that the connections don't rattle loose while used in a vehicle.

Eight-conductor stranded, shielded cable is also required to connect the Mini-DIN connectors to the HMLiberator. A specific type of cable has not yet been selected, and I am currently using salvaged cable from a 9-pin Serial Cable.

The ICSP connector will not be installed on devices intended for installation in end-user vehicles, as this connector is used solely to program the PIC. Individuals may add it if they choose in order to make reprogramming the HMLiberator easier.


Female 8-pin Mini-DIN Connector Soldering

Header / Cable Connections

Signal Name IPOD Connector on PCB PIN HML Connector on PCB PIN Mini-DIN Pin Wire Color
FireWire +12VDC 1 3 1 Red
FireWire Ground 2 8 2 Black
Audio - Left 8 2 3 Blue
Audio - Ground 6 4 4 Green
Audio - Right 4 6 5 Yellow
+3.3VDC (Sense) 7 1 6 Grey
Serial TX (To iPod) 3 -- 7 Purple
Serial RX (From iPod) 5 -- 8 Orange
Serial TX (To HML) -- 5 7 Purple
Serial RX (From HML) -- 7 8 Orange

Cable coloring is currently for the salvaged serial cable I've been using, with both the bare and brown wires removed, leaving eight conductors.


Enclosure

The HMLiberator's PCB and cable retention area will be wrapped in heat-shrink tubing. This will provide a durable, low-cost enclosure while keeping the whole assembly slim enough to easily fit adjacent to wherever the Honda Music Link is mounted in the vehicle. It is expected that the HMLiberator will be strapped to the side of the HML with plastic ties, so that it can be easily connected in between the iPod cable and the HML itself.


External Resources