Introduction: Paintball/Ballistic Chronograph

Create a low-cost Paintball Chronograph for less than $40!

A ballistic chronograph is a device that records the velocity of a projectile. This particular chronograph I have made has only been tested with a paintball gun and it is relatively simple to make. I have also implemented a function that can record the rate of fire at which a device is firing.

Seeing as you will be using a device that shoots projectiles at high speeds to test this chronograph, use your head and be smart. Follow all safety procedures and guidelines that pertain to the use of the paintball marker or other device that you are using to shoot projectiles.

Step 1: Electronic Requirements

Although this chronograph is pretty easy to build, a basic understanding of electronics and soldering skills is essential. The most trouble I had with this project was making the PCB. I use the toner transfer method, but that doesn't produce very nice boards when your laser-jet printer needs a new cartridge. The board itself has some spots that are pitted and doesn't look too neat, but it gets the job done. If you aren't able to make your own PCB's, one can just use some perfboard and point to point wire everything together.

Here is a list of the following electronic components required:

- 2x 47µf Electrolytic Capacitors
- 2x 0.1µf 0805 SMD Capacitors
- 1x 0.01µf 0805 SMD Capacitor
- 1x 0.01µf Ceramic Capacitor
- 2x 27pf 0805 SMD Capacitors
- 2x 10kΩ 0805 SMD Resistors
- 2x 2.4kΩ 0805 SMD Resistors
- 2x 470Ω 0805 SMD Resistors
- 1x 150Ω 0805 SMD Resistor
- 2x 100Ω 0805 SMD Resistors
- 1x 4.7kΩ Trim Potentiometer
- 1x 1N4148 Diode
- 1x LM7805 5v Regulator
- 2x TSOP4838 IR Detectors
- 2x IR Transmitters
- 2x Female 2-pin Molex Connectors
- 2x Male 2-pin Molex Connectors
- 1x 5-pin Header
- 1x MMMBT2222A General Purpose Transistor
- 1x 12MHz Crystal
- 1x Tactile Switch
- 1x Rocker Switch
- 1x PIC18F13K50 SOIC Microcontroller
- 1x 16x2 LCD Display
- 1x 9v Battery Clip

Most of these components I had already had on hand, but I would estimate the cost of this project to be around $30-$40. I have not shown any of the SMD components (except for the PIC) in the photo below.

I have gone and posted print screens of some places where you can buy the components. Some components couldn't be bought as 1 or were cheaper in higher quantities, that's why you may see some extra parts in the pictures. Many of the parts can be bought at a good price at I will tag the cost of each product in the photos below. With all of these parts, not including the board, it came to $38.11 to purchase all the components for this chronograph with all shipping included except for the PIC18F13K50 bought at Digikey. Then it would be a couple more bucks for the PVC pipe. Also, if you want to save $3.39, you can buy 16x2 LCD Displays on eBay for $2.99 including shipping.

Step 2: Tools Required

Here is a list of tools and supplies that were used to build this project:

- Solder
- Soldering Iron
- Flux Pen
- Super Glue
- Zip-ties
- Drill
- Digital Calipers
- Needle Nose Pliers/Side Cutters
- Heatshrink Tubing/Electrical Tape
- Scalpel/Utility Knife (Used for PCB touch-ups)
- PIC Programmer (I used a MPLAB ICD2 Clone)
- Anti-Static Tweezers for small SMD components
- Perfboard/Breadboard or Materials required to make a PCB
- Toothbrush and Rubbing Alcohol to clean the flux off the PCB
- 6" long, 1" Diameter PVC Pipe (May need a hacksaw to cut down a larger PVC piece)

A hacksaw/jigsaw or something of the sort is required to cut the PVC pipe down to 6". I bought a 5ft piece of PVC, cut a piece of pipe off that was 6" long and used digital calipers to measure out 4" between the IR transmitter/detector pairs and drill holes for them in the PVC pipe.

Step 3: How It Works

