STMicroelectronics AN4460 The steval-ill057v1 demonstration board is a complete Datasheet

AN4460
Application note
STEVAL-ILL057V1: four independent high brightness LED
Ambrogio D’Adda
Introduction
The STEVAL-ILL057V1 demonstration board is a complete and configurable solution to
manage four independent high brightness LED channels using the STLUX385A digital
controller, which embeds advanced peripherals tailored to generate high resolution PWM
signals. The LED current is independently regulated by the fixed-off-time (FOT) principle on
each channel.
This document describes how to use the STEVAL-ILL057V1 board, the hardware and the
firmware implemented on the board as well as the relevant measurements. The
STLUX385A shipped with this board has already been programmed with firmware tailored
for the STEVAL-ILL057V1 application and the source code is available.
Figure 1 gives an overview of the demonstration board diagram.
Figure 1. Demonstration board diagram
Buttons
DALI
STATUS
SWIM
Channel 0
Channel 1
STLUX
Channel 2
UART
+
Channel 3
Power in
AM16703v1
April 2014
DocID026129 Rev 1
1/54
www.st.com
Contents
AN4460
Contents
1
Demonstration board features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2
Getting started with the STEVAL-ILL057V1 demonstration board . . . . 8
First power-on procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3
4
5
6
7
2/54
Design concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1
LED channel schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2
Solving the equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
SMED implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.1
SMED input matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.2
State description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.3
Input/output signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.4
SMED state time evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Firmware implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5.1
Dimming algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5.2
Firmware evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.3
Printf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.4
Low power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Protection and regulation algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.1
Overcurrent protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.2
Initial estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.3
Adaptive voltage compensation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.4
Software crash protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
User interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
7.1
Control buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
7.2
Status LEDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
7.3
Serial interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
DocID026129 Rev 1
AN4460
Contents
7.4
7.5
8
Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
7.4.1
lc - change LED current . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
7.4.2
ll - change LED dimming level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
7.4.3
ln - configure LED number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
7.4.4
ad - read ADC channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
7.4.5
au - adaptive voltage compensation . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
7.4.6
st - verify status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
7.4.7
pw - PWM status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
7.4.8
vp - set VLED_PW simulated voltage . . . . . . . . . . . . . . . . . . . . . . . . . . 32
7.4.9
vc - set VCOMx simulated voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
7.4.10
wi - CPU load monitor and low power mode . . . . . . . . . . . . . . . . . . . . . 32
7.4.11
dm - dump memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
7.4.12
rr - read memory, single byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
7.4.13
rw - write memory, single byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
7.4.14
ed - enable global dimming function . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
7.4.15
di - set global dimming value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
7.4.16
ti - read time counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
7.4.17
co - clear error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
7.4.18
hl - command help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
7.4.19
hl - ? - global help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Error codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
8.1
Output current precision for different current setup . . . . . . . . . . . . . . . . . 36
8.2
Efficiency according to different current setup . . . . . . . . . . . . . . . . . . . . . 38
8.3
Current regulation on input voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
8.4
Current regulation validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8.5
OCP protection time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
9
Pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
10
Schematic diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
11
Bill of material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
12
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
DocID026129 Rev 1
3/54
54
List of tables
AN4460
List of tables
Table 1.
Table 2.
Table 3.
Table 4.
Table 5.
Table 6.
Table 7.
Table 8.
4/54
Current, DAC, K relation table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
SMED input association . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Error codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Efficiency according to different current when the input voltage changes . . . . . . . . . . . . . 38
Current regulation discrepancies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
STLUX385A pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Bill of material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
DocID026129 Rev 1
AN4460
List of figures
List of figures
Figure 1.
Figure 2.
Figure 3.
Figure 4.
Figure 5.
Figure 6.
Figure 7.
Figure 8.
Figure 9.
Figure 10.
Figure 11.
Figure 12.
Figure 13.
Figure 14.
Figure 15.
Figure 16.
Figure 17.
Figure 18.
Figure 19.
Figure 20.
Figure 21.
Figure 22.
Figure 23.
Figure 24.
Figure 25.
Figure 26.
Figure 27.
Figure 28.
Demonstration board diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Power supply connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
LED string connection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Schematic - LED channel 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
SMED state evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
SMED state evolution. Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Dimming channel relation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
FW timeline evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Console screen during startup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
“?” command. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
“st” command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
“pw” command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Console screen for “ti” command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Current regulation - 4 channels at 245 mA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Current regulation - the same channels, different current setup. . . . . . . . . . . . . . . . . . . . . 37
Current regulation - the same channels, different dimming . . . . . . . . . . . . . . . . . . . . . . . . 37
String efficiency based on different current levels - 3 LEDs for each string . . . . . . . . . . . . 38
String efficiency based on different current levels - 6 LEDs for each string . . . . . . . . . . . . 39
String efficiency based on different current levels - 10 LEDs each string. . . . . . . . . . . . . . 39
Current regulation vs. VPW_LED: 3 LEDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Current regulation vs. VPW_LED: 6 LEDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Current regulation vs. VPW_LED: 10 LEDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
MOSFET gate during short-circuit - 245 mA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
MOSFET gate during short-circuit - 738 mA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
MOSFET gate during short-circuit - 1.065 A. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Schematic - STLUX385A - top . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Schematic - 4 channel LED driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Schematic power section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
DocID026129 Rev 1
5/54
54
Demonstration board features
1
AN4460
Demonstration board features
The STEVAL-ILL057V1 demonstration board implements the following features:
 Four independent LED channels (external LEDs)
 3 to 10 LEDs per channel, connected in series
 Average LED current independently adjustable from 245 mA to 1065 mA with
~82 mA/step resolution
 LED brightness adjustable via PWM dimming (256 steps independent for each channel)
 Board power supply voltage (VLED_PW) from 12 V to 48 V based on the longest LED string
(external AC-DC power supply not included)
 Real-time fault detection and protection, such as open or short-circuit, independent for
each channel
 Board configuration (chain current, LED numbers, etc.) accessible via USB-UART
interfaces
 Three buttons to adjust the LED brightness for each channel
 Two status LEDs: green = ready-run, red = fault
Warning:
The user is responsible for configuring correctly the board
before connecting any LED string.
The user configures the right values according to the following parameters:

Number of LEDs connected on each channel (from 3 to 10)

Average LED current desired on each LED channel (from 245 mA to 1065 mA)

200 Hz PWM dimming duty cycle for each LED channel (from 0% to 100% in 256
steps)

Board power supply voltage (from 12 V to 48 V)
The number of LEDs, the current and the PWM dimming working point can be set through
the command interpreter accessible via the serial interface (Section 7.3 on page 28).
Alternatively, PWM dimming can also be manually adjusted via two on-board buttons.
The firmware installed on the STLUX385A automatically computes, for each LED string:
6/54

Primary frequency upper and lower limits (400 kHz to 15 kHz with frequency step
generated by PLL at 96 MHz - auto-setup)

Primary frequency duty cycle depending on the selected current, number of LEDs and
power voltage.
DocID026129 Rev 1
AN4460
Demonstration board features
To guarantee the maximum reliability of the demonstration board against the most common
LED failures, the STLUX385A implements the following software and hardware protections:

For each LED string:
–

