doc

advertisement
Final Report
Designing An Electronic Trigger Mechanism For A Paintball
Marker To Allow User Selectable Firing Rates
ECE4007 Senior Design Project
Section RP1, E-Trigger Team
Andrew Adams
Matt Roese
Nathan Densmore
Chris Britton (Team Leader)
Submitted
December 9, 2007
Team E-Trigger (ECE4007RP1)
1
TABLE OF CONTENTS
Executive Summary........................................................................................................... 3
1. Introduction ................................................................................................................. 4
1.1
1.2
1.3
Objective ............................................................................................................. 4
Motivation ........................................................................................................... 5
Background ......................................................................................................... 5
2. Project Description and Goals .................................................................................... 6
3. Technical Specification ............................................................................................... 7
4. Design Approach and Details
4.1 Design Approach .................................................................................................. 9
4.2 Codes and Standards........................................................................................... 11
4.3 Constraints, Alternatives, and Tradeoffs ............................................................ 11
5. Schedule, Tasks, and Milestones .............................................................................. 12
6. Project Demonstration .............................................................................................. 14
7. Marketing and Cost Analysis ................................................................................... 15
7.1 Marketing Analysis ............................................................................................ 15
7.2 Cost Analysis ...................................................................................................... 16
8. Summary and Conclusions ....................................................................................... 18
9. Bibliography............................................................................................................... 19
Appendix .......................................................................................................................... 20
Team E-Trigger (ECE4007RP1)
2
EXECUTIVE SUMMARY
The goal proposed this past semester was to build an electronic trigger (e-trigger) for the
Tippmann 98 Custom paintball marker. The 98 Custom is one of the most widely used paintball
markers on the market, and has proven itself a reliable marker with its operational simplicity.
However, it’s this simplicity that limits the 98 Custom’s performance against more
technologically advanced markers, such as the Tippmann A-5 E or Ion electric markers. Since
these markers have electric trigger devices, they can achieve automatic firing rates upwards of 20
balls per second, while operators on the traditional semi-automatic markers can only fire as fast
as they can manually pull the trigger. Building, programming, and implementing an e-trigger for
this marker would allow many players to take advantage of faster automatic firing rates.
The mechanics behind the operation of the e-trigger are simple. On a standard pneumatic
paintball marker the operator pulls the trigger. This presses the sear lever, releasing firing bolt
forward which positions the paintball in the barrel and discharges air propelling the paintball out
of the marker. After the paintball is expelled, the bolt is blown back to its original state, resetting
the sear lever and closing the air valve allowing it to re-pressurize for the next shot. Using a
powered solenoid, this firing process can be initiated at rates faster than the conventional manual
operation. The operator pulls the trigger, closing the contacts on the microswitch and sending a
signal to the e-trigger microcontroller. Depending on the selected settings, the microcontroller
sends a pulsed signal at the appropriate rate that will activate the solenoid. This type of upgrade
for the 98 Custom would benefit the paintball enthusiast interested in increasing their marker’s
capabilities without having to purchase a more expensive marker. And because the materials
needed to construct an electronic trigger are fairly inexpensive, cost passed onto the consumer
could be kept to a minimum.
Team E-Trigger (ECE4007RP1)
3
Designing An Electronic Trigger Mechanism For A Paintball Marker
1.
INTRODUCTION
The Tippmann 98 Custom is entry level paintball marker that lacks the electronic trigger
upgrades available for many other popular markers on the market. Introducing an electronic trigger
option to the 98 Custom market would allow these entry level markers to compete with the higher
end weapons. In addition to developing an upgrade not currently available, the trigger would feature
a simple, easy to use interface with a display and buttons to change modes and firing rates. Having
an easily configurable setup would allow the player to change settings in the field, as the tactics and
strategies of the game change. By reducing production costs and still offering the same capabilities
as that of more expensive markers and competing electronic triggers, the WTR .98 Special is now an
affordable option for Tippmann paintball enthusiast.
1.1
Objective
The objective over the past semester was to create an electronically-driven trigger mechanism for
the Tippmann 98 Custom paintball marker that would be comparable to triggers found on more
expensive markers. The advantage of having an electronic unit to control the firing of the gun is to
take advantage of a faster, fully automatic capability. Having two modes would allow for the
operator to tailor the trigger to the situation. Semi-automatic firing capability helps to conserve
ammunition and the air supply. Fully automatic mode fires much more ammunition, which is useful
for situations where you are not as concerned about accuracy or resources. The target market for
such a device would be scenario paintball enthusiasts who currently own the Tippmann 98 Custom
marker or are looking to purchase a marker with aftermarket options.
Team E-Trigger (ECE4007RP1)
4
1.2
Motivation
The Tippmann 98 Custom marker is widely used, and recognized as an entry-level paintball
marker. Designing an electronic trigger for the marker that offers fully-automatic and semiautomatic firing modes, owners of the 98 Custom marker will be able to play competitively against
owners of higher-end paintball markers. While electronic triggers exist for the 98 Custom marker
that offer many features of higher-end markers our electronic trigger design will offer most of the
same features as existing models and some more field practical features that would still appeal to the
scenario player. It will allow players to change settings for firing modes quickly and see the changes
made on an LCD display, rather than using a wrench and an instruction manual to change settings as
is the case with existing electronic triggers.
At one time electronic triggers were available for the 98 Custom, but production soon ended
and companies began to concentrate on the newer model markers associated with the speedball
competitions. The 98 Custom was left without upgradeable trigger options. Reintroducing this back
into the marketplace, along with a more user-friendly and field adjustable unit, would once again
give entry level players this type of option for their marker.
1.3
Background
There are existing electronic triggers in many higher-end paintball markers. Mechanically,
almost all electronic triggers function in the same manner. The controls that allow the user to
change between functions are usually what distinguish the units from one another. Other electronic
trigger units have notoriously been known to require a great deal of effort to changed selected modes
and firing rates. In addition to offering a trigger for a gun without current options on the market, a
second unique feature to be incorporated was a user friendly, field adjustable interface. Current e-
Team E-Trigger (ECE4007RP1)
5
trigger units require the tedious usage of step by step instructions from a user manual, an assortment
of small tools, and a great deal of patience to change any of the firing modes, firing rates, or other
features. Additionally, most units only use a single blinking LED to display these current settings,
using a set number of consecutive flashes to convey settings. These drawbacks were a motivating
factor for making a unit with intuitive controls and easy to manipulate functions.
2.
PROJECT DESCRIPTION AND GOALS

