Arduino Forum

Topics => Science and Measurement => Topic started by: Ben1234 on Sep 18, 2012, 05:07 pm

Title: Determining accleration due to gravity
Post by: Ben1234 on Sep 18, 2012, 05:07 pm
I have an accelerometer connected to an Arduino Uno that reads out 1 G when laying flat on a table. When it is in free fall that changes to 0g. Does anyone know the necessary math to convert this to acceleration so that when it is in free fall acceleration is 9.8m/s^s and when it is at rest acceleration is 0m/s^2? Thanks.
Title: Re: Determining accleration due to gravity
Post by: CrossRoads on Sep 18, 2012, 06:29 pm
Provide more info please:
accelerometer used, how connected, code.

Otherwise  there is nothing to go on besides speculating about something like this:
http://arduino.cc/en/Tutorial/ADXL3xx
Title: Re: Determining accleration due to gravity
Post by: Ben1234 on Sep 18, 2012, 07:21 pm
This is the accelerometer https://www.sparkfun.com/products/9652 with the same wiring and code as shown in this tutorial http://www.geeetech.com/wiki/index.php/MMA7361_Triple_Axis_Accelerometer_Breakout . It outputs the g forces along each axis and I have taken the square root of(x^2+y^2+z^2) to determine the magnitude. Hope this helps and thanks for your help.
Title: Re: Determining accleration due to gravity
Post by: Ben1234 on Sep 18, 2012, 08:20 pm
Never mind I figured it out. Sorry for the inconvenience.
Title: Re: Determining accleration due to gravity
Post by: CrossRoads on Sep 19, 2012, 03:24 am
What was the solution?
Title: Re: Determining accleration due to gravity
Post by: Ben1234 on Sep 20, 2012, 05:08 pm
Since gravity is always constant I have to subtract that out of the values. So at rest when it said g=1 then subtract 1 *9.8m/s^2 = 0 and when it is free falling with a reading  of 0 then subtract 1 * 9.8m/s^2 = -9.8m/s^2
Title: Re: Determining accleration due to gravity
Post by: Far-seeker on Sep 21, 2012, 11:38 pm

Since gravity is always constant I have to subtract that out of the values. So at rest when it said g=1 then subtract 1 *9.8m/s^2 = 0 and when it is free falling with a reading  of 0 then subtract 1 * 9.8m/s^2 = -9.8m/s^2


Technically the force of Earth's gravity (http://en.wikipedia.org/wiki/Gravity_of_Earth#Variation_in_gravity_and_apparent_gravity) is not constant from place to place and it can even slowly vary a bit over time.  However, for your purposes this is should be good enough. ;)
Title: Re: Determining accleration due to gravity
Post by: Delta_G on Sep 26, 2012, 05:43 am


Since gravity is always constant I have to subtract that out of the values. So at rest when it said g=1 then subtract 1 *9.8m/s^2 = 0 and when it is free falling with a reading  of 0 then subtract 1 * 9.8m/s^2 = -9.8m/s^2


Technically the force of Earth's gravity (http://en.wikipedia.org/wiki/Gravity_of_Earth#Variation_in_gravity_and_apparent_gravity) is not constant from place to place and it can even slowly vary a bit over time.  However, for your purposes this is should be good enough. ;)


Technically technically, the force of gravity depends on mass and is called weight.  The acceleration due to gravity is the one that is relatively constant.  Although you are right it does vary slightly from place to place and time to time, but I doubt the OP is going to measure that with his accelerometer. 
Title: Re: Determining accleration due to gravity
Post by: packocrayons on Oct 12, 2012, 03:27 am
If the accelerometer is accurate enough, wouldn't it be able to detect these changes and output an acceleration? Then you could use that as a calibration to find the percentage of gravity compared to standard (9.8N/kg) at that location.
Title: Re: Determining accleration due to gravity
Post by: Far-seeker on Oct 12, 2012, 06:33 pm

If the accelerometer is accurate enough, wouldn't it be able to detect these changes and output an acceleration? Then you could use that as a calibration to find the percentage of gravity compared to standard (9.8N/kg) at that location.


