Monday, June 28, 2010

RC-5 Protocol (InfraRed)

We have all used InfraRed based remotes to control various appliances around our house. All these remote work by transmitting data in form of flashes of infrared light - and wherever one needs to transmit data, there is always a protocol involved. The RC-5 protocol from Philips has been used in TVs, VCRs and other appliances since the past three decades. It was developed by Philips but was adopted by many other manufacturers.
Now days RC-5 has been superseded by RC-6 and various other protocols from various other manufacturers. These newer protocols have better features and are more flexible. San Bergmans's KnowledgeBase on Consumer IR is a nice place to lookup information (protocol specs, circuits, embedded code) on any of the old or new IR based protocols.

Here is how a RC-5 TV remote control transmitter unit looks like:





And here is a InfraRed receiver/demodulator:



A RC-5 codeword is 14 bit long. The first two are the start bits, then comes the toggle bit and finally the 5 bits of address and 6 bits of command code. The bits are manchester encoded and use a carrier frequency of 36kHz. By carrier frequency we aren't referring to the frequency of the infrared light used (which is around 300 TeraHertz) but the frequency at which the LED is flashed on and off. What all this means is that if we want to transmit a logic zero, we flash an infrared LED 32 times at 36kHz (which takes 889 microseconds) and then keep it completely off for a time equivalent to 32 cycles at 36kHz (ie 889 microseconds). For logic one, we reverse the order (details here).

At the transmitter side, we use a transistor to control the blinking of the LED and at the receiver , a decoder, demodulates the received infrared light into pulses (which are still manchester encoded, although inverted). A common decoder used in receivers is TSOP1736.

Here is a screen shot of a 14-bit RC-5 codeword as demodulated by the InfraRed Receiver. The signal has been saptured using a sound card.



And here are a few (progressively zoomed in) screenshots of waveforms captured on a PC based Oscilloscope. The signal on channel 1 is captured on the base of the transistor controlling the IR LED on the transmitter unit. The singal on channel 2 is captured at the output of the decoder on the receiving unit. Note the obvious delay between the transmitted signal and the decoded signal. You can count the number of pulses in the transmitted half bit is exactly 32 (compare it with waveforms on the wikipedia article).






The RC-5 decoder and remote control are present on the UNI-51-SDK, UNI-51-SDKmkII and UNI-PIC-SDK. These are development kits available from UC Micro Systems. You can acquire these kits if you want to experiment with RC-5 protocol and develop application around it (like remotely switching on/off appliances)

Addendum: Here is a photo of assorted infrared devices:


The ones in the center and top right are IrDA transceivers and the rest are InfraRed Demodulators (used for RC-5 decoding)

Friday, June 25, 2010

I2S

I2S stands for Inter Integrate Sound and is similar to the I2C which is used for transmitting data between Chips on a circuit board. (wikipedia article on I2S). I2S is used for connecting digital audio devices together, (for example between the main processor and the audio codec chip on cell phones or computers or between the CD transport and the DAC in a CD player).
I2S interface consists of atleast 3 signals:
  1. Clock
  2. Left right clock
  3. Data line

The eKA8562A Chip which is a USB Audio Controller (and can be used as an oscilloscope) sports an I2S interface. Here are a few signals captured at the various pins (I2S output) on this chip:


Pin 5 of eKA8562A - I2S BCLK Output
Clock - This signal is used as the clock to latch in the bits appearing on the data line.




Pin 6 of eKA8562A - I2S LRCLK Output
Left Right Clock - This signal is used to tell the receiving device whether the data being received by it on the data line is meant for the left audio channel or the right audio channel.




Pin 7 of eKA8562A - I2S SDATA Output
Data - This signal carries the actual PCM audio data alternately for the left and the right audio channels.




Since eKA8562A is a USB device, it uses a 12MHz Crystal as its clock source:

12MHz Clock on a USB Device: Pin 4 of eKA8562A

Further Reading: