Finja and I developed our scanner for vectorfield analysis of magnetic flux further: We have built a **new design** with a **linear 3-axis delta approach** – now **we can truly scan a 3d-space mapping the magnetic flux as a 6dimensional vectorfield!** And we have added some fine mathematics to ~~cheat~~ – eh, improve performance and/or resolution 😉

I am still not satisfied with this design because the ratio of the arms and the radius is not optimal and therefore you can only measure a very small area of 3x3cm because the sensor plate is raised at the edges of the measuring surface. I know this could be simulated e.g. with Geogebra, but I have no clue at the moment how to do simulations in this software…

**New scans – examples**

Here is a vectorfield plot of a round magnet from above:

And, of course, we have taken the traditional electric-current-in-a-wire magnetfic field to the next level: How do strange or funny shaped-wires produce magnetic fields? Have a look:

It is the shape of a heard with about 10amps going through it – but apart from the “girlish” attitude of showing a heart, there is real-world application for it. Think about the complex magnetic field necessary in fusion reactors… they need odd-shaped coils to produce them 😉

**Constructing the linear delta**

Coming back to the new mechanical design we have chosen: Delta printers have a parallel kinematics, since the positions of the motors are not interdependent, so one motor does not move the other. On the other hand, the positioning becomes more complex, because, in the case of a positional change in one plane, all three motors must always run at different speeds but start and end at the same time. The mathematics behind the delta design, for the precise control of the stepping motors, is derived from the theorem of Pythagoras itself – ignoring acceleration and deceleration. We 3d-printed the carriages and motor attachments and first used an Arduino Mega, 2 motorshields Bluetooth-Dongle and a smartphone to control the scanner. In the meantime we have started on porting this to the Raspberry Pi using Python and Matplotlib to visualize the scans.

**How to cheat nicely with math 😉**

In the case of different measurements it is noticeable that the visualization of the vector field can show “jumps”. This is why we asked ourselves which mathematical algorithms we can use to improve the measurement results, since we cannot change the sensor itself to reduce noise.

One way to increase the measuring accuracy or to reduce the “noise” is to carry out several measurements and calculate the average. The sensor itself allows an average value formation and transmits to the micro-controller the average formed by 2-fold, 4-fold or 8-fold measurements. We have also implemented this accordingly and have the sensor now always perform an 8-fold measurement at each individual measuring point. This way only the mean variation at a given point is reduced.

Nevertheless, a clear noise remains in the further pictures. We have therefore researched how noise can be reduced in a vector field and found a contribution in a scientific journal describing a corresponding filter for geophysical investigations: a so-called** vector-median filter**. Median is exactly in the middle of an ascending sorting series. MATLAB has the possibility to calculate a vector median filter. The specific characteristics of the field are preserved. **We’ll combine that with another mathematical improvement**:

A further mathematical optimization in measurement is the **interpolation of data**. Some of the measurements take quite a long time when a large measuring field is set – because a doubling of the resolution or the measuring field on two axes leads to a fourfold higher data volume and scan duration (quadratic relationship). If this is transferred to the z-axis, the time for an overall measurement is doubled (cubic correlation). Since the individual measuring points lie at a very small distance from each other (a few mm), it is unlikely that there is an extreme deviation in the magnetic field between them not affecting the neighboring points. So – can we use an algorithm to do educated guesses for sup-pixels of our analysis? Or in other words: **Can we cheat nicely with math?**

In the simplest case, the intermediate values could be found by means of a linear function, that is to say the values would be connected to a straight line. More complex ways would be to find a curve that fits the data to estimate the “in-between” values not measured.

In MATLAB there is a function that mathematically calculates approximate values between individual measurement results: The **spline function**. Starting from the neighboring points (for example, in a 3×3 or 5×5 grid), it reconstructs a graphical course on which these measured values lie by different methods – linearly or by curve trajectory. Have a look:

This is a zoom into a surface plot – on the left is the original data, middle shows linear interpolation and right image shows the spline function. The noise is preserved, but we already have a solution for it…

This function can be used to measure fields faster or with higher resolution. If, for example, a measurement is carried out only once every 5 steps in a 100×100 field, instead of measuring every single step, the measurement process can be 25 times faster. From the upper graph, however, it can also be seen that the measured values still show noise point despite the mean value formation. Just interpolating the data carries on these inaccuracies so that it can be useful to perform a smoothing of the data:

This comparison shows that the same magnetic field. In the upper left you see a zoom into a surface plot of a 20×20 field. The downer left shows the exact same magnetic field scanned with a 25times higher physical resolution of 100×100 samples.

The images on the right side show the mathematical approximations: The upper right image is interpolated from 20×20 to 100×100, increasing the physical resolution to a virtual one by factor 25 as well as an applied vector median filter. It still shows some of the noise, but it is very smooth and accurate now. The image on the down right side is a median filter on the pure 100×100 physical resolution – no noise, no artifacts.

As our aim was to keep the project as open as possible, so we looked for alternatives to visualize the data. We still work with MATLAB, but have an alternative version with the Raspberry Pi – there is Wolfram Alfa (which is for free on the Raspberry) as well as powerful tools like Matplotlib..

We submitted this project this year to Jugend Forscht in Berlin and won **first prize** on Berlin’s regional level. Keep your fingers crossed for the next competition level, please 😉