Projects.

Club Projects.

Mike Mallett's Infra-Red Project.

This page is still under construction.


The Beeb Bodybuilding Course Part 106

By Mike Cook Micro User June 1992

Mike Cook takes control

Remote control handsets are taking over; one for the TV, one for the video, one for the Hi-Fi. Even so, you have to spend longer looking for the remote controller than if you had to get up and press the buttons anyway. However, the remote control handset gives us an opportunity to control devices from the computer. Mr. Follett for example, wanted to control two VCRs from a computer in place of the hand control to enable him to edit. Also, supposing you had three hand controllers, you could simulate all of these from the computer. After all, when was the last time your computer slipped down the side of a cushion? Let us look first at how a remote control handset works. Most of them, nowadays, use infra-red, that is light that has a wavelength too long for us to see. Fortunately however, electronic sensors and emitters are much easier to make at these wavelengths than at visible ones. Basically, the handset transmits a series of pulses of infra-red light. One popular system is the bi-phase system illustrated in figure I. Here a falling edge represents a logic zero and a rising edge a logic one at the centre of the bit time. The signal also makes a transition at the start of the bit time if necessary. Another way is to use the pulse position system as shown in figure II. Here a pulse is placed in the middle of the bit time for a logic one and no pulse for a logic zero. However, this has the problem where the code consists of a number of logic zeros, no pulses would be produced. Therefore, if you want to send a logic zero and have just sent one then you have a pulse at the start of the bit time. This is the same sort of encoding scheme that is used in most modern floppy disc systems. However, it is not quite as simple as this. If this were to be the whole story then the system would be susceptible to all sorts of interference. In order to make sure that only the handset's infra-red is noticed, the beam is modulated. That means when the beam is on, it is really being switched on and off very rapidly. This modulation frequency is not critical, but it is around 5SKHz or 55 thousand times a second. Our strategy is basically simple, record the infra-red beam pulses and then play them back through an infra-red emitting diode. In some respects this is rather similar to the approach we used with the sound sampler. However, in this case we know that the beam is going to be on or off. All we need do is to time the on and off periods and record these times. Then we can recreate the signal by using the times as delays between switching on and off. The effect of doing this is that it does not matter what form of' pulse encoding your handset uses. Figure III shows the receive circuit and it is basically very simple. An infra-red photo diode is connected to a Darlington pair. This is an arrangement of transistors that gives a gain which is the product. of the gain of the two individual transistors. If the signal is sufficiently strong, the result will be a simple logic output. The rapid modulation of the beam will be removed due to an effect called `excess charge carriers', again for large signals. The result is that you have to hold the handset very close to the diode to record your signal. This is fine as we will only be reading the handset once and we don't need to do it from the other end of the room. If we did want to have the computer read the handset from a distance that would. be another project, I might tackle that one soon. Before looking at the software let's look at how we can re-generate the handset signal, this is shown in figure IV. 'The modulation signal we need is a little too fast to be comfortably generated by the computer so we need some hardware to do that for us. 'This is where the 74L513 comes in. It is basically an oscillator running at about 55KHz, we can gate it, turn it on and off from bit 1 of the User Port. This allows either a logic zero or a square wave to be produced from pin 8, we need this signal to drive the infra-red LED. 'This diode takes about l00mA and so we need to drive it with something a little heftier than a transistor. Here I have used a power FET. These are capable of switching heavy currents quickly. The 33R resistor controls the current through the diode and will allow it to run safely within its power limits. However, it is being turned on and off rapidly and so if you wanted greater range you could lower this to 15R. Another way of increasing the range is to use another diode and resistor in parallel with the existing one. The FET will easily cope with the extra current. Note you do need an extra resistor, don't be tempted to use the same one as LEDs will not share current and you will end up overloading a diode. Having got the hardware together we need to be able to drive it. This is shown in listing 1. It is written so that you can extract the parts you need in your own program. The basic idea is that the record section, lines 1460 to 1630, uses the VIA's timer is used to measure the time between successive high and low states. These times are stored in memory after the machine code, and then Basic reads them back into an array. Finally this time array is transferred into a two dimensional array containing the time for all the keys you have read. There are also two string arrays K$ and KD$ which contain the key you press to generate a pulse waveform and a descriptive message to go along with it. You can save the remote control waveforms to disc and load them back. Finally you can replay these waveforms from the keyboard. Line 30 defines the maximum number of keys you can use, it's surprising how quickly they add up on the average handset, although there is no need to use them all. I have only tested this system on my own Sony equipment and that uses a system of 13 pulses to generate its message. It is possible that other systems use a different number of segments, that's why the program has been written to accommodate these. Line 40 should be altered to suit but how do you know? Well after reading in a key the program draws the waveform at the bottom of the screen. If you see less than 13 low periods on this waveform then adjust the number in line 40 to match. If however there are more than 13 pulses produced by your handset you will still only see 13 on the screen. Then you must increase the number in line 40 until you see no more increase in the number of pulses and then drop back one. All handsets send the number repeatedly as long as you have your finger on the button and any extra pulses will be taken up by the next number. However, you will see a long gap between one message and its repeat. If your handset works at a different pulse speed you can change the division factor in line 1350 to alter the displayed waveform's scale. As I said a handset repeats the message, in the program line 1230 defines how many repeats there are for each key press, in this case there are five but it is easily changed. Construction is quite straight forward and all the parts are available as Body Build pack No. 78. It is built on Veroboard and a suggested layout is included in the pack. You will also need to be able to connect up to the User Port and the simplest way of doing that is with the transition board and lead, Packs 1 and 2. . Armed with this you can now control any infra-red remote device with your computer. You can arrange it to automatically change channels for you in time to catch that party political broadcast with you missing a minimum of the Cup final. It can be used to automatically program your video recorder, or simply replace that lost handset. Anyway now you know how to do it you can devise your own applications.
Has anybody noticed that the InfraRed TX diode was shown wrong way round?


Contact me if you feel the need, to add to this work or, add a project of your own.

Return to tvcc page