Why something for Poland? My blog doesn’t get that many views, but I noticed a while ago that I was getting fairly regular views from Poland (the Stats page on wordpress tells you the country of origin of all views on your site), and that these views were always to my previous post about using multiple IR receivers… I have NO idea what is going on in Poland, but I figured that if they are interested in IR transmitters/receivers, they may be interested in this new post, which follows on from my previous post about Databullets.
I finally got around to completing the design for my Arduino based laser tagger, designed to work with my nerf gun toting, powerchair based robot. Here is where I posted the tagger design on Thingiverse: http://www.thingiverse.com/thing:454862
Here’s what I intended it to look like:
Here’s how I designed it:
And here’s how it actually turned out:
Just for the hell of it, here it is in various states of undress:
Here’s a link to the latest video, showing the laser tagger being used on the robot, as well as links to the older videos:
Since the system uses infrared, which is also produced by the sun, the performance of the system is pretty bad when the receiver is in direct sunlight, but as soon as the sun is down a little it improves significantly, especially around dusk (probably REALLY good at night).
The laser tagger has a range of about 20m once the sun went down, but I’m sure that could be improved by putting higher current through the IR LED, or aligning the optics a little better.
A laser tag system based on this hardware would probably work quite well in an underground carpark, or in the office on a Friday afternoon once the boss has gone home…
In order for the receiver to pick up the IR signal, the signal needs to be strong enough. You can measure the strength of the beam in W/m². Those units tell us that there are two ways to get long range from your laser tagger:
- More power (increased W)
- Narrower beam (reduced m²)
Getting more power is easy. The infrared LEDs that I used (TSAL 6100) are rated for 100 mA (200 mA peak). If you want to be safe, you select your current limiting resistor for 100 mA, but since the IR protocols actually use a pulsed carrier signal, you should be able to push it higher, maybe take it to 200 mA. If you really want to get extra range, you can always crank the current right up, and have spare LEDs ready in case you blow it. Since the laser tagger uses an easily modified design, you could print some LED holder plugs so that you can swap it out mid-laser battle.
The problem with increasing power, is that (as the units of measurement suggest) the signal strength is inversely proportional to distance squared. So if you want to double the range, you have to quadruple the power. Which brings us to Narrowing the Beam.
If you think about your infrared remote, it is a bit like a torch. It doesn’t need to shine very far (only from your couch to your TV), but it has a very widely spread beam (you don’t want to have to be a sharp shooter just to change the channel). This is what your LED is like. The TSAL 6100 has an angle of half intensity of 10°. This is essentially the angle, around the centreline of the LED, that describes the cone of light put out by the LED (well, most of the light is inside this cone). See the datasheet extract below:
For a laser tagger, you want a fairly narrow, straight beam of light. Not only does this make the game more interesting (taking more skill to hit a target), but it gives you greater range. To achieve this, we can use a basic convex lens. I just used a standard 40mm lens from a small magnifying glass that I got from a $2 shop. By placing the LED at the focal point of the lens, the light emitted will come out the other side of the lens parallel to the centreline of the LED and lens. This means that the beam of light is now a straight, narrow cylinder (almost) instead of a wide cone. See the image below:
The best lens for the job is one where the cone of light from your LED reaches the diameter of your lens, when the LED is placed at the focus point of the lens. This way, your lens isn’t larger than necessary (increasing the size of your tagger), and it isn’t smaller than necessary (meaning that light from the LED would miss the lens, around the edges, wasting power).
The optimal diameter of the lens is calculated like this:
D_optimal = 2*tan(angle of half intensity)*focal length
To find the focal length of the lens, just go outside on a nice sunny day. Because the light from the sun has travelled so far, the rays are coming in almost parallel. So just hold the magnifying glass over something that won’t catch fire, and adjust the height until the light is focused into a tiny point (as if you were trying to set fire to the object). Now measure the height from the point of light to the magnifying glass; This is approximately equal to the focal length. I found that the focal length of my lens was about 123mm.
Now, at 123mm, a cone with a 10° half angle will have a base circle of 43mm. This means that I’m losing a little bit of light around the edges, because the lens is only 40mm in diameter. I have a 60mm lens with a focal length of 170mm, which is just about spot on, but I chose to go with the 40mm anyway, as it would make the laser tagger SLIGHTLY less bulky, awkward and ugly.
The next step is to actually fine-tune your optics. I suggest using a tagger design that lets you move your LED in three directions relative to the lens.
Set up your gun, but us a normal red (or any other visible colour) LED, instead of infrared. Stand in a dark hallway, and turn on the LED. Aim the tagger at a nearby wall, You should be able to see a faint circle. Now move the LED in and out, to get the circle sharply focused on the wall (a nice clear, crisp outline, instead of blurred). Also move the LED left/right, up/down, to get the circle bright and well rounded (not distorted). Point the tagger at a far wall to check the focus is still good. Now lock it down. I used a crap load of super glue to fix all three directions. This is important, because you don’t want the optics to shift during play, or when you replace the coloured LED for the IR LED.
Another point to take care of once you have done the above, is to align any laser pointers that you have mounted on your tagger. Since the laser on my design is mounted just below the lens, the laser (if aligned parallel to the LED) would always shine slightly below where the IR blast is shining. To ensure that a direct hit with the laser corresponds to a direct hit with the IR, I angled the laser up slightly. At close range, the laser is in the lower half of the IR circle; at long range, the laser is in the upper half of the circle. The diagram below will (hopefully) describe the arrangement better than I can.
I printed the tagger on my 3D printer; you can check out the design here: http://www.thingiverse.com/thing:454862
The intention was for the tagger to be easy to modify or enhance, and to use a user friendly mounting arrangement for all parts, so that others can design bigger and better taggers, with more features, such as:
- Ammo counter
- Sniper rifles (higher power IR LED, more precise optics arrangement, etc)
- Shotgun mode (wide angle, short range)
- Individually programmed favourites buttons
- Smartphone incorporation (using the smartphone as the controller to select ammunition types, track ammo, etc)
- IR receiver (to make a fully incorporated laser tagger system to track health, ammunition, kills, etc, for friendly laser skirmishes)
The possibilities are endless. I just wanted to make a cheap system that could be used by others for their own purposes.
The tagger functions fairly simply. It uses an Arduino Uno as the brain of the tagger (minimum. Arduino Mega would allow for greater flexibility).
The Loop code cycles through looking for events such as
- The encoder changing position (increment cursor position, or change ammo type if an ammo slot is selected)
- Trigger pressed (fire an IR signal containing the series of ammo selected)
- Timer elapsed (refresh LCD screen display to show cursor position and update loaded ammo list)
- Favourites button pressed (load ammo combination from favourites list)
The main code features that it uses to achieve this are:
- Quadrature encoder control (checks encoder position A and Position B at each cycle and compares to previous cycle. if different if determines which direction the encoder has turned, and calls an UP or DOWN function).
- IR library – as discussed in my previous databullets post, I used the library by Ken Shirriff:
- LCD library (standard with arduino software) – I still find these LCDs a little to temperamental, but they do the job, as long as your cables aren’t too long (interference can easily cause problems with the screen display)
The best way to figure it out is probably to look at my code, so here it is:
ARDUINO SKETCH FOR TAGGER (paste into Arduino, or rename to .ino):
Copy of tagger_uno_updated
ARDUINO SKETCH FOR ROBOT (paste into Arduino, or rename to .ino):
Copy of _9_1_TAG_BOT
Any questions, feel free to ask.
Here’s a copy of the schematic for the circuit board that sits between the Arduino Uno and the various switches / LCD screen / LEDs. It’s drawn up from memory, so let me know if any of it doesn’t seems right… I’m pretty sure that it’s right.
R1, R2, R3, R4, R5 – 10kOhm (pull down resistors for various switches
R6, R7 – 270 Ohm to limit base current controlling BC337 transistors.
R8 – mini potentiometer, for adjusting LCD contrast. Any rating should be fine. say 1kOhm?
R9 – 56 Ohm (or select as appropriate for your IR LED rating)
R10* – approx 72 Ohm (I had two LEDs wired in series). The reason for the asterisk is that this resistor was actually external to the circuit board, as I had a laser module wired in parallel to the muzzle flash LEDs.
Here’s a BOM for the tagger electronics, including cost:
- Arduino Uno – $10 on ebay
- Prototyping Breadboard (soldered type) – 20 cents on eBay
- Rotary Encoder – 30 cents
- Header Strips – 30 cents
- Microswitch (trigger) – 50 cents
- 16×4 LCD Screen (Hitachi HD44780 type) – $2.50 on eBay
- 2x Transistors (BC337) – 20 cents (check out RS components)
- Resistors – 5x10kOhm, 2×270 Ohm, 1×72 Ohm, 1×56 Ohm – negligible cost, you should already own some.
- mini potentiometer – 1kOhm? – negligible cost, find whatever you have lying around.
- LEDs – 1 x red, 1 x yellow – negligible cost, you should already own some.
- IR LED – TSAL6100 (940nm, 100mA, 10°) – 50 cents (check out RS components)
- Laser Diode – 50 cents
I scrounged the mini potentiometer and favourites button from an old VCR, I’m sure you can do the same with some of these parts.
My intention is to post additional parts for the A.R.M.S collection on thingiverse, such as:
- Alternative battery packs
- Alternative Arduino cases (i.e. for the Arduino Mega 2560)
- Alternative handles
- Accessory mounts compatible with Nerf Rail accessories
- Improved LCD screen mounts
- IR diode arrays
- Shotgun (sliding IR led mount to put LED closer to lens, giving shorter range but wider beam)
- Grenade launcher (under-mounted launcher that fires a ball array over-powered of IR LEDs connected to a wire, wire could be used to re-wind grenade)
And of course, I would use the same five-point screw mounting system for all of these parts, so that people can mix and match.