Theoretically yes. However, I doubt the accelerometers that most of us can afford to use in our projects would be capable that level of both accuracy and precision.  I was really just engaging in some harmless snark.
Title: Re: Determining accleration due to gravity
Post by: MarkT on Oct 15, 2012, 01:04 am
Of course the real mind-bending thing is to realize that the accelerometer is correct, an object in free fall isn't accelerating ;)
Title: Re: Determining accleration due to gravity
Post by: packocrayons on Oct 15, 2012, 01:38 am
Depends how long it's been in freefall.
Title: Re: Determining accleration due to gravity
Post by: AWOL on Oct 15, 2012, 11:14 pm
Quote
an object in free fall isn't accelerating

So why is its velocity increasing?
That bloke that jumped from the balloon, he was free falling, right?
And after 40 seconds, he was doing 800mph or so.
Title: Re: Determining accleration due to gravity
Post by: michinyon on Oct 21, 2012, 05:18 pm
An object in "free fall",  certainly IS accelerating.   For objects that jump out of aircraft or fall off the edge of tables,  anyway.
If the object is equiped with an accelerometer,   it detects no acceleration because the acceleration it is actually undergoing offsets the deflection of the sensor element which normally occurs because of gravity.   That is why an accelerometer reads 0 when it is in free fall.     It doesn't mean that it is not accelerating, though.
Title: Re: Determining accleration due to gravity
Post by: JimboZA on Oct 21, 2012, 05:41 pm
Quote
(9.8N/kg)


Interesting units for acceleration there....

I agree it's correct, since F=ma or a=F/m, but I've never seen acceleration expressed in any units other than displacement / time2. It's a useful way of looking at it, since what we're interested in as engineers calculating stress is the force exerted on a mass of certain size.

Hmmmm
Title: Re: Determining accleration due to gravity
Post by: packocrayons on Oct 22, 2012, 02:14 am
They are the same unit if you break N down and look at it. N/kg is considered gravitational force while m/s2 is an acceleration, but in reality they are the same thing and both work in any formula.
Title: Re: Determining accleration due to gravity
Post by: JimboZA on Oct 23, 2012, 11:58 am
Yes, I understand the maths.... just saying I'd never seen acceleration expressed in those units before.
Title: Re: Determining accleration due to gravity
Post by: AWOL on Oct 23, 2012, 12:52 pm
Quote
just saying I'd never seen acceleration expressed in those units before.

You have, you just haven't done the algebra before

N/kg = (kg m s-2) / kg = (kg m s-2) / kg = m s-2
Title: Re: Determining accleration due to gravity
Post by: JimboZA on Oct 24, 2012, 09:54 am
Quote
You have, you just haven't done the algebra before


No, I haven't seen acceleration expressed in those units before. By that I mean, nobody has ever said to me, nor have I ever read, that acceleration comes in N/kg....

I do understand the units' equivalency, and indeed have understood this stuff since  about 1971.... I doubt if I'd have graduated as a civil engineer without having understood the relationship between force, mass and acceleration...  8)
Title: Re: Determining accleration due to gravity
Post by: liuzengqiang on Oct 28, 2012, 07:32 pm

They are the same unit if you break N down and look at it. N/kg is considered gravitational force while m/s2 is an acceleration, but in reality they are the same thing and both work in any formula.


A kilo of mass experiences 9.8 Newton of weight. That was part of my middle school physics class. In high school when I learned F=ma, then a was given in m/s/s.

To correct age-old problem of engineers don't know physics, I have to clarify that accelerometer is a wrong term. The measured quantity is actually force. Imagine Spring scale and weight on scale. You will read force when the scale is at rest. You will NOT read force when you drop the scale and weight together. The real term should be something like a micromachined capacitive force sensor that outputs acceleration units.
Title: Re: Determining accleration due to gravity
Post by: wwbrown on Oct 29, 2012, 03:30 pm
There are far easier ways to measure the acceleration due to gravity using Arduino.  You can buy a photointerrupter like http://www.digikey.com/scripts/DkSearch/dksus.dll?WT.z_header=search_go&lang=en&keywords=425-1935-5-ND&x=0&y=0&cur=USD (http://www.digikey.com/scripts/DkSearch/dksus.dll?WT.z_header=search_go&lang=en&keywords=425-1935-5-ND&x=0&y=0&cur=USD), build the simple circuit shown in the data sheet.  Then get a piece of plexiglas maybe 2" x 10" and use electrical tape to make uniformly spaced opaque strips that are perpendicular to the long axis.  Take the signal from the photointerrupter and input that into one of the interrupt pins for timing purposes.

