IPod to TandA remotecontrol adapter
From wikiPodLinux
- The title of this article should be iPod to T&A remotecontrol adapter. The initial letter is capitalized due to technical limitations.
At first thanks to holto2go who forced me to start the translation of this project. I hope, that somebody is interested in what I did. As a non native english speaker, there are for sure some mistakes, but I think I managed to write an understandable documentation. Best wishes, BigCookie (alias Andre), and here it starts:
Recent Work: Adapter and program was updated. It works also with T+A M-System, RLink-Interface and K-system. The new translation-box also gives status using some LEDs. New control mode for iPod is introduced: Display and iPod controls will still work. Switching between both modes is possible!
Currently supported: play/pause, ffwd/rwnd, skip |</>|, Playlist-Navigation, Song-Navigation,Shuffle on/off, repeat all on/off and iPod-charging. New PCB design is equipped with filters, it's ESD-safe and CE-conform (tested!)... Please take a look at http://www.ipotato.de. For questions you can also use mailto:bigcookie@fantasymail.de. Support for this project on ipodlinux will of course be given.
BigCookies iPod2T+A remotecontrol adapter
The project combines an Apple iPod with a T+A-hifi stereo system (R-system). The iPod can be plugged into the stereo system and does not only deliver the Audio-signal to the T+A-system but is also remote controllable with the T+A remotecontrol without an own infrared receiver.
The following iPods are supported: All iPods with dock connector (no shuffle, no 1G, no 2G)!
The T+A hifi system connects its devices with a serial interface to transport the remote control signal. Since the iPod remotecontrol also uses a serial protocol, a translation seems to be possible.
At this point I would like to thank Mr. Wiemann from T+A Electroacoustics who supported me by answering a lot of questions concerning the T+A remotecontrol interface (the protocol is online at http://www.taelektroakustik.de). Another big thank you goes to Christoph, who discovered the iPod accessory protocol (http://stud3.tuwien.ac.at/~e0026607/ipod_remote/ipod_ap.html). Without these two persons, this project could not have be concluded.
I don't give guaranty on fault free functioning and the secureness of the described system. Everyone who uses this information does this on his own risk! I am not responsible for every kind of damage that can be caused to the involved devices.
Improvements are welcome, please use mailto:bigcookie@fantasymail.de to submit those... Please feel free asking questions at the same Email-address...
| Table of contents |
|
|
Theory (iPod and T+A)
The following subchapters are describing the needed interfaces and protocols as far as it is needed to understand this project. Detailed information can be found at http://www.elektroakustik.de concerning the T+A hifi system. A very good description of the iPod accessory protocol and the dock connector can be found at Apple Accessory Protocol and Dock Connector.
Short description of the T+A remotecontrol interface
The connection (remote control) between all T+A devices is done using the so called RC-interface. The connectors are simple 3,5mm-stereo-headphone-jacks. There is a socket for every device which can be connected to the T+A preamplifier. It is intended to plug the iPod into one of those sockets to react as a T+A device. the preamplifier is filtering the remotecontrol commands and sends the device specific commands to the corresponding sockets. The pin assignment is shown in figure 1.
For this project, the commands sent to the devices are of interest, not the adressed T+A devices. The device related commands are already "sorted" by the pre-amplifier. The structure of the whole instruction sent to the device is shown in Figure 2.
A remote control instruction starts with a start command, then (depending ipond the holing time of the button) one or more instructional commands are sent, and finally a stop command, which corresponds to the start command. The break between the starting command and the first instructional command amounts to 19,968ms, the break between two instructional commands is 177,76ms, while the stop command is sent at the earliest 2ms after the last instructional command, otherwise, as soon as the key of the remotecontrol is released.
One start-/stop-/instructional command has a length of 13,312ms and consists of a 512µs long pre pulse, a following 2560µs break and 10 bits. The first of the 10 bits is a start element (a "1"), the following 6 bits are command bits, while the latter 3 bits are address bits. The address bits (normally "0 0 0") are according to the standard and not interesting for this project. One bit has the length of 1024µs and is defined by a voltage level change: 0V to 5V = High bits, 5V to 0V = Low bit (see Figure 3). The signal line is a 5V signal line!
The following command table contains the important bit sequences (the 10 bits) of the interesting instructional commands of the T+A remote maintenance! Start/Stop means the start-/stop-command, which indicates, that a remotecontrol instruction is going to be sent/finished via the serial interface (see Figure 2). These 10 bits have to have the Pre-Bit and the following Pause to be sent first, otherwise they are not recognized as a command for the T+A devices.
| Command | Startbit | Cmd 1 | Cmd 2 | Cmd 3 | Cmd 4 | Cmd 5 | Cmd 6 | Adr 1 | Adr 2 | Adr 3 |
|---|---|---|---|---|---|---|---|---|---|---|
| Play | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| Pause | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 |
| Stop | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| Skip > | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| Skip < | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
| FFwd >> | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 |
| Rwnd << | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
| Start/Stop Cmd. | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
Short description of the iPod-Remotecontrol protocol
In this project the simple remote mode is used (for details visit Apple Accessory Protocol). The iPod uses a 8N1-protocol, that means one start bit, one stop bit, 8 data bits and no parity information. The transfer rate is 19200baud. Commands are repeated 66 times per second (all 15ms). A command consists of 7 bytes, which are sent directly in a row to the iPod. The first two bytes are header bytes (always the same: 0xFF, 0x55. 0xFF as a wake signal,0x55 for the detection of the transfer rate). The third Byte corresponds to the number of following bytes without the checksum byte (simple remote mode: always 0x03). The fourth byte addresses the iPod mode (mode for the simple remote maintenance: here always 0x02). The fifth and the sixth byte are instruction bytes (simple remote mode: the fifth is 0x00 and the sixth byte according to the desired instruction). The seventh byte is a checksum, computed by subtracting byte 3,4,5,6 from 0x00. In reality the signal line (RxD) is pulled up to 3.3V by the iPod. A high bit (1) corresponds thereby to 3.3V, a Low bit (0) corresponds to 0V! The start element is a Low bit, the stop bit a Highbit. I measured, like Christoph, a short delay between stop and the following start element. The individual bits have a length of 52µs, the stop bit 64µs! The serial communication works also neglecting this stop bit delay of 12µs, but the delay was considered in the microcontroller program. Table 2 shows the relevant simple remote mode commands for the iPod.
Each command has to have a "ButtonRelease" command followed, otherwise, the iPod doesnt react at all. Everytime you send a command to the iPod, the ButtonRelease command has to follow.
| Command | Byte 1 (Header 1) | Byte 2 (Header 2) | Byte 3 (Cmd size) | Byte 4 (Mode) | Byte 5 (Cmd 1) | Byte 6 (Cmd 2) | Byte 7 (Checksum) |
|---|---|---|---|---|---|---|---|
| Play/Pause | 0xFF | 0x55 | 0x03 | 0x02 | 0x00 | 0x01 | 0xFA |
| Skip >, >> | 0xFF | 0x55 | 0x03 | 0x02 | 0x00 | 0x08 | 0xF3 |
| Skip <, << | 0xFF | 0x55 | 0x03 | 0x02 | 0x00 | 0x10 | 0xEB |
| VolumeDown | 0xFF | 0x55 | 0x03 | 0x02 | 0x00 | 0x04 | 0xF7 |
| VolumeUp | 0xFF | 0x55 | 0x03 | 0x02 | 0x00 | 0x02 | 0xF9 |
| ButtonRelease | 0xFF | 0x55 | 0x03 | 0x02 | 0x00 | 0x00 | 0xFB |
Short description of the iPod Dock-Connector
The iPod got a serial port integrated in the remote control socket. Unfortunately this barely usable due to its special connector, so we have to use the serial port in the dock connector. This port has to be enabled on iPod 3G (I think with the iPod photo, it is already enabled by default). This can be done by using a 500K Resistor between Pin 21 and Gnd. The rest is pretty simple, just use the information in table 3, which shows the pin assignment needed for this project. Pin 19/20 allows the easy build of a charging cable (you can connect those Pins and ground directly to the car battery to charge your iPod - no extra circuits are needed!!!).
As cable I recommend using one of the cheap USB/Firewire-cable available on Ebay. I reassembled one of those to provide the serial connection and the Line-Out signal. Be careful during soldering, the pins are located pretty close together (0,5mm) and can be bent easily!!!
| Pin | Description | Notes |
|---|---|---|
| 1 | Ground (Gnd) | |
| 2 | Line-out ground | seperate audio ground |
| 3 | Line-out R (right audio) | |
| 4 | Line-out L (left audio) | |
| 11 | Ground (Gnd) | connected to pin 1,29,30 |
| 12 | TxD (iPod serial output) | unused in this project |
| 13 | RxD (iPod serial input) | used in this project |
| 18 | Power supply 3.3V | no high current available! |
| 19 | FireWire external 12V | connected to Pin 20, can be used for iPod charging |
| 20 | FireWire external 12V | connected to Pin 19, can be used for iPod charging |
| 21 | Device recognition | connected with 500K to Gnd |
| 29 | FireWire Ground (Gnd) | connected to Pin 1,11,30 |
| 30 | FireWire Ground (Gnd) | connected to Pin 1,11,29 |
The remote protocol translator
The serial protocol translation will be done by a PIC Microcontroller (http://www.microchip.com). I use a PIC 16F628 - simply, because I had one lying around. Naturally another micro controller can be also used. The micro controller should have an internal clock available of a minumum of 1MHz and should provide one digital in and one digital out port. Many micro controllers provide also a serial interface (btw. also the PIC 16F628). However, since I am not experienced in using the USART interface, I programmed everything I needed. The chosen micro controller offers high impedance outputs, so that the output of the T+A pre-amplifier can be connected directly to the micro controller. To be sure to maintain the standard level of 5V, I added two resistors (see figure 5). The iPod provides the supply for the PIC (attantion: the micro controller has to have the ability to be supplied with 3,3V), it offers 3,3V at pin 18, but can drive only small loads. Since the iPod is very sensitive to bit length variation an external oscillator is used. This oscillator is attached to the controller with two 15pF capacitors, like it is specified in the technical data sheet.
The electronic circuit
Figure 5 shows the electronic circuit. You can easily find the micro controller, the oscillator and some resistors for the signal lines. Electrical engineers might improve the circuit, but it works like it is for me. Figure 6 shows the testboard, I used for the first trials. Here the resistors are still missing. I noticed, that the PIC works more stable with them. The red marked reset button shown in figure 5 is not necessary, but I recommend it, to be able to reset the micro controller in case of software failure (That was needed with the missing resistors). Using the new design, I had not to use this button...
The microcontroller program
This won't become a course in PIC programming, but just a description of the program. The source code is filled with comments, so I think it might be good understandable. The program is quite simple, a flow chart would probably be an overkill. I am not an experienced programmer, so there might be a lot of possibilities for improvement...
Pressing Play/Pause/Stop on the T+A remote control corresponds to Play/Pause of the iPod, the start-/stop-command of the T+A serial protocol corresponds to the ButtonRelease-command of the ipod and the Skip-Buttons as well as FFwd/RWnd should also correspond to eachother (except, that pressing the T+A skip-button and holding it, should result in skipping one title; pressing the FFwd/Rwnd-button of the T+A remote should not result in skipping one title). The latter is not realized in the current program. The iPod distinguishes between skipping and FFwd/RWnd by sending the command once or several times in a row.
The program structure is likely like this:
1.) A short loop supervises the T+A-signal
2.) If a signal is present, check for pre-bit, correct break and start-bit sent by the T+A-system. This assures, that the micro controller doesnt start acting in the middle of one command.
3.) Reading the 6 command bits (not the adress bits) and checking if there is a voltage change in each bit (to prevent malfunctions)
4.) Search for the corresponding iPod-command (table search)
5.) Send the iPod command
6.) Send the iPod Release-Button command.
7.) Back to step 1.
That's the structure in general, but the following details have to be considered: Every iPod command should be sent only once and afterwards the ButtonRelease command must be sent (that's also described in the structure above), but the commands for FFwd and RWnd have to be repeated until the T+A-RemoteControl button is released. For this purpose, one micro controller bit is set after one command including the ButtonRelease is sent. This "CommandSend"-bit will be checked before the next command is going to be sent. if it is set, the iPod command is not sent. This bit is resetted if the T+A remote control button is released (like: be ready for the next action). This assures, that only one iPod command is sent, even if the remote control button is held. Another bit is set, if a FFwd/RWnd command is received. Setting this second "FFwd/RWnd"-bit results in the suppression of the ButtonRelease-command AND the setting of the "CommandSent"-bit. Therefore, the FFwd/RWnd command will be repeated, until the T+A remote control button is released (which forces the PIC to sent the ButtonRelease command and reset the mentioned extra bits).
The program consists of a short receiving loop to detect the T+A-signal, a code table to look up the corresponding iPod-command, a decoding part to determine which iPod command has to be looked up, a iPod-command sending part (including some small subroutines) and several waiting loops to get the correct bit length. By calling the iPod-send subroutine, the whole 7-byte command is going to be sent! The only varying byte is the command and the checksum byte. The first one is looked up in the table (in the program it is the IPOD6 byte), whereby the checksum is computed on the fly.
Important is the microcontroller configuration. I deactivated all input and output pins which are not used. The Reset function (MCLRE-bit) should be enabled to allow resetting (even if the reset-button is not attached!), the WatchDog-timer (WDT-bit) should be switched off, and Brownout (BODEN-bit) detection is not needed as well as low voltage protection (LVP-bit).
Files (original documentation, source code...)
Here you can find files related to the project. This includes the original german documentation, the microcontroller sourcecode and more... All files are provided as zipped ones due to the lack of uploading PDF- and other files to the wiki. Probably I also manage to provide the download for the english project description...
Please notice: I made a little mistake by giving the rev. no. The documentataion 1.2 ist still for the schematics v1.1 (A few pictures were changed and some parts better explained, so I thought that's worth a version 1.2 for the documentation). Sorry, next time, I'll be careful with that...
Original Documentation
German
German documentation v1.1: Media:Ta-remotecontrol-adapter_german_project_description_v11.zip
German documentation v1.2: Media:Ta-remotecontrol-adapter_v12_ger.zip
English
English documentation v1.2: Media:Ta-remotecontrol-adapter_v12_eng.zip
MicroController SourceCode
MicroChip PICs (16F628): Media:ta-remotecontrol-adapter_pic-program_src_v11.zip
Compiled SourceCode
MicroChip PIC 16F628: Media:ta-remotecontrol-adapter_pic-program_hex_v11.zip
PCB layout
Thanks to Günther, who designed some printed circuit board layouts for the circuit version 1.1 available. Resizing is necessary due to the resolution. Boardwidth should be 37mm, height 23mm:







