
Project: Inexpensive Firearm Accelerometer - wizdumb
https://blog.ammolytics.com/2019-01-01/project-cheap-rifle-accelerometer.html
======
wizdumb
Based on the feedback from my previous experiment[1], I wrote an in-depth
article about the accelerometer unit I built. In this article, I describe how
I built it, how it works, and how you can build your own for under $50! The
project is open-sourced and it uses off-the-shelf components. Data analysis
was done using Python, Pandas, and Plotly.

I hope that this content is high quality enough to justify the time you spend
reading it, and how much time it took me to create it!

I’d love to hear your feedback and answer any questions!

[1]
[https://news.ycombinator.com/item?id=18731322](https://news.ycombinator.com/item?id=18731322)

~~~
dfsdfklgjljg
Is there any reason why you can't connect the accelerometer directly to the
rpi?

~~~
wizdumb
You definitely could! I chose not to simply because I wanted to make it
smaller. The Feather boards are a bit smaller than the Pi Zero.

~~~
joshvm
You could try making it wireless rather than put the logging on the gun.
Something like an Esp8266 might do it if you buffer the measurements. Also
look at the Particle Photon which will do TCP out of the box. Squirt the data
to a pi and do the logging on there.

Your problem is that you need to find some asynchronous storage or
transmission method. For example in barebones avr, writing to the spi data
register initiates a transfer, but you can do other things while you wait ~8
clocks for it to send. Interleaving like this can go quite a long way on 8 bit
hardware.

In Arduino, there may be a lot of safety checking and blocking going on. Other
chips (eg ARM) can do things like DMA where you can route data from eg a
serial port straight into something else.

~~~
wizdumb
Thanks for the feedback! The Feather board I'm using actually has Bluetooth,
but I have not explored using it yet. If it's faster to send data over BLE to
an app, then that would make this project even more affordable and smaller
because the SD card and RTC are no longer required.

I believe the Feather M0 board I'm using is also capable of running
CircuitPython (fork of MicroPython). For this project, I wanted to keep it
simple, so I opted for Arduino, though I am more familiar with Python.

If you have any specific advice or improvements you'd like to suggest, I'd
love to get them in either PRs or Issues for the project over on GitHub!
[https://github.com/ammolytics/projects/tree/master/accelerom...](https://github.com/ammolytics/projects/tree/master/accelerometer)

~~~
joshvm
Will do!

------
burfog
You need to rig this up to an actuator. There are lots of things you could do
with that.

You could detect when a machine pistol is getting uncontrollable muzzle rise,
then stop it until the trigger is released and reapplied.

You could hold off firing until the gun is stable. When the trigger is pulled,
look for smooth movement. (no angular acceleration, and the regular
acceleration has a stable magnitude equal to gravitational acceleration) The
motion for leading a duck is fine, but the motion of stumbling and getting
snagged on bushes is not.

You could disable the gun if acceleration goes to zero, for example by being
dropped. After half a second of stable gravitational acceleration, reenable
the gun.

~~~
wizdumb
Hi! I see a lot of "you could" in your reply, but I'd like to point out that I
released this as an open-source DIY project so that _anyone_ could do whatever
tests they wanted. I encourage you to build your own -- I'd love to see what
you can make and learn with it!

~~~
burfog
It's just a few free ideas. I'm thinking you or anybody else could have fun
and/or create a profitable business.

~~~
wizdumb
Fair enough! I don't have the budget for a machine pistol, but maybe someone
who does can try that idea out.

~~~
burfog
The other two ideas apply to typical guns.

------
danielvf
I’ve played with the adafruit 9DOF sensor on a handgun. It was fun, but
trigger pull wasn’t my problem, so I went on to other things.

However, I’ve always idly wondered about mounting a cheap keychain cam to a
flashlight mount, then exploiting the rolling shutter effect to extract high
frequency rotation information.

~~~
wizdumb
Nice! I have that board as well, but only played with it briefly. Do you have
any data from your use of it on the pistol that you'd like to share? I've love
to see how it turned out.

~~~
danielvf
I looked through my files, but can't seem to find it - this was many years
ago.

I love the Feather's though!

~~~
wizdumb
Hey, thanks for looking!

