opto sensor, microcontroller, led display

THE_RB

Joined Feb 11, 2008
5,438
Why try to use light to measure the balls?

I would just use a mechanical switch on the gun mechanism, surely there is some moving component that cycles once per ball fired?
 

tshuck

Joined Oct 18, 2012
3,534
Why try to use light to measure the balls?

I would just use a mechanical switch on the gun mechanism, surely there is some moving component that cycles once per ball fired?
Some of the fancier guns have an electronic firing mechanism that can be configured to fire 1, 2, or more balls per trigger pull and/or release. The only moving parts would be hard to attach to as they are either moving very fast, or enclosed in the gun body. Of course, this is dependent of what type the OP has...

Also, the gun may dry fire, causing anything mounted to the mechanical portion register as a ball leaving...
 

Thread Starter

akramer08

Joined Jan 23, 2013
113
Tshuck your exactly right, that's why I don't really want to use a feather switch or one activated by the trigger pull. The gun I'm using does have an electronic trigger too. I believe the most accurate way to measure the shot count is by measuring the amount of paintballs leaving the barrel. I don't mind what hardware I use. I figured it would be a PIC but I have also heard of the arduino or raspberry. Whichever is easier and can accomplish my goals of using the opto sensor and a 3 digit led display. Which do you suggest.
 

thatoneguy

Joined Feb 19, 2009
6,359
How about a "ring" that clamps to the end of the barrel which the ball passes through?

Just need an IR LED + IR photo-transistor (unless you use nightvision, then use UV), mount the IR LED above the barrel pointing down, and the photo-transistor pointing up at the emitting LED. The microcontroller could easily count two balls firing at once if they are not in physical contact with each other. No mods to the barrel required, it could clamp on to any barrel.

PICAXE is an easy way to get started for $25, no programmer is needed, just a serial adapter cable.

The display would be the expensive part. I'd suggest something like a 16x2 OLED character display, they are quite bright, and driving them is simple, as most come with a UART interface rather than the 6 wire parallel interface of a standard 16x2 LCD. Figuring out how to mount a pair of 7 segment displays in a way they won't get damaged would be the hardest part, in addition to hiding 9 or 10 wires.

--ETA: Does your paintgun have any recoil? If so, the complete circuit could be built with a single axis accelerometer to measure the snaps of recoil if it spits them out a high velocity. This method is used on some firearm counters.
 
Last edited:

Thread Starter

akramer08

Joined Jan 23, 2013
113
What would be the difference between the IR LED/transistor and an opto sensor? I have no experience with either of them.

If I was to use the 16x2 OLED character display, I would want to put a little more data on it other than just an ammo count. Maybe the velocity my gun is putting out, anything really. I figured if I am just displaying 3 digits, I wouldnt spring for a big expensive display.

The gun doesnt really have much recoil, that you can physically feel outside the gun at least. I wanted to use some type of opto sensor for the reason that I think if I had an accelerometer I would need the sensitivity high, resulting in me bumping it with my hands or doing something to where it registered as a ball coming out.
 

tshuck

Joined Oct 18, 2012
3,534
Tshuck your exactly right, that's why I don't really want to use a feather switch or one activated by the trigger pull. The gun I'm using does have an electronic trigger too. I believe the most accurate way to measure the shot count is by measuring the amount of paintballs leaving the barrel. I don't mind what hardware I use. I figured it would be a PIC but I have also heard of the arduino or raspberry. Whichever is easier and can accomplish my goals of using the opto sensor and a 3 digit led display. Which do you suggest.
Well, as you said, there are a number of routes you can take in terms of the controller.
The Raspberry Pi is overkill for this project, you needn't have an OS, nor a 700MHz processor.

The PIC, any unmodified microcontroller, really, is a little complex and will require you to do some learning and experimenting to understand what to do.

Arduino comes with the microcontroller on a pre-built board. It is programmed in a language similar to the C programming language. It does not require a separate programmer.

As thatoneguy said, there is also a PICAXE, which is like the Arduino, in that it simplifies the programming and working of the microcontroller. The PICAXE is programmed through a serial port and programs are written in BASIC, so it does not require a separate programmer.

The barrel sensor would work, but in paintballing, if you stick it out, it will get shot. I think that making a suitable barrel attachment would require more design than most are willing to put into a project.

