The infrared impulse

Imagine a movie party with friends. Just as the 237-minute Love Exposure is about to start, you feel the need to have a remote controller. You remember the spare TV remote lying around. You also happen to have an infrared phototransistor from a Hauppauge HVR-1100 PCI card. So you quickly try to come up with a way to receive the signals using stuff you readily have at home.

[Image: A television remote control with a couple dozen buttons and the label 'Hauppauge!'.]

Far-fetched? Well, it did happen to me. The movie was some great stuff, so I decided to sit and watch it instead. But the next day, I finished this remotely useful contraption. (Of course proper USB IR receivers are cheap on eBay and well supported on Linux, but hey.)

Long story short, I connected the phototransistor directly into the sound card's line in by soldering the leads to a stereo jack. The sound card is becoming my favorite method of sampling the outside world into the computer.

[Image: A stereo miniplug with its lead connected to a phototransistor.]

And sure enough, pressing the button "1" on the remote produces this waveform:

[Image: An oscillogram with 12 strong downward spikes of two distinctly different durations.]

By comparing the timing to some common IR protocols I found out the signal is Manchester-encoded RC-5. After running-average type lowpass filtering, thresholding and Manchester decoding in Perl, we get these 14 bits:

[Image: Spikes from the above spectrogram superimposed with a regular clock signal and interpreted so that when a clock tick coincides with a spike, a logic one is produced, and when it coincides with zero, a logic zero is produced.]

The first "11" is a start bit sequence, then follows a toggle bit that tells whether this is a repeat or a new keypress. The rest is an address field (11110b = 1Eh) and the command itself (000001b = "number 1").

Yay, no new hardware needed!

6 comments:

  1. hi,
    what software do you use to plot these waveforms ?
    thanks

    ReplyDelete
    Replies
    1. The first one is a screenshot from Audacity, recolored in GIMP. The second one was generated from the captured .wav using PerlMagick and manually edited in Inkscape.

      Delete
  2. Also, when you do this..don't use a CdS photocell or a solar panel...they will make audio but the slew-rate will be too slow. Whenever I take my electronics around I carry a phototransistor soldered to a 1/8 in phone jack and if the remote stops working I can just stick it in my Zoom H1 recorder or Sony PSP (homebrew oscilloscope) and listen to see if I can hear data pulses when the remote is pointed at it with a button pressed.

    ReplyDelete
    Replies
    1. Interesting! I should try it with a phototransistor.

      Delete
  3. If you want to actually write a program that continuously monitors the soundcard input, and decodes anything sent to it, and then takes pre-programmed actions (like "start the program c:\windows\system32\calc.exe when you press the power button on your remote"), then you will need to do a LOT of programming. It could easily take a month or two to write a decent program that does this, even in VB6 which is the easiest programming language to use.

    ReplyDelete

The comments section is pre-moderated; it will take some time for the comment to show up.

You might want to check out the FAQ first.