AN2531
STEVAL-ILL009V1 reference board
27/40
The next block checks the temperature every 2.55 seconds. This time is considered fast
enough because, due to its inertia, there is no need to check the temperature any faster. If
its value is higher than the limit, the PWM duty cycle is increased (0% duty cycle is full bright
and 100% is no light) by one step. Therefore, the light is absolutely turned OFF after 163.2
seconds (64 levels times 2.55). If the temperature is lower then the limit, the PWM duty
cycle starts decreasing down to maximum brightness (0%) and normal operation.
Time3 = 200 ms is used as a stabilization time for the DC-DC converter and linear regulator.
The output capacitors C10 and C14 (
) should be charged first to avoid resetting
the microcontroller (low voltage detector) and the flickering application due to the high load.
At the end, the high power RGB LEDs are turned ON after 200 ms. This time delay occurs
only once, when the application starts.
Figure 16.
Blink function flowchart - first part
shows the second part of the blink function - the brightness setting (based on
value read on P2 in first part) and mode selection (mode is selected by pressing button S2).
MODE 1, MODE 2 and MODE 3 sets the brightness for the red, green and blue LEDs where
the brightness level (0 to 64) is obtained from the potentiometer P1 after each SW PWM
period (10 ms).
R, G & B elements could be set in single step with MODE 4 and MODE 5. This means the
color is moving on a predefined curve as indicated in
. The difference between
MODE 4 and MODE 5 is that MODE 4 is controlled by potentiometer P1 and MODE 5 is
working automatically (simulating the P1 input).
shows how it works. The integer
AI12684
Start
BLINK
Time base 156 µs
?
Coun+
Time1 = 10 ms
64 x 156 µs
N
Y
Y
N
1
Time1 = 0
Read brightness
from potentiometer
P2 (digital value
from ADC)
Time1 = 2.55 s
255 x 64 x156 µs
Y
N
Y
N
Time2 = 0
Temperature
Limit > measured
value
Negative
temperature
coeficient
Decrease bright
about 1 step
Increase bright
about 1 step
Time3 = 200 ms
20 x 64 x156 µs
Time3 = 0
Startup = OFF
1
2