Professional Documents
Culture Documents
Features
Description
For this reference design, the hardware design files (schematic, BoM and PCB
gerber) and software source code can be downloaded from Atmel website. The
provided hardware documentation can be used with not limitations to manufacture
the reference hardware solution for the design.
42071B−AVR−07/2013
Table of Contents
Current MCU Rx
Source Optocoupler
Comparator
DALI
Rectify
Bus
Bridge
MCU Tx
Optocoupler
Two optocouplers are used to isolate the voltage level between the DALI bus and microcontroller.
Using the comparator in above circuit has advantage over other simplified design in:
• Suitable for all working temperature range
• Trim the input waveform of signal for MCU
• Tolerant the difference of components for mass production
2.2 Microcontroller
ATmega88PA is one of the most popular devices in the Atmel MCU family. It is used as the main microcontroller in this
reference design. ATmega88PA handles the commands and data which comes from the DALI interface part.
3.1 Drivers
The driver layer aims at timer and encode/decode of DALI bits. For Atmel Atmega88PA in this solution, PCINT and
timer0/1 are chosen as the driver components. It is free to use other components if different method is used. PCINT
detects the logic change in the input signal pin after initialization. The signal change triggers the PCINT interrupt and
makes ISR handle the decode process.
Timer0 is configured as the time base for DALI encode/decode. It needs to count fast enough to measure the 1200 bit/s
bit rate in DALI data stream. Timer0 needs to work together with PCINT to decode DALI signal. Timer1 is mainly used
as time base for LED power output dimming.
3.2 Service
next repeat
frame
need repeat
Y
Short address?
Y
Group
address?
Y
Broadcast?
N N
Special
commands? Is me?
Y Y
N Y
Commands Process direct
256-275? Direct ARC?
power level
Y N
Process
commands 256- Process normal
275 commands 0-255
Return
3.3 Application
The whole system process is an infinite loop. After start up, it initializes the parameters and configures microcontroller
blocks. In the first power on period, if no command affecting power level is received, it shall go to power on level
immediately without fading. The system also processes frame, interface state detection sequentially.
Start up
Initialize
param eters,
drivers
N
Power on
state?
Process power on
Process fram e
Process interface
state
In this example, 12-bit PWM of the MCU is used to output power. PWM provides a duty ratio from 0 to 4095 which
corresponds to a precision of min. 0.1% power value. The PWM duty ratio lookup table is stored in arrays
high_PWM_val and low_PWM_val. The tables are stored in EEPROM to save FLASH space.
Timer1 is used as the time base for 12-bit PWM. The initialization is done in function dali_tc_init().
/*Timer1 clock with 8 prescaling */
tc_write_clock_source(TC1, TC_CLKSEL_DIV8_gc);
/* OC1B in Compare Match, PB2 output, non-inverting, Fast PWM,
* ICR1 is top*/
TCCR1A = (0 << COM1A1) | (0 << COM1A0) | (1 << COM1B1) | (0 << COM1B0) | (1 << WGM11) | (0 << WGM10);
TCCR1B |= (1 << WGM13) | (1 << WGM12);
/* Used as top value for PWM, 0x0fff makes this a 12-bit PWM */
ICR1 = TC1_TOP;
/* Clear counter */
TCNT1 = 0;
In this design, Timer1 is used as timer of FADE TIME and FADE RATE, and its overflow interrupt is used as time base
for light dimming.
32-bit variable dali.long_level is used to store power level whose lower 24 bits is the fractional value and upper 8 bits is
the actual DALI level.
union daliunion {
//dali.long_level is used during fade - allows smoother fading between fixed DALI levels.
uint32_t long_level;
struct {
// Lower three bytes store the fractional value of DALI level
uint8_t byte0;
uint8_t byte1;
uint8_t byte2;
// Upper 8 bits dali.level is the actual DALI level.
uint8_t level;
};
}dali;
For DALI commands UP and DOWN, FADE RATE is used for light dimming. In every timer period, the change of DALI
level is FADE RATE divided by Timer1 overflow frequency. Thus a 25-bits result is got with lower 24 bits used as
fractional. To save space while keep precision, the result is right-shifted by 9 bits and the remainder 16-bits value is
stored in lookup table flash_fade_rate_val. And accordingly in application, the value from lookup table should be left-
shifted by 9 bits before being used.
1 Q101A 6 R101
GND_DALI
5
150k
D101
R102 4 3 2 1 U101
2
7.5k BC857BS Q101B 1 4
VCC_5V
BC857BS BAT54XV2T1G R103
C101 1.0M
2 3
4.7uF DALI_Input
SFH6156-3
R104
1
8.2k
GND_DALI R105
D102 1.0M
MMSZ4682-V C102
1n
2
GND
GND_DALI
GND_DALI
GND_DALI
U102
1 5
OUT V+
R106
1.0M 2
GND_DALI V-
3 4
IN+ IN-
R107 C103 TLV3491
240k TLV3491AIDBVR
100p
Q102
BC847B
GND_DALI GND_DALI
4
J101
D103 R108
TP101 DALI_VP 1.5k
~
1
2 1
- +
2
~
GND_DALI
GND_DALI
DALI connector
3
VCC_5V
R109
1R TP102 DALI_GND
R110
360R
U103
Q103 4 1 GND_DALI
BC817-25
R111 3 2
DALI_Output
120R SFH6156-3
R112
100R
GND_DALI GND_DALI
1
2
GND
C301 C302 C303 TP302 GND
3 4
EN BYPASS 33n
4.7uF C304 4.7uF
GND GND_TEST
2
10n GND
GND GND GND GND J313
GND
GND
DALI_Input
VCC_5V
R301 R302
10k 10k
TP304 SCL
TP305 OUTPUT Driver_SCL
R303 Driver_SCL
100k
DALI_Output
TP306 SDA
Mega_RST Driver_SDA
Driver_SDA
32
31
30
29
28
27
26
25
R304 ATmega88PA-AU TP307 V_LED
R305 U302
1 2
GND_TEST LED_voltage
(.../INT0)PD2 LED_voltage
(.../RXD)PD0
(.../ADC4/SDA)PC4
(.../ADC3)PC3
(.../ADC2)PC2
(.../TXD)PD1
(.../RESET)PC6
(.../ADC5/SCL)PC5
180k
NCP18WF104J03RB
GND
PB0(CLKO/ICP1/...)
C308
PD5(OC0B/T1/...)
PB2(SS/OC1B/...)
33n
PB1(OC1A/...)
PB4(MISO/...)
PD7(AIN1/...)
VCC_5V
D301
620R GND
4 3 R306
R
2 1
G
R307 620R
LED2
9
10
11
12
13
14
15
16
SML-020MLT
TP309 PWM
Driver_PWM
Driver_PWM
J310
1 2
VCC_5V TP310 FLTB
3 4 Mega_MOSI
5 6 Driver_FLTB
Driver_FLTB
HEADER 2x3
GND
Mega_SCK
Mega_MISO
TP311 EN
Driver_EN
Driver_EN
2
JS201
D202 U201 MP2451DT C201 D201
J201 100nF MSS2P3
3 2 1 5 1
VIN BST L201
2
MSS2P3 C202 LQH44PN2R2MP0
1 R201 6
SW
1
18k J202
GND
TDC-021H-1 4.7uF C203
4 3 1
EN FB
10u/25V 2 Current Test
GND
2
R202
GND
10k R203 R204 GND
2.7k 150R
GND
2
D203 R205
GND 2 1 R206 120k D204
GND LED_12
FDLL4148 330R
VIN_12V J203
VIN_12V
2
U202 MSL2041GU R207 1
12
10k
Short test D205
R208 GND_DRIVER LED_12
100k
1 32 C204 1u
FBO1 FBI1
Driver_EN 2 31 GND_TEST
Driver_EN EN FBO2 GND_DRIVER
1
3 30
PWM3 FBI2
4 29
GND_DRIVER PWM2 GND
8
7
6
5
5 28 Driver_VIN C205 2.2u
PWM1 VIN Q201
Driver_PWM 6 27 Driver_VCC
Driver_PWM PWM0 VCC GND_DRIVER Si4168DY
Driver_FLTB 7 26
Driver_FLTB FLTB CVDD Si4168DY
Driver_SCL 8 25 Driver_VDD
Driver_SCL SCL VDD
Driver_SDA 9 24 4
Driver_SDA SDA NC
10 23
D0 D3
11 22
G0 G3
12 21
S0 S3
3
2
1
13 20 C206 2.2u
D1 S2
14 19
GND_DRIVER G1 G2 GND_DRIVER
15 18
S1 D2
16 17
NC NC
R209
GND_DRIVER 360mR
Driver_D0
Driver_G0 R210
Driver_S0 360mR
Driver_S0
LED_voltage
LED_voltage
GND_DRIVER
Atmel®, Atmel logo and combinations thereof, AVR®, Enabling Unlimited Possibilities®, megaAVR®, and others are registered trademarks or trademarks of Atmel
Corporation or its subsidiaries. Other terms and product names may be trademarks of others.
Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this
document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES
NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF
INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no
representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time
without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in,
automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.