PC IR Remote Control ==================== Chris Dodge - 9 June 1994 cdodge@awi-bremerhaven.de This file gives some information on a PC based IR remote control system I've developed for computer control of TV, video, satellite and hifi equipment etc. I have used an IBM compatable, so the software here is for such a machine, however I guess that it is straightforward (perhaps easier) to impliment this on another type of machine. 1 PC IR Remote Control Signals ============================== IR remote control signals are modulated with a 40KHz carrier frequency, so for transmission or reception of the signal, the appropriate de-modulation/modulation must take place. The demodulated signal itself has a basic frequency which varies from manufacturer to manufacturer, but must not necessarily be exclusive to one make. Therefore, there is also a signal address, identifying the target device before an instruction is sent. In itself, this is quite simple, but there are a couple of other signal variations which I have identified in writing the capture software. One is what I've called 'hi/lo bias', that is the difference in length between signal highs and lows, and the second is the 'repeat' factor, i.e. how many times the signal is repeated. Some controllers repeat every signal, others do not. Quite how important these factors are, I'm not sure, however, I have tried to allow for exact reproduction of the input signal, and a bit of experimenting has shown for example, that a repeating signal is in fact a bit more relaible on a device expecting that, but produces strange results on one not expecting them! 2 PC IR Remote Control Hardware =============================== The hardware (as I have bullt it) is constructed from two modules, one to capture the signal and provide timing functions, and the second as transmiter placed somewhere near the target equipemnt. I have interfaced this to my IBM compatable PC on the printer port, using the two pins "Paper Tray Empty" and "Printer Busy" as input, and Data lines 0 and 1 as output. 2.1 Signal Capture ------------------ The figure IR1.PS shows the circuitry used for capture and timing. I used a GP1U52X which I think is made by Sharp, but can be bought at Radio Shack (Tandy in the UK). This is a combined IR detector and demodulator, and in effect, this is all that is needed to capture the signals, which is then fed directly to the PC. (If you have problems getting hold of this, I can send you the postal address of Tandy UK, or maybe some kind person living near a Radio Shack shop could let me know if they are willing to pop round and pick up a few if I get any requests.) One big problem with PC interfacing is getting a reasonable timer for sampling. To simplify this, I have used an external timer, running at 100KHz (i.e. a bit than the Nyquist limit for a 40KHz signal). This is probably overkill, as the demodulated signal is nowhere near 40KHz, but I found this gives good results. 2.2 Signal Playback ------------------- The software calculates the signal from the stored data, and outputs this to the printer parallel port, as shown in IR2.PS The timer circuit on the playback board oscillates at 40kHz, and is switched by the data from 'data 0'. I have the transmitter board on the end of about 6m cable, so I've put a de-coupling capacitor in between the power rails in case the power supply was a problem. Also, the 100nF capacitor on the IR LED line was found to improve the output signal ie. I get a much more reliable respose from a troublesome amplifier now! A 100nF cap. just happened to be at hand, maybe a different value capacitor would improve things further. Unfortunatly I don't have a 'scope to look at the signals. 3 PC IR Remote Control Software =============================== Included here is a PC exe to capture, analyse and store the IR signals, plus source code etc. I have extracted the parts of the code that deal with driving the hardware for use in programs and turned them into a C++ class which can be VERY easily incorporated into programs. I wrote this stuff using Boland C++ v2.0, and have no idea how portable this is to other compilers. The progam IR is at version 1.0, i.e. not very well developed. It works ok for me, but then I wrote it! Feedback is appreciated, and I'll try and fix bugs etc. etc. 3.1 IR Data ----------- The data is stored in the form shown in the example IRINFO.DAT file. Each device (ie. video/TV etc) needs several parameters for a full description of the signal, plus the signal data. The filename that the program expects is IRINFO.DAT, and MUST contain dummy values for a device if you want to capture signals, plus signal names and the number of signals. This is easily done in a text editor, but you must adhere to the format given later. Once you have used the program to analyse the signals, the data is written to a file IRTEMP.DAT, which can be examined with any text editor, and if ok (it should be) copied to IRINFO.DAT for the next set of signals or testing or whatever. 3.2 The IR Program Main Menu ---------------------------- The program main menu gives you two options, firstly to record IR signals, and secondly to play signals back. The latter facility is purely a convenient method to test the signal data and/or hardware, and does not provide a very elegant method of computer equipment control. 3.3 Signal Capture ------------------ This program menu gives a list of devices for which data can be captured. Choosing any of these will load the data (dummy or real) for that device, and throw up the following screen. <Imagine that you have got a picture of the capture screen here!> Device and signal parameters are given in red, and instructions in blue. The two signals (white and red) are the input signal from the detector and the calculated signal from the file data. So how do you go about capturing your signals? a) Set up the IRINFO.DAT file to have all the dummy entries for the signals you want to capture. b) Go to the capture screen (above) and press 'i' (for input). The program then waits for IR input, but BE WARNED, the recording routine turns off interrupts, so if you don't have the hardware plugged in, the only way out is the reset switch! c) Once captured, the signal will be displayed. Press 'e' (for estimate), and the program will attempt to estimate the signal from the captured signal. d) Play around! Well, until you get a stored signal that looks somewhat like the original anyway. The aim here is to get the data string on the screen to represent a nearly identical signal to the input one. The first time you do this for a device, it is a bit more involved, as the frequency and bias must be found. One this is done for the first signal, it will be identical for the rest. To do this, you have to adjust the frequency, hi/low bias etc., pressing 'e' occasionally to see how your getting on. It may be necessary to adjust the calculated signal start offset to get the two signals in phase, otherwise estimation of signal won't work very well. If you really can't get the signal sorted out, then you can manually edit the data string - moving the highlighted figure with the cursor keys. A HINT: Using SHIFT and the control letter will give a x10 incriment/decriment in a changable parameter. e) If you thing your getting close, try 'r' to RUN the signal. Does your TV, Video, or whatever respond? f) Press 'n' for the next signal, and repeat the above process.... which should just be a matter of estimating the signal as the other parameters are already setup. g) Done? Press 'w' to write the data to the output file IRTEMP.DAT. 3.4 Signal Playback ------------------- This gives you the opportunity to test all the captured signals. The 'repeat signal' option repeatedly plays the chosen signal about once every second. This can be useful for positioning the IR transmitter, or adjusting the playback timer frequency to get a good response. 4 PC IR Data File Format ======================== The format of the data file (IRINFO.DAT) is explained here, but maybe you'll find it easier to simply look at the example file. I recommend creating a data file with dummy values before starting the IR program. It is more relaible if the program has to edit the data rather than create it all from scratch. Maybe the next version will be better..... Comments start with a '#' eg: # Info for IR Remote control # Chris Dodge - May 1994 The paramters for a particular device use a name, in this case 'Sat'. This name is used by programs to refer to this data. Clock - frequency of IR signal itself (not the modulation frequency) eg: Sat Clock 1726.000000 Bias - the difference in the high/low signal ratio, eg: Sat Bias 10 SignalNo - the number of signals for 'Sat', eg: Sat SignalNo 27 SignalLen - the length of the signal data string for 'Sat', eg: Sat SignalLen 150 Repeat - number of times the signals are repeated, eg: Sat Repeat 1 Pause - If the repeat value is > 1, then this is the pause between repeats (units of a single data string value), eg: Sat Pause 0 The signal data itself, in the form: [Device] Signal [Signal Name] [Data]. That is, the keyword MUST be there, to indicate that this is a signal, what's in the other...
fred1144