eCompass vs Fluxgate compass/magnetometer - Page 1
Forum section: electronics / projects

author: Sudo_apt-get_install_yum
author_rank: Regular Contributor
timestamp: January 20, 2025, 02:54:52 pm
content: Hi,I’m building a somewhat large RC boat and am looking to use a compass for heading/direction.Going of traditional design, both airplanes and boats used multi-axis fluxgate compasses combined with a gimble. Either suspended in a liquid or hanging from strings.This is quite complicated to build at home for one of project so would like to avoid this!The question is how good are these modern multi axis eCompasses?I’ve googled quite a lot but cannot seem to find any data from the manufacturers about drift over time etc. Are they good enough for something like this or will they drift significantly?As an example, ST's IIS2MDC seem quite good and easy to use but don’t mention much about "long term performance".Phones use eCompasses and they seem to work very well over time, but do they use the GPS to calibrate the eCompass?NXP/Freescale has a nice appnote AN4248 regarding tilt/angle compensation, but I haven’t been able to find much else...I’m using this as a learning experience since I’ve never really used "magnetics" so apologies if the questions are nonsensical!I know I could use a of the shelf GPS but this is for learningInput is appreciated!

author: jwet
author_rank: Frequent Contributor
timestamp: January 20, 2025, 11:26:09 pm
content: I've played with Fluxgates and compasses extensively- fascinating circuits. There are a few types and modern sensors which are often technically GMR (Giant Magneto Restrictive) are very good and likely nearly as good as good as the gimballed type you mention. The very best marine compasses from KVH and Autohelm and others still use those old sensor types with a puck sized remote sensor package, so there must be something they still do better. There is a very little published about their design. I've included a few pointers to references that helped me.I first started playing with toroid ring based designs around 1990. It all started from a series of articles in the experimental aviation journal that I was pointed to by an article by Don Lancaster. It used a 1" or so tape wound toroid core from Magnetics inc. with about 50 turns on it. Magnetics made saturable reactor cores and had some good docs (TWC-600 is one I have, about 3 Megs). This compass had an X and Y sense coil of very fine wire. The circuit used a 555 to drive the core and a synchronous demodulator using some cheap analog switches and op-amps with the output going into an 8 bit ucontroller with ADC. The firmware did the trig and displayed the result on an LCD. The micro was very small and the trig was pretty inaccruate, I think it could 2 degrees if kept level. I played with this for a long time and learned a lot. There were also some NASA papers about fluxgates around this time and I talked to that author. I likely still have paper files that I could find if you'd like more details. This was a lot of hobby fun but It never got very practical.The next thing I played with were modules from Precision Navigation in Mountain View, CA- they made military and marine compasses in the early 90's. They used little solenoids (1/4"D x 3/8"L) wound on saturable cores that they put into a simple circuit that oscillated. The frequency would change in fields. They had three of these sensors oriented in XY and Z. This was pretty darn clever. I went up and visited them (I was an FAE for Maxim at the time). They gave me a few sensors and a couple of eval boards. Maxim quoted an ASIC to them but they didn't have the volumes to make it work. They made car compasses for OEM, licensed their designs, etc. They also had several patents that were pretty good. With good circuitry and software, these could must .5 degrees or better.I finally played with some of the modern sensors and modules- Honeywell was pretty into this with HM55 and HMC6532 (IIRC). Phillips did a sensor called the KMZ52- it was from their sensor group in Hamburg. They also had some good app notes (AN00022 was sort of a reference design with a great overview). They had some clever stuff and had an array of sensor on a die and could compensate out a lot of systematic errors with clever operation of flipping the polarities and cancelling offset, etc. I have a pdf of AN00022 that I could send you by PM- its 300K bytes. I also have a US Govt. Pub called "HANDBOOK OF MAGNETICCOMPASS ADJUSTMENT" that is pretty good- about 2Megs.I think in this day and age, I'd get a good 9 DOF sensor (gyro, inclinometer, compass) like the TDK Invensense TDK InvenSense ICM-20948 9-DoF IMU (MPU-9250 Upgrade) from Adafrui- they're $15. If you marry one of these up to a ARM cpu with some room for floating point trig, you could probably get a great sensor. These are what are in phones and you can download a phone app and play with these to see if they're work. They're pretty darn good.When I was working on these things, I was using PICs with 4K of assembly language, etc. It was difficult- now it should be easy. Its a fascinating hobby and deep rabbit hole but if you want to build an RC boat, keep your eye on the ball and buy something.Good luck and have fun.

