MAKESHIFT IR DECODING

This article will describe an efficient and simple method for decoding ir signals. There is no electronics experience or use necessary. You will need an electric guitar or bass (or some kind of magnetic coil pickup), something to amplify the signal from line level, a sound card with audio input, and some kind of program to record and view the waveform. There are many freeware programs available such as Audacity. Just Google search "Wav editors".



First, a little background on ir signals:

Sony IR protocol


The picture above is a visual representation of Sony's ir protocol. The square wave is a mapping of the ir wave being turned on (wave high) and off (wave low). The signal itself is actually "modulated" at around 40kHz. What this means is that each time the ir wav is turned on (goes high) its is pulsing at a frequency of 40,000 beats per second. This is done because the receiver 'listens' for this specific frequency. That way, it isn't affected by noise, like the sun or lights in the room. When the receiver notices the start signal (that first signal that is high for 2.4 milliseconds), it starts the decoding algorithm. Since the protocol transfers binary numbers, the receiving circuit has to look for 2 distinctions, 0 and 1. Basically, each period (colored slice) is 2 milliseconds. If the incoming signal stays high for over 1 millisecond (or a duty cycle above 50%), it records a 1, if it stays high for less than 1 millisecond (a duty cycle below 50%), it records 0. It does this 12 times because the Sony protocol specifies 12 bits and in the end you have a 12 bit binary number. This number is then used for whatever command the sender was trying to execute. Now, how to record and read these:

me holding remote up to guitar


First thing you want to do is grab your guitar, or whatever you have, and route it from an amp of some sorts to your input on your computer. I used a Firepod but I'm sure you can just use an amp; and if you have a generic sound card, a 1/4 inch to 1/8 inch adapter (found at wal-mart or radio-shack). Now open up your wav editor. If you can "preview" the sound, do so and make sure a signal is coming through. Once you got it, make sure you select a pickup on your guitar and turn the volume and tone all the way up. Place the remote over the selected pickup in the orientation above or until you get a strong signal. As you do this, hold down one of the buttons and you should hear the signal repeating. It just sounds like a bunch of distinct high frequency pulses. After finding a sweet spot, hit record, choose a button, and record the signal. The wave will probably look like a bunch of fuzzy rectangles but when zoomed in to about a 30 millisecond window, it should look something like this (This pic is a little compressed):


wave drawing


First note that you can obviously see the start bit at the front. For the rest, I am guessing that each 'low pulse - high pulse' pair (defined here as a low trough followed immediately by a high crest) can be represented as a bit. The pairs with close pulses are 0 and the ones with long pulses are 1. That should mean that this number is (in 12 bit binary): %000001001000. To get the decimal representation you just convert from base 2 to base 10. You can use a formula like Ai*(2^i) summed from i = 0 to i = 11 (from the right-most bit to the left-most bit). 'Ai' is the constant digit (0 or 1) at position i. This formula works great for binary because all you have to do is count the positions of the 1s [3, 6] and then add 2^3 + 2^6 = 72. This is because 0*2^i is always 0. #Note that you would not need to do this for the whole message as I am doing, this is just for exercise. If that is still confusing, however I imagine most of you already knew it, you can learn more about it on Wikipedia. As for using these signals, that's another article.


Conclusion

When I was in middle school I was a big fan of Tom Morello and I always tried putting things up to my guitar and running them through effects to get weird sounds. The remote and phones were my favorites. After starting a project that required me to decode ir signals, I decided I would build my own decoder as a side project. A late-night discussion with a friend led me to believe that this might work, so I tried it and I guess it works. As for how this works, I'm not entirely sure. I would have to guess that this signal is caused by magnetic fluctuations in the amplification circuit of the IR led in the remote. I don't exactly know much about the physics of magnetism and electricity but that doesn't much seem to matter for this project. On another note, this method may be useful for decoding protocols other than ir. As long as they are slower than the Nyquist frequency for whatever sampling rate you are using and as long as you can record and make meaning out of these magnetic pulses.