How it Works
When we set out to design the Target we had a number of design goals in mind:
- Simple to build even for beginners
- Low power, long battery life – Target 1 year+ from a coin cell battery
- No on / off switch
- Always active, be able to leave somewhere and keep shooting it
- Single push button interface
- Several modes – utilise the power of a micro-controller.
- Design open source, must compile with a free compiler.
We did not want an on / off switch for a number of reasons. For starters it would add cost to the project and more importantly we didn’t want to have to switch the Target on to be able to shoot it. We wanted the targets to be able to be left around or installed in a room or workshop and to be always active. You could walk into a room pick up a nerf or BB gun and casually take a pot-shot at the nearest target. However, by not having an on / off switch, the target would need to be very low power but also wake up almost instantly.
We also wanted to be able to offer various modes of operation out of the box – not just simply register a hit. By using a microcontroller at the heart of the target we would have a multitude of possibilities. After a bit of quality time with Google, weighing up the pros and cons of various devices, we settled on the nanoWatt range of microcontrollers from Microchip, principally the PIC18LF1822. This comes in a small 8-pin package and bundled a jaw-dropping list of features and incredibly low power. Combine this with the new Microchip free toolchain and we had our baby.
In general terms the circuit operation is very simple: it uses a small piezo transducer as a shock sensor which is fed to a microcontroller input for detection. Upon being “shot” the microcontroller will then light an LED and produce a sound. On top of this a single switch is used as a user input device to setup parameters and trigger different modes.
The piezo transducer actually generates a voltage when it experiences a shock. This voltage can go both positive and negative and can reach quite high levels – several tens of volts, far higher than the input of the micro controller can handle. Thus the output of the piezo must be “conditioned”. First it is half-wave rectified by D2 and D3 which in effect removes the negative going part of the signal. Second we must limit the signal to a level that the micro can handle. This is the job of the zener D4 which will clip the signal to around the 2.7V level. As we are powering the circuit form a 3.0V button cell, this gives a small margin of error even when using tired batteries which can drop to around 2.8V. R1 and C3 further filter to signal and clean it up for the input. In practice C3 seems to dull the sensitivity of the target and is not fitted as standard.
The target uses a small buzzer BUZ1 to give audible feedback. There are two main ways of driving a buzzer like this: single-ended and differential.
In single-ended the buzzer is connected between one I/O pin and 0V. To drive the buzzer you can output a square wave on the I/O pin which in our case would drive it at around 3V. To get the maximum sound out you would also drive the buzzer with a square wave at the resonant frequency of the buzzer, which in this case is around 4kHz.
In differential mode a cunning trick is used in which the 0V and 3V end are swapped over continually during the square wave, effectively driving double the voltage across the buzzer and giving a corresponding increase in volume. In the Target the buzzer is connected between two I/O pins: P1A and P1B which can be setup to drive differentially using a peripheral within the microcontroller. In you fancy seeing the difference between single-ended and differential, the firmware includes a routine for each which can be swapped around and experimented with. It also includes routines to generate notes so that tunes can also be played.
The microcontroller spends the vast majority of it’s time asleep in a low power mode. However, it can be woken almost instantly from one of three sources:
- External Interrupt – Piezo hit
- Interrupt on change – Button
- Watchdog Timeout (when enabled)
In normal operation the target is permanently waiting to be shot. It has no on-off switch, so it goes into a low power state and waits. A signal from the piezo will cause the External Interrupt to fire, waking up the chip, which then will sound the buzzer and light the LED indicating a hit has been registered.
For timed operation, pressing the switch on the rear of the PCB will wake up the chip which will then process the interaction depending on how long or how many times the user holds down the switch.The switch is the main user interface for the control of the target.It can be used to setup a timed mode and also start a timed sequence. In between switch presses and during timed sequences the Target will also sleep and wakeup periodically using the watchdog timer. It keeps track of what mode it is in, where it is in a sequence and and what jobs need to be done next via a state machine.
When the target is sleeping in consumes around 10 uA of current with the LF low power variant of the PIC12LF1822. With the higher power variant, the PIC12F1822, this is around 24 uA. In both cases this rises to around 1.5 mA when the target is shot. So a normal 200 mAH CR2032 button cell could theoretically power the Target for a couple of years depending on how many times it is shot.
One of the earliest problems that we had was with the first style of battery holder that we used, the shock of hitting the target with the Nerf discs would jump the battery off it’s contacts momentarily and reset the micro. Two solutions were implemented to solve this: firstly a more robust battery holder was used and secondly a power supply reservoir capacitor C1 was added to buffer contact bounce during extreme abuse!
The target firmware can be modified and customised very easily. See Target Modification for more details.