A Ballistic Chronograph

Similar documents
GCE A level 1145/01 ELECTRONICS ET5. P.M. THURSDAY, 31 May hours. Centre Number. Candidate Number. Surname. Other Names

νµθωερτψυιοπασδφγηϕκλζξχϖβνµθωερτ ψυιοπασδφγηϕκλζξχϖβνµθωερτψυιοπα σδφγηϕκλζξχϖβνµθωερτψυιοπασδφγηϕκ χϖβνµθωερτψυιοπασδφγηϕκλζξχϖβνµθ

GCE A level 1145/01 ELECTRONICS ET5

GCE A level 1145/01 ELECTRONICS ET5

The rangefinder can be configured using an I2C machine interface. Settings control the

ELCT 912: Advanced Embedded Systems

Laboratory 11. Pulse-Width-Modulation Motor Speed Control with a PIC

IST TSic Temperature Sensor IC Application Notes ZACwire Digital Output

MicroToys Guide: Motors N. Pinckney April 2005

EASTERN MEDITERRANEAN UNIVERSITY FACULTY OF ENGINEERING Electrical and Electronics Engineering Department

Sensor Interface Using PIC12CXXX as a Sensor Interface for Metal Detection

Microcontroller Based Inductance Capacitance Meter

Embedded Systems. Interfacing PIC with external devices Analog to digital Converter. Eng. Anis Nazer Second Semester

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

Discrete Logic Replacement Garage Door Indicator

The Basics Digital Input

Three-Stage Coil Gun

Department of Mechanical and Industrial Engineering MECH 471 MICROCONTROLLERS FOR MECHATRONICS. Laboratory Specialist

PICmicro MCU APPLICATION DESIGN AND HARDWARE INTERFACING

Touchless Control: Hand Motion Triggered Light Timer

Binary Outputs: LEDs

Embedded Systems. Oscillator and I/O Hardware. Eng. Anis Nazer First Semester

Introduction to Using the PIC16F877 Justin Rice IMDL Spring 2002

Final Project Report E3390 Electronic Circuits Design Lab. RFID Access Control System. Jeffrey Mok Joseph Kim

Triple Stage Incubator

LAB 1 AN EXAMPLE MECHATRONIC SYSTEM: THE FURBY

ECE Senior Design Final Report For. Scalable Regulated Three Phase Power Rectifier. May 10, 2004 Rev. 1.0

ECE U401/U211-Introduction to Electrical Engineering Lab. Lab 4

PROCESS. Object. Block diagram of our design. DISPLAY THE DISTANCE (7 segment display) PIC 16F873

Chapter 13: Comparators

FM Tuner Controller for Portable and Car Radios

EE 314 Spring 2003 Microprocessor Systems

Section 22. Basic 8-bit A/D Converter

Devantech SRF04 Ultra-Sonic Ranger Finder Cornerstone Electronics Technology and Robotics II

PIC Functionality. General I/O Dedicated Interrupt Change State Interrupt Input Capture Output Compare PWM ADC RS232

LABORATORY EXPERIMENT. Infrared Transmitter/Receiver

Houngninou 2. Abstract

Pololu TReX Jr Firmware Version 1.2: Configuration Parameter Documentation

Measuring Distance Using Sound

Physics 335 Lab 7 - Microcontroller PWM Waveform Generation

T6+ Analog I/O Section. Installation booklet for part numbers: 5/4-80A-115 5/4-90A-115 5/4-80A /4-90A-1224

The Breakdown. Figure 1: Block Diagram (above: Transmitter; below: Receiver)

Follow this and additional works at: Part of the Engineering Commons

;;;;;;; Variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; cblock Bank0RAM ;Temporary storage for STATUS during interrupts

Pulse Width Modulated Linear LED Bar Graph Display

A MORON'S GUIDE TO TIMER/COUNTERS v2.2. by

University of North Carolina-Charlotte Department of Electrical and Computer Engineering ECGR 3157 Electrical Engineering Design II Fall 2013

Pulse-Width-Modulation Motor Speed Control with a PIC (modified from lab text by Alciatore)

Frequency Synthesizer Project ECE145B Winter 2011

Hashemite University Faculty of Engineering Mechatronics Engineering Department. Microprocessors and Microcontrollers Laboratory

EXERCISE 4: A Simple Hi-Fi

Model 305 Synchronous Countdown System

MicroToys Guide: Motors A. Danowitz, A. Adibi December A rotary shaft encoder is an electromechanical device that can be used to

State Machine Oscillators

K1EL Granite State Crystal Matcher GS XTAL

Scope. Here are the times schedule of the pulse-echo technique detect method. Reflect pulse. Emit detect pulse (Ultrasound)

Mechatronics Project Kit - Getting Started Manual

ECE 511: FINAL PROJECT REPORT GROUP 7 MSP430 TANK

Chapter 2: Your Boe-Bot's Servo Motors

AN1730. Digital Amplification Control of an Analog Signal Using the MC68HC705J1A. Introduction

APPENDIX A HARDWARE DETAILS

Brian Hanna Meteor IP 2007 Microcontroller

LAB PROJECT 2. Lab Exercise

I2C Encoder. HW v1.2

The physics of capacitive touch technology

CALIFORNIA SOFTWARE LABS

Project 3 Build a 555-Timer

ECE 203 LAB 2 CONTROL FUNDAMENTALS AND MAGNETIC LEVITATION

UNIVERSITY OF VICTORIA FACULTY OF ENGINEERING. SENG 466 Software for Embedded and Mechatronic Systems. Project 1 Report. May 25, 2006.

Infrared Communications Lab

' The PicBasic Pro Compiler Manual is on line at: '

TECHNICAL NOTE. A COMPACT ALGORITHM USING THE ADXL202 DUTY CYCLE OUTPUT by Harvey Weinberg

Portland State University MICROCONTROLLERS

Input/Output Control Using Interrupt Service Routines to Establish a Time base

Part (A) Using the Potentiometer and the ADC* Part (B) LEDs and Stepper Motors with Interrupts* Part (D) Breadboard PIC Running a Stepper Motor

Many people in their spare time try to find interesting activities to do to keep them

High Current MOSFET Toggle Switch with Debounced Push Button

Application Note Temperature Sensor IC

HD66702 (LCD-II/E20) (Dot Matrix Liquid Crystal Display Controller/Driver) Description. Features

ENGR-4300 Fall 2006 Project 3 Project 3 Build a 555-Timer

2015 Technological Studies. Advanced Higher. Finalised Marking Instructions

PreLab 6 PWM Design for H-bridge Driver (due Oct 23)

Master Op-Doc/Test Plan