Overcurrent
–
Short-circuit
–
LED voltage drop falls below the 2.9 V limit
–
LED voltage drop higher than the 4.2 V limit
–
Disconnected string (open circuit)
Power voltage outside configured lower / upper limits.
The STLUX385A device drives the 4 LED channels (CH0, CH1, CH2, CH3) seen on the
right side of the board.
The board uses a DC-DC converter to supply the MOS drivers (U3, U2) with 10 V, while the
STLUX385A (3.3 V or 5 V) is powered by a linear regulator.
There are three buttons to manually change the dimming period. The DALI and UART TTL
interfaces are supported.
Two LEDs indicate the board status: the green one shows that the system is “ready” while
the red one indicates a system fault or the intervention of a protection mechanism.
DocID026129 Rev 1
7/54
54
Getting started with the STEVAL-ILL057V1 demonstration board
2
AN4460
Getting started with the STEVAL-ILL057V1
demonstration board
This section aims to help designers to correctly power up and control the demonstration
board in a short time. It describes how the board is connected to the load and how the serial
command line and the board buttons control the light/color of the LED strings.
The STEVAL-ILL057V1 board provides 4 independent LED channels and the user can
connect up to 4 different LED chains (not included in the STEVAL-ILL057V1 package). The
board is configured to control standard LEDs with a forward voltage (VF) between 2.9
(“V_LMIN”) and 4.2 (“V_LMAX”) on each LED. The limits are defined in the firmware and
they can be changed by modifying the source code (see [#define V_LMIN] and [#define
V_LMAX] into “led.h”). Alternatively, the user can simulate the required voltage drop by
configuring, via the (ln command) an apparent incorrect number of LEDs.
The LED numbers and the current associated are configured via the serial command
defined in Section 7.3 on page 28.
The board accepts a DC input power in the range 12 V - 48 V. The user chooses the correct
input voltage depending on the LED numbers and the voltage drop. The firmware accepts
a minimum voltage of 2.8 V (“V_COM_MIN”) across the inductances when the MOSFET is
ON. If an incorrect power voltage value is set up, the LED current is not regulated correctly
but the STLUX385A prevents the external LED module from damage. The only way to
damage an external LED module is to configure a current over the maximum accepted by
the LED module or define a number of LEDs different from those used. When a new LED
module is applied to the board, it is recommended the user to start with the minimum current
(“lc x 0") and with the dimming OFF (“ll x 0). Note that the firmware stores the last serial
commands (LED number, LED current, LED dimming and adaptive voltage compensation
enable/disable) on the internal E2PROM and applies those values at power-on or reset.
First power-on procedure
The following section describes a step-by-step procedure, which guarantees a correct
power-on during the first configuration of the board.
The guide assumes that the following elements are available:

STEVAL-ILL057V1 board

USB TTL serial cable shipped with the board

Power supply

Computer running Windows operating system

LED string
It is recommended the LED string to be disconnected before the first startup.
The first power-on instructions as follows:
8/54
1.
Connect the USB TTL serial cable to the USB port of the computer. Windows
recognizes the cable as a TTL and launches the driver installation.
2.
Install the appropriate USB TTL serial cable drivers. The drivers are the “virtual COM
port (VCP)” and they are provided by FTDI (www.ftdichip.com). Should you need any
help install the drivers, please refer to your IT administrator. Once the drivers are
DocID026129 Rev 1
AN4460
Getting started with the STEVAL-ILL057V1 demonstration board
installed, the Windows device manager panel shows a new USB serial port (COMx)
device and the COM number associated.
3.
Verify that the power supply output voltage is within the board specification.
4.
Switch OFF the power supply.
5.
Connect the power supply to the board and check the input polarity. Figure 2 illustrates
how to connect the power cables:
Figure 2. Power supply connection
6.
Power on the board and check that the power supply current level is within the
appropriate levels.
7.
Monitor the red status LED on the STEVAL-ILL057V1 demonstration board. During the
startup, the red status LED goes ON for few seconds before switching OFF. Should the
red status LED stay ON for more than 3 seconds, the STLUX385A device is indicating
a problem. The status LED should be checked after every step of the power-up
procedure. The STLUX385A indicates any issue encountered: short-circuit,
overcurrent, input power under the limit, etc. Note that, once the status LED is red, it
can only be switched OFF via the “co” console command.
8.
Connect the USB TTL serial cable to the STEVAL-ILL057V1 board.
9.
Run “Hyperterminal” or an equivalent program from the computer connected to the
USB TTL serial cable. The connection configuration is as follows:
–
Baud rate: 115200
–
Data bits: 8
–
Stop bits: 1
–
Parity: no
–
Flow control: no handshake
In order to verify that the connection is valid, type “?” and press ENTER. If the link is OK, the
STLUX385A list of commands is displayed.
10. Should the red status LED list a problem, use the “st” command and look at Table 3 on
page 36 to find the root of the problem.
11. Configure the LED string parameter via the “lc” (LED current) and “ln” (LED number)
commands. See Section 7.3 on page 28 for the command reference. Note that any
new setting is stored in Flash and is automatically used during the next startup.
DocID026129 Rev 1
9/54
54
Getting started with the STEVAL-ILL057V1 demonstration board
Warning:
AN4460
The current level has to be configured according to the LED
capability. A current level higher than the one supported by
the LED may damage the LED itself.
12. Switch OFF the dimming using the “ll x 0" command where “x” is the channel number
selected to drive the LED string. Once the dimming is disabled, channel x doesn’t
generate current.
13. Connect the LED string to the appropriate channel “x” connector. Please observe the
LED polarity. Figure 3 illustrates how to connect a LED string.
Figure 3. LED string connection
14. Increase the dimming level using the “ll” command and observe the LED string
switching ON.
15. Enable the adaptive voltage compensation using the “au x 1" command.
10/54
DocID026129 Rev 1
AN4460
3
Design concept
Design concept
The STEVAL-ILL057V1 demonstration board is based on a modified buck topology
(reversed buck) and the fixed-off-time (FOT) principle is used to regulate the current into
each LED string. The advantage of the FOT principle is that the high frequency current
ripple and, therefore, the average LED current depend only on the off-time and the LED
output voltage. With a fixed-off-time, the output voltage depends on the temperature and the
number of LEDs. To compensate this effect, the STLUX385A implements the adaptive
voltage compensation algorithm, which constantly monitors the LED voltage drop and
adjusts the off-time. The input voltage variations do not affect the average current.The
average LED current is directly controlled by regulating the LED peak current (configurable),
which is sensed during the MOSFET on-time.
While the off-time parameter is fixed, the on-time is a function of the time that the current
takes to reach the selected level: this time depends on the LED current, power voltage and
LED voltage. The firmware implements the following two functions to compute the OFF and
ON-time:
Equation 1
 2   I MAX – I AVR    L
T OFF = ----------------------------------------------------------V LED
Equation 2
 2   I MAX – I AVR    L
T OFF = ----------------------------------------------------------V LED_PW – V LED
where:

VLED: output voltage of the LED string (equal to VLED_PW -VCOMx signals on the
schematics)

IMAX: maximum (peak) current imposed by user and defined by Table 1 (near
92 mA/step)

IAVR: current imposed by design (IMAX - 10%)

L: inductance imposed by design (470 µH)

VLED_PW: input voltage present at the main power pin
The on-time calculated in Equation 2 has to be considered as an ideal value: the real one is
actually a consequence of the triggering of a comparator monitoring the peak value of the
LED current. For this reason, a percentage of the calculated on-time is added (Tx). This is
empirically imposed by adding 20% to the on-time and doubling the resulting value.
Equation 3
T ON  MAX  =  T ON + T X   2
DocID026129 Rev 1
11/54
54
Design concept
AN4460
Equation 4
T ON  MAX  =  T ON +  T ON  0.2  x2 = 2.4xTON
Where Tx is the time to search current and it is equal to 20% of TON. The extra time has two
effects: the former, during the dimming operation, allows a quicker response from OFF to
ON transition; the latter prevents a frequency lower than 15 kHz (in the audible spectrum).
On the board the circuit for the transition mode principle is also present but it is not
described in this AN.
3.1
LED channel schematic
To implement the FOT principle and to use the STLUX385A microcontroller, the following
schematic (single LED chain) is used. It represents a standard reverse buck structure. The
STLUX385A applies the PWM frequency via the PWM0 signal and monitors the voltage of
the VCOM0 signal. It also monitors the LED current during the “on-time” by sensing the
voltage present at CPP3 line. The VLED signal is calculated by the subtraction from VLED_PW
and VCOM0. The VCOM0 signal is acquired 100 µs after the PWM dimming starts.
The schematic for a single LED channel is reported in Figure 4:
Figure 4. Schematic - LED channel 0
GND
PWM2
OUT1
VCC
1
R21
L3
-
2
470uH
1,2A sat
Q2
STN3NF06L
10R 1
160R
GND
Cut Freq = 723 KHz
R28
R29
1R8
1R8
1W 1% 1W 1%
GND
GND
1
from 240 mA to 1 A
82 mA step
GATE_PWM0
LED_PW
100nF
100V
GND
Q4
2N7002
VCOM0
D8 LL4148
C18
10nF
GND
LED_PW
+ C12
1uF
100V
R25
26K1
GND
3
C14
1nF
R19
26K1
D6
+
C11
STPS0560Z
RS-250-347
3
R23
J6
CH0
1
CPP3
CPP3
1
STPS2H100A
RS-249-612
OUT2
GATE_PWM0
D4
1
PWM1
7 GATE_PWM0
6
VD_10
5
TP19
2
2
3
4
2
8
EN2
2
4
GND
EN1
2
PWM0
PWM0
U2
PM8834
2
1
R39
5K1
GND
R37
1K2
VCOM0
C16
10nF
GND GND
AM16704v1
Explanation:
12/54

The LED chain is connected to the J6 connector.

The MOSFET Q2 drives the current from LED_PW to the LED channel and the
inductor L3, charging it. The Inductor L3 is defined for all selectable current ranges.
Should the user change the inductor values, some parameters, described in this AN,
such as the K constant, have to be recalculated.

The resistors R28 and R29 act as a shunt resistor to sense the current through the
LEDs. The current signal is then fed to CPP3 pin through an RC filter represented by
the resistor R23 and the capacitor C14. The filter removes the spike caused by the
DocID026129 Rev 1
AN4460
Design concept
turn-on current generated by MOSFET Q2. The STLUX385A detects the peak current
by comparing CPP3 with an internal, DAC generated, voltage.
3.2

The R19, R25, Q4 and R37 are used to feed the voltage of the LED chain cathode to
the STLUX385A's ADC. The MOSFET Q4 is used to prevent the small biasing current
of the voltage divider from flowing through the LED during the dimming off-time. The
ADC maximum voltage is 1.25 V (the ADC gain is configured to x1).

The D4 diode is active during the OFF period, when the voltage across the inductor
goes high.

The U2 circuit (PM8834 MOSFET driver) is used to generate the correct gate voltage in
case the STLUX385A is powered from 3.3 V.

The D6 diode is used to protect the circuit if the LED chain opens or is accidentally
removed during the normal operation.
Solving the equations
The TOFF value introduced in Equation 4 has to be converted into a number that could be
used by the STLUX385A. In particular, TOFF is implemented in the SMED as a timer. This
timer is a 16-bit register and is clocked according to the SMED clock (CLK = 96 MHz). The
timer register value is equal to:
Equation 5
T OFF  SMED  = T OFF  CLK
where:

TOFF(SMED): timer value

CLK: SMED operating frequency
The STLUX385A monitors the voltage drop caused by the LED and it is calculated as the
difference between the power voltage (VLED_PW) and the voltage measured after the LED
string (VCOMx). Both VLED_PW and VCOMx are read by the ADC unit.
Equation 6
ADC LED_VAL  ADC FS  P
V LED = -----------------------------------------------------------------------ADC TOP
where:

ADCLED_VAL: the sensed LED drop voltage and calculated as VLED_PW - VCOMx

VCOMx: ADC value read from middle point of each channel (LED-inductor)

VLED_PW: ADC value read from the main power

P: is the resistor partition gain (R19 + R25 + R37) / R37 = (53400) / 1200 = 44.5 

ADCFS: ADC top voltage = 1.25 V

ADCTOP: is the step value of ADC (210) = 1024
DocID026129 Rev 1
13/54
54
Design concept
AN4460
Equation 1 can be rewritten as follows:
Equation 7
ADC TOP
T OFF  SMED  = 2   I MAX – I AVR   L   ------------------------------------------------------------------------  CLK
 ADC LED_VAL  ADC FS  P
for example:
Equation 8
2   I MAX – I AVR   L  ADC TOP  CLK
T OFF  SMED  = -------------------------------------------------------------------------------------------------------ADC LED_VAL  ADC FS  P
where:

IMAX: max.current imposed through the DAC setup (1/16)

IAVG: average current - imposed as 90% of IMAX (by design)

(IMAX - IAVG): current difference: (IMAX * 0.1)

I: is the inductance value = 470 10-6 H (by design)

CLK: Is the SMED CLK = 96 106 Hz
The average current IAVG is set by design to be equal to 90% of IMAX.The algorithm controls
the current to be centered in IAVG, with a ripple equal to ± 10% of IMAX. In Equation 8, the
current and the voltage across LED are unknown. The current (IMAX) is an input value
defined by the user. The voltage on the LED string is the difference between the main power
voltage and the VCOMx voltage sensed by two ADC channels. Considering 1.184 A IMAX
current and IAVG approximated to 1.066 (the real value is 1.0654), Equation 4 is expanded
into:
Equation 9
–6
6
2   1.184 – 1.066   470  10  1024  96 x10
T OFF  CLOCK  = ----------------------------------------------------------------------------------------------------------------------------------- =
ADC LED_VAL  1.25  44.5
K
196763
= ------------------------------------ = -----------------------------------ADC LED_VAL ADC LED_VAL
where K (196763 in this case) is a constant for the given LED current selected by the user.
The IMAX values accepted by the STEVAL-ILL057V1 board are bounded by the DAC limits
as shown in Table 1:
Table 1. Current, DAC, K relation table
14/54
Index
DAC value
Medium
current(1)
Maximum
current
K (dec)
10
13 (0x0D)
1065 mA
1184 mA
196.763E+03
9
12 (0x0C)
984 mA
1093 mA
181.628E+03
8
11 (0x0B)
901 mA
1002 mA
166.492E+03
7
10 (0x0A)
819 mA
911 mA
151.356E+03
DocID026129 Rev 1
AN4460
Design concept
Table 1. Current, DAC, K relation table (continued)
Index
DAC value
Medium
current(1)
Maximum
current
K (dec)
6
9 (0x09)
738 mA
820 mA
136.221E+03
5
8 (0x08)
648 mA
729 mA
121.085E+03
4
7 (0x07)
574 mA
638 mA
105.949E+03
3
6 (0x06)
492 mA
547 mA
90.814E+03
2
5 (0x05)
410 mA
456 mA
75.678E+03
1
4 (0x04)
329 mA
364 mA
60.543E+03
0
3 (0x03)
245 mA
273 mA
45.407E+03
1. Medium current: the value has been approximated to the nearest unit.
The index level is used by command “lc” (see Section 7.4.1 on page 30) to select a current
value.
The output of Equation 9 is the value to be stored in the SMED register that represents
TOFF.
Since K is constant, as long as the user doesn't change the current index level, the
STLUX385A updates the TOFF value only when the ADCLED_VAL changes, when the LED
voltage drop changes. The only operation required to update TOFF is a 32-bit division.
Equation 4 can be developed as follows:
Equation 10
2   I MAX – I AVG   L  ADC TOP  CLK
T ON  MAX  = T ON  2.4 = --------------------------------------------------------------------------------------------------------  2.4=
ADC VCOM_VAL  ADC FS  P
=
2.4  K
----------------------------------------ADC VCOM_VAL
Since “K” is constant during operations, TON(MAX) can be updated with a single 32-bit
division. SMED implements the TON(MAX) timer as two consecutive timers operating in
different states (S1, S2).The overall update of TON and TMAX timers requires 3 divisions plus
the time to update the relevant SMED shadow registers.The STLUX385A needs just 200 µs
to complete the operation.The “K” parameters are calculated to satisfy a board operating
with a 12 V - 48 V input power range and support from 3 to 10 LEDs. Should the user use
either different inductances or different parameters such as the I current, only the “K”
constant has to be recalculated and the FW has to be updated with the new K indexes.
DocID026129 Rev 1
15/54
54
SMED implementation
4
AN4460
SMED implementation
This section describes how the FOT (fixed off-time) principle is implemented in the SMED
(state machine event driven). Each SMED generates the correct PWM signals and the
SMED state evolution depends on both external events and internal timers.
Note:
Please refer to the STLUX385A product documentation for a detailed explanation of the
SMED technology.
The SMED is responsible for the generation of the PWM necessary to maintain the IAVG
current through the LEDs. When the SMED is triggering the PWM output, the LEDs are ON.
Digital dimming is achieved by applying a duty cycle to the LEDs. The software controls the
duty cycle (referred as dimming in this document) by suspending and restoring the SMED's
PWM generation. When the SMED stops triggering the PWM line, the LEDs are OFF.
Note that the dimming frequency is much lower (~200 Hz) than the PWM frequency used for
current control (70 kHz - 400 kHz).
4.1
SMED input matrix
Each SMED has three associated signals. Only two inputs are used in the FOT principle
described in this AN. The inputs have been logically mapped to represent:

SMED_in(0) - digital input: senses the inductor null current (currently not used).

SMED_in(1) - comparator input: detects when the current has reached the DAC value.

SMED_in(2) - software input: starts and stops the SMED. Used for dimming control.
Table 2 summarizes the input and event relationship:
Table 2. SMED input association
LED CH
SMED_in(0)
SMED_in(1)
SMED_in(2)
SMED 0
0
DIGIN 2
DAC-CPP 3
SW 0
SMED 1
1
DIGIN 1
DAC-CPP 2
SW 1
SMED 2
2
DIGIN 4
DAC-CPP 0
SW 2
SMED 3
3
DIGIN 3
DAC-CPP 1
SW 3
SMED 4
Not used
DIGIN 0
SMED 5
Not used
SW 4
SW 5
Option:
16/54

SMED 4 PWM output is optional.

SMED 5 PWM output is filtered and connected to CPM3. SMED5 may be optionally
used to generate a reference signal for the CPM(3) input. CPM3 can be used to sense
and detect the top-current event for LED channel 0 and increase the string average
current granularity. The possible current steps are equal to 5 mA (typical). This option is
not used in the current firmware version.
DocID026129 Rev 1
AN4460
4.2
SMED implementation
State description
The STEVAL-ILL057V1 demonstration board uses four independent SMEDs, one for each
LED string. All the SMEDs use the same configuration and share the same control
algorithm. This section describes a single SMED but the same principles are applied to all
the SMEDs. Figure 5 shows the SMED state evolution:
Figure 5. SMED state evolution
HOLD
S0
event(2) - ON
start
IDLE
event(2) - OFF
S0
TIM_Cnt(2) OR
event(1)
TIM_Cnt(0)
event(1) - ON
S1
S2
S3
TIM_Cnt(3)
TIM_Cnt(1)
Interrupt on exit
AM16705v1
A state is defined by the Sx symbol while a transaction between two states is represented
by a line. A transaction is generated by an event, displayed as text on the line. The event
TIM_Cnt (x) is generated by the timer when it reaches the value configured in State x. An
event (line) represents an event generated by the input line. The inputs associated to
a SMED are defined in Section 4.1.
Each SMED has 3 associated events, marked as event (line) in Figure 5. Each event can
be: type Event_Seq or Event_Jmp. While Event_Seq events push the state machine to the
next sequential state, Event_Jmp allows the state machine to reach any state.
Each state is here described:

IDLE: initial state
This is the SMED initial state. The PWM line is set to 0 to keep the MOSFET OFF.
The next state is S(0) and it is automatically entered when the SMED starts. On
exit: clear timer AND set PWM to ON.

S(0): off-time
This state implements the FOT time and the output PWM line is set at 0 V. S(0)
enters the HOLD state when the SWx bit (event 2) is set to 0 or it goes to S(1) if
the timer reaches the FOT time. The SMED timer is cleared on exit.
Event_Jmp = Hold jump ON = event(2).
Event_Seq = TIM_Cnt.
On exit: clear timer AND set PWM to ON.
DocID026129 Rev 1
17/54
54
SMED implementation

AN4460
S(1): fault zone
This state is used to prevent damages due to an external malfunction (either
a hardware problem or an extreme fluctuation of the input voltage). The PWM
output line is set high during the transaction between S(0) and S(1) and turns the
MOSFET ON, leaving the current flow through the LEDs and the sense resistor. In
normal conditions, the current shouldn't reach the peak during S(1) and the S(2)
timer overflows, pushing the SMED to S(2). The S(1) time is set to be equal 33%
of the total TON state (S(1) + S(2)) maximum time. In exceptional conditions, the
CPPx signal arrives earlier, the S(1) timer expires and the SMED evolves to S(3)
(OCP). CPPx indicates the overcurrent in the circuit. The SMED timer is cleared
on exit.
Event_Jmp = event(1).
Event_Seq = TIM_Cnt.
On exit to S(3): clear SMED timer; set PWM to OFF.
On exit to S(2): do not clear SMED timer; turn ON the PWM output.

S(2): current limit
This state is used to find the current peak in normal conditions. The current peak is
imposed by the voltage configured on the DAC. When the CPPx event is detected,
the SMED advances to the S(0) state. During this state, the output PWM line is
high and the MOSFET is ON. A timer overflow indicates that the current has not
reached the selected peak, for example because the LED string is not attached.
This time is computed by the (66% + 20%)*2 equation 3. On exit, the PWM output
is set to 0 V, switching OFF the MOSFET. The next state is the non-sequential
state S(0).
Event_Jmp = N/A.
Event_Seq = Event(1) OR TIM_Cnt (“and/or” bit guarantees a non-sequential
jump).
On exit to S(0): reset timer, set PWM to 0.

S(3): overcurrent protection
When Event_Jmp is received during state S(1), the SMED has found an OCP
(overcurrent protection) event and goes to S(3). During the transaction, the PWM
output line is set to 0 V in order to turn the MOSFET OFF. The S(3) timer is set to
its maximum value (0x1F0 = 5 µs) to protect the hardware. When the SMED timer
overflows, the SMED advances to sequential S(0) state. The transaction also
generates an internal interrupt and the software can monitor the OCP and stop the
SMED evolution.
Event_Jmp = N/A.
Event_Seq = TIM_Cnt.
On exit to S(0): reset timer, generate SW interrupt.

HOLD S(0)
This state starts from S(1) when the software needs to stop the SMED evolution,
due to the dimming duty cycle OFF time. HOLD is also used when OCP is
detected during S(1). The PWM output line on HOLD state is 0 and the MOSFET
is OFF. When the FW sets the SWx bit to 1, the SMED goes back to S(1).
Note:
18/54
The register associated to the SMED is updated when either the SMED is on HOLD state
(during the dimming off-time) or the output PWM line is zero (S0 state).This approach
guarantees that the PWM output is always set to 0 when the new parameters are applied.
DocID026129 Rev 1
AN4460
4.3
SMED implementation
Input/output signals
The SMED uses the following list of input/output signals and pins:

PWMx: PWM output signal
The signal is fed into the MOSFET's driver input to control the MOSFET's
switching state. The PWM operates according to the TON and TOFF time faced in
Section 2 on page 8. When the PWM is high, the MOSFET is ON and vice versa.
When the supply voltage of the STLUX385A is 5 V, the output signal can be
directly connected to the MOSFET. Instead, when the supply voltage is 3.3 V, the
PM8834 buffer is required.

CPPx: comparator input signal
CPPx receives the current sense signal and compares it to the internal DAC value.
When the voltage on CPPx pin is higher than the DAC value, the output of the
internal analog comparator goes high, and vice versa. The comparator output is
the event(1) internal signal. Event(1) is programmed at level mode so that the
SMED can detect immediately the eventual anomaly during S(1). If edge mode
was used and the anomaly happened outside S(1) then S(1) wouldn't receive the
edge event. There are only two SMED states that check for this event: fault zone
(S1) and current limit (S2).

SWx: software event
Used to start and pause the SMED. When the SMED is paused, the PWM output
has to be set to 0. The SWx event is used during S(0) to pause the SMED and
during HOLD to restart. The event is programmed at level mode and is used by
the software to define the dimming duty cycle period. Thanks to the event mode,
the SW trigger is detected by S(0) even if the SW edge happens while the SMED
is in a different state then S(0). In this case, the SMED completes the cycle,
reaches S(0), captures the SW level and goes on HOLD.

DIGINx: zero current detection
The pin is used for zero current detection while it is in transition mode. At the
moment the transition mode is a proposal and the pin is not managed.

VCOM0
The voltage applied to the pin is read by the STLUX385A ADC and it is used to
compute the TON time and the TOFF time. The voltage is captured 100 ns after the
beginning of the ON portion of the dimming cycle as the current is expected to
reach the correct value.

VLED_PW
The voltage applied to this pin is read by the STLUX385A ADC and is used to
compute the TON time and the TOFF time. It is acquired at the same time of the
VCOM0 voltage using the 8 values, four for VCOM0 and four for VLED_PW interleaved, stored by the ADC in registers ADC_DATH< 7-0 > and ADC_DATL<
7-0>.
DocID026129 Rev 1
19/54
54
SMED implementation
4.4
AN4460
SMED state time evolution
Figure 6 describes the SMED state time evolution. Only one PWM period is illustrated.
Figure 6. SMED state evolution. Timing
PWM
Current limit
Fault OCP
OK
OK
Current
S(4)
33% TON
STATE
IDLE
S(0)
Fixed- off time
S(1)
Fault zone
132% TON +20%
S(2)
Current limit
time
S(0)
Fixed- off time
AM16706v1
The colors identify the case of a correct or incorrect situation:
20/54

The black trace is the output current observed during a correct setup where the SMED
evolution is triggered by timer events only. In this case, no event_Seq or event_Jmp
are received; note that S2 may not have reached the peak level during S(2).

The blue trace represents the situation where the current reaches the limit point
(event_Seq) during S(2).

The red line shows the SMED evolution when an OCP event (event_Jmp) is detected
during S1. The SMED is programmed to generate an interrupt when an OCV condition
happens. The main program receives the interrupt and stops the SMED.
DocID026129 Rev 1
AN4460
5
Firmware implementation
Firmware implementation
The following section offers a view of the firmware implementation. For more details about
the firmware, refer to the source code. The compiled portion of the firmware core is
3.5 Kbyte and the code size is ~12 Kbyte. Most of the code size is allocated to the
debugging machine and general user interface (see Section 7.3 on page 28).
The PWM algorithm and the OCP controls are entirely implemented in the SMED block,
leaving the CPU free for control tasks such as: slow varying algorithmic compensations, the
command line, and interrupt management.
5.1
Dimming algorithm
The dimming algorithm controls the brightness of the LED string by modulating the amount
of time, the LED is switched ON during a ~5 ms period. This period defines the dimming
cycle, which operates with a ~200 Hz frequency. The longer the LED is ON during a single
cycle, the brighter the LED results to human eyes. To turn ON a LED, the algorithm simply
activates the SMED associated by setting the SMED's SWx event to active state.
Once the desired on-time period is passed, the LED is turned OFF and the algorithm waits
for the beginning of the next dimming cycle to turn ON the LED again.
To optimize power, the dimming cycle in channel x is 90 degrees shifted respect to channel
x-1. LED chains can be configured with different on-time length; however the dimming start
period is fixed by design. In this way, the LEDs are always turned ON at different times,
reducing current peaks on the power supply.
The LED on-time is instead a multiple of 20 µs and is based on the STMR timer, which itself
has 1 µs granularity.
The software stores the time-on length in the onoff[8][2]structure, where the first byte
indicates the channel and the PWM action (turn ON or OFF the LED) and the second byte
specifies the time (up to 256 time units = 256 x 20 µs = 5120 µs) before the next event.
The next example shows the activity of LED channels with different dimming on-times:
DIMM1 is active at 87,5%, DIMM2 is active at 25%, DIMM3 is active at 75% and DIMM4 is
active at 37.5%. When the dimming is ON the SMED output PWM is active and the LED
light is ON.
DocID026129 Rev 1
21/54
54
Firmware implementation
AN4460
Figure 7. Dimming channel relation
1/200 Hz = 5 mS
1/200 Hz = 5 mS
DIMM1
DIMM2
DIMM3
DIMM4
time
T8
T0
T2
T4
T6
T0
T2
T4
T6
T0
T2
AM16707v1
5.2
Firmware evolution
The following section describes the software timing characteristics as shown in Figure 8.
Figure 8 shows the relationship between two consecutive STMR_ISR() routines and the
other principal subroutines. The colors define if the routines run in interrupt mode (colored)
or are called from main (black). The PMW1_ON line is the dimming period: when the line is
high, the PWM signal is high too.
Figure 8. FW timeline evolution
1/200 Hz = 5 mS
PWM 1_ON
STMR_ISR()
SMEDx_ISR()
AWU time
ADC_ISR()
Get_Key()
Comp_PWM ()
Comp_DUTY()
time
Not in scale
T0
AM16708v1
The lines are here described:

STMR_ISR(): STMR timer interrupt.
The STMR timer has a granularity of 20 µs (STMR unit). The timer is used to start
and stop the dimming period for each SMED and triggers the SWx bit on the MSC
SMSWEV register. On every interrupt, the timer is reprogrammed so that the next
22/54
DocID026129 Rev 1
AN4460
Firmware implementation
interrupt is received when the next dimming even is required, as specified in the
onoff[][] structure.
When the interrupt routine sets a SMED ON, the startup flag for the ADC delayed
acquisition (using the AWU peripheral) is also set.

SMEDx_ISR(): SMED interrupt
The interrupt is used to stop the SMED when an OCP problem is detected. The
interrupt is generated by a SMED on exit from S3. The SMED is in S3 only if
event(1) is received during S1. The interrupt routines stop the SMED by changing
the SWx bit and giving the fault signal to the main function, which turns on the red
“fault” LED. The SMED is reactivated on its next dimming cycle and if the OCP
problem is not removed then the SMED evolves into S3, triggering the
SMEDx_ISR interrupt again.
Auto-wakeup unit. The auto-wakeup unit is used while the CPU waits for the
current startup and LED voltage settlement time before starting the ADC
acquisition. For a correct FOT implementation the ADC measures the VCOMx
voltage when the PWM is ON and when the VLED has a correct value. This time is
fixed to around 100 µs after the SMED start. When the AWU time expires, the
interrupt starts the ADC channel acquisition.

ADC_ISR(): ADC interrupt
The routine samples, for each channel, VLED_PW and VCOMx, 4 times respectively.
The values are then averaged and stored. The ADC sampling routine occurs 100
µs after the start of the PWM dimming. Should the PWM dimming time be smaller
than 100 µs, the ADC samples incorrect voltage values and therefore the samples
are discarded. This protection (inconsistent voltage protection) is implemented via
the SMED_Active bit.

The interrupt routine uses the adc_eoc flag to inform the main function that the
ADC operation is completed and that new data is available. As a consequence,
the software discards the ADC value. The interrupt routine uses the adc_eoc flag
to inform the main function that the ADC operation is completed and that new data
is available.
Get_Key()

This routine is used to detect if the board buttons are pressed. The STLUX385A
uses the ADC (ADCIN[7], pin 31) to sense the button status. Since the ADC is
used also to read VCOMx and VPWR, a protection is set to avoid conflicts.
Comp_PWM()

It computes the new SMED’s operating parameters as calculated by the adaptive
voltage compensation mechanism.The new values are updated on the SMED
registers only during the next STOP phases (using the upd_flags variable with
UPD_PWMx flags).
Comp_DUTY()
This routine is invoked when the user changes the dimming period. The routine
computes a new dimming period based on the ontime[] structures and stores
the result on tmp_onoff[][] structures. The update is performed at the
beginning of the next dimming period (using the upd_flags variable with
UPD_DUTY flags) and when the dimming is OFF. During the update, the
tmp_off[][] structure is copied into the onoff[][] structure.
The tasks displayed in the previous picture refer to the PWM and dimming control
operations only. The STLUX385A firmware handles other tasks such as the command line,
DocID026129 Rev 1
23/54
54
Firmware implementation
AN4460
which uses two interrupts to read or write characters to the serial line. The serial interrupts
use the lowest priority level among all the other sources (STMR, AWU, SMED and ADC).
5.3
Printf
The STLUX385A firmware implements the standard “printf()” subroutine, which takes
several cycles to expand the printed strings and the operation delay real-time events. It is
suggested the use of “printf” in production code is minimized or removed.
5.4
Low power modes
The STLUX385A may enter low power modes through the instruction WFI (wait for
interrupt), where the internal CPU is stopped until an interrupt is received.
The “wi” console command instruction allows the user to use the WFI instruction (see
Section 7.4.10 on page 33).
The user may implement more aggressive low power schemes via new software routines.
For example, the STLUX385A power consumption efficiency could be increased by
disabling the SMEDs and the 96 MHz PLL while the LED string is completely switched OFF.
24/54
DocID026129 Rev 1
AN4460
6
Protection and regulation algorithm
Protection and regulation algorithm
This section describes the protection and regulation algorithms implemented in the
STLUX385A. Every channel is independent from the others and the same logic applies to all
channels.
The STLUX385A implements software and hardware protections aimed to preserve the
external hardware in case of abnormal events or variations. The STLUX385A doesn't need
external active analog circuitry on the board as the firmware replaces them. Once an error is
recognized, the FW stores the error code and keeps sensing the system to verify that the
problem has been fixed. The error code can be verified typing the “st” command (see
Section 7.4.6 on page 32). Protections can be summarized according to different priority
levels.
6.1
Overcurrent protection
The overcurrent protection (OCP), which preserves the external circuit from damage due to
a component fault, is the most important protection and requires a short detection and
reaction time. The STLUX385A implements OCP directly in the SMED hardware (through
states S1 and S2) and doesn't require any high priority firmware intervention.The internal
SMED clock guarantees a detection time of ~10 ns (Fck_smed = 96 MHz) however the
external circuit response time pushes the overall detection time to 200 ns. When an OCP is
detected, the SMED stops its PWM output and generates an interrupt. The firmware can
then execute the recovery procedure by periodically restarting the PWM line.
6.2
Initial estimation
During the startup phase, the input power voltage is monitored by the Set_check_V()
routine. This routine reads the power voltage (on ADC channel zero) and stores it into the
global variable Vpwr[]. The voltage read back is stored into all channel locations (0 to 3).
The routine Set_check_V() estimates the voltage drop generated by the LEDs by using the
number of LEDs as specified by the user and the maximum and minimum predefined LED
voltage drops. The following formula is used:
Equation 11
wk_Volt  x .Min_vl + wk_Volt  x .Max_vl
------------------------------------------------------------------------------------------------------------2
where x is the LED channel. The estimated voltage drop is used for the initial calculation of
the TOFF and TON values.
6.3
Adaptive voltage compensation
The adaptive compensation is a technique that monitors the system and changes the
operational parameters to guarantee that the configured average current always flows
through the LED. As the average current depends on the TON and TOFF values, the
STLUX385A recalculates the values at the beginning of every dimming ON cycles. The
adaptive compensation is activated with the serial command “au x 1".
DocID026129 Rev 1
25/54
54
Protection and regulation algorithm
AN4460
The Vpwr[x] and Vled[x] voltages are updated by the Check_V() routine on every
dimming cycle. The voltages are read from the corresponding ADC channel 100 µs after the
beginning of the dimming ON phase. This time offset guarantees that the LED are receiving
the correct amount of current.
When the adaptive compensation is inactive, the Vpwr[x] and Vled[x] variables are not
updated and store the voltages updated either during startup or before the compensation is
disabled. When the adaptive compensation is inactive then the user can update the
Vpwr[x] and Vled[x] variables via the serial line (“vp” and “vc” command). The
Check_V() subroutine checks that:

The PWM signal is OFF when the ADC completes the operation; all the ADC readings
are discarded. This situation can happen during an OCP situation where the current
peaks before the 100 µs limit.

The Vpwr[x] voltage is lower than the vmax_50 constant (maximum power voltage). If
it is high, the ERR_MAX_V error flag is set.

The Vpwr[x] voltage is higher than the minimum imposed by the number of LEDs
(wk_Volt[i].Min_vcc). Otherwise the ERR_MIN_L error flag is set.

The common voltage point is higher than the minimum voltage imposed by the
V_COM_MIN constant. The value of V_COM_MIN constant is 2.8 V. Otherwise the
ERR_MIN_L error flag is set.

The voltage across the LED is within the minimum (wk_Volt[i].Min_vl) and
maximum (wk_Volt[i].Max_vl) values defined by the number of LEDs. Should the
voltage across the LED be out of this range, then the ERR_MIN_L error flag is set.
a)
The 100 µs delay is achieved using the auto-wakeup (AWU) feature provided by
the STLUX385A.
b)
Should SMED4 be available and not connected to a LED string, it can be used to
generate the delay for the ADC measurement. This leaves AWU free for other
purposes.
c)
The two voltages Vpw[] and Vled[] are acquired on each dimming ON phase, four
times alternately (CH0, CH1, CH0, CH1, CH0, CH1, CH0, CH1, CH0). The
automatic ADC sequential measurement is a unique STLUX385A feature.
When the compensation is active, the Comp_PWM() routine calculates the TON and TOFF
based on the most recent voltage measurements. Should the resulting frequency be out of
the designed range:

