Results 1 to 6 of 6

Thread: Homemade Infra-red remote control

Threaded View

  1. #1

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Homemade Infra-red remote control

    Homemade Infra-red remote control [VB 2005]

    If you are building a Home-Theater-PC (HTPC) one of the things you need to install is a remote control and its driver. Even without Media Center this is a simple thing to do.

    A hardware circuit that plugs into an RS232 port is actually pretty simple and easy to build. Here is a circuit that works just fine.

    I don't think that the Vishay TSOP1738 is available any longer, but any of Vishay's 38kHz IR Sensor Modules for remote Control Systems will work. I have used the TSOP31238 with no problem. You can get a few of these for free by requesting a sample from Vishay. http://www.vishay.com/product?docid=...uery=tsop31238 . LCD TVs output a lot of IR when they warm up, so you might want to instead use one of their modules designed for noisy environments. (i.e. TSOP31438)

    RS232 ports have become less common on modern computers being replace with USB ports. If you don't have a serial port available and don't want to add one, you can add a RS232 to USB converter to your system.

    There is a fantastic open source project for Linux called LIRC that handles the software interface to the device (http://lirc.org). Version 0.6.5 was ported to windows in 2003 (http://winlirc.sourceforge.net) but there is a serious flaw with this software. WinLIRC relies on the serial port interrupt for timing the pulses to decode the signal. The problem with this is that the serial port interrupt is a lower priority interrupt than the video interrupt so that when your system is performing some serious video task, such as video playback, the serial port interrupt will be delayed to an extent that makes the IR remote unusable. The solution to this problem is to perform the IR pulse detection and decoding via a polling technique instead. WinLIRC can still be used to generate the remote configuration file (obviously not while viewing motion video).

    Below is a replacement IR Remote daemon that works reliably even when video playback is going on.

    Most remote control units modulate the IR signal at 38kHz and follow the same basic protocol. When a key is pressed on the remote control, the unit produces a train of pulses who's widths identify what key was pressed. After demodulation, the signal consists of several square pulses of different widths separated by spaces of about 500 microseconds (us). The pulse train starts with a wide header pulse of about 5 milliseconds (ms). Next comes a series of 32 pulses. Each pulse represent a one or zero depending on its width. A one is represented by a pulse width of about 1600us and a zero is about 500us wide. These 32 digits can be combined to for a unique 32-bit unsigned integer that identifies the key pressed. Actually the high word identifies the remote control used and the low word identifies the key pressed. Finally a very wide tail pulse; about 40ms; is sent.

    Here is an overview of the software does:
    • We can use the serial port interrupt to detect the first pulse edge since an inaccuracy in the width of the first pulse (header) does not affect the results. The com-port PinChanged event signals us that an IR signal has been detected. This could be the beginning of a valid pulse train.
    • When the first pulse edge has been detected, start polling the com-port in a background thread with higher than normal priority to watch for future edges.
    • When a pulse comes in, measure its width with the high performance counter.
    • Start a one shot pulse-train timer to signal us when the pulsetrain should be finished.
    • When the one-shot timer expires, we should have collected 32 pulses. Convert the 32 valid pulses to ones and zeros (depending on the pulse width) and convert that into a 32-bit integer which tells us which key on the remote controller has been pressed.
    • Start a repeat timer to prevent repeat keys from being reported for the next 500ms.
    • Look up the name of the key and remote that correspond to the 32-bit integer above.
    • Send this data over TCP/IP to the clients.
    Attached Files Attached Files
    Last edited by moeur; Jun 13th, 2009 at 05:28 PM. Reason: The attached file now is complete and will run

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width