LCD MULTIMETER FOR YOUR SHACK. MEASUREMENT U, I, P, Ah FOR GREEN ENERGY - WIND TURBINE, SOLAR PANELS. MEASUREMENT U, I, P, Ah, kwh

MICROCONTROLLER TUTORIAL II TIMERS

IPR LA-3 KIT last update 15 march 06

Lesson 13. The Big Idea: Lesson 13: Infrared Transmitters

An Arduino-based DCC Accessory Decoder for Model Railroad Turnouts. Eric Thorstenson 11/1/17

LM2900 LM3900 LM3301 Quad Amplifiers

Construction of a high-voltage Buck-Boost capacitor charger. Transformer and logic

Module 9C: The Voltage Comparator (Application: PWM Control via a Reference Voltage)

Stepper Motors & Look Up Table

K7QO Marker Generator

Autonomous Robot Control Circuit

PRO-TACH CHRONOGRAPH OPERATING INSTRUCTIONS *** WARNING ***

PIC ADC to PWM and Mosfet Low-Side Driver

MICROPROCESSORS A (17.383) Fall Lecture Outline

Analog I/O. ECE 153B Sensor & Peripheral Interface Design Winter 2016

Thomas S. Narro David Zucker Darren Garnier 4/05. Copyright 2005 CPO Science

ASTABLE MULTIVIBRATOR

Transcription:

A Ballistic Chronograph Brandon Atkinson Steven Turner May 4, 2001 University of Maine ECE 403 Final Report

Abstract The goal of the Ballistic Chronograph project was to create a device having the ability to measure the speed of a paintball (or any similarly shaped projectile) and display this information to a display for a human to read. The design approach consisted of research, including Internet browsing, reading and consultation with advisors. The first decision made in the design was selecting the proper microprocessor. This decision was based on the minimum number of clock cycles needed for the project s accuracy specification, coupled with the need for a certain number of input and output pins, along with the desire for a relatively simple and inexpensive design. The second stage of design was brainstorming a measurement system. The problems in this stage were numerous. How do you detect the presence of a paintball without impeding its motion? What type of sensor will work most consistently without failure? These are just a few of the questions that were asked. The third stage of design involved choosing and assembling the display and physical prototype, followed by testing and verification. This stage went rather well, bringing only a couple of problems to light. The testing consisted of velocity measurement verification with an oscilloscope and real paintball projectiles. It is interesting to note that the accuracy of this project s velocity readings is comparable to the accuracy of some commercial products, although the speeds paintballs travel at are considerably less than the speeds of bullets. 2

Table of Contents Abstract...page 2 Table of Contents...page 3 List of Figures...page 4 Introduction...page 5 Breakdown...page 7 Details...page 8 Results and Conclusions...page 20 Directions For Use...page 22 Appendix...page 23 3

List of Figures Schematics Schematic 1 Infrared Emitter Schematic...page 24 Schematic 2 Infrared Detector Schematic...page 25 Schematic 3 Power Supply Schematic...page 26 Schematic 4 Wired OR Schematic...page 27 Schematic 5 Full Circuit Schematic...page 28 Flowcharts Flowchart 1 - Project Overview...page 7 Flowchart 2 Main Code...page 29 Flowchart 3 LCD_INIT Routine...page 30 Flowchart 4 CALC_RES Routine...page 31 Flowchart 5 RES_OUT Routine...page 32 Flowchart 6 Sq_Res Routine...page 33 Flowchart 7 Acc Routine...page 34 Flowchart 8 ACC_OUT Routine...page 35 Flowchart 9 Interrupt Service Routine...page 36 Tables Table 1 Approximate Current Total...page 54 4

Introduction The ballistic chronograph measures and displays the velocity of a projectile passing through it. The device interprets triggers of the internal sensors caused by the passing projectile as time-stamped events. After all the sensors are triggered the processor does some math with the time-stamps and displays the velocity measurement. Chronographs are used to calibrate firearms to a certain range of muzzle velocities (at least with paintball guns). Paintball is usually played with muzzle velocities in the high 100 s to low 200 s feet-per-second (fps). Paintball is played with people shooting plastic balls filled with paint at each other, so it is important that the weapons are shooting paintballs fast enough to break the paintballs, but slow enough that people playing don t get hurt. Under normal circumstances, a chronograph used for paintball would be useful before any match was played. All guns that were to be used in a game would be tested, one by one. A set speed would be decided for the game, and each gun would be adjusted until the muzzle speed was the same as the target speed decided upon beforehand. In this type of application, portability is not a big concern, because the adjusting happens before a match, and can take place away from the game (usually played outdoors). Accuracy is a big concern, however. Most chronographs operate on ambient light and the shadow of the projectile. This dependence on ambient conditions creates a source of error for measurements. The chronograph built for this project is not dependent on ambient light conditions, so measurements are more repeatable. There are several chronographs on the commercial market. Most of the chronographs for sale seem to be marketed as rifle calibrating devices, so the velocity range specifications are higher than for this project, but it is interesting to note some of them. 5

One chronograph, from Oehler Research, uses ambient light sensors (uses light from the sun or room to detect the projectile) that can be adjusted to different positions to attain better accuracy. The adjustment range is from one foot between sensors to four feet between sensors. The accuracy of this commercial grade chronograph at 1 ft. between sensors (the same spacing as this project s sensors) is published as within 5 feet/second (fps) at 1000 fps. The accuracy recorded by this project is somewhere around 3 fps at 500 fps. So it seems that the chronograph built in this project is reasonably accurate. The specifications for this project are as follows: Operation range (actual velocity of projectile passing)... 100-500 fps Accuracy... within 10 fps 6

Breakdown Most simply the ballistic chronograph consists of inputs, a processor, and a display (see Flowchart 1, below). The inputs are implemented with IR sensors detecting a passing projectile and connected to a PIC microprocessor. When the IR sensors are triggered, the PIC services an interrupt and determines which sensors have been triggered. The PIC uses a timing interrupt to determine the amount of time in between sensor trips. When all of the sensors have been triggered, the PIC has enough information (the time between sensors and the known distance between sensors) to determine the velocity of the projectile passing through the system. With the speed of the projectile determined, the PIC can now pass the velocity to an LCD display module so that it can be viewed. The sends the appropriate commands through one of its ports to the LCD module. The module captures these commands and displays the appropriate text on the LCD display. Projectile IR Sensors & Emitters PIC Microprocessor LCD Display Speed of Projectile Flowchart 1 Project Overview 7

