A laser tag system based on an AVR microcontroller - specifically, the AVR Atmel ATmega328p. For prototyping I’m using an Arduino Uno board, but I plan to make a custom circuit board with the microcontroller placed directly on it. The software is written in C and does not use the Arduino/Wiring library - it uses AVR libc directly. This means the code has direct control over the timers, interrupts and other features of the microcontroller, which allows many improvements over existing AVR-based systems I have seen (e.g. the code is capable of simultaneous infrared reception and transmission).
The infrared signals are encoded on top of a 38 kHz carrier wave. A packet starts with a 1200 microsecond burst and is then followed by 16 more bursts, each representing a single bit. A burst of 800 microseconds indicates a binary 1, a burst of 400 microseconds indicates a binary 0. There is a 400 microsecond gap between these bursts. The most significant bit is sent first and the least significant bit is sent last.
This is similar to the underlying protocol used by other hobby Laser Tag systems, however, not quite compatible (due to the fixed 16 bit length and slightly different timings to account for the properties of the detector). The protocol that is eventually used on top of this will probably vary significantly from that of other systems - interoperability is not a concern of this project.
A Vishay TSAL6100 infrared LED is actually used for transmission. A timer on the AVR chip is used to generate the 38 kHz carrier, and the software turns the carrier on and off at the appropriate times to generate the bursts. Vishay TSOP4838 sensors are used for reception. These demodulate the signal such that their output is low when the carrier is on, and high when the carrier is off. An interrupt is fired on a rising and falling edge, and some simple timing and decoding code allows the packet to be read.
The LCD screen uses a Hitachi HD44780-compatible controller connected to a 74HC595 shift register to conserve pins on the AVR chip. The code can only write commands/data to the controller because of this, but all of the required functionality can be implemented without read support.
The speaker is connected to a pin, which in turn is connected to a timer. The timer is configured to produce a square wave at varying frequencies, so a variety of flat tones can be generated, but no complex waveforms.
The LEDs are connected to a 74HC595 shift register, just like the LCD screen. There are two LEDs for each team (red, green, blue, yellow) giving eight in total. The code implements an alternate flashing effect for the team colour. In the future, for complex game modes, a particular colour could signal someone as having captured the flag, for example.
Connected directly to the AVR chip there is also a muzzle flash LED with a small viewing angle and high intensity.
In order for live scoring/hit feedback, complex game modes, etc., radio communications between the guns and a central server computer will be used. I’m currently looking at using HopeRF RFM12B chips for this.
|This photo shows the original version of the infrared circuit using a 555 timer to generate the 38 kHz carrier, which was made before I was aware that an internal timer on the AVR chip could accomplish this.|
|This is the newer version of the infrared circuit that uses an internal timer so it is a lot simpler. The current through the infrared LED is limited to 50mA by the resistor network, at the time I did not have the correct value resistor for this, and in the future a transistor will be added so higher currents can be used (the LED is capable of up to 200 mA).|
|This shows an LCD display using a HD44780-compatible controller, interfacing with the AVR chip in 4-bit mode.|
|This shows a health display on the left side and ammo display on the right side. The icons are implemented as custom characters in the controller's character generation RAM.|
|This shows a speaker being used to generate tones of various frequencies using one of the AVR timers.|
|This is a picture of a temporary circuit used to test the shift register code. The AVR chip does not quite have enough pins for the whole planned circuit, so shift registers will be used for things like status LEDs to free up pins for other purposes.|
|This is a near-complete prototype of the circuit (it lacks the RFM12B radio chip as that uses 2mm pitch instead of 2.54mm, so I can't easily breadboard it, and also lacks the buttons, as I almost ran out of wires.) It features the infrared circuitry (including MOSFET), LCD screen, speaker, team indicator LEDs and muzzle flash LED.|
The work-in-progress code is available on GitHub.
I’ve had a few emails asking me for schematics. Unfortunately I don’t yet have anything that is finalized or completely tested, as the project is still in development, and I am afraid I have neglected to keep this in sync with the prototype circuit I built above - however, I’ve decided to upload what I have got so that it can hopefully be of some use. Just to be clear - these will almost certainly not work “as is”!
This basically covers the overall circuit. Some things to note are:
The voltage regulator, oscillators, reset line and AVR ISP parts of the circuit have not been tested, as I’ve been working with an Arduino and have not yet tried doing things directly with AVR chips (I need to buy an AVR programmer first!)
The RFM12B part of the circuit has not been tested yet either (this is pretty much everything on the right side.) I’m not sure if using the voltage divider to get 3.3v from 5v is a good idea either…
The “LCD” plug would connect to a HD44780-compatible controller. Order of the pins doesn’t really matter as this can all be changed in the software (the src/lasertag/lcd.c file defines constants such as LCD_RS, LCD_EN, LCD_D4, etc.)
The “IR TX” plug would connect to the infrared LED, and a bright red LED so that you can also see when you are firing.
The “UART” plug exists for debugging purposes. It’s possible the circuit could be extended to include an RS232 port and MAX232 chip, so that this actually became useful. (On an Arduino all this is included already.)
Values of some resistors/capacitors are missing. The model of the MOSFETs used is just the first one I picked in the EAGLE editor (and in fact this counts for other things like resitors, capacitors, the crystals, etc. too) - they are not the model I’m using in the actual prototype circuit above.
This is what would be connected to the “IR RX” plug on the main board using some sort of parallel cable. Some more things to note:
I’ve not tested connecting multiple TSOP receivers in this way yet, but from the schematics on the MilesTag website, I believe it should work.
This is an old version of the schematic which uses RGB LEDs. As I haven’t been able to locate any for cheap enough prices, I have since abandoned the idea of using them, the new sensor board below simply uses four different colour LEDs.
It’s intended you would daisy chain these together so you could have multiple sensors (e.g. on the front and back of your body), but I’ve no idea how well this would work. For example the clock rate of the shift register may need to be reduced at such a long distance because of skew.
I realised that to save wires in the connections between sensors, I could move the shift register to each individual sensor board, instead of it being on the main board. This is the updated schematic of the sensor board (also it doesn’t use the RGB LEDs any more), but there’s no corresponding updated schematic for the main board - sorry.
This is basically the extraction of the part of the main board circuit above which contains the infrared LED for firing, and the colour LED for indicating you are firing. Again, as above, there is no updated schematic for the main board. The idea of this is that if I ever get to making real PCBs for this, it’s possible the main board may be too big to fit in the gun so it may need to be on the outside of it (and kept in your pocket or something), and the gun would just have this in it (it’d also need the trigger switch too - but again, the schematic is not up to date - sorry.)
The eventual intention is that the units will communicate wirelessly with the RFM12B chips to a central server computer which can do things like keep track of scores, and allow the implementation of complex game modes (e.g. capture the flag.) This is a completely untested and unfinished circuit which has the AVR/RFM12B chip (like the main board above), but also a MAX232 chip and RS232 socket so that you could connect it to the serial port of a computer.