The balls leaving the hopper must be the number leaving the gun(unless you open the hopper), so you are at no disadvantage between measuring the barrel or the hopper. Putting a hopper sensor could be as easy as putting a IR emitter/detector pair in a piece of PVC attached between the hopper and the gun itself. The sensor could be slightly off center, so as to measure the ball's side(as opposed to the center, which wouldn't be able to differentiate ball 1 from ball 2). The whole unit can be built around this PVC with the battery, display and sensor in one package.

The accelerometer approach would be tricky, as you'd have to be able to distinguish between the ball being fired and the user diving for cover behind a rotten out log. Finding the sweet spot may be more trouble than it's worth..

Also, mounting a small switch may work, however, finding the right switch might be quite a pain, as the wrong switch would impede the movement of the balls. Though the tactile switches I have used in projects seem like they might work...

I'm with thatoneguy in your display. A character LCD display would be nicer to look at and easier to put together, though it is another hurdle to learn how to use it, however, there are many, many tutorials on how to interface controller X to a LCD screen, so don't let that be your deciding factor.

@thatoneguy- night-vision required paintball sounds fun!
 

Thread Starter

akramer08

Joined Jan 23, 2013
113
I think ill go with the sensor at the very bottom of the hopper.

The PICAXE sounds like the way to go, you guys make it sound a little easier.

With the character display, can you change how large the digits appear or are the one size?
 

tshuck

Joined Oct 18, 2012
3,534
I think ill go with the sensor at the very bottom of the hopper.

The PICAXE sounds like the way to go, you guys make it sound a little easier.

With the character display, can you change how large the digits appear or are the one size?
Character LCD's are one size( I think usually 8x8 pixels?), You can define custom characters and, possibly display one big character using multiple custom ones, but the distance in between character positions might make it look odd...
A graphic LCD would allow for customizable sizes, but are much more complex than character displays...
 

tshuck

Joined Oct 18, 2012
3,534
You are going to but 2000 of them!?:confused:

Anyway, that is a seven-segment display(SSD), and unless I am going blind, I didn't see anything listed as to the size. You can get pretty big seven-segment displays, and they will work, you just need to keep that in mind. If fact, it probably would be easier to interface the microcontroller to the SSD, but you will need to design a good mounting scheme for them. I, personally, find SSDs cumbersome not very aesthetically pleasing, but this is your project, not mine.:)

We can help you either way.
 

Thread Starter

akramer08

Joined Jan 23, 2013
113
Yea definitely not getting 2000, lol. I just google for a pic as to what I was thinking. I just dont really want to get a big display for only 3 digits if the digits are relatively small. All the 16X2 displays I have looked at look kind of wide. I dont know if that will increase the chances of it getting hit by a ball. But then again, it may be mounted behind the hopper so that might help reduce those chances. I dont mind using the 16X2 display, as long as its easily visible at daytime.
 

SPQR

Joined Nov 4, 2011
379
I've used Arduino in the past, but I've been thinking about "upgrading", and I'd like to follow your project.
Looking at the PICAXE, there seem to be seven sizes, with digital I/O numbers of pins of 6/12/16/18/18/22/33.

So you'll need one pin for the sensor switch.
On pin for the reset switch.
10 pins for the LED display.

So if you go with the 16 pins, you'll perhaps pick the 18M2.
The output is 25 mA for each I/O pin, and you can get LEDs which need as little as 10mA per segment.

I'll be watching and learning with great interest!
 

thatoneguy

Joined Feb 19, 2009
6,359
The displays I am referring to have a serial interface, so they only need one wire.

Here are OLED types that I was thinking of.





Compared to LCD:
Backlit Reversed (light on dark):


Standard LCD:
Normal Backlight:



The OLED are Brighter, Sharper, and more compact than LCD, the graphical type can be as small as 1" x ½" (128x64 pixels), so a very large font (yellow, blue, or white on black background, though full color is also available) is clear and easier to read than a 7 segment LED.

YouTube Video of Graphical OLED (Small) with yellow pixels
 

thatoneguy

Joined Feb 19, 2009
6,359
You would need 10 I/O lines for the 3 7 segment LEDs, plus 1 output and one input for the detection. That is the limit of a 14M2, but a PICAXE may not be fast enough to catch two projectiles fired < 1/20th second apart.

