Tri-Axis Accelerometer
CumQuaT
Posts: 156
Hi,
I'm working on a project that involves the Hitachi Tri-Axis Accelerometer and I'm having some difficulty. I've read through the Smart Sensors book but can only find information regarding the 2-axis variant, and browsing the forum and the web, I can't find any good examples of what I'm trying to do, so I thought I'd ask on here.
I'm trying to build just a simple speed sensor that measures in G Forces. The condition I have to work with, however, is that it has to be able to just measure speed. Not speed in any particular axis or direction. I need to make an application that simply measures the amount of G Forces placed on the Accelerometer at any given time. It needs to have the fastest possible refresh rate and output the current G Force total.
Every example I can find only lets you measure things on a given axis, but my project will be shifting axis constantly, hence the need to measure total G Forces applied to it.
Can anybody help me at all with some source code ideas that can get me started? I am relatively experienced in PBasic, so even if it's just a head start I can probably take it from there.
Huuuge thanks in advance to anyone who can give me some pointers!
I'm working on a project that involves the Hitachi Tri-Axis Accelerometer and I'm having some difficulty. I've read through the Smart Sensors book but can only find information regarding the 2-axis variant, and browsing the forum and the web, I can't find any good examples of what I'm trying to do, so I thought I'd ask on here.
I'm trying to build just a simple speed sensor that measures in G Forces. The condition I have to work with, however, is that it has to be able to just measure speed. Not speed in any particular axis or direction. I need to make an application that simply measures the amount of G Forces placed on the Accelerometer at any given time. It needs to have the fastest possible refresh rate and output the current G Force total.
Every example I can find only lets you measure things on a given axis, but my project will be shifting axis constantly, hence the need to measure total G Forces applied to it.
Can anybody help me at all with some source code ideas that can get me started? I am relatively experienced in PBasic, so even if it's just a head start I can probably take it from there.
Huuuge thanks in advance to anyone who can give me some pointers!
Comments
Here is the code I'm using to calculate it and display it (it's a modified snippet from the original parallax code on the product page. The only part I've edited):
' calculate g-force
' -- "gForce" is signed word
IF (axCount >= rvCount) THEN
gForce = (axCount - rvCount) ** GfCnv ' positive g-force
ELSE
gForce = -((rvCount - axCount) ** GfCnv) ' negative g-force
ENDIF
DEBUG CRSRXY, 20, (7 + axis), ' display g-force
" " + (gForce.BIT15 * 13),
DEC1 (ABS(gForce) / 100), ".",
DEC2 ABS(gForce)
'DEBUG CRSRXY, 21, 11, DEC5 ABS(gForce)
TotalVal = TotalVal + gForce
NEXT
'TotalVal = TotalVal - 112
IF (TotalVal < 0) THEN TotalVal = 0
DEBUG CRSRXY, 21, 11, DEC5 ABS(TotalVal)
PAUSE 200
GOTO Main
You know... If that's even possible...
Thanks so far. I hope we can work this out! Knowing my luck it'll be something crazily simple that I have overlooked...
In order to use acceleration to determine speed, you must know the velocity you started with. Velocity is not the same as speed, for velocity includes both speed and direction. You must know how fast you're going, and in which directiion, on each of three orthogonal axes. To calculate your speed from these six pieces of data, you would use the three-dimensional version of the Pythagorean theorem (square root of the sum of the squares).
An accelerometer measures how fast your velocity (speed and direction) changes. You must, in each of three axes, continually calculate the integral of the acceleration, and add the integral to the previous velocity. This may be a little much for a Stamp, for a Stamp isn't very well chosen for precision calculations, having only eight or sixteen bits and being incapable of floating point arithmetic. Errors would, I think, accumulate so quickly that soon your calculated velocity would be a random number.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i
The starting speed will always be 0 if that helps...
Otherwise... What else could I use for this process?
Thanks guys!
You don't have to have absolute measurement of frequency, only a knowledge of the percentage change -- therefore you don't need an accurately calibrated measuring·clock, only a reasonably constant one.· Same for the tone emitted.
If, for example, you expect a punch to take about 1/5 second to travel 2 feet to the target, it will be going 10 feet per second (fps), which is about 9% of the speed of sound -- so you can expect about a 9% increase in the frequency.· This change will persist for perhaps 1/3 of the distance traveled, or 2/3 of a foot, therefore the frequency will be high for 1/15 of a second.· If you want to achieve, say, 5% accuracy, you'll need to count 20 cycles in 1/15 of a second, so you'll need a minimum fequency of 300 Hz.· Small transducers will work better at, say, 10KHz, so you ought to be able to achieve much better accuracies.
Now work it the other way.· Assume 10KHz and count long enough to count 100 cycles, which is 1/100 second.· Count the number of cycles the microphone hears in ten milliseconds with the hand or foot stationary, then count EACH ten milliseconds during the kick or punch, keeping only the highest count.· The highest of these figures, divided by the stationary count, will give you the frequency change·ratio, which will be the inverse of the ratio between the kick/punch speed and the speed of sound (about 1100 fps in air at sea level).
Another way would be to use a camera with a·rapid-firing strobe light and a time exposure, but you wouldn't get the result immediately.
Of all the methods, use of the accelerometer seems to me inherently the least accurate, and the most difficult computationally.
I'll bet if there were a roomful of us brainstorming, we'd come up with many additional methods, each better than the accelerometer method.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i
Assume a 1% change in frequency and 10KHz to start with, and you'll still have a 100Hz change, or ten counts in 100 milliseconds, giving about 10% accuracy.· Perhaps 20KHz would be a better choice.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i
Originally my idea was just to build a sensor I can place on the back of a punching bag that would tell me how hard it had been hit (sudden shift in velocity) so the accelerometer was my first thought for that.
After that I figured "why not make it attached to the hitter instead. that way you can also measure the speed at which the strike was occurring"
So that was what I was after to build first. I managed to get a VERY rough version of this working that seemed to work pretty well.
This project is underway, but I was just opening up my options on how to expand for later. I'm all for a good brainstorming session. Your idea to use the sound sounds pretty feasible. 5 stars for lateral thinking!!! Thanks heaps!
Any other ideas are also appreciated!
Since i have never used one these, i can't say if it would work or not, like how fast they acquire a reading.
You could try to contact them for some technical advice for your app.
www.eagletreesystems.com/Standalone/standalone.htm
For other people having a read, check out www.moven.com. This site is selling something vaguely similar to what I'm trying to build. They reckon they use paired accelerometers to do all this stuff... Reckon it's possible with a BS2?