opto sensor, microcontroller, led display

Discussion in 'General Electronics Chat' started by akramer08, Jan 23, 2013.

  1. akramer08

    Thread Starter Member

    Jan 23, 2013
    113
    0
    I am wanting to make an ammo counter for a paintball gun. I want to use an opto sensor in the barrel of the gun to sense when a paintball is fired. I want the ammo I have left to be displayed on a 3 digit led display. I have been told a microcontroller is what I need. I want to be able to set a number on the display, then count down every time a ball is fired. i am completely new to circuits and microcontrollers. I do not know what supplies I need or how to do it. Any assistance would be appreciated.
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    Didn't the Marines have that in the Aliens movie? Two big 7 segments showing rounds to go?

    It may be easier to count trigger presses, but I'm not a paint baller so I don't know what's inside the gun.

    It's a pretty easy circuit for a micro, which is to say you have a lot of work ahead to get one working.

    So I have one question to ask you... are you feeling lucky, punk?
     
  3. akramer08

    Thread Starter Member

    Jan 23, 2013
    113
    0
    Ha, nice one. Occasionally, a paintball may not be loaded into the chamber in time before the gun tries to shoot, basically a blank fire. So the trigger would be pressed, the ammo counter would go down by 1, but a paintball would never come out. Thats why I thought of using the opto sensor in the barrel so it only counts when it truly is supposed to.
     
  4. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    You then need to take into account the capability for the ball to break in the barrel and whether or not the sensing circuit will detect one, or two balls from that.

    What happens when your hopper is empty? Do you load more paintballs and reset your counter with the pre-counted number of balls in your reserve?
     
  5. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    If you break your balls (well, you have other problems) but if the counter has a time out then it could only count integer balls and not fragments. That's a minor code detail once the sensor and display are in place.

    I just thought of something: is the barrel transparent? How do you "see" thru it to see your balls?

    (This thread is just too much fun... going to peek at some dev boards for ya.)
     
    Last edited: Jan 23, 2013
  6. SPQR

    Member

    Nov 4, 2011
    379
    48
    Do you use a hopper or are you talking about just a magazine?
     
  7. akramer08

    Thread Starter Member

    Jan 23, 2013
    113
    0
    I want to try to utilize some type of sensor that will detect if a ball is ready to be fired. They call it an EYE system but that will be a secondary project. I guess finding out how much it will count a break will be a trial by error thing until i complete that project.

    The backup pods holding the extra paintballs normally fit around 140. I will probably do a number that I know that will fit, maybe 130. So yes, I would want to put a button that will reset to a specific number. Would I need to choose that number while programming the controller or if I feel that number is too high/low, could I preset a number to use at any time, maybe even on the field.
     
  8. akramer08

    Thread Starter Member

    Jan 23, 2013
    113
    0
    It will be hopper fed. Even though it can use a magazine, I would rather use the hopper. Its a spyder emr5
     
  9. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    The problem is that a broken ball will move at a slower sped than a non-broken ball and some of these paintball guns can shoot an incredible number of balls per second. If the fire fate is comparable to the speed of the broken ball, then you could register false positives...though that may not be too much of a problem for your gun?

    This isn't an Oracle or Angel, is it?:)
     
  10. akramer08

    Thread Starter Member

    Jan 23, 2013
    113
    0
    No, I love playing paintball, but I would never spend around $1000 on a gun. Mine was only $250.

    Ernie, just noticed your reply about breaking balls (lol). I wanted to either drill into the beginning of the barrel and mount the opto sensor there, or inside the body of the gun just before the barrel. I will probably go with the second option though.
     
  11. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Your second option may have problems in that your gas could expand out the holes instead of behind the ball. Or, you may see your balls flying all over the place(I can't change the wording on that one:p)... Just things to consider...

    It might be better to count the balls as they leave the hopper...
     
  12. akramer08

    Thread Starter Member

    Jan 23, 2013
    113
    0
    Yea I have a few options on where to place the sensor for it to work efficiently. My challenge is building everything together and programming the controller.
     
  13. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Well, once placement is settled, the rest is relatively easy(for most of the people here...)
     
  14. akramer08

    Thread Starter Member

    Jan 23, 2013
    113
    0
    Any advice or words of wisdom on how to do this?
     
  15. SPQR

    Member

    Nov 4, 2011
    379
    48
    I wonder about putting a mechanical sensor - a "feather switch" - at the bottom of the hopper.
    It would stay away from the workings of the gun, and allow the "counter" to be attached separately from the gun, on the hopper only.
     
  16. akramer08

    Thread Starter Member

    Jan 23, 2013
    113
    0
    Not a bad idea. I dont mind attaching anything to the gun though. My real problem is how to connect everything and program the controller.
     
  17. SPQR

    Member

    Nov 4, 2011
    379
    48
    I've done something like that before on THIS project where I had limit switches.

    So you have something like this:

    [​IMG]



    And HERE is something about driving a 7 segment display with a microcontroller.
     
  18. akramer08

    Thread Starter Member

    Jan 23, 2013
    113
    0
    What software do you need to write the program? How to you get the program on the microcontroller? Like I said I am completely new to all this stuff.
     
  19. SPQR

    Member

    Nov 4, 2011
    379
    48
    The type of microcontroller determines the software.
    I use the Arduino system. Easier than most.
    The code you'd need would be pretty easy.
    The hardware is the hard part.
     
  20. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    This depends on the type of microcontroller. Most people here are familiar with PIC and/or AVR. There is a hobby platform called Arduino that is basically an AVR with an easy-to-use interface. It has a bunch of libraries built for it(prebuilt code to do a specific task), though I don't think you''ll benefit from them.

    For PIC:
    -You should get a Pickit 2(~$35) or 3(~$45) (3 would be my choice as it supports a wider range of chips, though that may not be a concern for you).
    -You'd need to select a microcontroller and design the circuit board

    For AVR:
    -You'd need an AVR ISP programmer(~$15 - ~$600)
    -You'd need to select a microcontroller and design the circuit board

    For Arduino:
    The chip can be programmed through a serial interface. This comes in various forms, but the Arduino Uno is probably the basic version. The microcontroller is on a prebuilt board.

    If you want a one-and-done sort of approach without wanting to delve deeper into electronics, use the Arduino, otherwise, I'd say go with PIC or AVR, as you will learn a lot from using them.
     
Loading...