Shop OBEX P1 Docs P2 Docs Learn Events
Tri Axis G Force to Radius and Degree Conversion Question — Parallax Forums

Tri Axis G Force to Radius and Degree Conversion Question

jan dekkersjan dekkers Posts: 11
edited 2009-07-14 01:11 in BASIC Stamp
the Tri Axis returns X· Y and Z GForce Axis.· Now, I dont know what a GForce is to begin with.

How do I convert X Y and Z into Degrees in for instance C or Delphi·?

Thanks

Jan

·

Comments

  • achilles03achilles03 Posts: 247
    edited 2009-07-07 20:00
    You need to describe your application in more detail. You did not provide enough information for anyone to give you an answer. Is it attached to something that's relatively motionless? Can it change speeds quickly? etc...

    If it's a true 3-axis accelerometer, it's telling you acceleration, not degrees/orientation. The only way you can get orientation from a 3-axis accelerometer is if it's operating in a well-understood environment subject to low accelerations (i.e. it's attached to the hand of a clock).

    Dave
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2009-07-07 20:29
    jan dekkers,

    Look into the ArcTan (ATN) function for converting the force vectors from Cartesian to Polar values.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • jan dekkersjan dekkers Posts: 11
    edited 2009-07-07 21:01
    Its the "Hitachi H48C Tri-Axis Accelerometer Module"

    My goal is to visual display the X and Y Axis of an moving object such as a car, boat, plane etc.

    Can this be achieved using the "Hitachi H48C Tri-Axis Accelerometer Module" ? If not what Module should I use ?

    What value do I get back of ArcTan(X) ArcTan(Y) ArcTan(Z). Are that degrees of the angle ?
  • dev/nulldev/null Posts: 381
    edited 2009-07-07 21:29
    G-Force means change in angular momentum, or a measurement of acceleration.
    The H48C can measure up to 3G, which is 3 times the earth's gravitational field.

    The ATAN function gives you an angle in degrees if you have an X and Y coordinate. The angle you get is relative to the X axis.
    The syntax is in the Stamp manual: degrees = X ATAN Y.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    /dev/null
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2009-07-07 21:41
    jan dekkers,

    An accelerometer measures the amount of acceleration you have on a particular axis. Just standing still you have 1g of acceleration on the Z axis.

    Detecting the X,Y, and Z axis of any moving object is not an easy task. You need other sensors such as a Gyro in adition to an Accelerometer that work together that can provide X,Y, and Z information.

    As far as the ArcTan you can't just put in ArcTan(X) ArcTan(Y) or ArcTan(Z), because there is no angle relationship in a single vector. What the ATN or ArcTan function wants is a slope in terms of rise over run or typically ...

    ArcTan(Y/Z) gives the X axis of rotation
    ArcTan(X/Z) gives the Y axis of rotation
    ArcTan(Y/X) gives the Z axis of rotation

    To determine distance you use Pythagorean’s theorem on the same X,Y, and Z used in the ArcTan function that correspond to the axis



    Check out some of the DEMO's associated to the Accelerometer, you should find plenty of examples that express X,Y,Z, ro, and theta.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • jan dekkersjan dekkers Posts: 11
    edited 2009-07-07 22:00
    Thank, would it be better if I use the "Memsic 2125 Dual-axis Accelerometer" "X and Y Axis" or would I have the same problem on moving objects ?
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2009-07-07 22:47
    jan dekkers

    Yes, you would have the same problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • jan dekkersjan dekkers Posts: 11
    edited 2009-07-07 23:43
    Thanks, Can I use this gyro with the basic stamp ? http://www.sure-electronics.net/download/DC-SS010_Ver1.0_EN.pdf or does paralax has its own Gyro ?

    Jan
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2009-07-08 04:44
    jan dekkers,

    If you have a Basic Stamp 2P,2PE, or 2PX you can use the I2CIN and I2OUT to communicate to the sure-electronics Gyro, but keep in mind to do what you want o do requires a Gyro with 3 Axis and also an accelerometer with 3 Axis. The Gyro in the link that you provided only has 1 Axis.

    Once you have a 3-Axis Gyro and a 3-Axis accelerometer you combine the data with what is known as a kalman filter (an efficient recursive mathematical filter that estimates the state of a linear dynamic system from a series of noisy measurements). Without using external hardware, the Stamp does not have the computing power to implement a kalman filter. Once the Gyro, Accelerometer, and the kalman filter are in place you will always be able to determine where "down" is no matter what orientation or amount of motion you are in and from there you can determine the position of the X, Y, and Z axis

    I don't mean to discourage you, but once you put things into motion it starts to get very complicated determining your position from point A to point B. If you are stationary, it would be very simple; a 3-Axis accelerometer would work just fine.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 7/8/2009 4:50:14 AM GMT
  • jan dekkersjan dekkers Posts: 11
    edited 2009-07-08 05:30
    Thanks Beau
  • achilles03achilles03 Posts: 247
    edited 2009-07-08 15:32
    jan dekkers said...
    Its the "Hitachi H48C Tri-Axis Accelerometer Module"

    My goal is to visual display the X and Y Axis of an moving object such as a car, boat, plane etc.

    Can this be achieved using the "Hitachi H48C Tri-Axis Accelerometer Module" ? If not what Module should I use ?

    What value do I get back of ArcTan(X) ArcTan(Y) ArcTan(Z). Are that degrees of the angle ?

    If you want to know which way it is pointing and you're doing this with a car or boat (or something else that doesn't flip or roll over), then a compass would be your easiest option.

    Dave
  • achilles03achilles03 Posts: 247
    edited 2009-07-08 15:40
    Beau Schwabe (Parallax) said...

    Once you have a 3-Axis Gyro and a 3-Axis accelerometer you combine the data with what is known as a kalman filter (an efficient recursive mathematical filter that estimates the state of a linear dynamic system from a series of noisy measurements). Without using external hardware, the Stamp does not have the computing power to implement a kalman filter. Once the Gyro, Accelerometer, and the kalman filter are in place you will always be able to determine where "down" is no matter what orientation or amount of motion you are in and from there you can determine the position of the X, Y, and Z axis

    You might be able to implement a Kalman filter with a BS2 if it wasn't moving too fast and you hard-coded the gain values ahead of time.

    But the bigger problem is that the gyro you refer to isn't really a gyro, but a rate sensor. And you need to integrate that to get angular position... and with the accuracy and resolution of a digital rate sensor coupled with the sample rate and round-off errors... even with a Kalman filter, it's estimate of "down" would become incorrect very quickly.
  • achilles03achilles03 Posts: 247
    edited 2009-07-08 16:09
    dev/null said...
    G-Force means change in angular momentum, or a measurement of acceleration.
    The H48C can measure up to 3G, which is 3 times the earth's gravitational field.

    Sorry, but I need to correct you on this. Acceleration and angular momentum are totally different.

    Lets say I accelerate a 10kg bowling ball from 1m/s to 2m/s over 1000 seconds... its acceleration was .001 m/s^2, but it's momentum changed 10 kg-m/s. If I accelerate the same bowling ball from 1m/s to 2m/s over .001 seconds, its acceleration is 1000m/s^2, but it's momentum still only changed 10 kg-m/s.

    Also, linear acceleration is different than angular acceleration. Linear acceleration is how quickly an object's (linear) velocity is changing, and angular acceleration is how quickly an object's rotation is changing. Momentum is mass x velocity. A g-force is the acceleration you feel on the surface of the earth, which is 9.8m/s^2, and is not a change in linear OR angular momentum.

    Hope that helps,
    Dave
  • dev/nulldev/null Posts: 381
    edited 2009-07-08 16:42
    I agree, let me make myself clear:
    Angular momentum is a measurement of an obect's inclination to go in a straight line, if it is being acted upon by an external force.
    If you swing your car to the left going at a fair speed, your car will gain angular momentum (and kinetic energy, stolen from friction and existing potential energy) and this will be measurable by the accelerometer. If you accelerate in a straight line, angular momentum does not change, but kinetic energy will, and so both situations relate to the same force. The force is called angular momentum, or potential and kinetic energy.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    /dev/null
  • dev/nulldev/null Posts: 381
    edited 2009-07-08 16:52
    And that's why I said momentum OR acceleration. burger.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    /dev/null
  • achilles03achilles03 Posts: 247
    edited 2009-07-08 21:01
    I think you have a misunderstanding. Momentum is mass-dependent and reference-dependent. Acceleration is not.
    dev/null said...
    I agree, let me make myself clear:
    Angular momentum is a measurement of an obect's inclination to go in a straight line.

    That's linear momentum. Angular momentum is an object's tendency to keep rotating about a reference point.
    dev/null said...
    If you swing your car to the left going at a fair speed, your car will gain angular momentum (and kinetic energy, stolen from friction and existing potential energy) and this will be measurable by the accelerometer.

    1. The accelerometer isn't measuring the angular momentum. It's measuring the change in velocity with respect to time (i.e. acceleration). It's not measuring your car's tendency to keep turning.
    2. Assuming you're in neutral and on flat ground, you can't gain kinetic energy when you make a turn. Friction never adds kinetic energy to anything (other than heat), and there's no potential energy to "steal" if you're on flat ground.
    dev/null said...
    If you accelerate in a straight line, angular momentum does not change, but kinetic energy will, and so both situations relate to the same force. The force is called angular momentum, or potential and kinetic energy.

    If you accelerate in a straight line, your linear momentum increases, but your angular momentum does not. You also experience acceleration. In this situation, the accelerometer would measure the acceleration, but as you pointed out, there's no change in angular momentum. So you're aren't measuring acceleration OR angular momentum, just acceleration.

    Hope that helps,
    Dave
  • dev/nulldev/null Posts: 381
    edited 2009-07-08 22:28
    I think this discussion is a little off-subject, I don't want to fill the thread with this. But I can't help myself: Of course you can have potential energy on flat ground, you gain it as soon as you start moving. Where does all the energy from the motor go? It goes almost directly to potential energy, some off it wasted to friction, and some to the gravitational pull of the earth. If you stop or swing the car, this energy is converted to kinetic energy.

    Rotation is a special case of angular momentum. In a general sense, it is, as you say, related to mass, an object's reluctance to curve its path. Everything wants to go straight. If you bend the path of ANYTHING, a car, a planet, or an electron, it gains angular momentum. Look it up.

    BTW, I never heard of linear momentum before.

    Anything in presence of a gravitational field experiences acceleration. You can exchange acceleration and gravity as you pleace, according to the equivalence principle.

    My point is this: If you swing your car, you will experience outward acceleration, and your car gains angular momentum and kinetic energy. How is this hard to understand?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    /dev/null
  • achilles03achilles03 Posts: 247
    edited 2009-07-09 14:27
    dev/null said...
    I think this discussion is a little off-subject, I don't want to fill the thread with this. But I can't help myself: Of course you can have potential energy on flat ground, you gain it as soon as you start moving.

    What you gain when you start moving is kinetic energy. Kinetic energy is energy of motion, and it's equation is 1/2*m*v^2

    en.wikipedia.org/wiki/Kinetic_energy#Kinetic_energy_of_rigid_bodies

    Potential energy is stored energy, not energy of motion, and can take many forms: gravitational potential energy (m*g*h), elastic potential energy (1/2*k*x^2), chemical potential energy, etc... the point is, on flat ground, h never changes, so you don't "gain" or "loose" any gravitational potential energy. And unless you have your foot on the pedal, you aren't converting elastic or chemical potential energy either.

    en.wikipedia.org/wiki/Potential_energy
    dev/null said...
    Where does all the energy from the motor go? It goes almost directly to potential energy, some off it wasted to friction, and some to the gravitational pull of the earth.

    I think you have it backward. You are converting the chemical potential energy stored in gas into kinetic energy of motion to get the car going. And none of it goes to the "gravitational pull" of the earth since your car doesn't change height (remember we're on flat ground).
    dev/null said...
    If you stop or swing the car, this energy is converted to kinetic energy.

    If you stop, you are converting kinetic energy (energy of motion) to heat (your brake pads get really hot when you slow down). And if you turn the car, so long as you're coasting (not giving the engine gas), you don't gain any kinetic energy since v in the 1/2*m*v^2 equation doesn't change.
    dev/null said...
    Rotation is a special case of angular momentum.In a general sense, it is, as you say, related to mass, an object's reluctance to curve its path. Everything wants to go straight. If you bend the path of ANYTHING, a car, a planet, or an electron, it gains angular momentum. Look it up.

    Trust me, I have, and you're getting linear momentum and angular momentum confused.
    dev/null said...
    BTW, I never heard of linear momentum before.

    Seriously, if you don't understand what I'm talking about when I refer to linear momentum, then please read this:

    en.wikipedia.org/wiki/Momentum

    Here's a direct quote: "It is sometimes referred to as linear momentum to distinguish it from the related subject of angular momentum."
    dev/null said...
    My point is this: If you swing your car, you will experience outward acceleration, and your car gains angular momentum and kinetic energy. How is this hard to understand?

    Yes, yes, and no. Yes, it experiences acceleration. Yes, it gains angular momentum. But it doesn't gain kinetic energy unless your foot is on the gas (remember that v doesn't change).

    But back to your original point, a G-force is not a change in angular momentum, but it is a measurement of acceleration. Trust me on this.


    Hope that helps,
    Dave
  • dev/nulldev/null Posts: 381
    edited 2009-07-10 21:49
    I'm glad you agree on angular momentum. With regards to potential energy, you are 99% right. Most of the motor energy goes to kinetic energy, minus the tidal gravitational pull of the earth (which is negligable in this situation). Im sorry I got this mixed up.

    I didn't say G-force was a change in angular momentum, but that an accelerometer will measure angular momentum. Angular momentum is a measure of radial acceleration.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
  • achilles03achilles03 Posts: 247
    edited 2009-07-13 16:04
    dev/null said...
    I didn't say G-force was a change in angular momentum
    Actually, you did. You're exact quote was:
    dev/null said...
    G-Force means change in angular momentum...
    This is what I was trying to correct you on!
    dev/null said...
    Angular momentum is a measure of radial acceleration.
    Again, no. Even though you're modifying your original statement, which was that angular momentum was "...a measurement of acceleration" to "a measure of radial acceleration", this is still wrong.

    Case in point: Let's say you have a ball on a string that you're spinning around. If we hold its velocity constant and increase the radius, the angular momentum increases, but the radial acceleration decreases. Alternatively, if you hold the string length constant and double its velocity, the radial acceleration goes up four-fold, but the angular momentum only doubles. How can this be if one is "a measure" of the other?

    (Answer: one can't be "a measure" of the other).

    For reference, the formula for angular momentum (L) is L = radius x mass*velocity. The formula for radial acceleration (Ar) is Ar = velocity2/radius.

    Hope this helps,
    Dave

    Post Edited (achilles03) : 7/13/2009 4:10:03 PM GMT
  • dev/nulldev/null Posts: 381
    edited 2009-07-13 21:13
    Angular momentum is *proportional* to acceleration. Jeez I have to consentrate with you. Keep mass constant to see this.

    - If you change radius or velocity, you change angular momentum AND acceleration in curved-path system.
    - The measure of "whatever-you-wanna-call-it" does not depend on mass.
    - When you measure a change in angular momentum in a curved-path system, you will measure a change in G-force, and in acceleration (keep mass constant).
    - Point-in-question: If you change radius or velocity, the accelerometer will measure it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
  • achilles03achilles03 Posts: 247
    edited 2009-07-14 00:42
    dev/null said...
    Angular momentum is *proportional* to acceleration. Jeez I have to consentrate with you. Keep mass constant to see this.
    That's incorrect. Seriously. Look at the formulas I outlined for you. Radius x mass*velocity is NOT proportional to velocity2/radius. If I double the radius and halve the velocity, angular momentum is unchanged, but the radial acceleration has decreased by a factor of 8! This is NOT proportional!
    dev/null said...
    - When you measure a change in angular momentum in a curved-path system, you will measure a change in G-force, and in acceleration (keep mass constant).
    Incorrect. Angular momentum doesn't have to change for there to be radial acceleration. And if you increase angular momentum, sometimes the radial acceleration will increase, sometimes it will decrease, and sometimes it will stay the same.
    dev/null said...
    - Point-in-question: If you change radius or velocity, the accelerometer will measure it.
    Incorrect. Let me reiterate this point again: if I double the radius and halve the velocity, angular momentum is unchanged, but the radial acceleration has decreased by a factor of 8! I could also double the velocity and increase the radius by a factor of 4, and the object is still experiencing the same radial acceleration, but the angular momentum has INCREASED by a factor of 8!

    Please, take out a pencil and try these equations for yourself. I know you might think it "seems right" in your gut, but the math says otherwise. I have a M.S. in mechanical engineering, and I've worked with these concepts on a daily basis for many years. Trust me.


    Dave
  • dev/nulldev/null Posts: 381
    edited 2009-07-14 01:11
    Proportional here means there is a function that describes one equation in terms of the other. Sorry my english is not the best. Either one of the your equations doesn't give any new information about the other except for mass, which you can keep constant. And I said radius ORvelocity, your examples are trickery.

    I know that the accelerometer will measure change in radius or velocity, I have tried it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
Sign In or Register to comment.