Details Hardware Sensors The sensor system consists of 3 sets of sensors. Each of the 3 sets of sensors consists of an emitter circuit and a receiver circuit. The Emitter The emitter circuit consists of two diodes and two biasing resistors, R1 and R2 (see Schematic 1, page 24). The diodes are infrared emitter diodes (Lite-on manufactured Digikey PN# 160-1031-ND), meaning that instead of lighting up the way a visible LED does under bias, the diodes emit infrared radiation at a certain frequency. There is a direct correlation between the bias current magnitude and the amount of radiation thrown from the emitters. For this project s purposes, a strong IR beam is desired, therefore small 100-ohm resistors are used to maximize the current flow through the diodes. The schematic shows that there are two parallel diodes used in each emitter. One of the reasons for this is to maximize IR intensity as well. The other reason for having two parallel diodes in the emitters is to ensure direct alignment with the series phototransistors in the detector circuit. 8

The Detector The real work in designing the sensor system was in designing a reliable detector portion. Originally, the design consisted of one IR-phototransistor, and a single resistor (see Schematic 2, page 25). This circuit worked under test conditions in lab. When an object passed through the IR beam from the emitter, the voltage Vout dropped from its default state (near 5 volts) to its triggered state (near zero volts). A square wave was then used to power the IR-LED to simulate repeated switching. This revealed that slewing occurs as the IR light is taken away from the base of the IR-phototransistor. This slewing was a major concern in the beginning stages of design. The delay in changing states that this slewing represents means there will be some finite speed the circuit is able to detect. From the experiment using the 5v square wave powering the emitter, the maximum slew rate was found to be 0.0617 V/microsecond. From this information it was possible to make an estimate as to what maximum speed could be detected. Assuming the paintball to be a 0.5 inch diameter sphere, approximating the emitter beam as a plane, and knowing the resolution of the microprocessor (1/1e6 seconds) we found that the minimum time needed to switch states was 81.04 microseconds, and the maximum detectible velocity measurement at this time is 514 fps (feet per second). It is evident that the maximum velocity the sensor is able to measure is very close to the top end specification of 500 fps set for the project. In reality, the maximum measured velocity is probably much more than 514 fps simply because the microprocessor is edge triggered, rather than level sensitive, so full voltage deflection is not necessary, and the slew measurement taken in lab includes the slew of the IR-LED switching as well. 9

Adding the Second IR-Phototransistor Since the single transistor sensor seemed to work, why would adding the second transistor be necessary? The reason for adding the second phototransistor is more of a physical one than electrical. The tube the paintball is shot through is a 2 diameter tube, and the paintball is about 0.5 in diameter. If the emitter and receiver are placed on the centerline of either side of the tube, there is a good chance that the IR beam will not be broken. Shifting the emitter and detector down, away from the center line of the tube, while adding another set of sensors above the center line of the tube near the first set increases the chance that the passing projectile will be detected. The two transistors are wired in series so that if one of the phototransistors turns off, the output will go to the triggered state near 0 volts. 10

The Wired-OR While designing the sensor system, it was important that the outputs of the system were compatible with the PIC microprocessor we were using. Some potential designs included ideas using the interrupt-on-change feature of the pins on PORTB, and another used the RB0 pin on PORTB to trigger the interrupt, while the sensors were connected to pins on PORTB and their states were checked in the interrupt service routine. The first instinct could be to use the design that took up the least number of input pins. However, on the PIC16F84 microprocessor, the RB0/INT pin has a Schmitt Trigger input stage, giving us the ability to use positive feedback to speed up the transition between low and high states. The built-in Schmitt Trigger also has a small amount of hysteresis, meaning that there is no absolute switching threshold, rather there are different switching thresholds depending on whether the voltage is making a low-to-high or high-to-low transition. The appeal in having hysteresis on the external interrupt is the tendency to reject noise and prevent false edges from triggering the Interrupt Service Routine. The drawback of using RB0/INT pin is that there is only one, and there are 3 sensors that need to trigger interrupts. This is where the wired-or circuit (see Schematic 3, page 26) comes in. The wired-or consists of a pull-up resistor, and three PNP transistors. The Vout from each detector is wired into the base of a corresponding PNP transistor. With all of the sensors in the un-triggered state, Vout_Sensor_1, Vout_Sensor_2, Vout_Sensor_3, will be close to 4.5v (small voltage drop due to base-collector diode in phototransistors). This means that each of the PNPs in the wired-or will essentially be off. Due to a voltage below 5v on the bases of the transistors, there will be some current flow through the transistors. This is not important, as long as Vout_Wired_Or deflects over a considerable range with a distinct edge. In fact, having the wired-or BJT s biased at rest gives us a current gain, speeding up the transition from the rest state to triggered state. Once one of the sensors is triggered, the voltage at the output node of the wired-or switches sharply to the triggered state near zero. This circuit, along with tying all of the outputs of the sensors to input pins of the PIC allows us to use a single external interrupt pin with three sensors. Resolving which pin triggered the interrupt is up to the interrupt service routine on the PIC. 11

Internal Power supply The power supply built for this project is pretty straight forward, so most of it is hardly worth mentioning. What is worth mentioning, however, is the thought process that had to be conformed to in choosing components for a power supply like this (see Schematic 4, page 27). Before the power supply was constructed, knowing the needs of the loading devices (everything other than power supply) in terms of current was necessary. The approach used in this project was to assume everything was on and using it worst case (highest) values of current draw (see Table 1, page 54). As is evident from the table, the majority of the current drawn in the circuit is from the sensor circuits. Tallying up all the remaining currents, a final estimated current draw was found. In the analysis, some small currents were not counted (like the oscillator) and it was decided that the maximum current should be rounded up considerably due to the external power block. Although the estimated current draw of the circuit came to about one quarter of an Ampere, it was decided that the power supply would be designed to supply 1 Ampere or current. This left plenty of room for any devices that may be connected to the power block, small uncounted currents and/or any current fluctuations due to external temperatures. All components used in the supply were rated at greater than one Ampere, and a one- Ampere fuse was chosen. The fuse is included to prevent fire in the case of a short circuit. (Note: wire used in the construction of the power supply is heavy gage, to prevent an excessive amount of heat from being generated.) 12

PIC16F84 The PIC16F84 is a RISC (reduced instruction set computing) based microprocessor. It has 1k x 14 of program memory and 68 general-purpose registers (RAM). There are two ports, Port A which is 5-bits, and Port B which is 8-bits. For our project, we used RA2- RA0 for LCD control, RB7-RB4 for LCD data, RB3-RB1 for sensor input, and RB0 for sensor interrupt. We also have the PIC clocked by a 4MHz oscillator in OSC1/CLKIN. Hantronix LCD Module The Hantronix LCD Module is an LCD driver & controller package with a 4x16 character dot matrix LCD screen. It can be interfaced with either 4-bit or 8-bit data; we used the 4-bit data option. 13

Hardware Design Summary There were a number of considerations made in the design of this project. Since the use of a chronograph in the game of paintball would most likely happen long before play, portability was not a major concern. If portability were a major concern, battery operation would be necessary. This would most likely require redesigning the entire project for low power consumption, since diodes and always on transistors are major sources of current drain and hence consume large quantities of power. The decision to make the unit non-portable allowed for a simpler design loosening the design constraints, while not sacrificing functionality. The sensor options were mainly between ambient light detecting sensors or an emitter/receiver pair. With the ambient light detecting sensors, the functioning of the chronograph depends on an adequate amount of light being available (bright conditions). Most commercial grade chronographs use ambient light sensors, as most chronographs are for use with real guns that normally require outdoor use. While using this sensor arrangement allows for more room for error in firing (since there is no beam to be broken), errors in measurement can occur if ambient light conditions are changing or just inadequate. Furthermore, since this project is designed for use with paintballs rather than bullets, there is no worry about hitting the chronograph with the projectile. The paintball will simply break, leaving the chronograph unharmed. For these reasons, we chose to use an IR emitter/receiver arrangement. This method of sensing uses an infrared emitter on one side of the firing path, and a receiver on the other side of the firing path. A passing paintball creates an infrared shadow to trip the sensor. This arrangement is very insensitive to ambient light conditions since ambient light has relatively small IR component compared to the emitter intensity. This also allows for a more constant environment than would be possible depending on ambient conditions. 14

Software The software for the ballistic chronograph handles inputs from three IR sensors and outputs to a Hantronix 4X16 LCD display. The sensors are configured in a wired-or, so that when one of them is brought low, RB0/INT is brought low and interrupts on the falling edge. The status of Port B(RB3-RB1) is taken so that the sensor causing the interrupt can be determined. For the output to the LCD, the upper nibble of Port B(RB7- RB4) is used for data, and Port A (RA2-RA0) is used for control lines. The software is interrupt driven with the only interrupts being the timer overflow, which is used for timing, and RB0/INT which is used for sensor inputs. Error checking is done within the ISR to account for bogus sensor inputs. Below is a description of the code used in the project: LCD_INIT Description: Initializes the LCD for 4-bit communication. (see Flowchart 3, page 30) Initializes the Hantronix 4X16 LCD as described in the manufacturer s notes. SEND_CMD Description: Sends the command in register W to the LCD Uses code modified from Microchip Application Note AN587 to send a command split in upper and lower nibbles to the LCD. The wait delays are long enough so that the busy bit does not need to be checked. Description: Sends the character in register W to the LCD Uses code modified from Microchip Application Note AN587 to send a character split in upper and lower nibbles to the LCD. The wait delays are long enough so that the busy bit does not need to be checked. 15

INTRO_SCREEN Description: Sends an introduction screen to the LCD. Sends the text Ballistic Chronograph Atkinson&&Turner (c)2000 to the LCD. Formats the text to approximately center each line. TOG_E Description: Toggles E line. Toggles the E line (the clock for the LCD) with a wait in between the up and down switches. WAIT_19 Description: Delays about 18.4ms. Uses an inner and outer loop to busy wait for about 18.4ms. This delay is more than long enough for the LCD functions. CALC_RES Description: Takes 3 byte number of cycles from XA, XB, and XC and returns 2 byte speed in ResA and ResB. (see Flowchart 4, page 31) The speed can be determined by dividing 1e6 (f osc /4) by the number of cycles. The division is handled by subtracting the number of cycles X from a count initialized to 1e6 until a negative result is yielded. The number of subtractions is the result. Since the arguments are 3 bytes each, the subtraction is handled in parts, high byte to low byte, borrowing from a higher byte if needed, and incrementing a counter after all 3 bytes are handled. If the result is negative, the function returns, and the result is given. 16

RES_OUT Description: Takes result in ResA and ResB and prints it on the LCD. (see Flowchart 5, page 32) This function divides by 100 to get the 100 s place, and subtracts the 100 s, divides by 10 to get the 10 s place, and subtracts the 10 s and is left with the 1 s place. The division is handled by counting the number of subtractions until a negative result is yielded. The subtractions take place in the ResB because 100 and 10 are 1 byte numbers. Sq_Res Description: Squares a number. (see Flowchart 6, page 33) A result from a velocity calculation is determined and stored with this routine. It calculates the square, by adding the velocity v to itself v times. Acc Description: Calculates the acceleration. (see Flowchart 7, page 34) This routine assumes that the two speeds are instantaneous velocities one foot apart. Using this assumption, the formula is a = (v 2 1 v 2 2 )/2. The Sq_Res routine is used to square the two velocities, then this routine subtracts them and uses bit rotation to divide by 2. The sign (positive or negative) of the acceleration is also returned in NEGACC. ACC_OUT Description: Outputs the acceleration. (see Flowchart 8, page 35) This routine continually subtracts 10 from the acceleration given by Acc. This allows the digits to be built up for the output display much like a car odometer. Once the digits are determined, they are converted to ASCII and output along with the proper sign from NEGACC. Interrupt Service Routine (ISR) Description: Interrupt service routine. (see Flowchart 9, page 36) 17

Handles the interrupts from the 3 sensors and from the timer overflow. Checks which interrupt occurred, then services it. Uses a flag, SENFLAG, to determine which sensors have been triggered in order to prevent invalid inputs. TIMER Checks to see if SENFLAG is set, if not, it drops out. Otherwise, it increments the counter. If the count is larger than a maximum count, it turns the timer interrupt off. This prevents bad inputs from either making the chip hang or giving bad outputs. SEN1 First sensor. Clears counters and sets S1 flag on SENFLAG. SEN2 Second sensor. Checks for the S1 flag on SENFLAG, if not set, it drops out. Otherwise, it clears SENFLAG, then sets the S2 flag on SENFLAG. It stores the counts for the sensor 1 to sensor 2, and clears the counters. SEN3 Third sensor. Checks for the S2 flag on SENFLAG, if not set, it drops out. Otherwise, it calculates and out puts the two speeds and the acceleration. Main code Description: The main routine for the program. (see Flowchart 2, page 29) Sets up data direction for Ports A and B (RA3-RA0 outputs, RB7-RB4 outputs, RB3- RB0 inputs). Calls LCD_INIT to initialize LCD, and INTRO_SCREEN to print intro. The code is interrupt driven, so main enables the interrupts then drops into an infinite loop. 18

Software Design Summary Since the PIC is interrupt driven, the bulk of the real work is done in the ISR. Proper design methods were used to make the code readable, editable, and possibly portable. Thus, as much of the code as is possible and prudent is done in subroutines to add abstraction to the main parts of the code. In fact, all of the code involving the LCD display could easily be transferred to another program and implemented with little effort. The code is commented thoroughly to allow future editing and readability. 19

Results and Conclusions Testing Methods Our testing method assumed that the sensor provide an accurate representation of the paintball passing through. By hooking the sensors up to an oscilloscope and setting it on the Roll mode, we were able to capture the signals generated when the sensors were triggered. By dividing 1 foot (the distance between sensors) by the time we obtain this way, we were able to measure the actual speed of the projectile. Conveniently, the oscilloscope provides the frequency of the pulses, or 1 divided by the time. Because of this, we didn t even need to take out a calculator to determine the time. This method works very well for firing a paintball. It is not practical to always test the chronograph by firing a paintball, and it is not possible to fire paintballs at the extremes or our specs with our paintball equipment. In order to solve this problem, we created a paintball simulator using another PIC chip. This simulator pulses the sensor inputs on the chronograph to simulate a paintball passing through the sensors. When using this, we disconnect the sensors and hook up the test PIC chip in their place. We then proceed with the above method. The software for the testing PIC chip is very simple. It consists of loops that busy wait in between pulses on the sensor input pins. The testing program is set up to test through range of the specs to show that the chronograph is working properly. 20

Results In our testing, we found that our chronograph can measure speeds beyond both extremes of our spec. Below our 100 fps spec, we were able to measure around 80 fps within 1 fps of accuracy. Above our 500 fps spec, we were able to measure around 600 fps within 3 fps of accuracy. This is clearly beyond or specifications for both range of 100 fps to 500 fps and for accuracy of +/- 10 fps. Conclusion & Future Improvements The ballistic chronograph proved to be an interesting and worthwhile project. We were able to learn much about IR sensors, the PIC microprocessor, and interfacing to LCD modules. We were happy to not only get our project working, but to also beat our specs and put in an attractive enclosure. There are some things we could improve upon, however. One thing we could try would be to do our project with a faster microprocessor to obtain better accuracy. Another interesting addition would be to measure two speeds and determine the deceleration. Finally, it would be interesting to determine the energy of the paintball coming out of the barrel. 21

Directions For Use Indoor Use For indoor use, screw end-stop in the threaded end of the chronograph. Make sure the end-stop is securely fastened. Place the chronograph on a fairly level, flat surface. Plug chronograph into 120VAC-60Hz outlet (U.S. Standard). When the start-up text finishes coming up on the display, fire your loaded paintball gun in the open end of the chronograph. When firing, take care to keep the gun level and away from the sides of the chronograph, paintballs may break on the sides of chronograph otherwise. Measurement will appear on display. Outdoor Use The end-stop is not absolutely necessary for outdoor use. If end-stop is not used, care should be taken so that exiting paintballs will not harm people or property. Cleaning the Chronograph Paintballs will sometimes break inside the chronograph. For clean-up, simply remove the end-stop, stuff paper towels or rags into non-threaded end of chronograph, and push rags/paper towels through chronograph with a short stick. Repeat until chronograph is sufficiently clean. 22

Appendix Schematics...page 24 Flow Charts...page 29 Data Sheets...page 37 Project Proposal...page 39 Source Code...page 40 Parts List...page 53 Tables...page 54 23

Schematics Schematic 1 IR Emitter Circuit 24

Schematic 2 IR Detector Circuit 25

Schematic 3 Wired OR Schematic 26

Schematic 4 Power Schematic 27

Schematic 5 Entire Circuit Schematic 28

Flowcharts Main Code Initialize Ports Initialize LCD (LCD_INIT) Print Intro Screen (INTRO_SCREEN) Set up Interrupts Loop Flowchart 2 Main Code 29

LCD_INIT Put LCD in Control Mode Send 0x30 3 Times Send 4 Bit Control Send Function Set Send Display Off Clear Display Entry Mode Send Cursor Return Flowchart 3 LCD_INIT Routine 30

CALC_RES Set Up 1 Million Clear Result MilA-XA Neg? Yes Return No MilB-XB Yes Yes Neg? MilA=0? Return No MilC-XC MilA-1 No Yes Yes Yes Neg? MilB==0? MilA==0? Return No No No MilB-1 MilA-1 Result+1 Flowchart 4 CALC_RES Routine 31

RES_OUT Clear Digits ResB-100 Neg? No DigA+1 Yes ResA=0? No ResA-1 Yes ResB+100 ResB-10 Neg? No DigB+1 Yes ResB+10 DigC=ResB Add ASCII '0' to Digits Send Digits to LCD Return Flowchart 5 RES_OUT Routine 32

Sq_Res Store RES in Counter Clear Sq_Res Sq_Res = Sq_Res + Res Decrement Counter Counter = 0? No Yes Return Flowchart 6 Sq_Res Routine 33

Acc Clear NEGACC Flag Acc = V2 -V1 Acc < 0? No Yes NEGACC = 1 Acc = V1 -V2 Acc = Acc / 2 Return Flowchart 7 Acc Routine 34

ACC_OUT Clear Digits Acc = Acc -10 Acc >= 0? No DigE = Acc +10 Yes DigD + 1 NEGACC = 1? Yes Print "-" No DigD = 10? Yes No Convert Digits to ASCII DigD = 0 Print Digits DigC + 1 Return No DigC = 10? Yes DigC = 0 DigB + 1 No DigB = 10? Yes DigB = 0 DigA + 1 Flowchart 8 ACC_OUT Routine 35

ISR Get PortB Timer Overflow? No Sensor No Sensor No Sensor No 1? 2? 3? Return Yes Clear Interrupt Flag Yes Clear SENFLAG Yes Is SENFLAG = S1? No Return Yes Is SENFLAG = S2? No Return Return No Increment Counter Counter Overflow? Clear Counters Clear Interrupt Flag Yes Set SENFLAG=S2 Yes Clear SENFLAG Print V1 (RES_OUT) Clear SENFLAG Yes Yes Counter = Max? No Return Return Store Temp Counters for V1 Clear Interrupt Flag Return Calculate Result (CALC_RES) of V2 Square V2 (Sq_Res) Store V2 Get V2 Print V2 (RES_OUT) Calculate Acceleration (Acc) Calculate Result (CALC_RES) of V1 Square V1 (Sq_Res) Print Acceleration (ACC_OUT) Clear Interrupt Flag Return Flowchart 9 Interrupt Service Routine 36

Data Sheets Data Sheet 1 Character Module Initialization 37

Data Sheet 2 Commands for Character Modules 38

Project Proposal Ballistic Chronograph Short Description The ballistic chronograph will measure and numerically display the speed of a projectile. In order to determine the speed, microprocessor will measure the time the projectile takes to travel between two fixed points. Inputs Outputs Specifications Projectile Two sensors Speed of projectile At least 3-digit display Measures speeds from 100-500 fps Will be accurate within 10 fps 39

Source Code ;************************************************************************** ;* Ballistic Chronograph Code ;* Steven Turner & Brandon Atkinson ;* 2000-2001 ;************************************************************************** ;************************************************************************** ;* CONSTANTS ;************************************************************************** W EQU 0 ; destination bits F EQU 1 C EQU 0 ; status bits Z EQU 2 TMR0 EQU 0x01 ; PIC built-in registers OPT EQU TMR0 PCL EQU 0x02 STATUS EQU 0x03 FSR EQU 0x04 PORTA EQU 0x05 TRISA EQU PORTA PORTB EQU 0x06 TRISB EQU PORTB INTCON EQU 0x0B INTMSK EQU 0x90 ; mask for interrupts TOIF EQU 2 ; timer overflow interrupt flag INTF EQU 1 ; RB0 interrupt flag RBIE EQU 3 ; RB0 interrupt enable TOIE EQU 5 ; timer interrupt enable RP0 EQU 5 ; bank selects RP1 EQU 6 S1 EQU 1 ; sensor flags S2 EQU 2 S3 EQU 3 TRISAMSK EQU 0x00 ; tristate port masks TRISBMSK EQU 0x07 LCD_DATA EQU PORTB ; LCD control LCD_DATA_TRIS EQU TRISB LCD_CNTL EQU PORTA E EQU 0 ; LCD Enable control line RW EQU 1 ; LCD Read/Write control line RS EQU 2 ; LCD Register Select control line DELOUT EQU D'23' ; values for WAIT_19 DELIN EQU D'200' XAMAX EQU 0x01 ; largest XA can get 40

;**************************************************************************** ;* VARIABLES ;**************************************************************************** TEMP EQU 0x10 ; temp value CNTOUT EQU 0x11 ; count loops for WAIT_19 CNTIN EQU 0x12 CHAR EQU 0x13 ; character for LCD routines MilA EQU 0x14 ; bytes for 1 million in CALC_RES MilB EQU 0x15 MilC EQU 0x16 XA EQU 0x17 ; ISR counters XB EQU 0x18 XC EQU 0x19 ResA EQU 0x1A ; results for CALC_RES ResB EQU 0x1B DigA EQU 0x1C ; digits for RES_OUT & ACC_OUT DigB EQU 0x1D DigC EQU 0x1E DigD EQU 0x1F DigE EQU 0x20 BIN EQU 0x21 ; Port B capture in ISR XA1 EQU 0x22 ; temp values for ISR counters XB1 EQU 0x23 XC1 EQU 0x24 Sq1 EQU 0x25 ; temp values for Sq_Res Sq2 EQU 0x26 Sq3 EQU 0x27 CountA EQU 0x28 CountB EQU 0x29 V1Sq1 EQU 0x2A ; vars for v1 & v2 squared V1Sq2 EQU 0x2B V1Sq3 EQU 0x2C V2Sq1 EQU 0x2D V2Sq2 EQU 0x2E V2Sq3 EQU 0x2F Acc1 EQU 0x30 ; output of acceleration from Acc Acc2 EQU 0x31 Acc3 EQU 0x32 ResTEMPA EQU 0x33 ; temp values for ISR ResTEMPB EQU 0x34 NEGACC EQU 0x35 ; flag for negative acc values SENFLAG EQU 0x36 ; flag of sensor triggers for ISR ; ****** END EQUATES ************************************************************ 41

; ****** PIC SETUP CODE ************************************************************* ORG 0x000 ; setup code for PIC GOTO START ORG 0x004 GOTO ISR ; ****** MAIN CODE ************************************************************** START ; POWER_ON Reset (in HW) CLRF STATUS ; Do initialization (Bank 0) CLRF INTCON CLRF PORTA ; ALL PORT output should output Low. CLRF PORTB BSF STATUS, RP0 ; Select Bank 1 CLRF TRISA ; RA3 - RA0 outputs 0x0F TRISB ; RB7-4outputs, RB3-0 inputs 0x0F ; strong pullups, falling edge RB0 OPT BCF STATUS, RP0 ; Select Bank 0 LCD_INIT ; initialize LCD INTRO_SCREEN ; print out intro screen CLRF SENFLAG ; clear out sensor flag INTMSK ; setup interrupt INTCON BSF INTCON, TOIE ; enable Timer LOOP GOTO LOOP ; loop forever ;************************************************************************************* ;* ISR ;************************************************************************************* ISR MOVF PORTB, W ; get portb BIN BTFSC INTCON, TOIF ; check timer overflow TIMER BTFSS BIN, S1 ; check S1 SEN1 BTFSS BIN, S2 ; check s2 SEN2 BTFSS BIN, S3 ; check s3 SEN3 RETFIE TIMER ; timer overflow handling BCF INTCON, TOIF ; clear int flag MOVF SENFLAG, F ; if no sensors set, drop out BTFSC STATUS, Z RETURN INCF XB, F ; increment counter BTFSS STATUS, Z RETURN INCF XA, F XAMAX ; check if too large SUBWF XA, W BTFSS STATUS, C RETURN CLRF SENFLAG ; if too big reset sensors 42

RETURN SEN1 SEN2 CLRF SENFLAG BSF SENFLAG, S1 ; mark 1st sensor CLRF TMR0 CLRF XA ; clear counters CLRF XB CLRF XC BCF INTCON, INTF ; clear int flag RETURN MOVF TMR0, W ; grab time XC1 BTFSS SENFLAG, S1 ; check for 1st sensor RETURN ; drop out if not set CLRF SENFLAG BSF SENFLAG, S2 ; set only S2 CLRF MOVF MOVF CLRF CLRF BCF RETURN TMR0 XA, W XA1 XB, W XB1 XA XB INTCON, INTF SEN3 MOVF TMR0, W ; grab time XC BTFSS SENFLAG, S2 ; check for 2nd sensor RETURN ; drop out if not set CLRF SENFLAG CALC_RES ; calculate result Sq_Res ; square result MOVF Sq1, W ; store result V2Sq1 MOVF Sq2, W V2Sq2 MOVF Sq3, W V2Sq3 MOVF ResA, W ; store result ResTEMPA MOVF ResB, W ResTEMPB MOVF XA1, W ; move temps back XA MOVF XB1, W XB MOVF XC1, W XC CALC_RES ; put out 2nd speed Sq_Res ; square result MOVF Sq1, W ; store result V1Sq1 MOVF Sq2, W V1Sq2 MOVF Sq3, W V1Sq3 0x01 ; clear LCD SEND_CMD 0x80 ; goto line 1 SEND_CMD 'v' ; output result 1 43

'1' '=' ' ' RES_OUT MOVF ResTEMPA, W ResA MOVF ResTEMPB, W ResB 0xC0 SEND_CMD 'v' ; output result 2 '2' '=' ' ' RES_OUT Acc ; calculate acceleration 0xD0 SEND_CMD ACC_OUT BCF INTCON, INTF ; clear int flag RETURN ;************************************************************************************ ;* SUBROUTINES ;************************************************************************************ ;************************************************************************************ ;* LCD_INIT Subroutine ;* ;* Initializes LCD for 4 bit communication ;* Initialize LCD by sending: ;* RS RW D7 D6 D5 D4 ;* 0 0 0 0 1 1 ;* wait > 4.5 ms ;* 0 0 0 0 1 1 ;* wait > 100us ;* 0 0 0 0 1 1 ;* 0 0 0 0 1 0 for 4 bit control ;* send command 001010xx (function set) (0x28) ;* send command 00001000 (display off) (0x08) ;* send command 00000101 (display clear) (0x01) ;* send command 00000110 (entry mode) (0x06) ;************************************************************************************ LCD_INIT WAIT_19 WAIT_19 WAIT_19 BCF LCD_CNTL, RS ; put in control mode BCF LCD_CNTL, RW 0x30 ; send 0011 3 times LCD_DATA TOG_E WAIT_19 TOG_E WAIT_19 TOG_E WAIT_19 0x20 ; send 0010 for LCD_DATA ; 4 bit control TOG_E WAIT_19 44

0x28 ; send funtion set SEND_CMD 0x08 ; send display off SEND_CMD 0x01 ; clear display SEND_CMD 0x06 ; entry mode SEND_CMD 0x0E ; send cursor SEND_CMD WAIT_19 WAIT_19 RETURN ;************************************************************************************ ;* TOG_E Subroutine ;* ;* Toggles E line ;************************************************************************************ TOG_E BSF LCD_CNTL, E ; toggle E for LCD WAIT_19 BCF LCD_CNTL, E RETURN ;************************************************************************************ ;* WAIT_19 Subroutine ;* ;* Uses a double loop to eat up CPU time and give >18.4ms delay ;* DELOUT=23, DELIN=200, gives about 18.4ms of delay ;************************************************************************************ WAIT_19 DELOUT ; get outer level count CNTOUT BKOUT DELIN ; get inner delay CNTIN BKIN NOP DECFSZ CNTIN, F ; dec, skip next if 0 GOTO BKIN DECFSZ CNTOUT, F ; dec outer count, skip next if 0 GOTO BKOUT RETURN ;************************************************************************************ ;* SEND_CMD Subroutine ;* ;* Modified from Microchip code ;* Sends the command to the LCD in upper and lower nibbles ;************************************************************************************ SEND_CMD CHAR ; Character to be sent is in W MOVF CHAR, W ANDLW 0xF0 ; Get upper nibble LCD_DATA ; Send data to LCD TOG_E SWAPF CHAR, W ANDLW 0xF0 ; Get lower nibble LCD_DATA ; Send data to LCD TOG_E WAIT_19 RETURN 45

;************************************************************************************ ;* Subroutine ;* ;* Modified from Microchip code ;* Sends a character to the LCD in upper and lower nibbles ;************************************************************************************ CHAR ; Character to be sent is in W MOVF CHAR, W ANDLW 0xF0 ; Get upper nibble LCD_DATA ; Send data to LCD BSF LCD_CNTL, RS ; Set LCD to data mode TOG_E SWAPF CHAR, W ANDLW 0xF0 ; Get lower nibble LCD_DATA ; Send data to LCD TOG_E BCF LCD_CNTL, RS RETURN ;************************************************************************************ ;* CALC_RES Subroutine ;* ;* Determines the speed, given the number of cycles taken. ;* Speed = 1e6/X where X is the number of cycles. ;* Result is stored as ResA*FF+ResB ;********************************************************************************** CALC_RES 0x0F ; set up 1M MilA 0x42 MilB 0x40 MilC CLRF ResA ; clear out result CLRF ResB LOOP_RES MOVF XA, W ; MilA-XA SUBWF MilA, F BTFSS STATUS, C ; if neg, then done RETURN ; A= neg (done) MOVF XB, W ; MilB-XB SUBWF MilB, F BTFSC STATUS, C ; if not neg, go to next op GOTO OPC MOVF MilA, F ; check if A is zero BTFSC STATUS, Z RETURN ; A=0, B=neg (done) DECF MilA, F ; subtract 1 from A OPC MOVF XC, W ; MilC-XC SUBWF MilC, F BTFSC STATUS, C ; if not neg, next part GOTO FINISH MOVF MilB, F ; check if B is zero BTFSC STATUS, Z ; if B is zero goto next GOTO CHKA DECF MilB, F ; B is not zero GOTO FINISH CHKA MOVF MilA, F ; if A=0 then done BTFSC STATUS, Z RETURN ; A=0 B=0 C=neg (done) DECF MilA, F DECF MilB, F ; MilB=FF FINISH INCF ResB, F ; increment result BTFSC STATUS, Z INCF ResA, F ; add carry if needed 46

GOTO LOOP_RES ; next iteration ;********************************************************************************** ;* RES_OUT Subroutine ;* ;* Takes result given by CALC_RES & outputs to LCD ;********************************************************************************** RES_OUT CLRF DigA ; clear out counters CLRF DigB CLRF DigC DIG_100 0x64 ; 100's SUBWF ResB, F BTFSC STATUS, C ; if neg GOTO INC100 MOVF ResA, F BTFSC STATUS, Z GOTO DIG_10A ; done 100's DECF ResA, F ; take 1 from ResA INC100 INCF DigA, F GOTO DIG_100 DIG_10A 0x64 ; put 100 back on negative # ADDWF ResB,F DIG_10 0x0A ; 10's SUBWF ResB, F BTFSS STATUS, C ; if neg GOTO DIG_1A INCF DigB, F GOTO DIG_10 DIG_1A 0x0a ; put 10 back on negative # ADDWF ResB, F DIG_1 MOVF ResB, W DigC '0' ; covert digits to ASCII ADDWF DigA, F ADDWF DigB, F ADDWF DigC, F MOVF DigA, W ; output result MOVF DigB, W MOVF DigC, W ' ' ; print ft/s 'f' 't' '/' 's' RETURN 47

;********************************************************************************** ;* INTRO_SCREEN ;* ;* Prints out the introduction screen for the project ;* More readable and about the same amount of code as using a table ;********************************************************************************** INTRO_SCREEN 0x02 ; home SEND_CMD WAIT_19 WAIT_19 ' ' ; print "Ballistic" ' ' ' ' 'B' 'a' 'l' 'l' 'i' 's' 't' 'i' 'c' 0xC2 ; line 2, col 2 SEND_CMD 'C' ; print "Chrongraph" 'h' 'r' 'o' 'n' 'o' 'g' 'r' 'a' 'p' 'h' 0x90 ; line 3 SEND_CMD 'A' ; print "Atkinson&&Turner" 't' 48

'k' 'i' 'n' 's' 'o' 'n' '&' '&' 'T' 'u' 'r' 'n' 'e' 'r' 0xD4 ; line 4, col 4 SEND_CMD '(' ; print "(c) 2000" 'c' ')' ' ' '2' '0' '0' '0' RETURN ;****************************************************************************** ;* Sq_Res Subroutine ;* ;* Squares result (ResA ResB), returns ;* to Sq1 Sq2 Sq3 ;****************************************************************************** Sq_Res CLRF Sq1 ; clear out result CLRF Sq2 CLRF Sq3 MOVF ResA, W ; copy counters CountA INCF CountA, F MOVF ResB, W CountB Sq_Res1 MOVF ResB, W ADDWF Sq3, F 49

BTFSC STATUS, C ; if carry inc next INCFSZ Sq2, F GOTO Sq_Res2 INCF Sq1, F Sq_Res2 MOVF ResA, W ADDWF Sq2, F BTFSS STATUS, C ; if carry, inc next INCF Sq1, F DECFSZ GOTO DECFSZ GOTO RETURN CountB, F Sq_Res1 CountA, F Sq_Res1 ;******************************************************************************* ;* Acc subroutine ;* ;* Calculates the acceleration given two squared ;* speeds V1Sq1 V1Sq2 V1Sq3, V2Sq1 V2Sq2 V2Sq3 ;* Stored to Acc1 Acc2 Acc3 ;******************************************************************************* Acc CLRF NEGACC MOVF V2Sq1, W ; put V2 in result Acc1 MOVF V2Sq2, W Acc2 MOVF V2Sq3, W Acc3 MOVF V1Sq1, W ; sub high byte SUBWF Acc1, F MOVF V1Sq2, W ; sub mid byte SUBWF Acc2, F BTFSS STATUS, C DECF Acc1, F MOVF V1Sq3, W ; sub low byte SUBWF Acc3, F BTFSC STATUS, C GOTO Acc_1 0x01 SUBWF Acc2, F BTFSS STATUS, C DECF Acc1, F Acc_1 BTFSS Acc1, 7 ; if negative do opposite GOTO Acc_2 INCF NEGACC, F MOVF V1Sq1, W ; put V2 in result Acc1 MOVF V1Sq2, W Acc2 MOVF V1Sq3, W Acc3 MOVF V2Sq1, W ; sub high byte SUBWF Acc1, F MOVF V2Sq2, W ; sub mid byte SUBWF Acc2, F BTFSS STATUS, C DECF Acc1, F MOVF V2Sq3, W ; sub low byte SUBWF Acc3, F 50

BTFSC STATUS, C GOTO Acc_1 0x01 SUBWF Acc2, F BTFSS STATUS, C DECF Acc1, F Acc_2 BCF Acc3, 0 ; clear out odds RLF Acc1, W ; get high bit in C RRF Acc1, F RRF Acc2, F RRF Acc3, F RETURN ;********************************************************************************* ;* ACC_OUT Subroutine ;* ;* Takes result given by Acc & outputs to LCD ;********************************************************************************* ACC_OUT CLRF DigA ; clear out counters CLRF DigB CLRF DigC CLRF DigD CLRF DigE 'a' ; output a= '=' ' ' MOVF NEGACC, F ; check for negative BTFSC STATUS, Z GOTO ACCO_10 '-' ; output negative sign ACCO_10 0x0A SUBWF Acc3, F BTFSS STATUS, C ; if negative GOTO ACCO_CARRY ACCO_10A INCF DigD, F 0x0A SUBWF DigD, W BTFSS STATUS, Z GOTO ACCO_10 CLRF DigD INCF DigC, F 0x0A SUBWF DigC, W BTFSS STATUS, Z GOTO ACCO_10 CLRF DigC INCF DigB, F 0x0A SUBWF DigB, W BTFSS STATUS, Z GOTO ACCO_10 CLRF DigB INCF DigA, F GOTO ACCO_10 ACCO_CARRY MOVF Acc2, F ; carry from Acc2 BTFSC STATUS, Z GOTO ACCO_1 DECF Acc2, F GOTO ACCO_10A 51

ACCO_1 0x0A ADDWF Acc3, W ; put the remainder in 1's place DigE end '0' ; covert digits to ASCII ADDWF DigA, F ADDWF DigB, F ADDWF DigC, F ADDWF DigD, F ADDWF DigE, F MOVF DigA, W ; print digits MOVF DigB, W MOVF DigC, W MOVF DigD, W MOVF DigE, W ' ' ; print ft/s^2 'f' 't' '/' 's' '^' '2' RETURN 52

Parts List Quantity Part Description Comment 6 IR Phototransistor Digikey Part # 160-1062-ND 6 IR Photodiode Digikey Part # 160-1031-ND 13 16 pin chip carrier 2 Perf. Board Sheets 3 Wire wrap wire spools Many Various Resistors 1 470uF Electrolytic Cap. 1 0.1uF Ceramic Cap 2 Archer Copper Clad board 1 LM7805 Voltage Reg. 1 1 Ampere Fuse 1 120v-14.4v transformer (1.2 Ampere) 1 Power LED with resistor 1 Hantronix LCD Module 1 RadioShack Project Box 1 RadioShack QR Power B. (Speaker-like power terms) 1 RadioShack Isolation Block 3 PNP Transistors (2N3906) (Wired-OR) 1 PIC16F84 10MHz rated 1 TTL Crystal Clock Oscillator 4MHz Jameco Part # 27967 53

Tables Circuit Component Current Draw 3 ON Detectors 0.234 A Max Current from 3 ON Wired OR 0.0034 A transistors Maximum Current from PIC 4.5 ma Maximum Current from Display 0.3 ma LM7805 max current 8.0 ma TOTAL 250.2 ma Table 1 Approximate Current Total 54