# Linearizing hall effect sensors outputs

I'm trying to find a robust solution to linearize four hall effect sensors outout to obtain a signal that I can use in a PID control scheme.

The output data is collect via 4 ADC channels on an ATmega328p chip (Arduino) by sliding a magnet with the south pole first, perpendicular across the sensors with a fixed velocity and distance

I then remove the offset, my idea is to look at the phase shift between the "sine waves" with the atan2(x,y) function

avgADC0 = ADC0-mean(ADC0);



The idea came from this application note Application note

The result is, very very poor :) Mostly because the sensors aren't spaced exactly 90 deg. but I would expect to see something that doesn't look like this and more in the style of what's refered to in the application note.

I'd love to end up with a nice curve, I can curve fit and feed into my control system? But how would you go about linearizing this signal, am I missing something?

The sensor data sheet is linked here

I realize the application note isn't targeted for my sensors, and usually I don't mix and match. But surely the method would still work regardless.

• Thank you
• you can start off by moving the magnet further away so they don't clip at max field, if it is indeed the Halls clipping. If they're still linear, then attenuating the signal into the ADCs. It won't solve the problem, but throwing away data at the start of the process is a good way to make it even worse. – Neil_UK Aug 27 '19 at 12:57
• But the sensor outputs not nearly have sine wave like outputs, to use then atan2(), they are saturated also. You have to move the magnets away, as stated in the app note. – Marko Buršič Aug 27 '19 at 12:57
• You could also use a Halbach array or to shape the magnet flux so that it have sine waveform. – Marko Buršič Aug 27 '19 at 13:12
• Yeah i need to cut the legs of my testbench @Neil_UK :) – Sorenp Aug 28 '19 at 5:37
• Have you considered trying to fit it to a second degree 4 dimensional polynomial? Such as f(x,y,z,w) = (ax²+bx+c)(dy²+ey+1)(fz²+gz+1)(hw²+iw+1) where a to i are the coefficients and x,y,z,w are the 4 inputs? – Harry Svensson Sep 2 '19 at 20:26