Auto calibration of IR horizontal sensors

How it works

From firmware V7, an auto-calibration of the sensors was introduced. We discovered that about 10% of the sensors were not working like the others. We found that the shut-off time of the photo-transistor was longer than normal. This caused the value of those sensors to be higher than expected.

We analysed this problem and found a way to correct this malfunction by software. Now all sensors are auto-calibrated during the lifetime of the robot. We use the smallest raw value ever seen on a sensor to correct its value using this formula:


where $\mathrm{proxmin}$ is the smallest raw value ever seen and $\mathrm{prox}$ the current raw value.

Implementation details

Attention: playing with the settings is for advanced users and is not recommended.

The values of $\mathrm{proxmin}$ are stored in the buffer of settings in positions 1 to 7. Position 0 is used for the volume control. To read the settings you can use this code:

var settings[8]
var i

onevent readsettings
for i in 0:7 do

To disable the auto-calibration you can write -1 in this value as follows:

onevent disablecalibration
for i in 1:7 do
    call _system.settings.write(i,-1)

To reset or re-enable the calibration you simply write 0x7FFF in the settings as follows:

onevent resetsettings
for i in 1:7 do
    call _system.settings.write(i,0x7FFF)

Settings are stored in flash memory which has a limited number of writing cycles. We strongly recommend not to use the function:

call _system.settings.flash()
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License