The Beeb Body Build course 137 Mike Cook Has The Magic Touch Some projects just don't turn out how you expect them to, this is one of those. It's the sort that sound quite simple but for one reason or another they aren't. I set out to make a touch screen for our computer, and indeed that's what I produced but it appears to have other uses as we shall see. On the face of it the design of a touch screens is simple, all you need are several Infra red beams across the front of the screen and when ever you touch the screen you break one of the beams. Simply detect which beam is broken and you know where about the screen was touched. However, within that simple remit is a lot of design and construction, not only because of the number of components in the system but also trying to minimise the hardware required. Most commercial touch screens are built into the monitor with the Infra red emitters and detectors moulded unobtrusively into the case. In fact the opaque looking plastic of the surround is transparent to Infra red. There is another system that uses transparent conducting inks painted onto the screen but that's not possible in a home construction situation. So the first thing we have to work out is how to mount the detectors and emitters close to the screen. Some screens are slightly recessed into the case and this makes things difficult. I decided to mount my components on a frame made of angle aluminium, it was an asymmetrical piece with the two sides being 1" by 2.5". I made the frame so that the monitor would push in the back of the frame forming a snug fit. The weight of the monitor should then hold the frame in place. The first snag here is that my monitor, whilst looking quite square is full of subtle angles. I used the technique of holding the peaces against the monitor and marking them up before cutting and drilling them. I didn't use anything more fancy than a saw and a drill. The whole thing is held together by 4BA nuts and bolts. Having constructed a mount for the components now came time to design the electronics. The first problem was knowing how far apart I could put the beams. Too far and there would not be much resolution, too close together and the light from one beam would spread out and interfere with the next detector. I tackled this on three fronts, first of all I scoured the component catalogues for a narrow angled Infra red emitter. I found one in the OP298B, this has a half angle beam width of 25 degrees and a high light output, 4.8mW at 100mA. A matching detector BPV11F was found with a half angle of 30 degrees. This is a photo transistor and has enough sensitivity to detect the beam without needing further amplification, further more it has a built in filter to minimise interference from visible light. In order to reduce the stray light further I then fitted 1" long tubes over the emitters and detectors. I made these from black art paper rolled twice round a pencil the same diameter as the sensor. The ends of the roll were fixed with a little double sided sticky tape. The final way to reduce the effects on adjacent sensors is to alternate sensor and emitter, in this way the sensors can be twice as close as if you had a row of emitters and a row of sensors. This sounds quite complex but is quite simple, the basic idea is shown in Figure I. Note that the screen is surrounded on all four sides with emitters and sensors, each column is labelled V for vertical and each row H for horizontal. I managed to squeeze eight beams in each direction but this can be modified for your convenience. Still having eight sensors enabled me to split the screen into 64 different sensing areas, more than enough for most projects. Now when it comes to the interface you can usually trade extra hardware for computer input and outputs and this is no exception. On the face of it having 16 emitters and 16 detectors would require 32 computer I/O lines, my design reduces this to four! I could have gone for three but that would have needed much more logic circuitry and not have been worth while. So how is this trick performed? Well, if you switch the emitters on one at a time you only need to see if any of the detectors has seen a beam. This is because if you know what light is on there is only one detector that can possibly have seen it. In fact in this design I decided to turn two emitters on at once, one vertical and the other horizontal. Then I only need to know if I have a detection on the horizontal or vertical axis. So that cuts down the number of computer inputs from 16 to two. However, even turning two emitters on at a time would take 8 computer outputs. The way round this is to use a counter, you see you always want to turn them on in sequence so all you need is one output to clock the counter and another to reset it. You need a reset so that you know the initial condition of the counter. This requirement of two inputs and two outputs can be met from any number of interfaces, however I chose to use the printer port so as to leave the other interfaces free as we shall see later. You don't need a fancy bidirectional printer port, a normal one will do as you have a BUSY and an ACKnowledge input from the printer as well as its normal outputs. The only difference between the two types of printer port are in the software required to drive it. With the older port you need to access it directly in the supervisor mode where as with the new type you can use the SWI calls direct from Basic. Figure II shows the circuit diagram of the emitter side of the touch screen system. The printer outputs are fed into the clock and reset inputs of a 4 bit counter. This is then fed to a decimal decoder, this will put to a logic zero the output who's number is being addressed on the input lines. In other words if we feed it a binary count each output will go low in turn. Note here that output zero is not connected to anything as we do not want an emitter on when the counter is reset. From here we need to boost the signal to drive two LEDs quite hard, in fact we require a drive of 300mA. The LM18293 will provide this quite comfortably and so will other drivers, the push pull output of this device is not really needed but I had them to hand, so I used them. Finally you will see that each LED requires its own current limiting resistor, these should be rated at 1 watt, however as they are only on for a short length of time you could get away with using half or even quarter watt resistors here. Figure III shows the receive side of the system, note that here you need to make two of these but the circuit is so much the same that it is only printed once. The second circuit should use the pin numbers for the NOR gate shown in brackets. I said that the detector could register the beam without further amplification but I found the output impedance was too high to drive a logic gate therefore, each detector is buffered with an emitter follower before being fed into a 4 input gate. This has a Schmitt input to remove any noise jitter. The two 4 input gates are combined so that the output will go low when any detector sees a beam. Construction of these circuits is a little tricky simply because of the number of components involved. I mounted the emitters and resistors along with the detectors and transistors on thin strips of veroboard mounted to the inside of the frame, this is shown in Figure IV. The rest of the electronics was on a board attached to the top of the frame. With so many wires carrying quite large pulses of current you have to be careful about the earths. For a start I earthed ( connected to zero volts ) the aluminium frame and ran separate 5 volt lines for the emitters and detectors. This caused a bit of extra wiring but I had no problem with interference. I used flat ribbon cable to run wires between these side strips and the main circuit which was mounted rather un aesthetically on top of the frame. It is essential to get the emitters and detectors pointing directly at one an other, so a bit of judicious pushing when testing is in order. No project is complete without the software, here there are two stages needed. First of all you have to test the system to make sure all the beams are being produced and detected. Then you have to map the sensitive areas onto the screen, that is identify where you touch the screen with screen coordinates. You will notice that as with any touch system there are areas of the screen that can be detected and gaps between them where detection is uncertain. The test software will help you identify these areas. You can then use some of the routines in your own programs. One I want to try is a screen full of animals that will make the appropriate noise when you touch them. There are also the many obvious applications like on screen information systems for open days or displays. However, as I said at the start there are other uses of this system not really related with a touch screen. If you take the frame off the screen you have a system that will respond to your hand position. This is a great input device for those with a physical handicap, hand movement could be translated into changing patterns or sounds. On system I want to try is to link this up with the computer controlled xylophone I made for last years special issue. Imagine simply prodding at the air and playing a real instrument! Well that about raps up 1994 have a very merry Christmas and I will see you in the new year.