Firing modes: semi-automatic and fully automatic
Two modes were programmed, where each mode is activated with the toggle switch. The
selectable firing mode objective was successfully implemented in the final trigger unit. A
continuation of this project could include more mode firing options, such as three shot bursts or
semi-automatic and fully automatic combination mode.

LCD features: display the selected mode of fire
A main feature incorporated into the design was a display to communicate selected settings to
the player. The LCD was implemented as the main communication path for displaying settings.
This objective was successfully met in the final trigger unit, displaying “SA MODE” when the
trigger is set in semi-automatic mode, and “FA MODE” when in fully automatic mode.

LCD features: display the selected rate of fire
The approach to this objective was to supply the firing rate data from the PIC to the LCD. This
was attempted, but the final working version of the code does not implement this feature. The
difficulty came in supplying this firing data to the LCD at the same time as the currently selected
mode, and having the firing rate data update as it was being changed by the operator. Although
Team E-Trigger (ECE4007RP1)
6
this goal was unsuccessfully met, observing from a user standpoint lends a positive position.
The operator is not necessarily concerned with the actual firing rate setting, but rather that the
trigger is firing at a “slower” rate or “faster” rate. The omission of this rate being displayed has
no detrimental effect to the operation of the marker.

LED indicator: Low ammunition indication
The LED was incorporated as a second component to communicate settings to the user. After
the operator has fired a preset number of times, the LED will alternately blink red and green.
Ideally, this preset limit would correspond to the capacity of the hopper, usually around 200
balls. For demonstration purposes, the unit is programmed for ten shot intervals before the LED
reload indication is tripped. This objective was successfully implemented into the working
trigger.

LED indicator: Selected mode of fire indication
The LED is also programmed to indicate the selected mode by displaying green for semiautomatic mode and red for fully automatic mode. These are in place for a “quick glance”
indication of the selected mode, keeping the operator from having to turn the gun up to be able to
read the LCD screen.

