ANY-maze Help > The ANY-maze reference > The I/O page > Making I/O connections > Connecting using generic digital I/O devices > Connecting a photobeam

Connecting a photobeam

The details given in this topic provide guidance on connecting a photobeam to generic I/O devices such as the Switch and Sense 8/8. Connecting a switch using the ANY-maze interface is much simpler - refer to the ANY-maze interface topic for further details.

Introduction

The purpose of this topic is to describe the process of attaching a photobeam to a generic I/O device, so that ANY-maze can detect when the beam is broken. However, as off-the-shelf photobeams are quite hard to find, I've also included some details on how to build a simple photobeam using easy to source components.

Photobeams

Most photobeams consist of an infra-red emitter and an infra-red detector - as in figure 1.

  

  

Figure 1. Schematic of an infra-red photobeam.

Photobeam emitter

The emitter in a photobeam is usually just an infra-red LED and all you need to do to make it work is connect it to a power source in such a way that a certain current flows through it. The required current depends on the emitter and will be quoted in its datasheet under Forward current - values from 20mA to 100mA are typical. To set this current you'll need to include a current-limiting resistor, as shown in the circuit in figure 2.

  

  

Figure 2. A simple infra-red photobeam emitter circuit.

To calculate the resistance required, you can simply apply ohms law although you will need to take the LED's Forward voltage into consideration (again this can be found in its datasheet).

  

Resistor = (Power source voltage - LED Forward voltage) / Forward current

Typical values might be R = (5 - 1.8) / 0.05 = 64 ohms. Something important to bear in mind is the power rating of the resistor. The power lost in the resistor will be P = current x current x resistance, which in my example would be 0.16 Watts. So you would need to use at least a 0.25W resistor.

Photobeam detector

A photobeam detector is usually a photo-transistor. In simple terms, this is a device that only conducts electricity between its two terminals when IR light strikes it. A simple circuit that will act as photobeam detector is shown in figure 3.

  

  

Figure 3. A simple infra-red photobeam detector circuit.

When there is no IR light striking the device it doesn't conduct, so the output will be held at 5V by the resistor. When IR does strike the device it conducts and the output will be connected to 0V - so the device is working like a switch.

In fact it's not really true to say the detector conducts or doesn't conduct, rather the amount of current that flows through it depends on the amount of IR light striking it. So with little light the current will be very low and it will increase as the IR light increases.

A complete photobeam design

Finding off-the-shelf photobeams is quite hard so you may want to build one yourself. As you can see from the above descriptions, this is quite simple and just requires a few components.

Figure 4 shows a complete circuit diagram for a simple photobeam that should work at distances of about 50cm, and below is a list of the parts you'll need - they're all available from Digi-key and the total cost should be under $2.00.

 •L1, Infra-red LED  -  Fairchild QED123 
 •T1, Infra-red Photo-transistor - Fairchild QSD123 
 •R1, LED current-limiting resistor - 100 ohm 0.25W carbon film 
 •R2, Detector resistor - 22K 0.25W carbon film  

  

  

Figure 4. A complete infra-red photobeam circuit.

If you mount two or more of these simple photobeams close together you may experience cross-beam interference. This can be reduced by shielding the beams and/or by using a LED with a narrower angle. To completely avoid this problem you would need to use a more sophisticated (switched) beam design, which is what the ANY-maze interface does.

Connecting the photobeam to an I/O device

The "inputs" found on the I/O devices supported by ANY-maze fall into two categories, TTL level inputs and opto-coupler inputs - but what do these names actually mean?

TTL inputs have this name because they connect directly to a TTL 'chip' (for the curious, TTL stands for Transistor-transistor logic). In practical terms this means that the chip will be able to tell when the input is at a "logic high" (around 5 volts DC) or a "logic low" (around zero volts DC) - this is the 'digital' part of computing, everything is high = 1 or low = 0. We'll come back to TTL in a minute, but what about those opto-couplers.

Opto-couplers, as their name implies, 'couple', i.e. connect, your input to the I/O device using light. The big benefit of an opto-coupler is that it isolates the I/O device, and hence the computer connected to it, from the equipment you attach. There are a number of technical benefits to this isolation, but they're beyond the scope of this help - suffice to say that quite a few I/O devices use opto-couplers so you may need to connect to them.

Connecting a photobeam to a TTL input

This will be easy to do if the output from your photobeams is at TTL levels. For example, if the photobeam design given above is powered from a 5V supply then you could connect the output directly to a TTL input without any additional circuitry. However, some off-the-shelf devices may use different output levels in which case you will need use a 'level-shifting' circuit to interface to the TTL input. Contact ANY-maze Support if you need help with this.

Connecting to an opto-coupler input

This is more complicated than connecting to a TTL input because the opto-coupler requires current to flow through it, so we need to make our photobeam output control this current. If you have some knowledge of electronics then you should be able to achieve this quite easily using a simple transistor circuit like the one shown in figure 5 - again you can contact ANY-maze Support if you need help with this.

  

  

Figure 5. Circuit to interface a simple photobeam to an opto-coupler input. The transistor Q1 is controlled by the photobeam and will allow current to flow through the opto-coupler whenever the beam is broken. Note that depending on the device being used you may need to include a current limiting resistor in series with the output.

  

© Copyright 2003-2026 Stoelting Co. All rights reserved

ANY-maze help topic T0920