Dropping the plexiglass strip through photointerrupter, lets call it a photogate, from the times displayed by the Arduino on the computer screen or LCD you can determine the acceleration due to gravity.

You may find that the plexiglass hits the photogate and this will increase the uncertainty of the measurement and you can either accept that or break the photogate and mount the two pieces on another frame to make a larger fixture so the plexiglass will hit it less often.

I have left out some steps as there is a derivation needed utilizing some kinematics to be worked out but it is not too bad. 
Title: Re: Determining accleration due to gravity
Post by: AWOL on Oct 29, 2012, 03:35 pm
Quote
There are far easier ways to measure the acceleration due to gravity using Arduino

How is that "far easier" than using an accelerometer?
Title: Re: Determining accleration due to gravity
Post by: liuzengqiang on Oct 29, 2012, 03:51 pm

Quote
There are far easier ways to measure the acceleration due to gravity using Arduino

How is that "far easier" than using an accelerometer?

I share the same doubt with AWOL. If you really want an easy method, define what equipment you have first. The easiest one that requires no electronics would be using your own pulse as a time reference as Galileo probably did in his time, or use your watch/clock. Then hang a pendulum (any heavy and compact object will do, such as a key or a stack of coins taped together) with a known string length L. Watch it oscillate say 100 periods and solve the simple T=2*PI*sqrt(L/g) equation to get g. The period should be fairly close to 2 seconds for 1m string. For those in the US, I know for sure you will have 5,6,7 foot references (relatively accurate) right outside most bank branches. You don't even have to own a tape measure.
Title: Re: Determining accleration due to gravity
Post by: AWOL on Oct 29, 2012, 03:54 pm
Quote
with a known string length L

A pendulum should be rigid.
Title: Re: Determining accleration due to gravity
Post by: MarkT on Oct 29, 2012, 04:20 pm

Quote
with a known string length L

A pendulum should be rigid.

a) Why?  A swinging chain keeps time.
b) A string under tension _is_ rigid.
Title: Re: Determining accleration due to gravity
Post by: AWOL on Oct 29, 2012, 04:44 pm
Quote
a) Why?  A swinging chain keeps time.

That would be a compound pendulum.
Title: Re: Determining accleration due to gravity
Post by: liuzengqiang on Oct 29, 2012, 07:10 pm

Quote
with a known string length L

A pendulum should be rigid.


It just needs to be light compared with the bob and not springy. And the angle of oscillation be quite a bit less than 50 degrees with vertical.
Title: Re: Determining accleration due to gravity
Post by: wwbrown on Oct 30, 2012, 04:49 am
Why is the photogate method I described a far easier method of measuring gravity than an accelerometer?

Well there was quite a bit of discussion about using cheap off the shelf accelerometers and I never did see anyone having a solution that actually did measure the acceleration due to gravity, without first assuming what it was to begin with.  By using the photogates you can easily derive the solution for the acceleration due to gravity based on first principles, and not by assuming what the result is you are looking for.  The photogate method is used in first-year physics labs everyday, I used to have my first year students derive the solution for homework, tests, or labs.
Title: Re: Determining accleration due to gravity
Post by: liuzengqiang on Oct 30, 2012, 05:45 am

Why is the photogate method I described a far easier method of measuring gravity than an accelerometer?

Well there was quite a bit of discussion about using cheap off the shelf accelerometers and I never did see anyone having a solution that actually did measure the acceleration due to gravity, without first assuming what it was to begin with.  By using the photogates you can easily derive the solution for the acceleration due to gravity based on first principles, and not by assuming what the result is you are looking for.  The photogate method is used in first-year physics labs everyday, I used to have my first year students derive the solution for homework, tests, or labs.


