Saturday, 24 December 2011

OpenChrono - Cheap and Simple Airsoft Chronograph

This project is about making a chronograph cheap and easy to build. This is achieved by taking the same basic concept of any commercial chronograph - 2 (optical) sensors spaced a fixed distance apart are tripped by a bb and the time between them being tripped determines the speed of the passing projectile. Speed = Distance / Time.

The simplification comes from offloading the processing from a microprocessor, which are fairly daunting to program and onto a regular computer, which can have the software installed like any other program and the software can be patched, updated and generally is a lot easier to work on by all.

The slightly clever bit is how to connect the hardware to the software - In the past this has been done by using a serial port, but, come on, what is this, the 90s?

No I shall be using a mic port to do the data transfer, as pretty much all computers have one. AND this opens up the ability to integrate a USB sound card and convert the entire thing to a single USB slot.

Naturally, as with all simple ideas, it's been done before, but the analysis is never really properly automated. There is a fantastic "how-to" on the hardware principles written by Jim. His method involves recording the shots on Audacity and then doing a quick bit of math on the peaks of audio. However this is slow, tedious and is obviously possible to automate. But the concepts are sound. Thanks Jim!

There was also one guy that saw the same problem and actually tried to build this software, but his hardware was based on a serial port (urgh) and the software has got lost in the ether. I can't even find the link to his blog now, but you get the idea.

So, lets take a look at this in more detail...

Hardware
Other than the computer itself, the hardware consists of 2 parts. The light source and the receptor.

Light Source
In essence this is simply a pair (or more) IR LEDs connected to USB's 5v supply, dropped down to the correct voltage.

Receptor
The receptor consists of a pair (or more) of IR Phototransistors, which capture light from the LEDs. The bb passes between the two and creates a voltage spike down the wire. This is then captured via the sound card through a standard 3.5mm TRS connector. Although not yet tested, I see no reason why you couldn't use both the ring and the sleeve as separate (stereo) channels, just to make it easier to separate out the first and second spikes. Also using 2 channels means you can have up to 4 completely distinct spikes which are very easy to separate out without any overlap.

Software
The software itself is being written in C# using WinForms, just because it's a really easy language to use and there are some really nice audio libraries out there as well, such as NAudio. It listens to the 2 channels of the Mic port and when the volume is tripped over a certain level (a spike is heard) a timer is started. A timer is then stopped by the second sensor and we have the time. The distance is defined via the settings (stored as XML) and the speed is simple math!

Rate of fire can also be calculated by counting how often one of the sensors is hit.

This can be extended further to log these values, tag them as various rifles and configuration and even be used as a before and after results of work done on a rifle.