AN2839 Freescale Semiconductor / Motorola, AN2839 Datasheet

no-image

AN2839

Manufacturer Part Number
AN2839
Description
Implementing a Lamp Dimmer with an HC908Q Family MCU
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Freescale Semiconductor
Application Note
Implementing a Lamp Dimmer
with an HC908Q Family MCU
by: Jefferson Daniel de Barros Soldera
Introduction
Many homes have lamps that can be made brighter or dimmer by a control on the on/off switch. This
application note describes how to implement a low-cost lamp brightness control or dimmer using a
member of the M68HC08 MCU Family. The circuit controls the amount of energy that reaches the bulb
during each half-cycle of the AC power line. Moreover, a microcontroller may grant extra automation
features to the circuit, such as soft start and programmable timing. Additionally, an application in which a
lamp is turned on for a specific amount of time is described. The dimmer circuit implementation requires
few external components.
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
This product incorporates SuperFlash
© Freescale Semiconductor, Inc., 2004. All rights reserved.
Andre Luis Vilas Boas
Alfredo Olmos
Marcus Espindola
Brazil Semiconductor Technology Center — BSTC/SPS
®
technology licensed from SST.
Rev. 0, 9/2004
AN2839

Related parts for AN2839

AN2839 Summary of contents

Page 1

... The dimmer circuit implementation requires few external components. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. This product incorporates SuperFlash © Freescale Semiconductor, Inc., 2004. All rights reserved. ® technology licensed from SST. AN2839 Rev. 0, 9/2004 ...

Page 2

Dimmer Features Dimmer Features • 110 V or 220 supply voltage • 100 W lamp dimming • Full wave AC phase control • No transformer for AC power isolation • Up/down touch ...

Page 3

Varying α will control the portion of the total AC sine wave applied to the load and, thereby, regulate the power flow to the load. The main disadvantage ...

Page 4

Application Description • Flexible I/Os allow direct drive of LEDs and other circuits to eliminate external drivers and help reduce system cost • System protection features, including watchdog timer and on-chip low-voltage detect/reset to help reduce cost and increase reliability ...

Page 5

Figure 2. Dimmer with the HC908Q Family The triac must be chosen according to the required load current. For a 100-W lamp, the load current at 115 V is 0.87 A and at 240 0.42 A. Therefore, ...

Page 6

Application Description Figure 3. Triac Control with the HC908Q Family Implementing a Lamp Dimmer with an HC908Q Family MCU, Rev The Power Line Signal b) The Zero-Crossing Reference Signal c) MCU Short Pulses Triggering the Triac d) ...

Page 7

Figure 4. The Load Supplied at 50% of the Total Average Power Figure 5. The Load Supplied Approximately 25% of the Total Average Power Implementing a Lamp Dimmer with an HC908Q Family MCU, Rev. 0 Freescale Semiconductor Application Description 7 ...

Page 8

Design Customization Design Customization This design works for many applications without modification. However, some customers may want to customize its functionality. A few variations for this circuit include: • Modifying the circuit to use a single button. For this modification, ...

Page 9

Figure 6. Isolated Dimmer with HC908Q Family Figure 7. Lamp Timer with HC9098Q Family Implementing a Lamp Dimmer with an HC908Q Family MCU, Rev. 0 Freescale Semiconductor Design Customization 9 ...

Page 10

Software Description Figure 8. Switching Inductive Loads with HC908Q Family Software Description Two software codes were developed for this application note. The first one implements a lamp dimmer; the second one was developed for an application where a lamp is ...

Page 11

Increment Timer Decrement Timer Figure 9. Flowchart for Lamp Dimmer Source Code Lamp Timer Source Code Figure 10 shows the flowchart for a lamp timer. The code starts by initializing configuration and timer registers, defining ports, and clearing variables and ...

Page 12

Software Description A 2-byte counter is incremented at each zero-crossing ( used) and compared to CntHcmp and CntLcmp constants. These constants may also be changed if the user desires to increase or ...

Page 13