You may want something faster with fast hardware interrupts for timing better, and 2 more I/O + 2" spacing between sensors (if using both past end of muzzle) to determine velocity in addition to counting rounds.

The code gets a bit more complex, but since you are new to controllers, an Arduino may be a more expensive, physically larger, but more "plug and play".
 

tshuck

Joined Oct 18, 2012
3,534
You would need 10 I/O lines for the 3 7 segment LEDs, plus 1 output and one input for the detection. That is the limit of a 14M2, but a PICAXE may not be fast enough to catch two projectiles fired < 1/20th second apart.

You may want something faster with fast hardware interrupts for timing better, and 2 more I/O + 2" spacing between sensors (if using both past end of muzzle) to determine velocity in addition to counting rounds.

The code gets a bit more complex, but since you are new to controllers, an Arduino may be a more expensive, physically larger, but more "plug and play".
Hmmm... I've never used the PICAXE before...didn't think the speed would have been sacrificed that much from a bare PIC...


@thatoneguy, what is the reason for the speed discrepancy?
 

thatoneguy

Joined Feb 19, 2009
6,359
Hmmm... I've never used the PICAXE before...didn't think the speed would have been sacrificed that much from a bare PIC...


@thatoneguy, what is the reason for the speed discrepancy?
PICAXE at 8Mhz runs about 500k Basic instructions per second (bootloaded OS/Interpreter). They do clock up to 32MHz, so they blow the Basic Stamp out of the water, but they aren't the optimal choice for microsecond level timing. The ability to directly use the CCP module is limited in making the chip easy to use for absolute beginners.

PICAXE is far cheaper and essentially zero learning curve to getting started in microcontrollers. Once that is understood, an informed choice can be made for what is needed, rather than thinking "must have 32 bits and a lot of RAM!". :D
 

tshuck

Joined Oct 18, 2012
3,534
PICAXE at 8Mhz runs about 500k Basic instructions per second (bootloaded OS/Interpreter). They do clock up to 32MHz, so they blow the Basic Stamp out of the water, but they aren't the optimal choice for microsecond level timing. The ability to directly use the CCP module is limited in making the chip easy to use for absolute beginners.

PICAXE is far cheaper and essentially zero learning curve to getting started in microcontrollers. Once that is understood, an informed choice can be made for what is needed, rather than thinking "must have 32 bits and a lot of RAM!". :D
Is the program interpreted on chip?

If that is the case, then the Arduino might be better suited for this project as the Arduino code is compiled to native assembly.
 

thatoneguy

Joined Feb 19, 2009
6,359
Is the program interpreted on chip?

If that is the case, then the Arduino might be better suited for this project as the Arduino code is compiled to native assembly.
Yes, but more efficiently than Basic Stamp Basic, it's not as good as native C on any platform.

The Arduino would be better for the speed requirements, and has easy to libraries for the 7 segment display and interrupts. The only downsides are cost per project and the size, unless you use the board to program, then use it out of circuit with a separate power supply and crystal.

The PICAXE advantage is very low cost (<$5) per chip, and extremely easy to get going for most projects (no crystal, no programmer needed, just a USB->RS232 cable), this project may be past the edge of speed if wanting to measure velocity or count 2 paint balls shot at the same time.
 

tshuck

Joined Oct 18, 2012
3,534
Yes, but more efficiently than Basic Stamp Basic, it's not as good as native C on any platform.

The Arduino would be better for the speed requirements, and has easy to libraries for the 7 segment display and interrupts. The only downsides are cost per project and the size, unless you use the board to program, then use it out of circuit with a separate power supply and crystal.

The PICAXE advantage is very low cost (<$5) per chip, and extremely easy to get going for most projects (no crystal, no programmer needed, just a USB->RS232 cable), this project may be past the edge of speed if wanting to measure velocity or count 2 paint balls shot at the same time.
Well, I know C is a compiled approach as opposed to the interpreted approach that the PICAXE, uses apparently. Compiled will always be faster than interpreted.

I think that since the OP has stated that he is using a electronic trigger with multiple fires per trigger pull and/or release, there is a very good chance for multiple balls being shot very fast.

OP, what is the maximum fire rate & fps your gun can shoot?
 
Top