Now that we got all of the requirements and setup out of the way, we can move on and finally get to the exciting stuff. The operation of this chronograph is rather simple, there are two IR transmitters and two IR Detectors, each transmitter/detector pair is placed exactly four inches apart.

When an object breaks the first beam the microcontroller starts a timer (Timer1). This timer will keep running until the object breaks the second beam or the timer causes an interrupt (on the 65,536th instruction cycle). If the object breaks the second beam before the timer causes an interrupt, it will stop the timer and read the 16-Bit value in the registers TMR1H and TMR1L. We can then calculate the amount of time that it took the projectile to travel the length in between the IR beams, which are 4 inches apart, and find the speed of the projectile.

If the object is too slow, or if the projectile breaks beam #1 but does not break beam #2, the chronograph will display an Error message on the LCD Display. Seeing as this is a 1" diameter pipe, and a paintball is 0.68", I have never had a paintball that failed to break beam #2. However, if a paintball chops in the barrel you might get some inaccurate data and you will more than likely have to clean out the paint that would have splattered in the chronograph to ensure a good "connection" from the transmitter to the detector.

Step 4: Calculations

Now we'll take a look at what calculations are needed to get the actual velocity of the projectile.
The PIC18F13K50 is setup to run at 48MHz. It takes 4 cycles to perform one instruction cycle, so the MCU is running at 12 MIPS (Million Instructions per Second). So the time it takes for the PIC to perform one instruction cycle is equal to (1 / 12MIPS), which is 83.3333 nanoseconds/instruction.

We know that the distance between the IR "beams" is exactly 4 inches. So all we need now is to know how long it took the projectile to travel from beam #1 to beam #2. This is what Timer1 is used for. Every instruction cycle (83.3333 ns) the value of TMR1H:TMR1L will increment.

Say we fired a paintball through the chronograph. Once the paintball has traveled through the chronograph and broke beam #2, we go and read the value of TMR1H:TMR1L (it's a 16-Bit value). For examples sake, we'll say the value we read was 15,930. Here is how we calculate the velocity of the paintball:

MCU Speed = 12 MIPS
                       = 83.3333 ns/ins

Distance = 4 in.
                 = 1/3 ft

Time = MCU Speed * TMR1H:TMR1L
          = 83.3333 ns/ins * 15,930 instructions
          = 1.3275 milliseconds

Velocity = Distance / Time
               = (1/3 ft) / 1.3275 ms
               = 251 feet per second

The paintball was traveling at a speed of 251 fps. While this way of calculating is perfectly fine, in my code I just rearranged the equation so the MCU could calculate it a little bit quicker. The equation I use in my code is:

Velocity = ((FOSC / 4) / TMR1H:TMR1L) / 3
              = ((12 MIPS) / 15,930) / 3
              = 251fps

Step 5: Rate of Fire Mode

As mentioned in the intro, this chronograph also has a Rate of Fire (RoF) mode. This allows the user to determine how many shots per second their paintball marker is capable of. It is pretty straightforward, when switch #2 (S2) is pressed, the chronograph switches from velocity mode to RoF mode and vice versa.

In RoF mode, Timer0 is setup to interrupt after 1.00s as soon as it is enabled. The chronograph waits for a projectile to break beam #1, once it does it enables Timer0 and increments the variable 'rate' which keeps track of the shots fired in the 1.00s time period. The program will then poll beam #1 to see if another projectile has been fired. If another shot has been fired within the 1.00s time period, it will break beam #1 and increment the variable 'rate', yet again, by one. It will then loop until beam #1 is restored back to its default state (not obstructed) before continuing on and checking for another shot. This is to make sure that we do not count the same projectile several times as it passes through beam #1.

Once the 1.00s time period has elapsed, the MCU will display the RoF for 2.00s on the LCD regardless of how many more shots go through the chronograph in the 2.00s time period. This is to ensure that the chronograph does not start recording any shots right after the 1.00s time period which would then result in a new RoF value. Without this delay, the user would have to stop shooting before the 1.00s interrupt occurs, otherwise if the user didn't stop shooting right before the interrupt and an extra ball or two traveled through the chronograph, it would record the RoF of the extra balls that went through because the function would just start over again.

