UM1632
User manual
STM8L DALI slave interface
Introduction
This document describes the implementation of the Digital Addressable Lighting Interface
(DALI) in the STM8L 8-bit microcontroller family.
The DALI slave library for STM8L microcontrollers simplifies integration of the DALI slave
interface into customer applications. The implementation of DALI in STM8L, together with
the various STM8L features (peripherals, computation power, communication interfaces), is
mainly used in light control applications (example, electronic ballast control).
The STM8L DALI slave library was tested according to the DALI specification and comes
with a simple application example (DALI slave device), which was designed (and tested) for
use with the following evaluation boards:
•
STM8L1526-EVAL
•
DALI transceiver board (see UM1032: STEVAL-ILM001V1 hardware module)
The application example controls the light of the on-board LED diode. Light intensity is
controlled by the PWM method using a built-in timer. The external DALI master device must
control this application example (DALI slave device).
The DALI master devices were tested using the ST7DALI evaluation kit (master device
board and PC software).
Useful information and links regarding the DALI interface can be found on http://www.dali-
ag.org.
June 2014
DocID024513 Rev 1
1/32
www.st.com
Contents
UM1632
Contents
1
DALI information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1
DALI standard overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.1
1.1.2
1.1.3
DALI purpose and properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
DALI physical layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
DALI stack layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2
STM8L DALI slave library overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2
Structure of final user application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1
2.2
User application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
I/O pin driver layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3
Function description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1
I/O pin driver layer functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.1
3.1.2
STM8l15x_it.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
DALIslave.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2
DALI stack layer functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
3.2.6
3.2.7
dali.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
dali_cmd.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
dali_pub.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
dali_reg.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
eeprom.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
lite_timer_8bit.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
dali_config.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4
5
6
Application setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Application description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Running the PC software for DALI-STM8L . . . . . . . . . . . . . . . . . . . . . . 26
6.1
6.2
Basic commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Light level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
7
8
2/32
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
DocID024513 Rev 1
UM1632
DALI information
1
1.1
DALI information
DALI standard overview
DALI is an international standard (IEC 62386) lighting control system that provides a single
interface for electronic control gear (light sources) and devices (lighting controllers).
The DALI standard enables dimmable ballasts, transformers, relay modules, emergency
fittings and controllers from different manufacturers to be mixed and matched into a single
control system. A DALI system provides designers, installers, building owners, facility
managers and end-users with a powerful and flexible digital lighting system, with security of
supply from many sources.
The DALI standard is overseen by the “AG-DALI” activity group, which comprises
engineers, manufacturers and institutions working in the field of digital lamp/ lighting control.
More information about the DALI standard can be found in the following documents:
•
•
IEC 62386
NEMA STANDARD 243-2004
The following sections provide an overview of the DALI standard. They describe the basic
principles of the DALI interface.
Note:
To better understand the STM8L DALI slave library, knowledge of the DALI interface
specification is essential. This document does not provide a description of this specification.
1.1.1
DALI purpose and properties
The DALI protocol was designed to control modern light sources using a computer.
Functions include:
•
•
•
•
Dimming
ON/OFF switching
Grouping lights to a common control
Scene storage and selection
The DALI design properties include:
•
•
•
•
•
•
Simple wiring using standard electrical installation cables
No special wiring topology (as with electrical power cables)
Simple installation with cable polarity independence
Automated light source addressing
Low cost microcontrollers on the light source side minimize the cost of the light source
A simple protocol to control light dimming and switching.
1.1.2
DALI physical layer
The DALI interface consists of a physical layer from two wires. This is a simple installation
for which the polarity is independent.
DocID024513 Rev 1
3/32
DALI information
UM1632
The protocol used on these cables is a standard serial protocol.There is 1 start bit, 8 data
bits and 2 stop bits.The communication speed is fixed at 1200 Bd.Manchester coding is
used for improved resynchronization: rising edge is logical 1 and falling edge is logical 0.
Bytes are grouped into frames. One frame usually consists of 1 or 2 bytes, which is either
data only (answer from the device) or address + data (command to device).
Voltage levels present on DALI communication wires are higher than the transistor-
transistor logic (TTL) levels that are usually used. This is to provide better noise immunity to
higher interference from nearby power installation cables. Voltage levels are defined as
follows:
•
Low level state:
–
–
•
–
–
-4.5 to 4.5 V (transmitter)
-6.5 to 6.5 V (receiver)
11.5 to 20.5 V (transmitter)
9.5 ... 22.5 V (receiver)
High level state:
The low level state is dominant on the DALI bus. The device can force this level on the DALI
bus by shorting the DALI wires. Consequently, current levels are defined for devices used
on the DALI bus. There are two device types:
1.
DALI master or DALI slave communication devices. In these devices, the current is
sunk from the DALI bus. They consume a maximum of 2 mA to receive high level state
and sink a minimum of 250 mA to transmit low level state.
DALI power supply. These devices power the DALI bus and are the source current for
it. Supply is limited to a maximum of 250 mA
2.
The maximum length of the DALI bus depends on the cables used for the DALI
communication wires. The length is linearly dependent on the cross section of the
conductor. For example, a 1.5 mm
2
cable (typically used in light installation cables) allows a
maximum bus length of up to 300 m.
Collisions between several DALI masters on the DALI bus are resolved on the basis of
timing priorities. When a collision is detected (the DALI master should check the sent data),
communication is muted for a period of time according to the assigned master priority. There
are five defined priority levels: 12 ms, 13 ms, 14 ms, 15 ms, and 16 ms. The longer the
waiting time, the lower the priority.
4/32
DocID024513 Rev 1
UM1632
Figure 1. Example of DALI device connections
DALI information
Figure 2. Voltage and currents on the DALI bus
DocID024513 Rev 1
5/32