The TON and TOFF values are not updated.

A single conservative TON - TOFF period (TON[max]=3 µs, TOFF = 5 µs) is applied
during the actual dimming ON cycle.

The error ERR_MAX_F or ERR_MIN_F is risen.

The previous TON and TOFF values are applied to the next dimming ON cycle.
From the application point of view, the LED frequency is bounded to this prevent excessive
dissipations or audible noise.
26/54
DocID026129 Rev 1
AN4460
6.4
Protection and regulation algorithm
Software crash protection
A final protection is used to prevent deadlock and software crashes and it's implemented via
the watchdog timer (IWDG). The watchdog is reset in the main function and must be
refreshed at least every 10.4 ms, otherwise the reset signal is internally generated to solve
the lock-up situation. In the current software implementation, the “printf” routine also
refreshes the IWDG timer due to the long time required to process strings.
DocID026129 Rev 1
27/54
54
User interface
AN4460
7
User interface
7.1
Control buttons
The STEVAL-ILL057V1 demonstration board features three buttons, used to manually
change the dimming duty cycle. The buttons can be configured to operate in two different
ways and their behavior is controlled via the “ed” command. Holding a button causes its
action to continue.
Single channel dimming: when the “ed” command is OFF (“ed 0"), the buttons behave as
follows:

“LED CH SEL”: selects a channel. The new selected channel blinks once.

“INC”: increases the dimming duty cycle on the selected channel.

“DEC”: decreases the dimming duty cycle on the selected channel.
Multichannel dimming: when the “ed” command is ON (“ed 1"):

The button “LED CH SEL” is not used.

The button “INC” increases the dimming duty cycle on all channels.

The button “DEC” decreases the dimming duty cycle on all channels.
The three buttons are read by the ADC channel line 7.
7.2
Status LEDs
There are two status LEDs attached to the board:


7.3
Green LED (status): the green LED is active when the input power is correct and the
STLUX385A is running. The LED can also act as a firmware performance monitor and
show the CPU usage. The performance mode is enabled by the “vi” instruction (see
Section 7.3) and the LED toggles as follows:
–
LED ON: CPU running
–
LED OFF: CPU sleeping
Red LED (failure): the red LED is used to report an error or the intervention of
a protection to preserve the hardware. Once the red LED is ON, the only way to clear is
to use the “co” command (see Section 7.3).
Serial interface
This section describes the terminal interface line available on the STLUX385A firmware.
The serial line allows the configuration of the:

Working point of the LED channel

Current level

LED numbers

Dimming percentage
It also allows the device internal status to be inquired.
The STLUX385A command line interface is accessible via a standard terminal utility
installed on the user's PC.
28/54
DocID026129 Rev 1
AN4460
User interface
The serial (TTL 0 - 3.3 V) cable is shipped together with the demonstration board. The onboard connector is identified as UART I/F. The serial line uses only three lines: GND, TX,
RX, the baud rate is 115200, no parity, 8-bit, 1 stop bit, no handshake. The user should
identify the PC COM line number, please refer to your local IT department if the COM
number is difficult to retrieve. The PC also installs the serial COM drivers as soon as the
cable is connected. If the driver is not installed, please call your IT support.
Warning:
The command line executes all the commands entered. The
user has the responsibility to use the correct commands as
per circuitry adopted. For example, should the user configure
1 A current through a 300 mA LED chain, the LEDs could be
damaged.
The STLUX385A, during power-up and reset, sends the following strings to the serial line.
The strings are received and displayed on the console:
Figure 9. Console screen during startup
EVALSTLUX385 - 4chLED VxRx
Build Jan 20 2012 14 : 00 : 44
Ready
AM16709v1
This message is used to verify that the link between the PC and the STLUX385A is up and
that the correct baud rate is selected. The strings “VxRx” report the firmware version and
revision and, on the next line, the time and the date during the compilation process. “Ready”
appears when the STLUX385A chip is ready to receive a command.
At this point, the user can interact with the STLUX385A using one of the following
commands.
Note:
The command list is shown by the “?” command.
DocID026129 Rev 1
29/54
54
User interface
AN4460
Figure 10. “?” command
Monitor channel command
lc [ch] [I]
Setup led current [0 - 10] for channel [ch]
ll [ch] [0; 6 - 256]
Setup led dimming for channel [ch]
ln [ch] [num]
Setup led numbers [3- 10] for channel [ch]
ad [ch]
Get adc channel [0- 7] value
au [ch] [0,1]
Control [ch] loop, 1=en. 0=dis
st
Get status
pw [ch]
Get pwm status on channel [0 - 3]
vp [ch] [0 - 1023]
Simul. POW voltage on channel [0 - 3]
vc [ch] [0 - 1023]
Simul. Common voltage on channel [0 - 3]
wi [0,1]
Enable [1], disable [0] the wfi instruction
dm [add] [len]
dump register/memory
rr [add]
get register/memory
rw [add] [dat]
write register/memory
ed [0,1]
Enable [1] disable [0] global dimming key/cmd
di [value]
Globally dimming the light to [0- 100]%
ti
Get time
co
Clear OVC flag
hl [??]
help cmd [??] string
hl
get help
?
get help
use [enter] to end line, use [backspace] to delete char
AM16710v1
Every command is composed of two parts: the command prefix (normally two characters)
and the command fields. Any incorrect typed character can be changed using the
backspace character.
Each LED channel is identified by the channel (ch) number only (from 0 to 3).
7.4
Commands
The following section describes the commands accessible through the console.
7.4.1
lc - change LED current
The command is used to change the current in the specific LED chain. The configured value
is stored into the E2PROM data area for its read back and applies to next power-on.
Syntax: lc [ch] [I]
Parameters:

ch [0-3]: the LED string channel value.

I [0-10]: current index as shown in Table 1 on page 14. It represents the peak of the
chain current and the index ranges from 0 (273 mA) to 10 (1184 mA).
Output: none
Example: lc 2 3: configures channel 2 to use 492 mA mean current.
30/54
DocID026129 Rev 1
AN4460
7.4.2
User interface
ll - change LED dimming level
To change the LED dimming level, use the “ll” command. The value is stored into the
E2PROM data area for its read back and applies to next power-on.
Syntax: ll [ch] [level]
Parameters:

ch [0-3]: the LED string channel value.

level: [0-256]: indicates the dimming level in a scale from 0 (OFF) to 256 (always ON),
a value between 1 (0.4%) and 255 (99.6%) indicates the dimming level. A value of 256
turns the LED chain on at full brightness (100%). When the global dimming level is
different from 100% (via “ed” and “di” command), the equivalent current on example is
equal to ('level / 256) * (global dimming level).
Output: none
Example: “ll 3 200": sets up channel 3 to use a current equal to 200/256 of the maximum
current defined by the “lc” command.
7.4.3
ln - configure LED number
Used to setup, before connecting any LED, the number of LEDs used in a specified chain.
The value is stored into the E2PROM data area for its read back and applies to next poweron.
Syntax: ln [ch] [num]
Parameters:

ch [0-3]: the channel number.

num [3-10] the number of LEDs. The minimum LED number is 3; the maximum LED
number is 10.
Output: none
Example: “ln 1 6": sets up six LEDs on the channel 1.
7.4.4
ad - read ADC channel
Reads the ADC channel [ch] and displays the result in decimal value.
Syntax: ad [ch]
Parameters:

ch [0-7]: ADC channel number. For the ADC channel association, see the board
schematics.
Output:

The output value is the decimal conversion read from the ADC channel. The value read
from the LED channel (VCOMx point) depends on the dimming level. The correct input
voltage at the STLUX385A pin is given by the ADC value multiplied by 0,001221896
{= (1.25/[(210)-1]}. For channels 0, 1, 2, 3, 4, 6, the ADC value has to be multiplied for
0.05437489.
Example: “ad 0": reads the power line voltage.
DocID026129 Rev 1
31/54
54
User interface
7.4.5
AN4460
au - adaptive voltage compensation
The adaptive voltage compensation (control loop) is used to calculate the new PWM
parameters in relation to the voltage read by the VCOMx or VLED_PW. When the adaptive
voltage compensation is OFF (“au x 0"), the voltage compensation simulation mode is
enabled and the commands vp and vc become available. The value is stored into the
E2PROM data area and applies to next power-on.
Syntax: au [ch] [enable]
Parameters:

ch [0-3]: channel number

enable [0,1]: enables (1) or disables (0) the adaptive voltage compensation.
Output: none
7.4.6
st - verify status
The command reports the STLUX385A status.
Syntax: st
Parameters: none
Output: an example of the output is shown:
Figure 11. “st” command
Status: err=0
Led ch=0 on
Led ch=1 on
Led ch=2 on
Led ch=3 on
cnt=0
di=1:050
l=1 d=010 led=6
l=1 d=020 led=6
l=1 d=210 led=6
l=1 d=0 55 led=6
cur=0
cur=3
cur= 2
cur= 1
Vpw=432 Vcom=80 OVC=off
Vpw=432 Vcom=89 OVC=off
Vpw=429 Vcom=91 OVC=off
Vpw=430 Vcom=94 OVC=off
AM16711v1
The first line reports the last error [err=] and the total number of errors found [cnt=] by the
FW. The [di=] field reports the “ed” status [0 or 1] and the “di” global dimming percentage
(from 0% to 100%). It also reports, for each channel [ch], the channel activation or
deactivation [on or off], the automatic loop status [l=1 or l=0], the dimming level [d=010], the
number of LEDs, the current index and the VLED_PW and VCOMx voltages when the dimming
is ON. The voltage data (VLED_PW and VCOMx) is the raw data read from the ADC. Multiply
by 0.05437489 to convert into a voltage.
7.4.7
pw - PWM status
Syntax: pw [ch]
Parameters:

ch [0-3]: channel number
Output:

32/54
Retrieves the TIM_Cnt values configured in the [ch] channel. The command “pw 0"
output is shown in Figure 12:
DocID026129 Rev 1
AN4460
User interface
Figure 12. “pw” command
Led ch=0 on S0=156 S1=276 S2=939 D=32
AM16712v1
It reports the channel status (ON or OFF) and the TIM_Cnt counters for states S0, S1 and
S2, frozen at the moment when the command is invoked. The counters in S0, S1 and S2 are
based on the 964 MHz clock unit. The command also reports the dimming period (“D = 32").
In this case, the value is the dimming period and starts from 1 (0.4%) and ends to 256
(100%).
7.4.8
vp - set VLED_PW simulated voltage
The command is used during the voltage compensation simulation phase (“au ch 1") to
change the simulated voltage read from the VLED_PW ADC pin. This command is enabled
only when the adaptive voltage compensation is disabled (“au ch 0" command).
Syntax: vp [ch] [voltage]
Parameters:

ch [0-3]: channel number

the parameter represents the new simulated voltage value, expressed as (real voltage /
0.05437489)
Output: none
Example: “vp 0 590": simulates the power voltage at 32.08 volt.
7.4.9
vc - set VCOMx simulated voltage
The command is used during the voltage compensation simulation phase (“au ch 1") to
change the simulated voltage read from the VCOMx ADC pin. This command is enabled only
when the adaptive voltage compensation is disabled (“au ch 0" command).
Syntax: vc [ch] [voltage]
Parameters:

ch [0-3]: channel number

voltage [0-1023]: same as the “vp” command
Output: none
7.4.10
wi - CPU load monitor and low power mode
The command enables the CPU load monitor where the CPU load can be observed via the
green LED on the demonstration board. The command also enables the STLUX385A low
power mode by using the WFI (wait for interrupt) instruction when idle. The “wi” command is
used to reduce the power consumption of the STLUX385A.
7.4.11
dm - dump memory
It displays the memory content of a specific area of memory.
Syntax: dm [add] [len]
DocID026129 Rev 1
33/54
54
User interface
AN4460
Parameters:

add: the memory address. It is possible to use a hexadecimal value using the “0x”
prefix. The total memory area available on the STLUX385A is 64 Kbyte.

len: total length of memory to be retrieved, in bytes. “0x” can be used as prefix for
a hexadecimal number.
Output:

7.4.12
The memory content starting from [add] address and [len] bytes long.
rr - read memory, single byte
The command reads and displays the specified byte of memory.
Syntax: rr [add]
Parameters:

add: the memory address. It is possible to use a hexadecimal value using the “0x”
prefix. The total memory area available on the STLUX385A is 64 Kbyte.
Output: the byte located at [add] address
7.4.13
rw - write memory, single byte
The command writes a single byte of memory. The incorrect use of this command could
overwrite internal registers and change the behavior of the device and could cause the
destruction of the demonstration board.
Syntax: rw [add] [dat]
Parameters:

add: the memory location to write. It is possible to use a hexadecimal value using the
“0x” prefix. The total memory area available on the STLUX385A is 64 Kbyte.

dat: the byte to be written. It is possible to use a hexadecimal value using the “0x”
prefix.
Output: none
7.4.14
ed - enable global dimming function
It enables or disables the global dimming function. When the function is enabled, the “di”
command applies to all channels. At the same time, the “+” and “-” buttons operate in global
dimming mode. When the function is disabled, the “di” command is disabled and the LED
dimming can only be changed via the “ll” command. Besides, the “+” and “-” buttons control
a single channel. The [ed] value is stored into the E2PROM data area for its read back at the
next power-on. On reset, should “ed” be enabled, the last “ll” dimming value is not applied
immediately but with a gradual light increment (from 0% to the “ll” value).
Syntax: ed [enable]
Parameters:

enable [0,1]: enables or disables the global dimming function.
Output: none
34/54
DocID026129 Rev 1
AN4460
7.4.15
User interface
di - set global dimming value
It sets the dimming of the LED strings to be used when the board is operating in global
dimming mode (“ed 1"). At power-on the “di” value applied is 100 (equal to 100%) after
a ramp-up period only if “ed” command is enabled.
Syntax: di [value]
Parameters:

value [0,100]: the percentage of the value configured with the “ll” command. The global
dimming is applied to all channels.
Output: none
Example: “ll 0 220", “di 50". Channel 0 is dimmed at 220 at 50% = 110. All other channels
are dimmed at 50% of the their current dimming value.
7.4.16
ti - read time counter
It retrieves the time since the last power-up or reset.
Syntax: ti
Parameters: none
Figure 13. Console screen for “ti” command
Time is 0x00000098: 7d
AM16713v1
Output: the time counter, in hexadecimal.
The output is composed of two parts, separated by the comma sign. The first part shows the
number of seconds elapsed since power-on or reset. The second part is the tick: a number
from 0 to 191 (in hex: 0x00 to 0xBF) that represents the number of dimming period elapsed.
One dimming period is exactly 5.1813 ms (193 Hz).
7.4.17
co - clear error
It clears any system error. This command clears (“off”) the error code, removes the OCP flag
monitored by the “st” command and switches OFF the fault LED. The command does not
clear the error counter tracked by the “st” command. The fault LED may remain switched
ON after the “co” command if the cause of error has not been removed.
Syntax: co
Parameters: none
7.4.18
hl - command help
It visualizes a brief description of the command selected.
Syntax: hl [command]
Parameters:

command: a terminal command
Output: the description of the command selected.
DocID026129 Rev 1
35/54
54
User interface
7.4.19
AN4460
hl - ? - global help
It displays a list of all accepted commands.
Syntax:

hl

?
Parameter: none
Output: the list of all accepted commands.
7.5
Error codes
The STLUX385A firmware performs several system checks during its execution. When an
error is found:
1.
The red fault LED is triggered.
2.
The error counter is incremented.
3.
The error code is stored in an internal variable. The last error code is reported by the
status command (“st”).
The fault LED can only be reset via the “co” command. The “co” command also clears the
error code. The error counter is never reset.
Table 3 describes the error codes:
Table 3. Error codes
Code
Mnemonic
0
ERR_NO_ERR
1
ERR_PW
2
ERR_MAX_F
PWM frequency is over the limit
N/A
3
ERR_MIN_F
PWM frequency is under the limit
N/A
4
ERR_FLASH
Error while writing in Flash
5
ERR_OVC
6
ERR_MAX_V
Main input voltage over the upper limit (50 V)
7
ERR_MIN_V
Main input voltage too low to drive the configured number
of LEDs.
N/A
8
ERR_MIN_L
Power voltage across the inductance lower the limit (lower
than 2.8 V)
Dimming OFF
9
ERR_MAX_L
LED voltage over the maximum.
N/A
10
ERR_MIN_D
Number of LEDs below the limit (< 3 LEDs)
N/A
11
ERR_VOL_L
LED voltage drop below the minimum
N/A
12
ERR_DALI
Failure on the DALI I/F – only when DALI FW is enabled
36/54
Meaning
No error
Action
N/A
Power voltage under or upper the limit at power-on
Overcurrent protection (OCP). Preventing short-circuit or
overcurrent point
DocID026129 Rev 1
Dimming OFF
The last serial command is
not stored into E2PROM
Dimming OFF
v
DALI error
AN4460
8
Measurements
Measurements
This section reports several measurement results validating the STEVAL-ILL057V1
demonstration board performance.
8.1
Output current precision for different current setup
Figure 14 shows the current flow through the LEDs, measured with a current probe on all
four channels. The operating current of all channels is the point 0 in Table 1 on page 14
(245 mA mean). Note the channel has delayed startup point and the current precision on all
channels displayed. R1 is channel zero, R2 is channel two, R3 is channel three and 3 is
channel four. The dimming periods, same for all channels, is ~5 ms (193 Hz).
Figure 14. Current regulation - 4 channels at 245 mA
AM16714v1
Figure 15 represents the different current regulation on the same channel and at the same
dimming level. The current has changed using the “lc” command using, as second
parameter, the index of the expected current. The vertical grid resolution is 100 mA/div. See
Table 1 on page 14 for the index and current relation.
DocID026129 Rev 1
37/54
54
Measurements
AN4460
Figure 15. Current regulation - the same channels, different current setup
AM16715v1
Figure 16 shows a single channel with different dimming levels. The dimming values are:
R1 = 20 units (7.8%); R2 = 50 units (19.5%); R3 = 150 units (58.6%); R4 = 200 units
(78.1%); 3 = 255 units (99.6%). The OFF phase of the 3 line is equal to one dimming unit
corresponding to 1/256 parts of 5,12 ms (~20 µs).
Figure 16. Current regulation - the same channels, different dimming
AM16716v1
38/54
DocID026129 Rev 1
AN4460
8.2
Measurements
Efficiency according to different current setup
Table 4 shows the efficiency reached based on different number of LEDs. All 4 channels are
using the same current. The measure reports the minimum, average and maximum
efficiency for a configured fixed current on all input power voltage range. The current is
calculated based on Table 1 on page 14.
The plots use “y” axis representing the efficiency, expressed as a percentage.
The board configuration is with the LED always ON (“ll x 256" and, if “ed” is enabled, “di
100").
The best efficiency value measure is 98%. Since the board is designed to be “generic” and
supports a wide range of configurations (LED numbers, power voltage range, etc.) the
efficiency reaches 85% in some cases.
The input board power when the PWM outputs are disabled (the LED strings are OFF) is
~300 mW at 12 V and ~600 mW at 48 V.
Table 4. Efficiency according to different current when the input voltage changes
Plot
index
Average current
Efficiency
3 LEDs
6 LEDs
10 LEDs
Min.
Mean
Max.
Min.
Mean
Max.
Min.
Mean
Max.
1
245 mA (lc x 0)
92.8
93.4
94.5
92.5
94.2
95.8
96.0
97.3
98.5
2
329 mA (lc x 1)
92.1
92.6
94.1
93.7
95.0
96.5
95.5
96.0
96.5
3
492 mA (lc x 3)
91.1
91.6
92.1
94.4
95.1
96.1
95.9
96.0
96.2
4
738 mA (lc x 6)
89.2
89.5
89.9
94.1
94.8
95.2
95.3
95.4
95.5
5
1.065A (lc x 10)
84.9
85.1
85.4
92.3
92.8
93.1
93.4
93.9
94.1
Figure 17. String efficiency based on different current levels - 3 LEDs for each string
96.0
3 LED max.
94.0
3 LED mean
92.0
3 LED min.
90.0
88.0
86.0
84.0
82.0
1
2
3
DocID026129 Rev 1
4
5
AM16717v1
39/54
54
Measurements
AN4460
Figure 18. String efficiency based on different current levels - 6 LEDs for each string
97.0
6 LED max.
96.0
6 LED mean
95.0
6 LED min.
94.0
93.0
92.0
91.0
90.0
1
2
3
4
5
AM16718v1
Figure 19. String efficiency based on different current levels - 10 LEDs each string
99.0
10 LED max.
98.0
10 LED mean
97.0
10 LED min.
96.0
95.0
94.0
93.0
92.0
91.0
90.0
1
40/54
2
DocID026129 Rev 1
3
4
5
AM16719v1
AN4460
8.3
Measurements
Current regulation on input voltage
From Figure 20 to Figure 22 show the current regulation in relation to the input power
voltage. The plots report the current on the “y” axis and the voltage on the “x” axis. The input
power voltage in every figure is the effective voltage range only for the number of LEDs
selected.
Figure 20. Current regulation vs. VPW_LED: 3 LEDs
1.200
1.000
0.800
1.065A
738mA
0.600
492mA
329mA
0.400
254mA
0.200
0.000
13V
16V
20V
24V
28V
32V
36V
40V
44V
48V
AM16720v1
Figure 21. Current regulation vs. VPW_LED: 6 LEDs
1.2
1
1.065A
0.8
738mA
492mA
0.6
329mA
0.4
254mA
0.2
0
12V
16V
20V
24V
28V
32V
36V
40V
44V
48V
AM16721v1
DocID026129 Rev 1
41/54
54
Measurements
AN4460
Figure 22. Current regulation vs. VPW_LED: 10 LEDs
1.2
1
1.065A
0.8
738mA
492mA
0.6
329mA
0.4
254mA
0.2
0
13V
16V
20V
24V
28V
32V
36V
40V
44V
48V
AM16722v1
8.4
Current regulation validation
Table 5 compares the real current values, as captured by the oscilloscope, with the
expected ones as configured by the user. The input power voltage is fixed and set at the
middle of the usable range. The current is the mathematical average current (not the peak
current) as got and calculated by the scope.
Table 5. Current regulation discrepancies
42/54
Command
3 LEDs – 20 V
6 LEDs – 32 V
10 LEDs – 44 V
Expected
lc x 0
0.251 A
0.254 A
0.255 A
0.245 A
lc x 1
0.329 A
0.333 A
0.333 A
0.329 A
lc x 2
0.407 A
0.414 A
0.413 A
0.410 A
lc x 3
0.486 A
0.493 A
0.492 A
0.492 A
lc x 4
0.563 A
0.571 A
0.570 A
0.574 A
lc x 5
0.639 A
0.647 A
0.646 A
0.648 A
lc x 6
0.715 A
0.725 A
0.724 A
0.738 A
lc x 7
0.791 A
0.802 A
0.800 A
0.819 A
lc x 8
0.867 A
0.879 A
0.877 A
0.901 A
lc x 9
0.943 A
0.957 A
0.955 A
0.984 A
lc x 10
1.016 A
1.031 A
1.030 A
1.065 A
DocID026129 Rev 1
AN4460
8.5
Measurements
OCP protection time
Figure 23, Figure 24 and Figure 25 show the current protection reaction time. The current
working point is fixed at 245 mA in the first plot, at 738 mA in the second and at the
maximum current (1.065 A) in the third. In all pictures, the blue track (2) shows the MOSFET
gate signal while the purple track (3) displays the output current when the output is shorted.
The cycle starts every 5.12 ms.
Figure 23. MOSFET gate during short-circuit - 245 mA
Figure 24. MOSFET gate during short-circuit - 738 mA
DocID026129 Rev 1
43/54
54
Measurements
AN4460
Figure 25. MOSFET gate during short-circuit - 1.065 A
44/54
DocID026129 Rev 1
AN4460
9
Pinout
Pinout
Table 6 describes the STLUX385A pinout and the associated function.
Table 6. STLUX385A pinout
Pin
Dir.
Function
Note
1
OUT
PWM[0]
2
OUT/IN
DIGIN[0]/CCO_clk
3
IN
DIGIN[1]
DIG1
4
OUT
PWM[1]
PWM - LED chain 1
5
OUT
PWM[2]
PWM - LED chain 2
6
IN
DIGIN[2]
DIG0
7
IN
DIGIN[3]
DIG3
8
OUT
PWM[5]
Output to R/C – voltage reference on CPM3 (LED0) – (optional)
9
I/O
SWIM
10
I/O
RESETn
11
PS
VDD
Power to 3.3 V or 5 V
12
PS
VSS
Digital GND
13
PS
VOUT
14
OUT
LED (red)
15
OUT
LED (green)
Normal signaling (blink) or DALI RX line
16
OUT
PWM[4]
Option – PWM for the DC-DC converter
17
IN
DIGIN[4]
DIG2
18
IN
DIGIN[5]
Not used or DALI key input (option)
19
OUT
PWM[3]
PWM - LED chain 3
20
OSC_out
External oscillator or FW trigger used to debug application
21
OSC_in
External oscillator or FW trigger used to debug application
PWM - LED chain 0
Internal clock check output – (option)
Debug interfaces
To reset key and debug I/F
Filter capacitance for 1.8 V internal voltage
Fault signaling or DALI TX line
22
OUT
UART TX
Serial TX line
23
IN
UART RX
Serial RX line
24
A-IN
CPP3
Compare 3 – LED chain 0
25
A-IN
CPP2
Compare 2 – LED chain 1
26
A-IN
CPM3
Connect to PWM[5] – chain 0 current (5 mA/step) – (option)
27
A-IN
CPP1
Compare 1 – LED chain 3
28
A-IN
CPP0
Compare 0 – LED chain 2
29
PS
VDDA
Analog power supply
30
PS
VSSA
Analog ground
31
A-IN
ADCIN[7]
Key input – voltage depends whether key is pressed or not
DocID026129 Rev 1
45/54
54
Pinout
AN4460
Table 6. STLUX385A pinout (continued)
Pin
Dir.
Function
32
A-IN
ADCIN[6]
External dimming signal – 0 -10 V equal to 0% 100% – (option)
33
A-IN
ADCIN[5]
Not used
34
A-IN
ADCIN[4]
Analog input CH4 – VCOM3 – voltage from LED3 chain
35
A-IN
ADCIN[3]
Analog input CH3 – VCOM2 – voltage from LED2 chain
36
A-IN
ADCIN[2]
Analog input CH2 – VCOM1 – voltage from LED1 chain
37
A-IN
ADCIN[1]
Analog input CH1 – VCOM0 – voltage from LED0 chain
38
A-IN
ADCIN[0]
Analog input CH0 – ADCIN0 – voltage on VLED_PW signal (VIN)
Note:
46/54
Note
When the DALI I/F is used, please remove the R78, R77 resistor (lose RUN-FAULT
function), enable the “USE_DALI” constant on the “led.h” source file, recompile and load the
new code.To request the source code for the DALI stack, please contact your local ST
representative. The STEVAL-ILM001V1 kit gives access to the DALI hardware interface.
DocID026129 Rev 1
6WDWXV
9&&
9&&
5
5
5
6:,0
5
5
.
.
8$57,)
-
'
)$8/7
581
'
5
8$57B5;
*1'
8$57B7;
*5((1
5('
*1'
8$57B7;
8$57B5;
86%WR8$5777/ 9
-
*1'
5
5
*1'
9&&
*1'
*1'
5(6Q
5
5
9&&
5
'$/,B7;
'$/,B5;
'$/,B7;
73
8$57B7; 8$57B5; 3:0
3:0
3:0
3:0
3:0
3:0
X)
*1'
&
Q)
9&&
'$/,,)
-
*1'
67/8;$
'$/,B5;
*1'
.(<B'$/,
*1'
3
/('&+6(/
.
5
*1'*1'
3
,1&
63
$'&,1>@
$'&,1>@
$'&,1>@
$'&,1>@
$'&,1>@
$'&,1>@
$'&,1>@
$'&,1>@
&33>@
&33>@
&03
&33>@
&33>@
',*,1>@&&2BFON
',*,1>@
',*,1>@
',*,1>@
',*,1>@
',*,1>@
9&&$
*1'
*3,2>@8$57B7;
*3,2>@8$57B5;
*3,2>@,&BVGD+6(2VF2XW
*3,2>@,&BVFO+6(2VF,Q
*3,2>@'$/,BW[
*3,2>@'$/,BU[
*3,2>@3:0>@
*3,2>@3:0>@
*3,2>@3:0>@
*3,2>@3:0>@
*3,2>@3:0>@
*3,2>@3:0>@
6:,0
1567
9287
8
*1'
&
Q)
'$/,,)XVLQJ67(9$/,/09
5
5HPRYH5ZKHQ
XVH'$/,,)
5
5
73
73
&
&
Q)
*1'
6:,0
&
Q)
; 0+]10
& S10
& S10
*1'
+6(0+]
12786('
*1'
6:,0,)
-
6:,0,)
5
.
10
X)
9
&
9'',2
*1',2
9''$
*1'$
9&&
1HDUWKHSRZHUSLQ
:(&%)
56
9&&$
.
5
*1'*1'
*1'
3
'(&
*1'*1'
7LWOH
*1'
.
.
.
5
9&&
*1'
5
73
73
:(&%) &33
:(&%) &33
:(&%) &33
:(&%) &33
9.(<
9.(<
63
63
9/('
9/('
9/('
9/('
$'&,1
5 .
/
/
/
/
5
73
73
73
73
73
&33WRPRQLWRU/('FKDLQFXUUHQW
95(*B9&&
',*
',*
',*
',*
.(<B'$/,
5(6(7
3
*1'
&
Q)
73
73
73
73
$OO73LVD60'7HVW3RLQW
([FHSW73RQ*1'DQG32:(5
&&2RXWSXWWR73WHVWSXUSRVH
/
9&&
9&&LV9
DocID026129 Rev 1
*1'
9&&
.
5
3:0
3:0
3:0
3:0
*1'
5(6Q
&
Q)
3RZHU
3RZHU
.
/HG&KDLQ
5
.
10
5
3:0
3:0
3:0
3:0
/HG&KDLQ
3:0
63
*1'
5
.
5
.
5
$'&,1
/('B3:
/('B3:
&33
&33
&33
&33
9/('
9/('
9/('
9/('
',*
',*
',*
',*
$0Y
*1'
-
',00,1*9
.
$'&,1
/'B3:
&33
&33
&33
&33
9/('
9/('
9/('
9/('
',*
',*
',*
',*
10
AN4460
Schematic diagrams
Schematic diagrams
Figure 26. Schematic - STLUX385A - top
47/54
54
48/54
&33
DocID026129 Rev 1
.+]
*1'
*1'
5
.
&
Q)
5
*1'
1
5
10
9/('
',*
*1'
8
*1'
9/('
&
Q)
9&&$
9/('
/09,/7 10
9&&$
',*
&XW )UHT
*1'
&
Q)
5
.+]
5
5
5
:
5
*1'
5
:
5
4
6711)/
*1'
*1'
5
.
10
6736=
56
'
5
.
10
6736=
56
'
*1'
&
Q)
5
*1'
' //
*$7(B3:0
IURP P$ WR $
P$ VWHS
*1'
X+
$VDW
/
'
*1'
*1'
&
Q)
5
6736+$
56
//
5
.
5
.
*1'
5
.
&
-
&+
5
10
Q)
9
&
5
10
Q)
9
&
Q)
5
5
*1'
1
4
5
.
-
&+
&
Q)
5
5
*1'
5
.
5
.
1
4
*1'
*1'
5
.
*1'
*1'
8
',*
/('B3:
&
Q)
9/('
$0Y
*1'
9/('
&
Q)
9&&$
9/('
/09,/7 10
8
',*
/('B3:
*1'
9&&$
9/('
/09,/7 10
9&&$
X)
9
&
*1'
9/('
',*
9&&$
X)
9
&
*1'
9/('
',*
*1'
&
Q)
4
5
&33
75$&. +LJK
LPSHGHQFH SURWHFW
WR 6:
FX UUHQW
&33
5
' //
*$7(B3:0
10
*1'
*$7(B3:0
*1'
'
*$7(B3:0
'
6736+$
56
73
73
IURP P$ WR $
P$ VWHS
*1'
&XW )UHT
5
5
.
73
73
5
:
*1'
5
5
:
IURP P$ WR $
P$ VWHS
*1'
X+
$VDW
/
4
6711)/
9'B
*$7(B3:0
5
5
:
*1'
/('B3:
*1'
9/('
&
Q)
9&&$
9/('
.+]
*$7(B3:0
5
:
*1'
5
X)
9
&
*1'
8
&XW )UHT
*1'
5
Q)
9
/09,/7 10
9&&$
',*
&
Q)
5
5
10
287
9&&
5
5
.
&
6736=
56
'
4
6711)/
-
&+
9/('
',*
5
5
5
3:0
(1
287
X+
$VDW
/
*1'
5
10
*$7(B3:0
&33
75$&. +LJK
LPSHGHQFH SURWHFW
WR 6:
FX UUHQW
&33
/('B3:
*1'
3:0
(1
&
Q)
5
6736+$
56
*1'
*1'
5
.
&
Q)
5
5
*1'
X)
9
&
'
*1'
&
Q)
5
.
1
4
Q)
9
/('B3:
*1'
//
'
*$7(B3:0
10
5
.
5
.
&
3:0
3:0
5
5
*1'
)URP P$ WR $
P$ VWHS
*1'
5
6736=
56
'
-
&+
3:0
3:0
75$&. +LJK
LPSHGHQFH SURWHFW
WR 6:
FXU U HQW
&33
*$7(B3:0
.+]
5
:
5
:
&XW )UHT
*1'
*1'
5
*1'
5
5
X+
$VDW
/
4
6711)/
'
*1'
6736+$
56
73
73
10
&
Q)
9'B
*$7(B3:0
*$7(B3:0
5
10
287
9&&
5
5
3:0
(1
287
8
30
5
&33
5
*1'
3:0
(1
&
Q)
9'B
75$&. +LJK
LPSHGHQFH SURWHFW
WR 6:
FX UUHQW
*1'
&
Q)
9'B
*$7(B3:0
3:0
3:0
10
&33
3:0
3:0
8
30
5
Schematic diagrams
AN4460
Figure 27. Schematic - 4 channel LED driver
DocID026129 Rev 1
*1'
&
Q)
*1'
*1'
5
.
/09,/710
8
5
*1'
&
Q)
9&&$
$&',1
$'&,1
5
.
(1
9'B
*1'
.
5
676
'.1'
)%
6:
Q)
&
6+'1
9,1
8
*1'
5
.
5
.
*1'
*1'
*1'
&
S)
&
Q)
56
%<3$66
287
/.075
'
6736/8
56
X+
56
$,VDWRKP
/
9&&$
5
*1'
&
Q)
9
(1
(1
%227
*1'
5
.
5
.
*1'
X)
9
9&&$
X)
9
&
3*22'
&
*1'
&
Q)
9
9,1
8
&
Q)
*1'
%=9&9
9:
'
*1'
:(&%)
56
/
5
:
*1'
/('B3:
(;3B3$'
/('B3:
*1'
5
$3&%75$.
9&&
-
&21132/,
X)
9
&
/('B3:
&
Q)
9&&
9
X)
9 *1'
&
9'B
$09
&
Q)
P$PD[
9RXWSXW
AN4460
Schematic diagrams
Figure 28. Schematic power section
49/54
54
Bill of material
11
AN4460
Bill of material
Table 7. Bill of material
Item
Quantity
References
Part value
Package and
supplier code
Notes
1
2
C1, C4
1 F
CAPC-0603
10 V
2
4
C2, C8, C43, C45
10 nF
CAPC-0603
3
8
C3, C19, C20, C31, C32, C40,
C44, 46
100 nF
CAPC-0603
4
2
C5, C6
12 pF - N.M.
CAPC-0603
5
1
C7
4.7 nF
CAPC-0603
6
4
C9, C11, C21, C23
10 nF
CAPC-1206
100 V
7
4
C10, C12, C22, C24
1 F
CAPC-1206
100 V
8
4
C13, C14, C25, C26
1 nF
CAPC-0603
9
8
C15, C16, C17, C18, C27, C28,
C29, C30
10 nF
CAPC-0603
10
6
C33, C38, C42, C47, C48, C49
100 nF
CAPC-0603
25 V
11
2
C34, C37
100 nF
CAPC-1206
100 V
12
1
C35
150 pF
CAPC-0805
25 V
13
1
C36
22 F
D250P100
100 V
14
1
C39
150 F
CAPC-7343
16 V
15
1
C41
10 F
V-3216
10 V
16
1
C50
47F
CAP-AXP1000D400
100 V
17
1
D1
Fault
LEDC-0603
18
1
D2
Run
LEDC-0603
19
4
D3, D4, D9, D10
STPS2H100A
SMA
20
4
D5, D6, D11, D12
STPS0560Z
SOD123
21
4
D7, D8, D13, D14
LL4148
SOD80-ST
22
1
D15
BZV85-C51V
DO41
23
1
D16
STPS3L60U
SMB
24
1
J1
SWIM I/F
4-pin-pitch 2.54
25
1
J2
DALI I/F
Pin 2x6 pitch 2.54
26
1
J3
UART I/F - TTL
3-pin-pitch 2.54
27
1
J4
UART I/F
JACK-3_535RASMT2BHNTRX
28
1
J5
CH2
2-way connector
WAGO-250-402
50/54
DocID026129 Rev 1
Not mounted
51 V 1.3 W
AN4460
Bill of material
Table 7. Bill of material (continued)
Item
Quantity
References
Part value
Package and
supplier code
29
1
J6
CH0
2-way connector
WAGO-250-402
30
1
J7
CH3
2-way connector
WAGO-250-402
31
1
J8
CH1
2-way connector
WAGO-250-402
32
1
J9
2-way connector
2-way connector
WAGO-236-402
33
1
J11
Dimming 0 - 10 V
2-pin-pitch 2.54
34
2
L1, L7
WE-CBF
CAPC-0603
35
4
L2, L3, L4, L5
470 H
DS5022P-Coilcraft
36
1
L6
8,5 H
ELL4GG
Panasonic
37
4
L8, L9, L10, L11
WE-CBF
CAPC-0603
38
1
P1
RESET
EVQPSM
Panasonic
39
1
P2
LED CH SEL
SMD-SWITCH-B3FS
40
1
P3
INC
SMD-SWITCH-B3FS
41
1
P4
DEC
SMD-SWITCH-B3FS
42
4
Q1, Q2, Q5, Q6
STN3NF06L
SOT223
43
4
Q3, Q4, Q7, Q8
2N7002
SOT23
44
10
R1, R2, R3, R9, R77, R34, R35,
R56, R57, R68, R78
0
RESC-0603
45
1
R4
15 K
RESC-0603
46
1
R5
4.7 K
RESC-0603
47
2
R6, R7
1 K
RESC-0603
48
1
R8
51.1 K
RESC-0603
49
1
R10
3.3 K
RESC-0603
50
1
R11
47 K
RESC-0603
51
2
R12, R73
100 K
RESC-0603
52
1
R13
27 K
RESC-0603
53
8
R14, R15, R16, R17, R32, R33,
R54, R55
N. M.
RESC-0603
54
12
R18, R19, R24, R25, R40, R41,
R46, R47, R67, R69, R72, R75
26.1 K
RESC-0603
55
4
R20, R21, R42, R43
10 
RESC-0603
56
4
R22, R23, R44, R45
160 
RESC-0603
DocID026129 Rev 1
Notes
1.2 A sat.
Not mounted
51/54
54
Bill of material
AN4460
Table 7. Bill of material (continued)
Item
Quantity
References
Part value
Package and
supplier code
Notes
57
8
R26, R27, R28, R29, R48, R49,
R50, R51
1.8 
R2512
1 W 1%
58
4
R30, R31, R52, R53
N.M.
RESC-0805
Not mounted
59
6
R36, R37, R58, R59, R70, R76
1.2 K
RESC-0603
60
4
R38, R39, R60, R61
5.1 K
RESC-0603
61
1
R62
10 
R700DIAM100
62
1
R63
18 K
RESC-0805
63
2
R64, R66
10 K
RESC-0805
64
1
R65
2.7 K
RESC-0805
65
2
R71, R74
100 K
RESC-0603
66
1
U1
STMLUX38
TSSOP38
67
2
U2, U3
PM8834
SOI8
68
5
U4, U5, U6, U7, U10
LMV321ILT
SOT23-5L
69
1
U8
ST1S14
SO8-EP-9
70
1
U9
LK112M33TR
SOT23-5L
71
1
X1
16 MHz - N.M.
X32-3_2x2_5-MEC
52/54
DocID026129 Rev 1
1W
Not mounted
Not mounted
Not mounted
AN4460
12
Revision history
Revision history
Table 8. Document revision history
Date
Revision
17-Apr-2014
1
Changes
Initial release.
DocID026129 Rev 1
53/54
54
AN4460
Please Read Carefully:
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
ST PRODUCTS ARE NOT DESIGNED OR AUTHORIZED FOR USE IN: (A) SAFETY CRITICAL APPLICATIONS SUCH AS LIFE
SUPPORTING, ACTIVE IMPLANTED DEVICES OR SYSTEMS WITH PRODUCT FUNCTIONAL SAFETY REQUIREMENTS; (B)
AERONAUTIC APPLICATIONS; (C) AUTOMOTIVE APPLICATIONS OR ENVIRONMENTS, AND/OR (D) AEROSPACE APPLICATIONS
OR ENVIRONMENTS. WHERE ST PRODUCTS ARE NOT DESIGNED FOR SUCH USE, THE PURCHASER SHALL USE PRODUCTS AT
PURCHASER’S SOLE RISK, EVEN IF ST HAS BEEN INFORMED IN WRITING OF SUCH USAGE, UNLESS A PRODUCT IS
EXPRESSLY DESIGNATED BY ST AS BEING INTENDED FOR “AUTOMOTIVE, AUTOMOTIVE SAFETY OR MEDICAL” INDUSTRY
DOMAINS ACCORDING TO ST PRODUCT DESIGN SPECIFICATIONS. PRODUCTS FORMALLY ESCC, QML OR JAN QUALIFIED ARE
DEEMED SUITABLE FOR USE IN AEROSPACE BY THE CORRESPONDING GOVERNMENTAL AGENCY.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.
© 2014 STMicroelectronics - All rights reserved
STMicroelectronics group of companies
Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America
www.st.com
54/54
DocID026129 Rev 1
Similar pages