author: Sudo_apt-get_install_yum
author_rank: Regular Contributor
timestamp: January 22, 2025, 08:04:08 am
content: Thank you for all the info and interesting story about this technology!You mentioning the aviation journal and the drive-principle and hearing autohelm reminded me about their old "Tiller Pilots" who use fluxgate for heading.Their service manuals are available online and seem to use the exact same principle as you described. Both seem to use cheap components to build a lock-in amplifier combined with a two-axis fluxgate.Maybe they derived the design from that paper, or just the "best" design principle for the job?That solenoid principle sounds really clever, might look into something like that in the future!I followed your advice and checked what IC's my phone uses and stumbled upon the company Memsic and the IC on my phoneMMC5616WA.The IC seems to do exactly what I want!What would the downside be of using this one magnetic sensor rather than the TDK one that incorporates accelerometers/gyros etc?The appnotes mention using the accelerometer for tilt compensation, how much does it affect it in practice?Wouldn’t the combination of the 3-axis be enough to figure out the heading on 3D space?I’m not too worried about the firmware side of things!Half the fun for me is exploring/building new things, not necessarily the end goal of the RC-boat. I’m an EE by trade and work with completely unrelated things so it’s always refreshing to learn something new from a field I’ve never looked into!I would appreciate any papers regarding this as I have zero experience with magnetic things.

author: jwet
author_rank: Frequent Contributor
timestamp: January 22, 2025, 05:27:51 pm
content: Great stuff! PM me with a private email and I can dump some files on you. They're a few megs and I don't want to bog down the board with this stuff.I think for a boat application- the MEMsic is perfect, you don't need tilt comp with a good 3 axis sensor. Tilt comp is important in airplanes and can give you some funny artifacts- generally known as northerly turning error. A 3 axis sensor fixes all the real errors. The biggest error that isn't obvious is that the field lines from the pole come through the earth, they don't follow the globe so the true vector is coming up out the ground at something like your latitude. Its called DIP. 2 axis compass don't compensate but 3 axis ones do. Have you found an app that will let you look a the raw values from the your phone's sensor? It should be free.That service manual is excellent. That's exactly the flux gate circuit. A rare find.Good luck- looks like fun. Its a great time to be a nerd!

author: jwet
author_rank: Frequent Contributor
timestamp: January 22, 2025, 06:24:08 pm
content: I dug into those autohelm schematics and some others, Thanks!- really interesting! They "roll their own" dual slope ADC type circuit with those muxes and op-amps. In the old circuits I played with, the uP was just of a smart voltmeter at the end of an analog chain- they have the uP more involved in the compass operation and it simplifies it immensely. For example, there is no sense in having a 555 timer to drive the coil- use the uP and then you can do all the sync demod stuff in sync. Learned a lot.Don't let this distract you- this is buggy whips and horse and carriages best left to old men like me... Use that MEMSIC IC.You've got me back in the rabbit hole. Check out PNI (the original solenoid guys). They sell relatively cheap board and modules that are probably significantly more accurate than the standard phone stuff.https://www.pnisensor.comespecially look at the 3100.

author: Sudo_apt-get_install_yum
author_rank: Regular Contributor
timestamp: January 29, 2025, 10:36:59 am
content: Apologies for not responding sooner, been quite busy!I’ll look into using the MEMSIC for a start and then move to the more advanced ICs if needed. Never heard of PNI but they seem to know their stuff!Got a bit intrigued to about the old school flux-gates. Pretty sure one could integrate the entire analog stage in a modern & cheap mixed signal µC or DSP without too much hassle. But this is a whole other can of wormsRegarding the calculations and tilt-compensation.Maybe I have the wrong understanding about this?The compass heading is determined by: rad = atan2(Y, X)My phones compass gives the following values when pointing northZero tilt.X = -3.91 µTY = 11.37 µTZ = -43.41 µTThis would give atan2(11.37, -3.9) = 1.9 rad = 108 Deg ~ESE45 degree tiltX = -2.40 µTY = 39.52 µTZ = -20.54 µTThis would give atan2(39.52 , -2.40) = 1.6 rad = 91 Deg ~EThe phones heading changes slightly when tilting it but I am sure that the change is much less than almost 20 degrees.Tilting the phone will change the Z reading AND X OR Y. The Z-axis change seems to be proportional to the change in the other axis.Do I need to calculate the 3D vector of all channels and then project it onto a 2D plane, or am i barking up the wrong tree?My linear algebra is a bit rusty...I’ll send you a PM for the docs, it might be nice to post them publicly if someone else goes down this rabbit holeAll the information I can find on the internet only uses the X/Y channels and uses the accelerometer for tilt-compensation.Image below is my phone pointing towards north. The phone is lying flat in the left image and tilted roughly 45 degrees in the right.The plots are field strength as a function of time.

author: jwet
author_rank: Frequent Contributor
timestamp: January 29, 2025, 07:17:19 pm
content: Let me look at this and compare to my phone.I wonder if those values are complete raw from the sensor. Scale the X and Y to give you a good north and see if it tracks around for other bearings. This is apart of "calibration", most compasses require to swing them through 360 where they store the maxes and mins.Keep posting-