# Building a ChronoGraph

Hi there, so I've been mulling around this project in my head a little bit. SO I built a rig that uses IR leds/IR recievers to sense when a BB was going out of the barrel of an airsoft gun (counting ammo usage through the course of a game). And I had a little bit of trouble with actually getting a signal off of some guns.

I'm wondering, what might have been causing the problem. I doubt that the arduino is running too slow to pick up the pulse. I think, assuming a 5mm bb, going say 500fps, Thatd be the 5mm turned into inches is ~.2in, to feet thats .016ft for the bb's cross section. .016 divided by the 500f/s gives you the amount of seconds that the BB takes to go by a point (the sensor), then multiply that by 1000 to get the number of milliseconds that it takes to pass by.

So .032ms, too fast for the arduino to pick up? Or is my math wrong? Or is there a better way overall to go about this?

Instinct says your arithmetic is incorrect. Never was very good with imperial units though. 500 fps sounds quite fast.

Your math appears to be correct. I get 33 microseconds (.033ms) which the Arduino should be able to measure. But I suspect that the cross section of a BB pellet is too small for the IR receiver to see reliably, or perhaps at all.

Pete

What does the code look like?

545kmh-1?
That’s quite fast, isn’t it?

Thatd be the 5mm turned into inches is ~.2in, to feet thats .016ft for the bb's cross section. .016 divided by the 500f/s gives you the amount of seconds that the BB takes to go by a point (the sensor), then multiply that by 1000 to get the number of milliseconds that it takes to pass by.

5 mm at the speed of sound 340m/s ==> 0.005/340 ~ 14.7 microseconds 5 mm at 500 feet/sec 150 feet = 150 meter ==> 0.005/152.4 ==> 32.8 microseconds = 0.033 msec. (Your math is OK)

A pulse of 32.8 micros can be measured by an Arduino, the precision/stepsize using micros() is 4 micros() . If you use a hardware timer you can get more precise results.

See - http://arduino.cc/forum/index.php?topic=96971.0 - for some detailed discussion.

Using an interrupt since if im not mistaken, thats the fastest sensing capability of the arduino is it not? And yeah 545km/hr is fairly fast. THats a pertty standard outdoor projectile speed though. Many guns however fall into the 350fps range (~380km/hr for AWOL). It probably is however the BB is too small to block out the light enough for the sensor. Though I know when I tried to do this on a couple pistols I have, it sensed just fine. So probably speed coupled with the small cross section.

So then, what could one do then to make the sensor read better, cause I cant really change the size of the BBs in the gun.

TY btw

Using an interrupt since if im not mistaken, thats the fastest sensing capability of the arduino is it not?

Probably not. Simple direct port read would be quicker.

If it works reliably on slower projectiles than the most likely source of the problem is the code not the sensor. In other words... http://arduino.cc/forum/index.php/topic,99388.msg745270.html#msg745270

Id love to post the code but its at home, and im at school. Later this evening when i get home.

But suffice to say it goes something like this.

``````int count=0

Setup{
Attach interrupt 0 [falling].
//Turn on SD read/writer and LCD screen
}

Loop
LCD.clear;
LCD.print(count);

VoidInterrupt 0
{
count++;
file.print(count)
}
``````

not too much happening, just printing the count of pulses so far into an LCD screen, serial, and to an SD card (with an arbitrary filename, BBcount)

With regards to "its probably the code since its reading on the slower guns" In thinking about it, its probably more of cross section, and mounting problems on the guns. Why do I say this. Well pistols usually just have a little tip that sticks out, no fancy geometry or anything other then maybe a peep sight. When mounting the sensors to the 2 pistols I've tried, I get a small diameter plastic tube that fits over the end of the barrel. Mount the sensor and LED to that, and run. Its a lot more stable (and cuts across the BBs crossection better) then when I do it on rifles that all have some muzzle break that I have to try and mount the LED and sensor to.

Perhaps I can get the CNC teacher @ my school let me borrow a machine for a little while and cut something out of a piece of nylon stock or something. With nice low tolerance drilled holes to mount everything in that slides onto the equipment rails of one of the guns, to do the sensing. That'll account for any improper mounting.

The brightness of the LED, amount of light blocked by the BB and ambient light will affect the sensor. Could you have reflections from the mounting bracket allowing light to bypass the BB?. Make sure the LED and sensor are aligned with each other and the BB's path. Is there be any play or vibration in the mount? Anything you can do to reduce external light into the sensor will probably help.

Increase and decrease the brightness of the LED until the sensor reads 'dark' then increase the brightness a little. That way it will only take a small change in light to trigger the sensor.

I assume the sensor is digital. If it is analog and you are using a comparator circuit You can adjust both the brightness and the threshold so the sensor is in the middle of it's range which is probably the most sensitive and linear region.