First principle is not always easy. I consider pendulum easy. You need a cheap string, some weight and a cheap watch. There is no need to set things up and there is no concern for electronics not working. photogates are fine but not cheap or easy if you compare with yarn and some deadweight.
Title: Re: Determining accleration due to gravity
Post by: JimboZA on Oct 31, 2012, 06:12 am
This reminds me of how we measured it back in high school...

It involved a battery operated bell and a huge long strip (as long as the drop from the window to the ground) of carbon paper with a weight on the end. Then dropped the weight while the bell was ringing, with the strip between the bell and the ringer lever thingy. The impact of the ringer made marks on the carbon paper, and of course the marks got further apart as the weight accelerated.

Measured the time it took to drop from the science lab window to the ground. Counted the total number of marks. That gave the number of marks per second or seconds per mark.

Measured the (varying) distance between marks. That, with the now known time between marks, gave the (varying) velocity at any instant.

And hence the acceleration....

But using a pendulum is by far the easiest way to do it... (As long as the bob is very heavy compared to the string, the whole mass may be deemed to be at the bob's CoG.) Beauty of the pendulum method is that since the period T is constant regardless of how wide the swing is, it can as suggested above be measured over 100s of swings and that reduces the impact of the reaction time when the stop watch is started and stopped.

Title: Re: Determining accleration due to gravity
Post by: michinyon on Oct 31, 2012, 08:03 am
"I do understand the units' equivalency, and indeed have understood this stuff since  about 1971.... I doubt if I'd have graduated as a civil engineer without having understood the relationship between force, mass and acceleration.."

You might have,  if you were an American.   The distinction between force, mass and weight becomes rather obfuscated in their system.
Title: Re: Determining accleration due to gravity
Post by: michinyon on Oct 31, 2012, 08:08 am
OK, so suppose I am not interested in measuring small fluctuations in the force of gravity,  because I am not looking for buried iron ore deposits or big meteors.

Suppose I want to measure the direction of the graviational force,   and I want to do this from a moving platform like a car or an aircraft.

If I get a 3D MEMS accelerometer,  that will do a good job if the vehicle is stationary or moving at a constant velocity,   but otherwise,  it won't.

Is there another way to measure the direction of the gravitational force which will work in an erratically moving vehicle ?
Title: Re: Determining accleration due to gravity
Post by: liuzengqiang on Oct 31, 2012, 01:43 pm

OK, so suppose I am not interested in measuring small fluctuations in the force of gravity,  because I am not looking for buried iron ore deposits or big meteors.

Suppose I want to measure the direction of the graviational force,   and I want to do this from a moving platform like a car or an aircraft.

If I get a 3D MEMS accelerometer,  that will do a good job if the vehicle is stationary or moving at a constant velocity,   but otherwise,  it won't.

Is there another way to measure the direction of the gravitational force which will work in an erratically moving vehicle ?

Thanks to Einstein's general relativity, you can't tell between gravity and acceleration. You can't find gravity with accelerometer if you yourself is accelerating. If you have a gyroscope, you can spin it in the direction of gravity and see how your down direction compares with it, I suppose.
Title: Re: Determining accleration due to gravity
Post by: wwbrown on Oct 31, 2012, 04:30 pm
How about a magnetometer if you only want to measure the direction of the acceleration due to gravity.  I am pretty sure that a magnetometer will not be affected by linear or rotational acceleration.
Title: Re: Determining accleration due to gravity
Post by: liuzengqiang on Oct 31, 2012, 04:40 pm

How about a magnetometer if you only want to measure the direction of the acceleration due to gravity.  I am pretty sure that a magnetometer will not be affected by linear or rotational acceleration.


Is that a magnetic sensor? It can only measure your angle to local magnetic field, not your angle to local gravity. Facing north while tilting up 30 degrees and facing south while tilting down 30 degrees will read the same on a magnetic sensor.
Title: Re: Determining accleration due to gravity
Post by: liuzengqiang on Oct 31, 2012, 04:46 pm

This reminds me of how we measured it back in high school...

It involved a battery operated bell and a huge long strip (as long as the drop from the window to the ground) of carbon paper with a weight on the end. Then dropped the weight while the bell was ringing, with the strip between the bell and the ringer lever thingy. The impact of the ringer made marks on the carbon paper, and of course the marks got further apart as the weight accelerated.

Measured the time it took to drop from the science lab window to the ground. Counted the total number of marks. That gave the number of marks per second or seconds per mark.

Measured the (varying) distance between marks. That, with the now known time between marks, gave the (varying) velocity at any instant.

And hence the acceleration....

But using a pendulum is by far the easiest way to do it... (As long as the bob is very heavy compared to the string, the whole mass may be deemed to be at the bob's CoG.) Beauty of the pendulum method is that since the period T is constant regardless of how wide the swing is, it can as suggested above be measured over 100s of swings and that reduces the impact of the reaction time when the stop watch is started and stopped.


Oh the old memories. They were probably called impact timer?! Later they were replaced with spark timers that generated sparks with car ignition coils at 60Hz so wax tapes will have regular burn marks on them. A bit less friction. Then photo gates became more popular so did sonic rangers and then video cams. You can measure gravity with any method that involves a formula where g is a part of. Pendulum is definitely easy and accurate (you mentioned about response time!). Not doing it easy way can have instructional values such as seeing the dots separating further and further away or video frames doing the same thing. There is another way, just to toss in the discussion, is to use sound. You record sound clip of scissors cutting string and ball hitting floor. I've been doing this for a while. Results are pretty good with 0.x m/s/s as error bar. Some kids these days can't even cut with scissors. That's a whole other discussion topic.
Title: Re: Determining accleration due to gravity
Post by: wwbrown on Oct 31, 2012, 05:54 pm
Yes I made a huge error I thought for some strange reason the poster wanted to determine the direction of the magnetic field and not the acceleration due to gravity.

I believe with a full-up IMU you could get the direction of the acc. due to g.

Title: Re: Determining accleration due to gravity
Post by: michinyon on Nov 01, 2012, 07:15 am
Well the idea is, if you know the accelerations and gyro readings in 3D,  then you can calculate the change in orientation.  But you get variations and drift in the gyro readings which make this not actually work in practise.   

You need to keep correcting the gyro-derived orientation using some other means,   and two of the available means are the direction of "down"  and the direction of the earth's magnetic field.

The problem is,  a lot of the feasible schemes for doing this ( for example,  read Magdwick's papers ) kind of assume that the acceleration of the body is small and that therefore the accelerometer reading indicates the direction of gravity ( either "up" or "down" ).   I've developed another scheme which also works and has the advantage ( for me ) that I can understand it.

It would be useful to have some means of identifying the direction of gravity independently from acceleration but I guess if Einstein says you can't,  we it is probably right.    Now a very small higgs boson detector might be able to detect the direction where they are coming from, independent of the actual motion of the device.
Title: Re: Determining accleration due to gravity
Post by: liuzengqiang on Nov 01, 2012, 05:36 pm

Well the idea is, if you know the accelerations and gyro readings in 3D,  then you can calculate the change in orientation.  But you get variations and drift in the gyro readings which make this not actually work in practise.   

You need to keep correcting the gyro-derived orientation using some other means,   and two of the available means are the direction of "down"  and the direction of the earth's magnetic field.

The problem is,  a lot of the feasible schemes for doing this ( for example,  read Magdwick's papers ) kind of assume that the acceleration of the body is small and that therefore the accelerometer reading indicates the direction of gravity ( either "up" or "down" ).   I've developed another scheme which also works and has the advantage ( for me ) that I can understand it.

It would be useful to have some means of identifying the direction of gravity independently from acceleration but I guess if Einstein says you can't,  we it is probably right.    Now a very small higgs boson detector might be able to detect the direction where they are coming from, independent of the actual motion of the device.



You can still device an external measurement, say a person standing on the ground telling the device its orientation wrt gravity. You just can't have the device tell itself so. If you have a flat floor with regular dots, you can use that and a bottom facing camera to tell orientation.