Académique Documents
Professionnel Documents
Culture Documents
by Rick Prescott
07/13/2010
Table of Contents
1 Introduction......................................................................................................................................................................3
2 Overview..........................................................................................................................................................................3
3 Operation..........................................................................................................................................................................3
4 Gun Modifications............................................................................................................................................................4
4.1 Electronic Trigger...............................................................................................................................................4
4.2 Tripod Modifications..........................................................................................................................................7
5 Sheetmetal Pieces.............................................................................................................................................................9
6 Assembly........................................................................................................................................................................11
6.1 AntiTilt Piece Installation................................................................................................................................11
6.2 Gun Mount........................................................................................................................................................12
6.3 Motor Mount.....................................................................................................................................................14
6.4 Electronics Enclosure.......................................................................................................................................15
6.5 Gun installation.................................................................................................................................................17
6.6 Cables................................................................................................................................................................17
7 Code Description............................................................................................................................................................19
8 Bill of Material...............................................................................................................................................................21
9 Resource Files................................................................................................................................................................22
10 Schematic......................................................................................................................................................................24
11 PCB Layout...................................................................................................................................................................25
12 Sheetmetal Layouts.......................................................................................................................................................26
1 Introduction
The concept of a sentinel machine guns has fascinated me ever since I first saw these machines popping up in various
movies as a younger person. The astounding ability to automatically detect, track, and fire upon a target has always
seemed technically unobtainable on the available time and budget of a simple hobbyist. Obtaining and operate a
machine gun is also a bit out of the realm of reality for most of us as well. An idea sparked in my mind one day while
walking the toy gun isle in a store with my kid and later that evening learning of the workings of a thermopile array
while surfing the internet. The result is this infrared seeking sentinel which joins a realistically priced infrared sensor
to a realistically operatable Nerf® machine gun to create a slightly less deadly yet still highly deterring automated
machine. Personally I have grand plans to deploy the infrared seeking sentinel facing the entrance of my work cubical
in order to speed interaction with less desirable visitors.
2 Overview
The following instructions detail the necessary modifications to a Nerf® Vulcan EBF25TM, describe the Devantech
TPA81 thermopile array sensor combined with other required electronics, show how to assemble the other needed
components, review the code employed on the Atmega168 microcontroller, and lists the materials needed.
The TPA81 thermopile array sensor is an array of 8 thermopile sensors all on one chip. Each of the 8 thermopile
elements has a lens and shrouds so that they have a view of 5.1˚ horizontal and 6.0˚ vertical. Each element reports
the temperature of the objects in it's field of view over the I2C bus. More information on the TPA81 sensor can be
found here: http://www.robotelectronics.co.uk/htm/tpa81tech.htm
A few modifications must be made to automate the functionality of the Nerf® EBF25TM. The manual trigger is
bypassed with an electronic trigger. Also a connector is added to provide external power and a trigger signal interface.
A stepper motor and drive train is added to provide automated pan ability Aluminum sheetmetal pieces are
incorporated onto the tripod to remove the tilt ability of the gun and provide mounts for the motor and electrics
enclosure.
Power to the system is provided by a 7.2 amp hour seal rechargeable lead acid battery. This allows operation of the
gun in areas with out an AC outlet around. The larger than stock battery pack provides sufficient power to the gun and
pan motor for extended duration operation.
An Atmega168 microcontroller provides control of the sentinel. It functions to read the TPA81 sensor and then
provides signals to properly position the pan motor. It also read/writes to various I/O to control the mode of operation
as well as the trigger of the gun.
3 Operation
Before being powered on the barrel of the gun must be manually positioned to point straight forward relative to the
infrared sensor. This syncs the position of the gun to the sensor. When powered the sentinel first scans the
background. All heat generating targets must be clear of the sensors total field of view or they will be incorporated
into the background and not be detectable. Once finished scanning and averaging the background temperature the gun
moves to its full right position to indicate it is now in scan mode.
While in scan mode the sentinel compares current temperature values to previous obtained background values for all 8
elements. If the current temperature is a selectable level above the background temperature a detection is made. The
motor is then commanded to aim the gun towards the target. If multiple elements make detections a weighted average
target is calculated to position the gun.
Several fire control modes are selectable. The first is simply a scan mode which turns on the amber lock LED when
the gun is properly aligned to the target. The second mode is single shot mode. While in this mode a single shot will
be fired when the gun aligns with the target. Finally is full auto mode. While in this mode the gun will fire when
aligned to the target and continue to fire as long as the lock is maintained.
In addition to the power and three way fire mode select switch the background reset switch is also located on the front
of the electronics enclosure. Located on the back of the electronics enclosure are the connectors for power, gun
interface, and motor control. There are also 4 dip switches that select the temperature level above the background the
target must be.
4 Gun Modifications
The following section describes the modifications that are made to the Nerf® Vulcan EBF25TM. The intent was to use
as much of the original hardware as possible and also allow for normal operation of the gun if desired.
4.1 Electronic Trigger
In order for the microcontroller to be able to firing the manual trigger must be bypassed with an electronic trigger. A
power MOSFET is used for this task. The gun must be disassembled in order to gain access to the electrical wiring.
This is done by removing the gabillion screws on the action end of the gun and then separating the shells. The action
will remain screwed to the right shell. The action will also need to be removed in order to gain access to all the
electrical wiring.
Gun action original wiring back view Gun action original wiring front view
The electrical circuit in the gun must be rearranged to allow the source pin of the MOSFET to be tied to ground so it
will function properly. Normally power flows from the positive terminal of the battery pack though the ammo belt
present switch, through the on/off switch, through the trigger switch, through the motor, and then back to the negative
terminal on the battery pack. The circuit must be changed so that power still flows from the positive terminal of the
battery pack though the ammo belt present switch, through the on/off switch, but then through the motor, trigger
switch, and back to the negative terminal on the battery pack. The electronic MOSFET switch is placed in parallel
with the trigger switch. It can be placed right on the trigger switch PCB. A pull down resistor is added to keep the
gate pin from floating. See the photos and schematic for more detail.
Current wiring configuration
Modified wiring configuration
Trigger switch original wiring Rerout around trigger switch
Motor negative rerouted to trigger switch; other side MOSFET added in parallel to trigger switch; with pull
of trigger switch routed to ground terminal adding down resistor on base
extension wire
A four pin connector is also added on the right side of the gun just forward of the battery compartment of the gun. A
hole is cut, the connector inserted, and then glued in place with 5 minute epoxy. Wires are connected to the internal
battery pack terminals and to the gate of the MOSFET. See the schematic wiring details and photo for pinouts
Connector hole cut in gun; power, ground, and trigger
Connector glued in place
signal are routed to connector
Reassembling gun
4.2 Tripod Modifications
There are several modifications to make to the tripod stand. The first is to remove the catches that somewhat lock the
gun from panning and tilting. Next the clips that mount the tripod to the gun must be removed so that a more robust
mounting system may be installed later.
The mount head is removed by unscrewing four screws and lifting it free. With the mount head off four more screws
are unscrewed to remove the pan cover and the pan tray. The white catches will now be exposed. They are held in
place by springs and are easily removed. The pan tray and cover may be reinstalled but do not install the screws yet
as a sheetmetal piece will be added later.
Tripod base unmodified Mount head removed from tripod
White pan and tilt catches and springs to be removed Pan cover and tray removed from base along with
catches
The mount clips are removed from the mount head by removing the springs and lifting out the pins and clips. Remove
both. Do not reinstall the mount head at this time because the new mount pieces will be added later.
Mount head with clips not yet removed top Mount head with clips not yet removed bottom
Mount head with clips removed top Mount head with clips removed bottom
5 Sheetmetal Pieces
Several sheetmetal pieces must be constructed to remove the tilt capability from the tripod, provide a motor mount,
provide a electronics enclosure mount, and a means to mount the tripod to the gun. Full scale prints of the sheetmetal
pieces are provided as well as .dwg and .dxf flies. It works well to cut out the prints and glue them to the piece of
sheetmetal with rubber cement. The shapes may them be cut out and drilled. Finally the shapes may be bent into the
proper shape.
The first sheetmetal piece is the antitilt piece that also adds stiffness to the tripod. The process described above is
completed using a 1/32 thick piece of aluminum sheetmetal that can be found at the local hardware store.
Cutout of sheetmetal print on sheetmetal Sheetmetal piece cutout
Tilt removing sheetmetal piece formed
Using the same process the motor mount is made. It is made from the same 1/32 thick aluminum sheetmetal. It will
later mount to the back of the tripod.
Motor mount view 1 Motor mount view 2
The same process is used to locate the holes in the gun mount. The mount piece is made from 1/8” thick aluminum
plate. The holes for mounting it to the tripod are countersunk in one side while the holes for mounting it to the gun
are countersunk on the other side.
Mount piece with countersunk gun mount holes top Mount piece with countersunk tripod mount holes
bottom
Finally the electronics enclosure is made using the same method. It is cut from 1/32” aluminum sheetmetal and
formed to shape. It will later be mounted to the front of the tripod.
Electronics enclosure mount screwed to enclosure
6 Assembly
Now that the sheetmetal components have been made and the tripod has been modified the sentinel is ready for
assembly. The following sections describe how to assemble the various components.
6.1 AntiTilt Piece Installation
In order to restrict the tilt capability of the gun tripod the sheetmetal stiffener is first added. This is done fitting the
sheetmetal piece around the tripod as shown. Make sure the pan tray and cover are installed first. New screws must
be used on the top of the tripod as the old ones are not long enough. Use some 420 x 1/2” long flat head plastic
screws. For the remaining screws drill pilot holes into the plastic tripod. Use 10 * 816 x 1/4” long pan head plastic
screws.
4 screws replaced on pan cover to hold sheetmetal tilt
eliminator
Tilt eliminator installed front view Tilt eliminator installed back view
6.2 Gun Mount
Before the gun mount can be assembled the large timing belt pulley must be modified. As shown in the picture the
hub and bushing are removed. Mounting holes are drilled through the pulley using the mount head as a guide. Use
extreme caution to insure that the mount head and pulley are concentric before drilling the holes. If not later on the
timing belt will have tight and loose spots as the gun pans. Longer than original screws are used to hold the mount
head, timing pulley, and mount plate to the tripod. Use some 420 x 1 1/4” long flat head plastic screws.
Timing pulley premodification Timing pulley postmodification
Gun mount stack unassembled Gun mount stack assembled
Gun mount assembled
6.3 Motor Mount
The motor is mounted to the tripod by first installing the sheetmetal mount. This is done by removing the 4 rear
screws previously installed when the antitilt sheetmetal piece was fitted. The motor mount uses these same 4 screws
for mounting to the tripod. Install the motor mount and screws. Fit the small pulley to the stepper motor shaft. Place
the timing belt around the large pulley and install the motor into the mount. Use 4 * 1032 x ½ long machine screws
with washers and locknuts.
Motor installed in mount (note that mount must first be Motor mounted with timing belt
installed onto tripod before installing motor)
The timing belt must be properly tensioned by loosening the mounting machine screws and sliding the motor either in
or out on the mount. Too loose and the belt will slip, too tight and the motor will not step. Note that tensioning may
need to be adjusted again once the gun is installed as the weight of the gun changes the stress on the tripod.
Completed gun mount with pan capability
6.4 Electronics Enclosure
A PCB123 file with the associated schematic and PBC layout is attached later in this document. Also raw prints of the
trace layout is provided. The first step in assembly is to solder all the electrical components to the PCB. I suggest
starting with the small resistors and capacitors working up to the ICs. Solder the large connectors, switch and
infrared sensor last. Solder on short wires that will go the the switches mounted in the front panel. Use at least 22
gauge wire for the power switch. 24 or 26 gauge is sufficient for the fire mode select switch.
DIY PCB after copper etching but prior to removing Assembled PCB
toner
Use the templates to cut the holes in the front and back panels. Use rubber cement to temporarily glue the templates
to the panels. Drill a center hole with an appropriately sized drill and square out corers with an hobby knife. Mount
the power switch and fire mode select switch in the appropriate holes. Solder the switch wires to the switches leaving
enough slack to maneuver the components. The aluminum frame of the enclosure was originally 4” long. It has been
cut down to 1 3/4” long with a hack saw.
Electronics enclosure prior to assembly
Lock LED PWR Gun Interface
IR Sensor Sensitivity
Switch DIPS
Before mounting the enclosure mount to the tripod use the mount to mark the three hole locations on the enclosure.
Drill the holes and use more of the 816 x 1/4” long pan head plastic screws to thread the enclosure holes. Do not
attach the mount to the enclosure at this point. Instead install it on the tripod by removing the front antitilt sheetmetal
piece screws and reinstall them with the enclosure mount underneath. At this point the enclosure may be assembled
with the PCB installed. Leave the back panel off so that access will be available to program the microcontroller.
Mount the enclosure to the mount.
Enclosure and mount installed
6.5 Gun installation
The gun is installed by aligning the mount plate on the bottom side of the gun. Center the plate widthwise. Line the
center line of the original mount up with the center line of the tripod. Drill pilot holes. Install the 4 * 1214 x ¾” long
flat head screws.
Gun mount with gun installed
6.6 Cables
Cables are made by soldering pins to the wires and installing them into the connectors. Spiral wrap is wrapped around
the wire bundles. ¾ heatshrink is fitted over the connectors and shrunk down around the connector and spiral wrap.
Three cables are needed power, gun interface, and the motor interface. Lengths need to be long enough to reach
enclosure box.
The power cable has two wires at least 20 gauge. Crimp connectors are used connect to the battery end and a standard
2 pin connector to interface the enclosure. The pinout is shown in the picture.
+12VDC
GND
Battery and power cable
The gun interface cable has three wires; two power wires that are at least 20 gauge and one signal wire that is 24
gauge. One 4 pin standard connector are used on each end. Pinouts are shown in the picture below. Note that the
cable is not reversible; the gun end must go to the gun.
Gun Interface
SIG SIG
PWR
PWR +PWR
+PWR Enclosure
Interface
Gun interface cable Gun interface cable pinouts
The motor cable consists of 6 wires. A 6 pin connector is used on the enclosure end of the cable and the wires go
directly into the motor on the motor end. Pinouts are shown in the photo.
GRN
BLU
WHT
BLK
RED
Motor cable and pinouts YEL
7 Code Description
The code on the Atmaga168 reads the output of the infrared sensor, controls the position of the motor, reads various
I/O for mode of operation control, and turns the gun trigger on and off. Source code in the form of .c and .hex is
attached later in this document. The following is a list of the functions and a general description of the operation of
each:
Function Name Function Operation Description
ISR(TIMER0_COMPA_vect) Interrupt service routine handler for timer0. This time is set to generate an
interrupt at 12.5 Hz. Upon interrupt communication to the TPA81 IR sensor is
initiated. The TWI interrupt takes over control once communication is started.
ISR(TIMER1_COMPA_vect) Interrupt service routine handler for timer1. This time is used to control the the
speed of the stepper motor. Upon interrupt generation a decision is made
whether to take a step or not. As accelerating and decelerating are employed a
step may not be taken even if the current position does not equal the target
position. The decision to start shooting or maintain shooting is also made here.
ISR(INT0_vect) Interrupt service routine handler for interupt0. This interrupt is tied to the
momentary push button on the front of the enclosure. Upon interrupt the
background temperature is rescanned and averaged.
ISR(TWI_vect) Interrupt service routine handler for the two wire interface or I2C. This interrupt
handles communication to the IR sensor once it has been initiated by timer0. It
provides the addresses of the 8 registers to be read and then stores the data from
each register.
ISR(USART_UDRE_vect) Interrupt service routine handler for the asynchronous serial port. Serial
communication is not normally needed but was used for debugging during
development.
main Main sets up most of the peripherals while the interrupts handle most of the
program flow. First the port pins are configured for inputs or outputs with the
proper pullups, pulldowns, or state settings. Next the timers are setup and
configured. Then the TWI is configured. Next the serial port is turned on.
Finally the interrupt pins are setup.
errorreport The function was used during the development process to debug what was going
on with the TWI.
dataout This function processes the data from the IR sensor. First if needed the
background measurements are taken. 100 samples are taken for each of the 8
elements of the sensor and averaged together. In normal scan mode new reading
are taken and if above a certain level above the background measurements they
are averaged in with the last four measurements Next a weighted average of each
of the 8 elements is calculated in order to determine the target position of the
gun. Finally the readings are formated for output through the serial port.
TakeStep This function determines is the stepper motor needs to take a step left, right, or
none at all in order to align with the target position. Acceleration and
deceleration is used to drive the motor as fast as possible without causing the
motor to skip due to the inertia of the gun. This gets a bit tricky as the target
position can constantly be bouncing around. If a motion direction change is
needed the motor must decell, stop, and then acell in the other direction. It does
this no mater what position it is in during its acell or decell ramp. Delay is
added by not taking a stepping action for the appropriate number of interrupt
generations.
Shoot This function decides to start shooting, continue shooting, or stop shooting the
gun. In scan mode the LED will come on when the current position of the gun
and target position are aligned but the gun will not shoot. In single shot mode
the gun will shoot once aligned to a target and then wait 5 seconds before being
allowed to shoot again. In full auto mode the gun will shoot as long as it is
aligned with the target.
StepDir1 This function tracks and determines which port pins to turn on and off to take a
step right.
StepDir2 This function tracks and determines which port pins to turn on and off to take a
step left.
The following lists is of the port pins and the assigned functions of each:
Port/Pin Function Comments
PB0 Motor coil 2B Blue Wire
PB1 Single shot mode Active low; both high scan mode
PB2 Auto shot mode Active low; both high scan mode
PB3 Program MOSI
PB4 Program MISO
PB5 Program SCK
PB6 Crystal 1
PB7 Crystal 2
PC0 Lock LED Active low
PC1 DIP Switch 4 LSB; on connects to gnd
PC2 DIP Switch 3 on connects to gnd
PC3 DIP Switch 2 on connects to gnd
PC4 TPA81 SDA
PC5 TPA81 SCL
PC6 Reset Active low
PC7 Not Used
PD0 Com Port Rx
PD1 Com Port Tx
PD2 Reset Background Interrupt 0
PD3 DIP Switch 1 Interrupt 1; MSB; on connects to gnd
PD4 Fire Control Active high
PD5 Motor coil 1A Red wire; step order 1A, 2A, 1B, 2B
PD6 Motor coil 2A Yellow wire
PD7 Motor coil 1B Green wire
The code is downloaded to the microcontroller via the 6 pin programming header. 16MHz crystal and no clock divide
fuses are set.
8 Bill of Material
The following is a list of components needed to put together the IR seeking sentinel A general description is provided
along with the manufacture part number. Quantities are listed as well. For PCB components a marker is listed to
identify location on the PCB and schematic
9 Resource Files
Movies: General Description; Single Shot Mode; Auto Shot Mode
Source Code: .c file; .hex file
Schematic/PCB Design: Schematic
Sheetmetal Design: .dwg file; .dxf file
10 Schematic
11 PCB Layout
12 Sheetmetal Layouts