Step 6: Chronograph - Pseudo Code

Below is the attached schematic of the chronograph, here is a pseudo code representation of how the chronograph operates:

========== Chronograph Operation ==========

- Power Up
- Initialize Ports
- Initialize LCD
- Initialize PWM
- Initialize Timer0 but keep it disabled
- Initialize Timer1 but keep it disabled
- Initialize External INT2 (S2)
- Enable Interrupts

- Loop Forever
   - Check if its set for "velocity" mode or "RoF" mode
        - If its set for "velocity" mode, debounce S2 and enable INT2, then enter "velocity" mode
        - Else if its set for "RoF" mode, debounce S2 and enable INT2, then enter "RoF" mode

Velocity Mode:
- Prepare Timer1 to record the speed of the projectile (set TMR1H:TMR1L to 0x0000)
- Loop until a flag is set (pressing S2 would cause this) or an object breaks beam #1
- Start Timer1
- Loop until a flag is set (S2 is pressed or Timer1 overflows) or an object breaks beam #2
- Stop Timer1
- Make sure that a flag hasn't been set (Make sure the operation completed successfully)
   - If no flag has been set, increment the shot count and calculate the projectiles speed
      - Display the projectiles speed on the LCD display
   - Else if a flag has been set and it has not been changed to "RoF" mode, display an error
      (This error is due to the projectile moving too slow for the chronograph to capture its speed)
- Return to main loop and check which mode the chronograph is in

