# Magnetometer in space

See, i recently buy a magnetometer to experiment with arduino, i want start building a litle fly computer for a cubesat (this cubesat have an ion engine, so, have thrust). I start reading the Azimuth of the magnetomenter and all was ok, my question is: What is the use of a magnetometer in fly computers? is for detect the North as a compass or just to detect the X-axis move?, and: a Magnetometer work equal in the space as in the earth? i think no, bcs uses the Magnetic field of the earth to detect, right? I buy an accelerometer + gyroscope too so i know how detect the rest of the axis of move and velocity. Thats why i just find that use on the Magnetomenter.

Thanks for any help or document.

I am no expert in this but I think this is right as far as it goes. Your question is about the use of a magnetometer in space with Arduino style sensors and algorithms, so I can provide some links which will be helpful.

On earth in a local area like a room up to kilometer-sized flying radius, people try to use magnetometers to help establish a baseline for their algorithm that uses gyro signals to determine direction.

A stream of signals from a gyro might tell you that you've turned about 20 degrees ccw in the last 5 seconds, but "20 degrees from what?" is the question. The answer is "From wherever you were pointing five seconds ago." As long as you are flying gyros-only you have to keep adding every change to the list of previous changes to see where you are pointing now.

Gyros always have errors and offsets, they can think they are spinning when they aren't, can be nonlinear and can mix rotations in different axes together incorrectly or misinterpret accelerations as rotations, especially the ones we use with hobby projects.

So people turn to our friend the Earth and its stable magnetic field because it tends to point in a fixed direction locally.

When the accumulated gyro errors start deviating too much from the compass direction too much, the attitude is combined with, or reset to the compass information as best as it can be guessed. Every algorithm is different.

The problem is that the compass can not tell you anything about rotation around the magnetic field direction, which at mid-latitudes points diagonally up out of the ground.

Luckily our friend the Earth gives us a second stable field as well, gravity!1 We can use the axis of the local magnetic field and the axis of the local gravitational field to build a non-rotational fixed frame.

Problems:

Any ferromagnetic materials like iron in the ground or rocks or buildings (e.g. rebar in reinforced concrete) will distort the local magnetic field.

And the Earth plays games with its magnetic field as well!

as do other planets!

Low cost hobby or cellphone compass modules are suboptimal:

As are the accelerometers:

More background:

The implementation of gyros (sometimes together with accelerometers) for absolute pointing is sometimes called a gyrocompass.

Great flying often involves the incorporation of several different streams of data from very different sources. Motion detection and patter recognition from vision systems are used by insects and birds and some drone flying algorithms, radar (radio or acoustic pings) doppler (radio, audio), laser scanners for field mapping can and have all also be explored at the hobby level as well.

1note added in proof; "down" from gravity is not available to those in orbit!

The magnetometer in cubesats is used in attitude determination, in general for measure of local earth magnetic field vector. To implement the most basic attitude determination algorithm (TRIAD) you will need 4 vectors, related to two physical quantities (usually the magnetic field and sun position), two of them observed with sensors and the other two with reference from the orbit propagation1.

The reference sun vector is easily archived by estimate the sun position of a given orbit. The magnetic vector reference you need the orbit information and an Earth magnetic model (like world magnetic model-WMM, or International Geomagnetic Reference Field - IGRF).

1For attitude determination, essentially, you need to find a rotation operator (a cosine matrix for example) to apply on the coordinate system fixed on the satellite body to reach on a given inertial reference system (e.g.ECI - Earth-Centered Inertia). With a vector described (components) on both coordinate system ("observe vector" in the satellite body and a "reference vector" in the referential system) you can determine the rotation operator but with some ambiguities. You can work with two vectors described in the two systems (two obs and two ref) you can resolve these ambiguities

• Nice answer! Can you add a little bit more explaining why four vectors related to two quantities are needed? Maybe it's two vectors representing four quantities (vector components or angles)?
– uhoh
Nov 4, 2020 at 1:37
• Thks ^^ For attitude determination, essentially, you need to find a rotation operator (a cosine matrix for example) to apply on the coordinate system fixed on the satellite body to reach on a given inertial reference system (e.g.ECI - Earth-Centered Inertia). With a vector described (components) on both coordinate system ("observe vector" in the satellite body and a "reference vector" in the referential system) you can determine the rotation operator but with some ambiguities. You can work with two vectors described in the two systems (two obs and two ref) you can resolve these ambiguities. Nov 5, 2020 at 12:40
• Okay thanks. I pasted that back into your answer as a footnote, please feel free to edit further if you like. The idea is that comments are considered temporary, so anything that's important we should try to move back into the post itself. Welcome to Stack Exchange!
– uhoh
Nov 5, 2020 at 12:59