Close

Normalization and Linearization

A project log for Space Whistle - wind controller - musical IoT

A highly responsive wind controller with expressive continuous push buttons based on linear hall-effect sensors - A musical IoT device -

ventosusventosus 08/17/2014 at 09:060 Comments

Normalization of respiratory air pressure values

The raw respirator air pressure ADC readout P we want to transmit from the device to the host must be mapped from the original 12bit ADC range [0,0xFFF] to a normalized floating point range of [0,1]. This is easily accomplished with some precedent calibration of minimal raw ADC readouts of Pmin and Pmax. The formula for nomalized pressure Pn thus is:

Normalization and Linearization of linear hall effect sensor data

The formula for nomalized magnetic field strength Bn is equivalent to normalized pressure Pn with precedent calibration of minimal raw ADC readouts of Bmin and Bmax and raw magnetic field strength B. 

The strength of the magnetic field of a permanent magnet decreases with increasing distance (or decreasing stroke septh) from the sensor. This decrease is non-linear and the equations involved are non-trivial, it depends on the material and form of the permanent magnet. As a general rule, at least a cubic relationship can be assumed.

What we are interested in the end, regarding the signal of the linear hall-effect sensors is not normalized magnetic field strength Bn per se, but normalized stroke depth yn. We thus need to linearize this non-linear signal.

Nowadays, magnetic fields can be approximated with finite-element calculations, this however is overkill and not practical in realtime on a microcontroller. To approximate the stroke depth of a given magnet from the sensor based on the sensed magnetic field strength at the latter in realtime it is therefore best to do some non-linear curve fitting for the given pair of sensor and magnet before-hand. In realtime, the fitted distance-function is simply applied to the normalized magnetic field strength Bn to get to the normalized stroke depth yn.

The relationship can vary considerably between different types of permanent magnets, we thus need a way to calibrate on-the-fly to different types of permanent magnets. This is done with a five point least squares fit and leads to an analytical solution with the help of some linear algebra. Points 1 and 5 are boundary conditions (0,0) and (1,1), points 2-4 will actually be measured.

Discussions