Self-Calibrated Colour-Reader
The colour-reader is great but suffers from high sensitivity to ambient light and low discrimination between close colours, as black and blue, as red and white. Red and white are critically close, because the light used in the color-reader is a red LED.
Setting the correct trigger values is not always easy. I was tired of adjusting the values each time I started my model Magasin 9. So I designed an easy and automatic way to self-set the trigger values for differenciating red from white and blue from black. What do I need? I need a trigger value to separate one colour from another. First idea is to take the average between both colours. So I measure the values for each colors and calculate the average between both. |
Initialisation
Colour reading
Calculation
First Version |
Second Version |
First version is based on the average of the two measures Valeur1 and Valeur2.
That's the way to obtain the very first value of Limite23, i.e. 1866. |
In the second version, I obtained better results including the previous trigger value.
Calculation remains quite plain. The trigger value is calculated as the average of 3 values: the previous trigger value and the two measures Valeur1 and Valeur2 done on a red cylinder and a white cylinder. However, this method requires to have a hint of the trigger value, that could be easily obtained by the first method. |
After some tests, the trigger value wasn't stable and was prone to one erratic measure. So I went to a second version.
|
For optimum result, I run the routine three times at the start. Each ambient light change or if a colour is not correctly recognised, I could launch the procedure again to recalibrate the trigger value.
|