RoF Mode:
- Prepare Timer0 to interrupt at exactly 1.00s (It is still disabled at this point)
- Loop until a flag is set (pressing S2 would cause this) or an object breaks beam #1
- Check to make sure that a flag has not been set (S2 wasn't pressed)
   - If no flag has been set, start Timer0
   - Loop until a flag is set (until Timer0 has interrupted after 1.00s)
       - If beam #1 is broken, increment variables 'rate' and 'shots'
       - Loop until beam #1 is restored (wait for the projectile to finish passing through beam #1)
   - It has been 1.00s and Timer0 has interrupted, display the RoF on the LCD
- Return to main loop and check which mode the chronograph is in

========== Interrupts ==========
- Shut off Timer0
- Set a flag
- Clear the Timer0 interrupt flag

- Set a flag
- Clear the Timer1 interrupt flag

- Make sure both Timers are shut off; Shut off Timer0 and Timer1
- Change the mode from "velocity" to "RoF" or vice versa
- Set a flag
- Disable INT2 (So we can debounce the button press of S2)
- Clear the INT2 interrupt flag

P.S.> I apologize for how the schematic looks a little scattered.

Step 7: Making the Chronograph "Barrel"

Take your 1" diameter PVC pipe and measure 6" in from one of the outer ends. Make a mark here with a pencil or a marker. Use a hacksaw or similar tool to cut the PVC pipe at the mark you made. You should now have a 6" piece of PVC pipe. From there, measure 1.5" in from one end of the piece. Make a mark on the pipe. This is where you will drill the hole for the first IR transmitter. Drill the hole with a 3/16" drill bit, then from the exact center of that hole, measure 4" to the other side of the pipe and make another mark. You will then drill the hole here for the second IR transmitter.

After you have drilled the two holes for the IR transmitters, put the drill in the second hole you drilled and make sure it is completely perpendicular to the PVC pipe (there is pictures for most of these steps). Drill through the other side of the PVC pipe. You have just drilled out the hole for the second IR detector. Next, flip the pipe over and measure 4" across the pipe from the exact center of the second IR detectors hole. Make a mark and drill another hole, this one is for the first IR detector.

The reason I don't drill through both IR transmitter holes and instead I measure 4" from the second IR detector hole is for accuracy. It is to ensure that both IR transmitters and both IR detectors are spaced exactly 4" apart from each other. This minimizes the error in the calculations and allows for greater accuracy.

After all the holes are drilled, the two IR transmitters are placed in their respective holes. Seeing as we used a 3/16" drill bit, the holes diameter is only ~4.8mm. This means that the 5mm LED will not completely fit in the hole, this is what we want though. We just want the IR LED's to slightly poke into the barrel, for two reasons. First, it helps direct the IR beam in a straighter path to the IR detector. Second, it reduces the chance of a projectile striking the IR LED itself and damaging it.

Once the IR LED's are placed in their holes, a small dab of super glue is used to tack them in place. Don't fully glue the IR LED in the hole, just in case you need to replace it later. Once tacked into place, take your soldering iron and solder some wires to the IR LED's. Ensure that the wires can reach the other side of the PVC pipe where we will later be installing the PCB. I would recommend putting connectors on the wires so that it is easier to disassemble the chronograph in the event that you need to clean it.

Step 8: Putting It All Together

Below I have uploaded the photos of the saved PCB at 300DPI. This is the circuit board that I have designed for the chronograph. The crucial part to this board is that the IR Detector holes are exactly 4" apart. This will allow us to align them with the holes on the PVC pipe. I have also uploaded a PDF file which contains all the board faces required to create a PCB using the Toner Transfer Method.

Once you get the PCB made and solder all of the components to it, you are ready to put everything together. I have gone through the steps for putting it together in the pictures. Its is much easier to follow when you can visually see it, so I will not write them up in two paragraphs as they are in the pictures tags.

Step 9: Testing

Once you have it all assembled, program it using the ICSP header and the hex file below. I have also attached all of the source code that I used. It is written in C with the C18 Lite Compiler which can be downloaded from the site below this paragraph. This is a free version of the compiler.

I do not use the C18's driver files in my code for this chronograph. Instead I wrote my own driver files for the timers, external interrupts, pwm, etc. These files are all located at the bottom of this step, enclosed in a downloadable zip file.

I have included the schematic in this step so you don't have to go back to step #6 to view it. You will notice that IR1 and IR2 Detectors are connected up to INT0 and INT1 respectively. Although I did not need to use INT0 or INT1 because my device has nothing else to do anyways when its polling their inputs, I placed them at these locations so that they could be used as interrupts in case someone wants to have the code doing other things and not being tied up in a loop. INT2 has to be used if the user wants to use both modes ("velocity" and "RoF") in their chronograph.

The IR transmitters produce a 38KHz frequency, which is then picked up by the IR Detectors. This is how the device knows when an object is passing through its "beam". The IR Detector will not see a 38KHz IR pulse because it has been blocked by the projectile. I originally wanted to use a comparator and phototransistors to do the job of the TSOP4838's, because I then wouldn't have to worry about pulsing the IR Transmitters at a rate of 38KHz and I could just apply the specified voltage to the IR transmitters. However, I did not have any high-speed comparators here so I went ahead and decided to use IR detectors, of which I did have on hand. As for pulsing the IR transmitters at a rate of 38KHz, I simply used the hardware PWM module on the PIC18F13K50.

In order to program the PIC18F13K50, one must use a programming adapter to avoid damaging the USB pins which are also PGC and PGD. I have included a PDF file which contains the schematic and board layout of a cheap programming header for this device. I did not make the schematic itself, I simply ported it into Cadsoft Eagle and made a board for it. The link is below this paragraph. I have added a 470Ω resistor on the PGC and PGD lines to the microcontroller and it will program this way, but it may damage your USB D+/D- lines without the programming header.

Step 10: Accuracy and Error

Now that we have the chronograph up and working, we will find the worst case scenarios and error tolerances of this device. I will calculate the accuracy according to a 300fps velocity (I assume that the IR Transmitters/Detectors are placed exactly 4" apart, I won't account for manufacturing error).

If a paintball is traveling at 300fps, it takes 3.3333ms to travel 1ft (1 / 300fps = 3.3333ms). Seeing as our IR Transmitter/Detector pairs are spaced 4" apart, we have to divide 3.3333ms by 3 (1ft / 4in. = 3). So the time it will take the paintball to travel 4" at 300fps is 1.1111ms.

300fps = 3.3333ms/ft

time to travel 4in. = 3.3333ms / (1ft / 4 in.)
                                = 1.1111ms

CPU Speed = 12 MIPS
                       = 83.3333ns/ins

Accuracy = 100 - (100 * (83.3333ns / 1.1111ms))
                 = 99.9925% accuracy @ 300fps

Now that is not the actual accuracy of this chronograph. If this microcontroller could detect an object at any instruction cycle, it would have an accuracy of 99.9925% at 300fps because its worst case scenario of not detecting an object when it has broken the beam could only be 83.3333ns before it would actually detect it.

Seeing as I am polling the IR Detectors and waiting to see when an object has broken beam #1, it takes 8 instruction cycles per loop when I am trying to detect if there is an object breaking the beam. Then once it has detected an object, it has one more instruction cycle to perform because it has to start Timer1. After it has done all of this, it has begun recording the time period that it takes the projectile to travel from beam #1 to beam #2. The same goes for beam #2. It takes 8 instruction cycles per "detection" loop and one more instruction to turn Timer1 off. Therefore the worst case scenario is:

Ins/Loop = 8 ins * 2 Loops
                        = 16 instructions before a detection

Ins/Enabling of Timer1 = 1 ins * 2 (enabling and disabling of Timer1)
                                          = 2 instructions

Longest amount of time possible before a detection = (16 ins + 2 ins) * 83.3333ns/ins
                                                                                               = 1.5 µs
Accuracy = 100 - (100 * (1.5µs / 1.1111ms))
                 =  99.865% accuracy @ 300fps

So assuming that there are no other sources of error (distance is exactly 4", beams are broken identically on each side, etc) we would have an accuracy of 99.865% at 300fps for this chronograph. This is very good, however, there are many other small sources of error that I have not accounted for. Therefore it is highly unlikely that the chronograph that I build or you build will be 99.865% accurate. Nonetheless, it works quite well and I am very pleased with it.

I forgot to add the minimum velocity of the projectile. Seeing as the highest count that Timer1 can count up to is 65,535, plus it uses one more instruction to make it overflow back to 0 and its running at 12MIPS, we can calculate the speed of a projectile as low as 62fps. The calculations are as follows:

MCU Speed = 12 MIPS
                       = 83.3333ns/ins

Max Count Timer1 = 65,535 instructions + 1 more instruction to make it interrupt
                                  = 65,536 instructions

Min Velocity = ((12MIPS / 65,536 ins) * 1/3ft)
                      = 61.03516fps (To be safe, we'll say 62fps)

Step 11: Conclusion

All in all, I am quite pleased with how the chronograph works. It wasn't very difficult to build and the code itself is pretty easy to follow. Eventually I plan to update the code and use INT0 and INT1 to detect when a projectile is being shot through the chronograph. This will increase the accuracy and allow for much more efficient code. I would like to make a smaller version of this chronograph, but it is pretty tough to make a lot smaller due to the 16x2 LCD Display. Perhaps I will look into using 7-Segment Displays as a means of relaying the data to the user.

If you have any questions or concerns about this project, send me a message or post a comment and I will get back to you as soon as I can. I may have missed some parts in the Instructable (some parts may be unclear or worded funny) so don't be afraid to ask for help or guidance. The more feedback I get, the better this Instructable will become.

Well, this concludes my first Instructable. As I said before, I am open to any constructive criticism, as I know there will be many spots in the Instructable that I can "touch up". Thanks for having a look!


llArMaDall (author)2016-06-19

I will buy one for $70.

five56 (author)llArMaDall2016-07-11

I have an extra commercial chrono that i'll sell for $70.

Dirtay AnndrianG (author)2016-01-27

Can you build one for me Ill buy it for $45?

bpauza (author)2014-03-22

@Regax, how much would you sell a working one for?

siffup (author)2012-09-03

Check the code, even if it compiles, it can never work!
Either fix it or delete this mess.

Regax (author)siffup2012-10-08

You sent me an email in which you stated the chronograph always says you are shooting at 16960 fps. This happens when neither of the IR receivers are seeing the IR transmitted signal. Double check that your IR transmitters are PWMing at 38KHz. If the outputs on the 38KHz IR receivers don't change when you obstruct the view of the IR transmitter, that is your problem. Apologies for not getting back to this post sooner.

sadstorm (author)2011-04-17

Gran trabajo, pienso intentar poder contruir uno, peor me gustaria saber si a parte de darme los fps, podria darme los m/s y julios.

¿Como podria programarlo? Gracias por todo un saludo.

manza_1983 (author)sadstorm2012-09-16

Has conseguido respuestas con el tema del cronografo?

manza_1983 (author)2012-09-12

Hola Sadstorm, estoy interesado en contruir un cronografo como el del amigo Regax, tu lo has conseguido?

neodymium (author)2012-05-10

what is the maximum fps you think it can detect? I want to build this for my airspft gun but it shoots over 500fps (not sure exatly how much) but I need to know it it will even work. thanks.

bschiera (author)2011-11-12

Very good project, i'd like it, please, can you tell me the correction for reading the velocity in m/s, thanks.

Tom Hargrave (author)2011-10-25

Considering the size of the paintball relative the ID of the pipe are you worried about back pressure slowing down your paintball? I would assume it would have some effect on your measurements because aerodynamics are different.

kswift2 (author)2011-10-22

Is There a reason the .pdf files are blank, can new files be uploaded of saved to another site.

I will be building this and the layout files would help a lot.


Regax (author)kswift22011-10-22

I'm not sure if users without a "Pro" membership can view PDF files (This was brought to my attention a couple of months after I had already created this instructable). I'll create a zip file with all of the contents required for the project and post it in the last step.

ravenbrother (author)2011-07-13

Thanks for this. I just finished building and testing. Didn't like the SMD componnents so I built it off you schematic with the old fashoned parts :D Works I was thinking of redesiging the sensor to have a wider field for use with a firearm. works great with my paintball guns.

Regax (author)ravenbrother2011-07-17

That's awesome! Glad this instructable helped you build your project! I'm not sure how a person could make a wider field for use with a firearm. You could make a line of IR transmitters and receivers, but you would have to make sure that the transmitters have very narrow viewing angles so the stray light does not cross into the path or another IR detector. Let me know if you find out a way to do this. Good luck!


ravenbrother (author)Regax2011-07-17

I was actually looking at motion detectors something like this from radio shack..

PIR Sensor Module then limiting it's field of vision to a slit.

Ferouque (author)2011-06-26

Regax well done mate but it all went right over my head !!!
it totally ment nothing to me

how about i buy that one of you ?? ;-)

tromano2 (author)2011-06-05

Interested in possibly using this to chrono airguns (.177/.22 cal.) as well as .68 cal. paintballs. Any idea as to the maximum FPS this chrono can detect?

ddávila (author)2011-03-11

Hi I would like to know wich other PIC can I use to build this amazing chrono?!!! is just that i cant find the 18F13K50 at my city.

Regax (author)ddávila2011-03-11

Well you would want a minimum of 11 I/O pins, a hardware PWM module, at least one 16-Bit Timer, the higher its operating frequency the greater its accuracy, so I would recommend a PIC18F that operates at a speed of at least 10MIPS (40MHz) to get pretty good accuracy. Also, I use one external interrupt for the RoF mode, so that would be an asset.

Here is a nice program from Microchip that will narrow the results down to based on what you need in a PIC.

A pretty common chip that you could use would be a PIC18F2455, however you will have to modify the driver files for that device or else replace my driver files with microchips driver files.


ddávila (author)Regax2011-03-11

:( I think I will keep searching for de 18f13k50 because I'm not too much experimented on this things so .... I could get lost in this.

Regax (author)ddávila2011-03-11

Well if you purchase online at all, you can check out Digikey or buy them straight from Microchip at When you do purchase them, make sure you purchase them in a "SOIC 300mil" package type if you plan to use my PCB. If you are just breadboarding buy a "PDIP" package.

Regax (author)Regax2011-03-11

The link didn't show up, sorry, the PIC Chip Selector is located at:

robomaniac (author)2011-02-16

Your instructables is very good for your first one! Great graphic and explanation.

If you have better lighting when you take those electronic and tools pictures, it would look even more pro! CFL lighting works great. (coolwhite or daylight) You can also play with the setting of the camera before taking a picture.

Keep it up!

Regax (author)robomaniac2011-02-22

Thanks for the tips! I'll be sure to take that into consideration for my next instructable.

rhanson294 (author)2011-02-22

Excellent instructable! Very well thought out! Would the diameter of the tube make a difference in the reading? I would love to have a shot counter for when I play airsoft.

Regax (author)rhanson2942011-02-22

Thanks! And nope, the diameter of the tube does not matter. You could use a smaller tube and as long as the airsoft bullet manages to break both IR beams it will work the same as this one does.

silencekilla (author)2011-02-15

I'm not accusing anyone but im pretty sure this was stolen from somebody's post for a measuring the velocity of a coilguns projectile. I'll update when i find the website.

Jenna N (author)2011-02-15

This is soooo cool!! You should sell them, make some $$, haha!

Electroinnovation (author)2011-02-06

This is really cool! about how much does it cost to make one?


I just bought all the components from Digikey for $60. Add another couple for the board and I had to buy some etching liquid but you can do it all for around $70 in real life. Figured I'd throw that out there

Regax (author)rspoelstra2011-02-12

Ya making the PCB will up the cost if your don't already have the materials to make one, I had everything on hand so I just estimated the cost. The majority of my stuff is bought off of eBay, which in some cases is much cheaper than Digikey's parts. Just look around for parts, eBay is great for hobbyists that don't need high quantities of supplies.

Regax (author)Regax2011-02-12

I just went and found the cost of all the components at 3 different websites,, and Digikey (only for the Microcontroller) and it came to a full cost of $38.11 for all of the electronic components. I have posted all of this information in step #2.

rspoelstra (author)Regax2011-02-13

Kinda figured it's possible to find everything for cheaper, I'm just a fan of one-stop shopping. Thought I'd just give an estimate for anyone looking to buy everything.

Regax (author)rspoelstra2011-02-13

The only shipping that I didn't add up was the PIC18F13K50 from Digikey. Of course, shipping could cost you more or less, it is totally location dependent. But you are right, it is much less hassle to order everything from one place and get all the parts delivered at the same time. I find eBay has much slower shipping than most other sites such as Digikey. Good luck on your project! Feel free to post pictures when you've got it all finished.

rspoelstra (author)Regax2011-02-13

Plus when you add shipping, it starts to add up.


Create a low-cost Paintball Chronograph for less than $40!

profpat (author)2011-02-10

very good, will try to modify for airsoft or airgun use! thanks

Regax (author)profpat2011-02-10

If you're modifying it for air gun use, seeing as the pellets are so small you may have to decrease the intensity of the IR beams or make a barrel where the beams are more "concentrated".

To decrease the intensity of the IR beams you can add larger resistance values for R4 and R5. Or else you may be able to decrease the PWM frequency from 38KHz to something a bit smaller, which will decrease the sensitivity of the IR Detectors. If you go too low though, they won't detect a beam at all.


profpat (author)Regax2011-02-10

great! will do as you suggest, also i am planning to use a smaller pvc pipe or tube, i was planning to use a umbrella stem or old tv antenna elements..

Regax (author)profpat2011-02-11

Good idea! Feel free to post pictures of your prototype when you get it made!

shahzade (author)2011-02-07

Hey great Instructable!
I like how easy and straight forward it is!
But I have a question, you write "The PIC is setup to run at 48MHz. It takes 4 cycles to perform one instruction..." I think one instruction is like one loop? One time going through the whole script? How did you find out how many cycles it takes to run the script. Is that a given characteristic of the PIC or is it depending on the length of your script and how complex it is?
Well thanks a lot.
keep it up

Regax (author)shahzade2011-02-07

Not quite, I should have watched my wording a little more carefully. Let me restart:

An instruction is like a command, it allows you to tell the micro what you want it to do. Normally, one would think that if this micro was running at 48MHz, it could execute one command every clock cycle, which is equal to 20.83333ns (1 / 48MHz). However, that is not the case. I won't go very deep into it, but due to the way that the microcontroller is built, it takes 4 clock cycles to perform one instruction cycle. That's how we get 12MIPS, (1 / (20.83333ns * 4 clock cycles)). Now every instruction that the microcontroller can use takes at least one instruction cycle, some take more.

For example, If I wanted to turn an 'active high' LED on that is located at RB0, I could write this:

PORTBbits.RB0 = 1;

That is 'C' code. This is a higher level language, which means it is easier for the programmer to use. All a C compiler does is it converts your "easier to read and write" C code into Assembly Language Code. An example of what the above C code would convert to in ASM (Assembly) is below:


This instruction tells the microcontroller "Set bit #5 on PORTB high", which would turn on the LED. If you look in the PICK18F13K50 data sheet (link added below), starting on page 309 is the detailed part of all the ASM instructions. Here you can see how many instruction cycles it takes to perform any of the listed instructions. The above "BSF" instruction only takes one instruction cycle, which is 83.3333ns with this projects configuration. So you could go and look at the disassembled C code for this project and figure it out by hand how much time a section of code will take to execute, or you could do like me and just use the MPLAB simulator.

Its kind of confusing to wrap your head around I know, but if you don't fully understand it, you can just use the MPLAB simulator and its stopwatch which will do all the calculations for you.

Heres a link to the datasheet:

Sorry for the long, confusing explanation. I don't know if this helped, I am a bit better at explaining things in person haha

Regax (author)Regax2011-02-07

How did you find out how many cycles it takes to run the script. Is that a given characteristic of the PIC or is it depending on the length of your script and how complex it is?

Sorry I missed this last part. The amount of time that it takes to run your code is totally dependent on how large and complex your program is. More instructions mean more instruction cycles which means more time is needed to execute everything.

anode505 (author)Regax2011-02-10

For time critical sections interrupts can be used so the timing section is run outside of the main loop.

Plus, there is what if I remember right, imperial timing, where you know the number of instructions, hence time it takes to get from one point in the program to another. Its typically frown upon, but for smaller programs where it won't branch or interupts, it can be used carefully.

dishpit (author)2011-02-08

Nitpick: you're measuring speed, not velocity. There's a difference.

Regax (author)dishpit2011-02-08

You are right, unless I was to state the direction in which the projectile is traveling it is speed. Should have remembered that one from physics haha

dishpit (author)Regax2011-02-08

Sorry, I know nobody's going to be confused because you said velocity, I just can't help being pedantic.

And I feel bad that I forgot to mention: awesome project! As a paintballer, I know how frustrating the chronos at the field can be, especially in the morning, when they're cold. Nice job!

Regax (author)dishpit2011-02-08

No problem! I appreciate feedback like that. I for one can't stand when people don't capitalize any sentences or have terrible grammar, so I know where you're coming from. Thanks for the review!

About This Instructable




More by Regax:Interactive LED Beer Pong Table 2.0 (BPT X5)Laser Cut Wooden Jewelry BoxInteractive LED Beer Pong Table
Add instructable to: