2017-01-01

Laser Trap: Dexterous Escape is a hobby project I have been working on for some time. In this post I will go though the things you will need to build your own laser course at home. The goal is to move as fast as possible through a room filled with laser beams without touching any of the beams.

The following tools are useful to have during the assembly of a laser trap. Soldering
iron, tin solder, flux, tweezers, nippers, toothpick (for the flux), microscope, Blu-Tack, permanent
marker and a FTDI USB TTL serial cable.

You need some experience at soldering to be able to put together a laser trap. Some of the components are quite small and can be difficult to handle for a beginner.

Main Board

The following parts are needed when assembling the main board for a laser trap.

Start by applying flux to the pads for R1, C1 and D1. This will make the components stick a little and you avoid having to chase the components around the board with the soldering iron. Place the components on the pads and solder them in place. Note that D1 have polarity and should be placed with the cathode pointing towards R1. The polarity is marked on the back with a T. The top side of the T is the cathode. (This is a bit strange as all guides on the net say the opposite, but the diode I am using, HSMH-C190, has its marking reversed.)

Put a small amount of Blu-Tack on the back of HM-10 and put it in place on the Main PCB and solder it to the seven pads. If you have Main PCB R1 (without revision marking) you only need to solder one of the four ground pads on the lower side. If you have a HM-10 module without USB as the one in the image, you don't even have pads for two of the ground connections.

Put U1 in position and solder the three legs and the heat sink in place.

Insert the leads from the 9V battery connector into the holes below U1 and solder them in place. Black is ground and should be soldered to the hole out in the corner of the PCB.

If you have Main PCB R1 you need to cut the copper trace that connects the two outer pads in the lower 3p connector. You should then connect the lower pad to one of the spare ground pads next to HM-10.

Put both 1x3p female connectors in position and solder them in place.

Mark the top side of the board as shown in the image.

Connect a 9V battery or another power source between 4.8V and 15V. The LED should start to blink. Attach a USB TTL serial cable to the serial terminals and exchange the following request response sequence at 9600-8N1.

AT+MODE1
OK+Set:1

AT+NAMELASERTRAP
OK+Set:LASERTRAP

The trap is now ready to connect to the Android application.

For lasers that draw more than 30mA the voltage regulator needs to be cooled more efficiently than what the PCB alone can manage. Attach the steel stripe with Blu-Tack on the opposite side of U1. This stripe is also useful for mounting the trap and sensor in the correct position to monitor the laser beam.

Sensor Board

The following parts are needed when assembling the sensor board for a laser trap.

Start by applying flux to the pads for R1. Place the component on the
pads and solder it in place.

Insert the two photo resistors at the top and the two photo resistors at the bottom into the mounting holes. Cut the leads and solder them in place.

Remove the pins from the two 1x1p male connector and put the remaining plastic tubes on the outer legs of the right and left photo resistors as support. Insert the three center row photo resistors into the mounting holes. Cut the leads and solder them in place.

Put the 1x3p male connector in position and solder it in place.

Red Laser

The following parts are needed when assembling the red laser for a laser trap.

Laser Trap

The game Laser Trap: Dexterous Escape uses dedicated hardware modules called traps for its implementation. Each trap has a laser module, which can be turned on and off, and a light sensor which can measure the amount of light that illuminates its surface. The game is supervised by an Android application which uses Bluetooth LE to communicate with the traps.

Central Processing Unit

When I started designing the trap I didn't know which parts I would use. I wanted to use wireless communication as I imagined the laser module and the sensor to be located in opposite parts of the room. Wifi and Bluetooth LE were two technologies I considered. I knew wifi modules used a lot of power so I began to search the net for BLE modules with GPIO capabilities. HM-10 [1] turned up frequently. A pair of HM-10 modules can connect to form a bidirectional serial data link, but we are only interested in the AT commands. When I read the specification I figured I could use the AT+PIO command to control the laser and read the state of the light sensor, although a GPIO with interrupts would have been better than constant polling. Later I found the AT+ADC command which allows the application to read the exact sensor level between 0V and 3.3V instead of just a digital 0 or 1 with a switch of value somewhere between 0.8V and 2.0V. It is handy to be able to adjust the detection level in software to be able to adapt to different light conditions. HM-10 can be set to AT+MODE1, where it can receive AT commands over the air, and not only from the wired serial port which is the default. To distinguish traps from other BLE modules nearby I decided to use the command AT+NAME and call them LASERTRAP.

Power Supply

The HM-10 runs on 3.3V. It is practical to have a voltage regulator supply this voltage and not a battery directly, as it makes it possible for the trap to accept a wider range of voltages (4.8V-15V) from various sources. A low current voltage regulator is cheaper, but I also want it to be able to supply power to the laser module. I decided to use a 800mA regulator [2].

Status LED

HM-10 will use a Light Emitting Diode (LED) D1 [3] connected to PIO1 as a status indicator. It will blink when it is waiting for a Bluetooth connection to be established. When connected it will be steady on. A LED have polarity and the anode should be connected to PIO1. The cathode should be connected to ground through a resistor R1 that will limit the current that flows through the LED. With PIO1 delivering 3.3V and a LED rated at 1.8V, 20mA, gives us a R1 = (3.3V-1.8V)/0.020A = 75Ohm.

The Laser Module

As the HM-10 runs on 3.3V it is practical to choose a laser module which can run on 3V, as it means they can share a single voltage regulator. Powerful lasers can damage the eye therefore I decided to use lasers with 1mW power or less. I selected PIO2, one of the available output pins on the HM-10, to control the laser. I decided PIO2 should act as ground for the laser and sending AT+PIO20 will turn on the laser and sending AT+PIO21 will turn off the laser. The laser module is connected to 3.3V with the positive part and the negative part is connected to PIO2.

Now I had to think about how much current PIO2 can handle before it starts to raise significantly above ground, say 0.3V. This is caused by the inner resistance Ri between the pin and the true ground. With a measured Ri = 10Ohm, PIO2 can handle 0.3V/10Ohm = 30mA. This is the maximum current the laser module is allowed to draw if it needs 3V to operate.

For more power hungry laser modules it is necessary to add a driver stage between PIO2 and the laser. Using a PNP transistor with an emitter to collector current large enough to drive the laser (BC327, BC807 [4]) we can still use PIO2 to turn the more power hungry laser on and off. The emitter is connected to 3.3V. To turn on the flow of current from emitter to collector which will drive the laser, the transistor base needs to be grounded through PIO2. An emitter to base current of 10mA is enough for the transistor to turn on the emitter-collector current. As the emitter-base pair is a diode with 1.2V voltage drop, it is necessary to add a current limiting resistor R1 between the base and PIO2. R1 = (3.3V-1.2V)/0.010A = 200Ohm. The voltage drop over the emitter-collector pair is typically between 0.05V and 0.3V, which leaves 3V for the laser. The laser module is connected to the collector with the positive part and the negative part is connected to ground.

The most affordable laser module is 650nm red. Unfortunately, our eyes are only about 20% efficient at this wavelength. This means the laser beam can not be seen from all angles in a dark room with smoke or fog in the air. For best visibility the more expensive 532nm green can be used. It is visible from all angles. Somewhere in between, both for visibility and price, is the 635nm red.

The Light Sensor

To detect that the uninterrupted laser beam reaches its destination a photo resistor (GL5528 [5]) can be used. The resistance of a photo resistor will drop when the light intensity at the surface increases. Together with a fixed resistor in series it forms a voltage divider for the 3.3V reference voltage. By measuring the voltage over the photo resistor it is possible to determine how much light it is detecting. I soon found out that it is quite difficult to aim a laser to point exactly at a 5mm photo resistor. I decided to use seven photo resistors in parallel to increase the target area where the laser beam can be detected. A 1mW laser gives us a resistance of 400Ohm over the photo resistor. I want the sensor to be compatible with a digital zero at 0.8V. With the same current flowing through both R1 and the photo resistor, we have the equivalence 0.8V/400Ohm = (3.3V-0,8V)/R1, which can be solved as R1 = 400Ohm*2.5V/0.8V = 1250Ohm, which is the lowest value of R1 that is acceptable to properly detect a 1mW laser.

The typical use case for the sensor designed above is a dark room. Normal daylight that reaches the sensor will make the resistance drop below 400Ohm and therefore make the sensor unusable under such conditions. We can make the sensor less sensitive by raising the laser detection level to 2.5V in a dark room. We will by this modification extend our headroom to also be able to work in a bright room, but at a detection level somewhere below 2.5V, as the combined light that hits the sensor will be more intense than the laser alone. The Android application will have to dynamically adjust to the correct laser detection level to be able to handle varying ambient light. R1 = 400Ohm*0.8V/2.5V = 128Ohm.