But as a stretch goal, I'd like to create a true "camera", where you can point the device at one or more magnets some distance away, and it would show the magnets and their field lines as a 3-d visualization on screen. To do this, it would use nonlinear optimization to identify the location, strength, and orientation of magnetic sources in 3-d space, based on the measurements taken by the array of magnetic sensors in the camera. This is a challenging bit of math, but one that I'm familiar with, and I have done a proof of concept to show that it can be done.
Electronic Design
Hall Effect Magnetic Sensors
These small magnetic field sensors are the core of the project. They are able to measure magnetic fields in 3 axes to fairly high precision (some can easily sense the Earth's field, but I'm not sure I want that.) The device's resolution will be limited by the number of sensors I can fit into the grid. There's no way I will be able to have as many sensors as if I were using the iron filings technique, but since magnetic fields vary in a simple mathematically predictable way, I may be able to do some smart interpolation.There are a wide range of these available as surface-mount componenents, for a price of $0.50 - $1.00 each in quantities of dozens, so I should be able to afford lots of them.
Open questions and things I'm worried about:
- Can I actually solder these? Some are very very small.
- Can I make a microcontroller talk to dozens of these at once?
- Will I be able to align them precisely on the board, so their XYZ axes are all aligned? Will I need some sort of placement jig? Post-construction calibration?
- Will a microcontroller be able to handle the necessary calculations and graphics, or will that have to be done by a smartphone or PC?
Display Options
I have two possible options for displaying the magnetic fields.
- The device could have a form factor like a smart phone, with an internal LCD display that shows the visualization. This is sexy, but it means all the computation and graphics have to be done on the microcontroller in my project, and it might not be powerful enough, and I won't be able to use many pre-packaged tools.
- Or, the device could be a peripheral that plugs into a smart phone. This would let the device be a "dumb" peripheral that just reports magnetic field data via USB, and I could write a smartphone app to do all the analysis and display. This might be more powerful, but it's less slick, and I'd have to learn how to program smartphone apps as well as microcontrollers.
- It might be cool to have the device mount to the back of a smartphone, but most smartphones have a bunch of permanent magnets inside (for wireless charging etc) that would distort the readings.
Does this exist already?
There are some old-school non-electronic ways of visualizing magnetic fields, and some research groups have developed arrays of magnetic sensors, but I have not found any commercial product that does what I'm proposing to do, and the "camera" angle seems to be entirely new.
An old-school way of visualizing magnetic fields is to sprinkle iron filings on a piece of paper resting on the magnet, but this has several limitations:
- It shows the orientation of field lines, but not their direction (north to south or south to north)
- It only shows orientation in the plane of the paper, not fields pointing into or out of the paper
- It doesn't show changing fields in real time
- It doesn't show a 3-dimensional view of the field surrounding the whole magnet
- It's messy.
Several engineering research groups have done some work with arrays of magnetic sensors.
- Texas Instruments provides some information on how to use an array of their Hall Effect sensors to detect the position of a magnet, but the goal here is to find the position of the thing the magnet is attached to, rather than to investigate the magnet's field.
- Zhang et al (2019) use a linear array of sensors to map out the magnetic field of a free electron laser undulator line, but they don't do a 2-d array, or visualize the field lines.
- Lee et al (2021) create a small 3x3 Hall effect array and use it to map out field strength, but not direction, and their device has only a few sensors.
I was unable to find anything that attempted to identify field sources from a distance, aka a true magnetic field "camera"
Proof-of-concept
Before building this thing, I need to check that the math actually works. That is to say, can I calculate the magnetic field that a magnet would create a the position of a few sensors, and then work backwards from the sensor data to find the position and orientation of that magnet? (Or multiple magnets, but let's start with one.)
In the mathematical proof-of-concept page, I work out the math and write some code to demonstrate that yes, I can use nonlinear optimization (the Broyden-Fletcher-Goldfarb-Shanno algorithm) to find the position and orientation of a magnet given at least three 3-d observations of magnetic field at different locations. I use a scipy python library to keep things simple and fast.
Can this algorithm solve for multiple magnetic sources? Can it do it in real time? I dunno, but this is good enough to go on for now.
Another important calculation is how far away would a magnetic field camera be able to "see" a magnet? The math page shows that we should be able to detect a rare-earth magnet at a distance of about 20 cm, which is far enough to be useful.