SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By jnz
#111502
Does anybody know how many magnetometer axes I need to be able to calculate my pitch angle, I do not need to know direction, just angle of elevation ??
By ryowens84
#111568
I don't think you can find the pitch angle with a magnetometer, I'm pretty sure you need a 3-axis accelerometer to do that.
By esklar81
#111658
Under suitably constrained conditions (constant magnetic field direction is the obvious one) you can measure pitch with a 3-axis magnetometer by determining the change (in the pitch direction of the vehicle) of the relative direction of the magnetic field. If magnetic field is constant in both direction and magnitude, the vehicle is not yawing or not rolling, you could do the measurement with a 2-axis magnetometer. If the magnetic field is constant in both direction and magnitude and the vehicle is not yawing and not rolling, you could do it with a 1-axis magnetometer.

One can also measure the height of a building by dropping a mechanical stopwatch of suitable durability and computing the distance travelled from the time between when one starts and releases the watch at the top of the building and the time the watch stops due to impact with the ground. :wink:

Have Fun,
Eric
By tecoist
#111661
Unfortunately, as Eric hints, it's kind of challenging to find a situation where yaw and roll are constrained but pitch is not. In the spirit of dropping clocks off of buildings, I should point out that on the magnetic equator or at the magnetic poles, the field is oriented so that you can measure pitch directly. Anywhere else, yep, the angle you measure doesn't really help much: you can measure an angle relative to a lovely vector that points at some oblique angle relative to gravity (but towards one of the magnetic poles, yay).
By esklar81
#111663
tecoist wrote:I should point out that on the magnetic equator or at the magnetic poles, the field is oriented so that you can measure pitch directly. Anywhere else, yep, the angle you measure doesn't really help much: you can measure an angle relative to a lovely vector that points at some oblique angle relative to gravity (but towards one of the magnetic poles, yay).
Thanks for pointing that out explicitly. I had considered it, which is why I said one could determine pitch angle from the change in the direction of the magnetic field in the vehicle's reference frame. The critical point being that one would need a baseline (zero-pitch) determination of the angle of the magnetic field relative to the vehicle.

Or am I missing something?

Eric
By tecoist
#111665
esklar81 wrote:Or am I missing something?
You measure some combination of roll, yaw, and pitch. Basically, the platform can't sense rotation around the local magnetic field vector, just like accelerometers can't measure heading changes. So imagine your platform spinning on an axis that's, say, 60 degrees below horizontal and pointing a little east of north, and your magnetometers would remain unchanged.
User avatar
By thebecwar
#111667
Use a Gyro. Magnetometers are great for getting a attitude reference, not determining attitude. Accelerometers need to be at a fixed point in space in order to determine attitude, and even so don't do well with their z axis (the z axis is tuned to show 0G when it's actually at 1G). A gyro will give you your angular velocity, and from there it's a cinch to calculate what you need.