AN_SPMC65_O0322_en_V1.2
Click here to load reader
-
Upload
hendra-teguh-martua -
Category
Documents
-
view
11 -
download
1
Transcript of AN_SPMC65_O0322_en_V1.2
![Page 1: AN_SPMC65_O0322_en_V1.2](https://reader037.fdocuments.in/reader037/viewer/2022100508/55cf98af550346d033991246/html5/thumbnails/1.jpg)
Zero Cross Detection V1.2 - Nov 01, 2006
English Version
19, Innovation First Road • Science Park • Hsin-Chu • Taiwan 300 • R.O.C.
Tel: 886-3-578-6005 Fax: 886-3-578-4418 E-mail: [email protected]
http://www.sunplusmcu.com http://mcu.sunplus.com
![Page 2: AN_SPMC65_O0322_en_V1.2](https://reader037.fdocuments.in/reader037/viewer/2022100508/55cf98af550346d033991246/html5/thumbnails/2.jpg)
Zero Cross Detection
© Sunplus Technology Co., Ltd. PAGE 1 V1.2 - Nov 01 2006
Important Notice
SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information
provided by SUNPLUS TECHNOLOGY CO. is believed to be accurate and reliable. However, SUNPLUS
TECHNOLOGY CO. makes no warranty for any errors which may appear in this document. Contact SUNPLUS
TECHNOLOGY CO. to obtain the latest version of device specifications before placing your order. No
responsibility is assumed by SUNPLUS TECHNOLOGY CO. for any infringement of patent or other rights of third
parties which may result from its use. In addition, SUNPLUS products are not authorized for use as critical
components in life support systems or aviation systems, where a malfunction or failure of the product may
reasonably be expected to result in significant injury to the user, without the express written approval of Sunplus.
![Page 3: AN_SPMC65_O0322_en_V1.2](https://reader037.fdocuments.in/reader037/viewer/2022100508/55cf98af550346d033991246/html5/thumbnails/3.jpg)
Zero Cross Detection
© Sunplus Technology Co., Ltd. PAGE 2 V1.2 - Nov 01 2006
Revision History
Revision Date Translated By Remark Page
Number(s)
V1.2 2006/11/01 Li Jing Proofreading
V1.1 2006/03/07 Li Jing Translate ‘Zero Cross Detection V1.1, Chinese version’
![Page 4: AN_SPMC65_O0322_en_V1.2](https://reader037.fdocuments.in/reader037/viewer/2022100508/55cf98af550346d033991246/html5/thumbnails/4.jpg)
Zero Cross Detection
© Sunplus Technology Co., Ltd. PAGE 3 V1.2 - Nov 01 2006
Table of Content PAGE
1 System Design.................................................................................................................................... 4
1.1 System Design Description ........................................................................................................... 4 1.2 System Block Diagram .................................................................................................................. 4 1.3 MCU Resource .............................................................................................................................. 4
2 Hardware Design ................................................................................................................................ 6
2.1 Function......................................................................................................................................... 6 2.2 Design Principle............................................................................................................................. 6 2.3 Time Error Between Interrupt Generation Point and Actual Zero Point of AC220V ...................... 8
3 Software Description.......................................................................................................................... 9
3.1 Source File .................................................................................................................................... 9 3.2 Subroutines ................................................................................................................................... 9 3.3 Variables ...................................................................................................................................... 10
4 Flowcharts..........................................................................................................................................11
4.1 Main Flowchart .............................................................................................................................11 4.2 Interrupt Subroutine......................................................................................................................11 4.3 Display Subroutine ...................................................................................................................... 12
![Page 5: AN_SPMC65_O0322_en_V1.2](https://reader037.fdocuments.in/reader037/viewer/2022100508/55cf98af550346d033991246/html5/thumbnails/5.jpg)
Zero Cross Detection
© Sunplus Technology Co., Ltd.
1 System Design
1.1 System Design Description
This document is intended to guide you how to detect the zero crossing point for AC220V on SUNPLUS SPMC65x series. Here we use SPMC65P2404A*28P as an example for demonstration purpose.
1.2 System Block Diagram
SPMC65P2404A*28P
IRQ0
Figure 1-1
1.3 MCU Resource
MCU Resource
RAM Zero crossing
Main program
Initialization
Interrupt procROM
Zero crossing
Hardware on zero crossing interrupt
Interrupt INT0 externaPB4
I/O PORT PORTA
PAGE 4 V1.2 - Nov 01 2006
Transform Commute
6 LEDs showing
16MHz2
AC220v
6
1
System Block Diagram
Occupation Memo
display 1 byte
15 bytes
38 bytes
ess 31 bytes
display 31 bytes
l interrupt triggered by rising edge in
Not used Only PA0~PA5
![Page 6: AN_SPMC65_O0322_en_V1.2](https://reader037.fdocuments.in/reader037/viewer/2022100508/55cf98af550346d033991246/html5/thumbnails/6.jpg)
Zero Cross Detection
© Sunplus Technology Co., Ltd. PAGE 5 V1.2 - Nov 01 2006
MCU Resource Occupation Memo
PORTB INT0 external interrupt Only PB4
PORTC Not used
PORTD Not used
![Page 7: AN_SPMC65_O0322_en_V1.2](https://reader037.fdocuments.in/reader037/viewer/2022100508/55cf98af550346d033991246/html5/thumbnails/7.jpg)
Zero Cross Detection
© Sunplus Technology Co., Ltd. PAGE 6 V1.2 - Nov 01 2006
2 Hardware Design
2.1 Function
This application is taking SPMC65P2404A*28P as the main controller to detect the zero crossing point of AC220V through the external interrupt on SUNPLUS SPMC65x series, which mainly performs the following three functions.
Triac trigger. Through detecting the zero crossing point, the turn-on time of triac can be controlled, thus to control the voltage.
Relay protection. When using relay to control AC220V power on/off, if the relay is closed around the peak voltage of AC220V, a larger spark will occur thus to shorten the relay lifetime and generate the electromagnetic interference (EMI); if closed at the zero crossing point, these influences will be decreased.
Timing. AC220V has a frequency of 50Hz and a period of 20ms. After performing the full-wave rectification, the interrupt occurs at each zero crossing point at a 10ms interval.
2.2 Design Principle
As shown in Figure 2-1, 220V AC (alternating current) is converted into 9V AC by transformer. After full-wave rectification, AC can be used to detect the zero crossing directly. and the filter capacitor c1 can connect with the other circuit (such as the circuit based on 7805 voltage regulator). In this power supply circuit diagram, D1 is used to isolate the parts of rectification and filtering so as to keep the waveform of ZDS and offer source for zero detection.
The sample signal is obtained at the zero point, and then it is connected with two 10K resistors to divide the voltage. After that it connects a triac, which operates on Switching mode. When the base voltage Vbe≥0.7V, the triac is turned on and the low voltage is output to PB4; otherwise, the triac is turned off and the high voltage is output to PB4. The corresponding relationship between the sample signal at the zero point and the input signal of PB4 is shown in Figure 2-2. Since the rising edge in PB4 will trigger a 10ms external interrupt, when the interrupt occurs, AC220V is just at the zero point.
In this application, six LEDs are adopted for display, which are refreshed when the zero crossing interrupt occurs. The LEDs refresh frequencies are shown as follows:
LED0 50HZ blink:
10ms on, 10ms off, synchronize with the zero point of power supply
LED1 25HZ blink:
20ms on, 20ms off, synchronize with the zero point of power supply
![Page 8: AN_SPMC65_O0322_en_V1.2](https://reader037.fdocuments.in/reader037/viewer/2022100508/55cf98af550346d033991246/html5/thumbnails/8.jpg)
Zero Cross Detection
© Sunplus Technology Co., Ltd. PAGE 7 V1.2 - Nov 01 2006
LED2 12.5HZ blink:
40ms on, 40ms off, synchronize with the zero point of power supply
LED3 6.25HZ blink:
80ms on, 80ms off, synchronize with the zero point of power supply
LED4 3.125HZ blink:
180ms on, 180ms off, synchronize with the zero point of power supply
LED5 1.5625HZ blink:
320ms on, 320ms off, synchronize with the zero point of power supply
AC220v--AC9v
PA1
Zero10k
10k
1k
1k
~
~+ -
PA4
LED0
1k
D1
0.1u
LED3
1k
1k
AC220v
PA5
Zero
10k
LED4
+ C1
LED2
8050
1k
PA0
PB4
PA2
1k
LED1
LED5
+5V
PA3
Figure 2-1 Zero Crossing Detection Schematic
![Page 9: AN_SPMC65_O0322_en_V1.2](https://reader037.fdocuments.in/reader037/viewer/2022100508/55cf98af550346d033991246/html5/thumbnails/9.jpg)
Zero Cross Detection
© Sunplus Technology Co., Ltd. PAGE 8 V1.2 - Nov 01 2006
Figure 2-2 Corresponding Relationship Between the Sample Signal at the Zero Point (upper) and the Input Signal in PB4 (lower)
2.3 Time Error Between Interrupt Generation Point and Actual Zero Point of AC220V
Figure 2-3 Actual Interrupt Generation Point
When the voltage decreases to 0.7V, as shown in Figure 2-3, the rising edge occurs on PB4 and the interrupt occurs at the same time. Between the interrupt generation point and the actual zero point of the AC220V, we can see a time error which is related to the output voltage of the transformer and the voltage dividing of the resistance connected to the triac. In this circuit, the ideal calculation for the time error between the interrupt generation point and the actual zero point is:
0.7=4.5√2 *sin(w * t)
where 4.5√2 is obtained by dividing the peak voltage 9√2 with two 10K resistors.
W=2*3.14* f (f 为 50Hz)
After calculation, t=350us.
Measured in practical via oscillograph, the time error between the interrupt generation point and the actual zero point is approximately 500us.
![Page 10: AN_SPMC65_O0322_en_V1.2](https://reader037.fdocuments.in/reader037/viewer/2022100508/55cf98af550346d033991246/html5/thumbnails/10.jpg)
Zero Cross Detection
© Sunplus Technology Co., Ltd. PAGE 9 V1.2 - Nov 01 2006
3 Software Description
3.1 Source File
File Name Function Type
main.asm Main process Source file (Sample)
Zero_Detect.asm Zero cross detection process Source file (User)
SPMC65P2404A.inc SPMC65X symbol definition Head file
3.2 Subroutines
V_Reset
Content Memo
Input None Output None Description Vector address pointed after MCU power on reset Caller main.asm
V_IRQ
Content Memo
Input None Output None
Description Zero crossing display which synchronizes with the zero point of power supply.
Caller main.asm
F_Main
Content Memo Input None Output None Description Wait for the generation of zero crossing interrupt. Caller Main.asm
![Page 11: AN_SPMC65_O0322_en_V1.2](https://reader037.fdocuments.in/reader037/viewer/2022100508/55cf98af550346d033991246/html5/thumbnails/11.jpg)
Zero Cross Detection
© Sunplus Technology Co., Ltd. PAGE 10 V1.2 - Nov 01 2006
F_Light
Content Memo
Input None
Output None
Description Drive the LED which synchronizes with the zero point of power supply
Caller Zero_Detect.asm
F_IO_Init
Content Memo
Input None
Output None
Description Initialize PA5~PA0 as the low level output pins, PB4 as the input pin.
Caller Zero_Detect.asm
F_IRQ0_Init
Content Memo
Input None
Output None
Description Configure PB4 as external interrupt which is triggered on the rising edge.
Caller Zero_Detect.asm
3.3 Variables
IB_10msCount
Content Memo
Description 10ms counter, which increases 1 every 10ms.
Size 1byte
Initialization Random
Symbol None
Content $0~$FF
![Page 12: AN_SPMC65_O0322_en_V1.2](https://reader037.fdocuments.in/reader037/viewer/2022100508/55cf98af550346d033991246/html5/thumbnails/12.jpg)
Zero Cross Detection
© Sunplus Technology Co., Ltd. PAGE 11 V1.2 - Nov 01 2006
4 Flowcharts
4.1 Main Flowchart
Start(V_Reset)
Initialization for interrupt (F_IRQ0_Init)and IO port (F_IO_Init)
Circular wait
Figure 4-1 Main Flowchart
4.2 Interrupt Subroutine
V_IRQ
Zero crossingdisplay(F_Light)
Return
Figure 4-2 Main Flowchart
![Page 13: AN_SPMC65_O0322_en_V1.2](https://reader037.fdocuments.in/reader037/viewer/2022100508/55cf98af550346d033991246/html5/thumbnails/13.jpg)
Zero Cross Detection
© Sunplus Technology Co., Ltd. PAGE 12 V1.2 - Nov 01 2006
4.3 Display Subroutine
F_Light
(IB_10msCount)+ 1
Return
Send bit5~bit0 of IB_10msCount toPA5~PA0 for display
Figure 4-3 Zero Crossing Display