Pushbuttons: up/down to select the rate of fire.
The pushbuttons have two functions for the trigger. The rate of fire, when in full automatic
mode, is adjusted using the up and down pushbuttons. The up pushbutton will increase the firing
rate by approximately three balls per second, while the down pushbutton will decrease the firing
rate by the same amount. When the low ammunition indicator is activated, the operator can reset
Team E-Trigger (ECE4007RP1)
7
by depressing both pushbuttons at the same time. The pushbuttons and the functions they
perform are fully operational on the trigger.
3.
TECHNICAL SPECIFICATIONS
Aspect of Design
Original Design Specification
Actual Design
Switchable Modes
Max Ball Rate of Fire
Adjustable Rate of Fire
Off, Semi-Auto, Full-Auto
15 BPS (Balls per Second)
1-15 BPS integer increments
Ammunition level alert
Alert <10% ammo remain
8 Char User BPS firing rate and low
ammunition indicator
Multicolor firing mode indication and
low ammunition indicator
TBD
Successfully met
Successfully met
Successfully met
Alert upon running out; Disable trigger
upon low ammunition
Displays firing mode and low
ammunition only
LCD User feedback
LED user feedback
Weight
Current Req.
Voltage Req.
Semi-Automatic
Full-Automatic
Push button BPS
Select
Ammo Indicator Reset
TBD
9V
Marker fires one ball per trigger pull
Marker fires set ball rate while trigger is
pulled and stops upon release of trigger
User can easily and quickly increase or
decrease rate of fire in full automatic
mode
Utilize existing pushbuttons to reset low
ammunition indicator
Team E-Trigger (ECE4007RP1)
Successfully met
14-15 oz.
Need higher current to fire solenoid
more forcefully
9V
Successfully met
Successfully met
Successfully met
Both pushbuttons pushed
simultaneously resets low ammunition
8
4.
DESIGN APPROACH AND DETAILS
4.1
Design Details
The PIC microcontroller is the component that controls the functionality of the electronic
trigger. The microcontroller will be powered by a 9V battery that passes through a 5V voltage
regulator. A micro switch positioned behind the trigger is responsible for the input signal to the
microcontroller, which allows a 9V signal to energize a solenoid. The solenoid pushes a rod up,
causing it to contact the sear pin and allows the marker to fire. Each time the solenoid is
activated, a magnet assists in resetting the solenoid back into the firing position.
To initially activate the e-trigger, a three way toggle switch is flipped from the off
position to either fully automatic or semi-automatic modes. The toggle switch passes a signal to
the microcontroller to determine what mode (off, semi-automatic or fully-automatic) the marker
will be in. After a firing mode is selected, the microcontroller outputs to an LED that displays
this mode based on the illuminated color. The LED will display red for fully automatic mode,
green for semi-automatic mode, and both colors for low ammunition warning. In addition to the
LED mode indicator, the PIC will also display the mode information on the LCD. The LCD
module incorporates the actual screen, an intermediate controlling unit, and its associated drivers
all in a single package. Having a unit such as this eliminates the need for integrating these
components individually and also allows for the mounting in a more compact enclosure. When
in fully automatic mode, the operator will use the two pushbuttons to fine tune his firing rate.
The pushbuttons control the selected firing rate by sending a signal to the PIC to increase or
decrease while in fully automatic mode. Additionally, depressing both the up and down
pushbuttons simultaneously will reset the low ammunition status on the LED.
Team E-Trigger (ECE4007RP1)
9
Figure 1: Housing that will hold all of the electronics
The housing shown above will include the three position switch for mode selection (off, semiautomatic, fully-automatic), the LCD screen to show the ball rate, pushbuttons to alter the rate of
fire, and the LED for selected mode and low ammunition warning. This housing will be
mounted on the right side of the marker in a way that will not hinder its operation, as shown in
Figure 2.
Figure 2: Housing in figure1 mounted on the paintball marker
Team E-Trigger (ECE4007RP1)
10
4.2
Codes and Standards
Due to the nature of this design, the team followed no specific standards in the
development of the e-trigger. However, the elements that were used to implement the design
followed the ISO9001, Underwriters Laboratories compliance, and other applicable industry
guidelines for electronic equipment.
4.3
Constraints, Alternatives, and Tradeoffs
The WTR .98 Special was intended to be placed on an unmodified marker, and because
of this weight and size were factors that heavily influenced many aspects of the design.
Powering the electronic trigger components was a first obstacle that needed consideration.
Taking the size limitations into account, the 9V battery provided the most compact option to
power the trigger. Using a battery of this size would allow for adequate power for the PIC, LCD,
and other components and take up a minimal amount of room in the enclosure. The tradeoff of
this choice was the battery life. Although the team did not have any notion of how long a single
battery would power the unit, existing electronic triggers for other markers have a range of 3000
to 3500 shots. A safe assumption was made that it would be considerably less than this
benchmark, due to the extra power being drawn for the LCD and LED.
A second constraint was the rate of fire and how it affected the mechanical components
of the marker. Moving parts of the marker, like as the pushrod and sear pin, were not
constructed to withstand the forces generated by high repetition fire. To keep a safe margin for
material tolerances and promote equipment longevity, an arbitrary maximum firing limit was put
in place. Not only will this help to keep the electronic trigger unit from damaging the marker,
but will also keep the operator safe from malfunctioning equipment.
Team E-Trigger (ECE4007RP1)
11
5.
SCHEDULE, TASKS, AND MILESTONES
Each week, the team subdivided task to individuals for completion towards a weekly
“team goal.” Weekly progress meetings were held to assess the team members’
accomplishments towards the current task. Pictured below is the original timeline the group
aimed at following towards completion.
Figure 3: Associated Gantt chart for the development and completion for the electronic trigger
Although the group accomplished all of the goals with the exception of incorporating the firing
rate into the display, there were a few areas that took slightly longer than were expected. The
enclosure fabrication, which was originally given one day to complete, took slightly longer.
After having the printed circuit board finished with all the circuit components, the group had
problems fitting it into the original enclosure. After realizing the space was not big enough for
the amount of wires needed and the circuit board, an alternative box had to be fabricated and
Team E-Trigger (ECE4007RP1)
12
refitted. This took a few extra days, but overall did not contribute to not completing any of the
original objectives.
Team E-Trigger (ECE4007RP1)
13
6.
PROJECT DEMONSTRATION
For the initial testing of the trigger, the circuit was partitioned into sections and assembled on
a breadboard. The circuit was then checked with a multimeter at full power to see that the
correct voltage was being delivered to each element, and the voltages were changing as different
modes were selected with the toggle button and the firing rates were altered with the
pushbuttons. There was some planning involved with the final demonstration because of the
inability of bringing the actual marker onto campus. The group wanted to present videos to the
audience, which would not only add to a slightly different presentation style, but would also be
available online for others to view from the website.
To demonstrate full functionality, the group recorded various stages in the build of the etrigger, and would walk the audience through all of the functions. Two videos were chosen for
the demonstration, one showing full functionality while assembled on the breadboard, and a
second showing full functionality in the final enclosure. To demonstrate full functionality, the
trigger was turned on and fired ten rounds in semi-automatic mode. In semi-automatic mode the
LCD would display “SA MODE” and the LED would illuminate green. After ten rounds, the
low ammunition status was activated, and the LCD screen would display “LO AMMO” and the
LED would alternately flash red and green. After resetting the low ammunition status by
depressing both the up and down pushbuttons simultaneously, the LCD screen would display the
last mode set, while the LED would illuminate either red or green based on the previous mode.
The selected mode was then changed to fully automatic mode, where the default rate of 15 balls
per second was fired. The firing rate was ten adjusted by using the up and down pushbuttons and
firing at these increased and decreased rates.
Team E-Trigger (ECE4007RP1)
14
7.
MARKETING AND COST ANALYSIS
7.1
Marketing Analysis
A primary goal incorporated into the unit was the ability for the operator to quickly and easily
change the configurations while on the field. Other comparable electronic trigger units do not
allow for quick mode switching, due to the location of the board inside the handle of the marker.
Once the user had access to the board, changes could be made by counting the flashes of an LED
and using a special tool to modify the firing modes. An in-depth understanding of the board, as
well as access to the tools and an operation manual were all drawbacks that were to be addressed
with the WTR trigger unit. The WTR unit gained its advantage with an easy to operate interface
that allows for quick selection of system configurations. At a glance, both the LCD screen and
LED display current firing mode, while the LCD also informs the operator of the selected firing
rate. In fully automatic mode, the firing rates are easily adjusted by use of the pushbuttons. The
LCD facilitates the processes of changing these rates by displaying the information on its screen,
as the buttons are activated. This is more straightforward when compared to other units, where
counting the number of flashes of an LED to determine the firing rate becomes tedious.
The
toggle switch allows the switching between modes an intuitive process, and because it does not
require any special tools or a manual, proves to be much more practical.
Team E-Trigger (ECE4007RP1)
15
7.2
Cost Analysis
To determine the development cost, first estimate 15 hours per semester for class time.
Estimate another 5 hours per week of work. There are 16 weeks of work for the semester. That
means on average, each person will spend 16*5+15= 95 hours per person per semester. Multiply
by 4 people in the group and that makes 380 hours total. Assume $25/hour starting salary and
that makes $9500 in development cost for labor. Development cost for parts is about $45 for a
programming kit for the microcontroller. On a series of 5 years, assume 100 units sold per year,
making 500 total units sold. Parts cost per unit is approximately $60. Assume 1 hour of assembly
at $20/hour. Assume 3 hours of testing for the product at $20/hour. Set fringe benefits at 0% of
labor because there are none for this type of team design, overhead at 5% of materials, labor and
fringe benefits due to the cost of sustenance and parts shipping, 25% of selling price for sales and
market expense for advertisements and time spent dealing with vendors, and none of selling
price committed to warranty and support expenses since there are no warranties included with
the product. Given these inputs, the WTR .98 Special would have to sell at a price of $223 to
make any profit. Shown below is the breakdown of how expenses and income is allocated.
Team E-Trigger (ECE4007RP1)
16
Fringe Benefits
0%
of labor
Overhead
5%
of materials, labor & fringe
Sales & Marketing Expense
25%
of selling price
0%
of selling price
Warranty & Support Expense
Development Cost (Non-recurring Cost)
What it costs the company to develop the product
Parts
45
Labor
9,500
Fringe Benefits, % of Labor
0
Subtotal
9,545
Overhead, % of Matl, Labor & Fringe
477
Total
$10,022
Determination of Selling Price
What the customer pays the company for the finished product
Based on:
500
Parts Cost
60
Assembly Labor
20
Testing Labor
60
Total Labor
80
Fringe Benefits, % of Labor
Subtotal
Overhead, % of Matl, Labor & Fringe
Subtotal, Input Costs
Sales & Marketing Expense
0
140
7
147
56
Warranty & Support Expense
0
Amortized Development Costs
20
Subtotal, All Costs
Profit
Selling Price
Total Revenue
Total Profit
Team E-Trigger (ECE4007RP1)
units
223
0
0.1%
$223
$111,500
$103
17
8.
SUMMARY AND CONCLUSIONS
The WTR .98 electronic trigger prototype taught the team members a great deal about
the work it takes to create a design and implement that design. The trigger was fully functional,
but there were some different approaches that could be taken on continuation projects to improve
the design of the unit. One of these areas is the LCD module that was chosen for this prototype.
The module displayed the settings sufficiently, but seemed too much for what was needed for
this application. The LCD module chosen displayed larger than what would be practical for a
paintball player, and the amount of wiring used to support the device was a factor when trying to
minimize the enclosure size. A second area that needed improvement was the size and design of
the printed circuit board created for the e-trigger. In trying to create the most compact design
possible, the team members overlooked how difficult it would be to mount and soldier the circuit
elements to this board. Having a circuit board that would allow for mounting the elements
around the perimeter of the board would allow for easier soldiering and would prevent the
elements from interfering with each other.
The team’s original objectives were successfully met for the most part, and the group
worked well together to divide and conquer the various tasks needed for completion of the
project. Looking back, a more thorough preparation of the PIC microcontroller’s operation and
programming would have been useful for quicker debugging and more efficient code structure.
To better prepare this design for release to the marketplace, a second prototype a smaller LCD,
smaller buttons, and a more compact enclosure would allow for better fitment to the marker. A
more powerful striking solenoid would also benefit the operation of the marker.
Team E-Trigger (ECE4007RP1)
18
9. Bibliography
Paintball Extreme Sport Tips & Strategies,” [Online document], 2007, [2007 Sept. 13],
Available: http://www.paintball-basics.com/paintball-guns.php
B. Mills, D. Mills, “World And Regional Paintball Information Guide,” [Online document],
2007, [2007 Sept. 14], Available:
http://www.warpig.com/paintball/technical/paintguns/tippmann/a5etrigger/index.shtml
“Rocky Mountain Sport,” [Online document], 2002, [2007 Sept. 14], Available:
http://www.rockymountainsport.com/howdoesthatp.html
Muhlestein, David. "Electronic Versus Mechanical Guns," [Online document], [2007
Sept. 14], Available:
http://paintball.about.com/od/markersguns/ss/electro_vs_mech_4.htm?terms=electronic+t
riggers%20paintball
Wikipedia contributors."Tippmann 98 Custom,”Wikipedia, The Free Encyclopedia; 2007
Sep 1, [cited 2007 Sep 1]. Available:
http://en.wikipedia.org/wiki/98_Custom#Custom_Pro.
Wikipedia contributors."Tippmann a-5,”Wikipedia, The Free Encyclopedia; 2007 Sep 1,
[cited 2007 Sep 1]. Available:
http://en.wikipedia.org/wiki/Tippmann_A-5#E-Grip.
Team E-Trigger (ECE4007RP1)
19
APPENDICES
Appendix Figure 1 : PCB component layout
Team E-Trigger (ECE4007RP1)
20
Appendix Figure 2 : PCB final layout
2 - VDD
1- Ground
PIC
2
Enable
6
4
Read/Write
5
5
Data bit 5
12
6
Data bit 4
11
7
Data bit 3
10
8
Data bit 6
13
9
Data bit 7
14
14
Data bit 2
9
15
Data bit 1
8
16
Data bit 0
7
17
Register Select
4
LCD Module
Appendix Figure 3 : PIC to LCD connections
Team E-Trigger (ECE4007RP1)
21
1
20
Solenoid Output
2
19
Firing Mode Input
LCD6
3
18
Trigger Input
LCD5
4
17
LCD4
LCD12
5
16
LCD7
LCD11
6
15
LCD8
LCD10
7
14
LCD9
LCD13
8
13
Red LED
LCD14
9
12
Green LED
10
11
Pushbutton Up
Pushbutton Down
PIC16F690
+5 V
Appendix Figure 4 : PIC to LCD connections
The final version of the PIC microcontroller code is shown below. The code was originally
written in a PIC-specific programming environment, and was formatted accordingly.
;**********************************************************************
;Author: Matthew Roese
;Date: 7 November, 2007
;Version: 4.0 EVERYTHING
;Comments: Georgia Tech Senior Design Fall 2007
;
E-Trigger Group
;**********************************************************************
;
here, we have to set up what processor we are using, tell the IDE
which header file to include based on the processor we are using.
;we also mark the beginning of the code, have the interrupt section here
(which we won't be using), and tell it to jump to the beginning
;of our running program.
processor
what processor is used
include
file for processor
16f690
;tell
<p16f690.inc>
;header
ORG 0000h
the beginning of the code
;marks
GOTO START
label start so we skip interrupt section
;jump to
Team E-Trigger (ECE4007RP1)
22
ORG 0004h
;beginning of interrupt section
;we don't really use interrupts, so... there's
nothing here.
RETFIE
;end of
interrupt section
;
this is the beginning of our running program. the first section here
is where we set up all of our constant names so we don't
;have to constantly be referring to the specific register that is being used.
Just a note, each register, unless it is something special,
;is 8 bits long. And all of our numbers are in hex, so get a calculator or a
pen/pencil and convert our hex values to see what each bit
;really is. That helps a lot. To keep things a little separated and more
organized, we first set up the constant names for the
;configuration and I/O registers. Then we change the settings of the pic for
our uses. Thirdly, we set up the constant names of general
;purpose registers that we will use to hold temporary values for programming
purposes.
START
;beginning of the running code
;set up constants for configuration and i/o registers
STATUS EQU 03h
use this register for changing the banks, areas
;mainly
;
where different registers are stored
;change
Banks: bits 6 and 5, RP1 and RP0 respectively
;
bits 6-5: 00-bank0 01-bank1 10-bank2 11-bank3
PORTA EQU 05h
for I/O pins, RA0-RA5
;register
;in Bank
0
PORTB EQU 06h
for I/O pins, RB4-RB7
;register
;in Bank
0
PORTC EQU 07h
for I/O pins, RC0-RC7
;register
;in Bank
0
TRISA EQU 85h
;Determines whether pins of porta are input or output
;bits set
to 1 are input, 0 output
;input
pins: RA0, RA1
Team E-Trigger (ECE4007RP1)
23
;in Bank
1
TRISB EQU 86h
;Determines whether pins of portb are input or output
;bits set
to 1 are input, 0 output
;input
pins: RB6, RB7
;in Bank
1
TRISC EQU 87h
;Determines whether pins of portc are input or output
;all are
output pins
;in Bank
1
ANSEL EQU 11Eh
analog/digital output of inputs ANS7:0
;controls
;in Bank
2
ANSELH EQU 11Fh
analog/digital output of inputs ANS11:8
;controls
;in Bank
2
;must initialize all ports (i.e. clear to zero)
before we can use them
BCF STATUS,6
BCF STATUS,5
CLRF PORTA
CLRF PORTB
CLRF PORTC
;Chang
;
;Initi
;Initi
;Initi
;this is where we set which pins are inputs,
outputs
BSF STATUS,5
CLRF TRISA
MOVLW 03h
MOVWF TRISA
CLRF TRISB
MOVLW 0C0h
MOVWF TRISB
CLRF TRISC
MOVLW 00h
MOVWF TRISC
;Chang
;clear
;Set R
;
;clear
;Set R
;
;clear
;Make
;
;must initialize ANSEL, ANSELH regs so pic will
be able to read the inputs
BCF STATUS,5
BSF STATUS,6
CLRF ANSEL
CLRF ANSELH
Team E-Trigger (ECE4007RP1)
;Chang
;
;set p
;set p
24
;change back to bank 0, because that's where
ports and general purpose registers we are using all are.
BCF STATUS,6
;Chang
;set up constants for temporary storage (local variables)
BALL_LOW EQU 040h
BALL_COUNTER EQU 041h
SOL_COUNTER equ 042h
FULL_ROF EQU 043h
FULL_COUNTER EQU 044h
;this is where we really start doing stuff that we can see. no more setting
up things, let's get to the meat!
;delay the program for a long time because the
pic is too fast for the lcd, especially on startup,
;so we give it some time before we start doing
things
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
Team E-Trigger (ECE4007RP1)
25
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
DELAY
;turn on the lcd module and set it up
BCF PORTA,2
MOVLW 0Ch
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
BSF PORTA,2
;set up our actual values for some constants
Team E-Trigger (ECE4007RP1)
26
MOVLW
MOVWF
MOVLW
MOVWF
MOVWF
030h
FULL_ROF
0Ah
BALL_LOW
BALL_COUNTER
;we run the rest of the program in an infinite loop for simplicity's sake.
the loop first checks if pushbuttons are pressed. then it
;checks to see what mode the trigger is in based on the position of the
rocker switch. after the pic sorts out semi or auto mode, it
;sets the color of the led appropriately. red for full auto, green for semi.
the it sets the lcd module to say what mode it is is.
;then it checks if the trigger is pressed. after that, it loops back around
and does the whole thing over again.
INFINITE_LOOP NOP
MOVLW 015h
BTFSC PORTB,6
CALL INC_ROF
BTFSC PORTB,7
CALL DEC_ROF
SEMI_TEST
BTFSC PORTA,0
GOTO FULL_TEST
BCF PORTB,5
BSF PORTB,4
;clear lcd and set lcd to say "SA MODE"
for semi-automatic
BCF PORTA,2
MOVLW 01h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
BSF PORTA,2
MOVLW 53h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 41h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 20h
Team E-Trigger (ECE4007RP1)
27
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 4Dh
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 4Fh
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 44h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 45h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
BTFSC PORTA,1
CALL SEMI_FIRE
GOTO INFINITE_LOOP
FULL_TEST
BTFSS PORTA,0
GOTO INFINITE_LOOP
BCF PORTB,4
BSF PORTB,5
;clear lcd and set lcd to say "FA MODE"
for full-automatic mode
BCF PORTA,2
MOVLW 01h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
BSF PORTA,2
MOVLW 46h
Team E-Trigger (ECE4007RP1)
28
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 41h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 20h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 4Dh
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 4Fh
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 44h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 45h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
BTFSC PORTA,1
CALL FULL_FIRE
GOTO INFINITE_LOOP
;this is the section that is all subroutines, methods, whatever you want to
call them. if we don't want to handle it in the main loop,
Team E-Trigger (ECE4007RP1)
29
;we call a subroutine and do it here.
;if pushbutton up is pressed in the loop, the program goes here. this
decreases the delay b/w shots in full-auto mode, making
;the gun shoot faster.
INC_ROF
SUBWF FULL_ROF,1
INC_LOOP
BTFSC PORTB,6
GOTO INC_LOOP
RETURN
;if pushbutton down is pressed in the loop, the program goes here. this
increases the delay b/w shots in full-auto mode, making
;the gun shoot slower.
DEC_ROF
ADDWF FULL_ROF,1
DEC_LOOP
BTFSC PORTB,6
GOTO DEC_LOOP
RETURN
;this is a general delay loop. it basically counts down from 255 to zero
twice. it's equivalent to about 8ms or so. Think about it.
;each command takes 1 or 2 cycles. a cycle takes the pic 200ns to process.
that's fast.
DELAY
MOVLW 0FFh
MOVWF SOL_COUNTER
SOL_LOOP1
DECFSZ SOL_COUNTER,1
GOTO SOL_LOOP1
MOVWF SOL_COUNTER
SOL_LOOP2
DECFSZ SOL_COUNTER,1
GOTO SOL_LOOP2
RETURN
;if trigger is pressed in semi auto mode, the program goes here.
SEMI_FIRE
BSF PORTA,5
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,5
TRIG_LOOP
BTFSC PORTA,1
GOTO TRIG_LOOP
DECFSZ BALL_COUNTER,1
RETURN
;this is where the low ammo status for semi auto mode is found. once ball
counter reaches zero, the code skips the RETURN function and
;goes on to start low ammo stuff. Keep in mind, the trigger and
increasing/decreasing rate of fire are disabled in low ammo status.
Team E-Trigger (ECE4007RP1)
30
;this is because once you get low on ammo, no one wants to be able to keep
firing and wasting air, shooting nothing. LCD module changes
;to say "LO AMMO" and the led flashes very fast b/w red and green.
BCF PORTB,4
LOW_BALL_S
BCF PORTB,5
BSF PORTB,4
;clear lcd and change lcd to say "LO AMMO"
BCF PORTA,2
MOVLW 01h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
BSF PORTA,2
MOVLW 4Ch
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 4Fh
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 20h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 41h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 4Dh
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 4Dh
MOVWF PORTC
BSF PORTA,4
CALL DELAY
Team E-Trigger (ECE4007RP1)
31
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 4Fh
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
;this is the delay between flashing red and
green. nothing much to it.
LOW_LOOP_S1
LOW_LOOP_S2
Team E-Trigger (ECE4007RP1)
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTB,4
BSF PORTB,5
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
BTFSS PORTB,6
GOTO LOW_BALL_S
BTFSS PORTB,7
GOTO LOW_BALL_S
BTFSC PORTB,6
GOTO LOW_LOOP_S1
BTFSC PORTB,7
GOTO LOW_LOOP_S2
MOVF BALL_LOW,0
32
MOVWF BALL_COUNTER
RETURN
;if trigger is pressed in semi auto mode, the program goes here.
FULL_FIRE
BSF PORTA,5
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,5
DECFSZ BALL_COUNTER,1
GOTO FULL_START
;this is where the low ammo status for semi auto mode is found. once ball
counter reaches zero, the code skips the RETURN function and
;goes on to start low ammo stuff. Keep in mind, the trigger and
increasing/decreasing rate of fire are disabled in low ammo status.
;this is because once you get low on ammo, no one wants to be able to keep
firing and wasting air, shooting nothing. LCD module changes
;to say "LO AMMO" and the led flashes very fast b/w red and green.
BCF PORTB,4
LOW_BALL_F
BCF PORTB,5
BSF PORTB,4
;clear lcd and change lcd to say "LO AMMO"
BCF PORTA,2
MOVLW 01h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
BSF PORTA,2
MOVLW 4Ch
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 4Fh
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 20h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
Team E-Trigger (ECE4007RP1)
33
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 41h
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 4Dh
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 4Dh
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
MOVLW 4Fh
MOVWF PORTC
BSF PORTA,4
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTA,4
;this is the delay between flashing red and
green. nothing much to it.
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
BCF PORTB,4
BSF PORTB,5
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
Team E-Trigger (ECE4007RP1)
34
LOW_LOOP_F1
LOW_LOOP_F2
FULL_START
FULL_LOOP
FULL
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
BTFSS PORTB,6
GOTO LOW_BALL_F
BTFSS PORTB,7
GOTO LOW_BALL_F
BTFSC PORTB,6
GOTO LOW_LOOP_F1
BTFSC PORTB,7
GOTO LOW_LOOP_F2
MOVF BALL_LOW,0
MOVWF BALL_COUNTER
MOVF FULL_ROF,0
MOVWF FULL_COUNTER
DECFSZ FULL_COUNTER,1
GOTO FULL
RETURN
CALL DELAY
GOTO FULL_LOOP
RETURN
;and that is pretty much all we have. it took a looong time to get all this
checked and done. what a hassle! anyway, as porky says,
;a-b-de-a-b-de-a-b-de-a-b-de.... that's all folks!!
END
Team E-Trigger (ECE4007RP1)
35
Download