Title: dimmer.asm ;******************************************************************************************* ;* Author: Marcus Espindola - Freescale SPS/BSTC ;* ;* Description: Implementing a Lamp Dimmer with HC908Qx MCU Documentation: HC908QY4 Data Sheet (MC68HC908QY4/D) for register and bit explanations ;* ;* Include Files: dimmer.equ, MC68HC908QT4.equ ...

Page 14

Software Description ;******************************************************************************************* ;* SUBROUTINES ;* This part includes subroutines ;******************************************************************************************* org FlashStart ;******************************************************************************************* ;* Table used for timer value after zero-crossing detection ;* This table uses indexed addressing mode ;******************************************************************************************* LSBTimer: dc.b $73; dc.b $90; dc.b $AD; dc.b $CA; ...

Page 15

DC.B $1A; dc.b $1B; dc.b $1D; dc.b $1E; dc.b $1F; dc.b $20; dc.b $21; dc.b $22; dc.b $23; dc.b $24; dc.b $25; InitTimer: mov #initTim,TSC ;Timer - Cleared + Stopped. ...

Page 16

Software Description lda MSBTimer,x sta TMODH lda LSBTimer,x sta TMODL bra Skip DecTimer: decx cpx #DecTcomp blo EscapeDec lda MSBTimer,x sta TMODH lda LSBTimer,x sta TMODL bra Skip EscapeDec: ldx #DecTcomp lda MSBTimer,x sta TMODH lda LSBTimer,x sta TMODL bra ...

Page 17

Waitpta0: nop brclr PTA0,PTA,Waitpta0 brclr PTA5,PTA,IncT ;Inc timer if PTA5 is clear brclr PTA4,PTA,DecT ;Dec timer if PTA4 is clear Next: mov #StartTim,TSC jsr TOverflow jsr Gate Waitpta: nop brset PTA0,PTA,Waitpta Next1: mov #StartTim,TSC ;Start the timer jsr TOverflow jsr ...

Page 18

Software Description ;******************************************************************************************* ;* Title: timer.asm ;******************************************************************************************* ;* Author: Marcus Espindola - Freescale SPS/BSTC ;* ;* Description: Implementing a Lamp Dimmer with HC908Qx MCU Documentation: HC908QY4 Data Sheet (MC68HC908QY4/D) for register and bit explanations ;* ;* Include Files: ...

Page 19

SUBROUTINES ;* This part includes subroutines ;******************************************************************************************* org FlashStart InitTimer: mov #initTim,TSC ;Timer - Cleared + Stopped. mov #InitTMODH,TMODH ;Set max. brightness mov #InitTMODL,TMODL ;after we start the timer. bra Skip ;Subroutine for Thyristor gate control Gate: lda ...

Page 20

Software Description jsr InitTimer cli ZeroDetec: nop brclr PTA0,PTA,ZeroDetec ;Wait for a edge on PTA0 (Zero crossing) mov #StartTim,TSC jsr TOverflow jsr Gate ZeroDetect: nop brset PTA0,PTA,ZeroDetect ;Wait for a edge on PTA0 (Zero crossing) mov #StartTim,TSC ;Start the timer ...

Page 21

Title: dimmer.equ ;******************************************************************************************* ;* Author: Marcus Espindola - Freescale SPS/BSTC ;* ;* Description: Constants and variables definitions for MC68HC908QY4 and MC68HC908QT4 Documentation: HC908QY4 Data Sheet (MC68HC908QY4/D) for register and bit explanations ;* ;* Include Files: ;* ...

Page 22

Notes ; |+-------IRQEN ; +--------IRQPUD initTim: equ %00110001 ; |||||||| TIM Status and Control Register ; |||||||+-PS0 ; ||||||+--PS1 ; |||||+---PS2 ; ||||+----0 ; |||+-----TRST ; ||+------TSTOP ; |+-------TOIE ; +--------TOF StartTim: equ %00000001 ; |||||||| ; |||||||+-PS0 ; ||||||+--PS1 ...

Page 23

Implementing a Lamp Dimmer with an HC908Q Family MCU, Rev. 0 Freescale Semiconductor This page is intentionally blank. Notes 23 ...

Page 24

... Learn More: For more information about Freescale Semiconductor products, please visit http://www.freescale.com AN2839 Rev. 0, 9/2004 Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document ...

Related keywords