Download: 8-bit RISC Microcontroller Application Note
8-bit RISC Microcontroller Application Note Rev. 2508B–AVR–01/04 AVR182: Zero Cross Detector Features • Interrupt Driven • Modular C Source Code • Size Efficient Code • Accurate and Fast Detection • A Minimum of External Components Introduction One of the many issues with developing modern applications is to keep the spikes and EMI at a minimum, especially when switching AC mains in and out. Most of today’s new applications are controlled by one or more microcontrollers and this gives the possibility to prevent this noise in a simple and cost efficient way. Noise produced during switching is d...
Author: Walway Shared: 8/19/19
Downloads: 1315 Views: 3625
RISC Microcontroller Application NoteRev. 2508B–AVR–01/04
AVR182: Zero Cross Detector Features• Interrupt Driven • Modular C Source Code • Size Efficient Code • Accurate and Fast Detection • A Minimum of External Components
IntroductionOne of the many issues with developing modern applications is to keep the spikes and EMI at a minimum, especially when switching AC mains in and out. Most of today’s new applications are controlled by one or more microcontrollers and this gives the possibility to prevent this noise in a simple and cost efficient way. Noise produced during switching is dependant on the amplitude of the AC sinus at the actual switching point. To get this noise as low as possible the ideal switching would be when the amplitude is 0 volt. The amplitude is crossing 0 volt at the sinus “zero crossing”. Switching mains in and out at the zero crossing requires a way of detecting when the next crossing will be and launching a switching action at the crossing. This raises the need for a cost efficient way to detect the zero crossing. This application note explains how to do that. Zero cross detection can also be used for other purposes, such as frequency calcula- tion and relative phase measuring., Figure 1. Zero Cross Detector Using AVR®
VCC VCCSerial Input Resistor PD2/EXT INT0 AVR Mains ATmega163 1M
GND1M Mains GND GND
Application Example This application note shows the user how to implement a zero cross detector with a min-imum of external components. It should be noted that this solution will not give any galvanic isolation for the microcontroller against the AC mains. The zero cross sense resistor can be a way for electronic noise to get into the system. This will not be described in this application note. Please see “AVR040: EMC Design Considerations” for further details about this. The application uses ATmega16, but the code can be recompiled for any AVR device.
Hardware To protect the device from voltages above VCC and below GND, the AVR has internalclamping diodes on the I/O pins (see Figure 1). The diodes are connected from the pins to VCC and GND and keep all input signals within the AVR’s operating voltage (see Fig- ure 2). Any voltage higher than VCC + 0.5V will be forced down to VCC + 0.5V (0.5V is the voltage drop over the diode) and any voltage below GND - 0.5V will be forced up to GND - 0.5V. By adding a large resistor in series, these diodes can be used to convert a high voltage sinus signal down to a low voltage square wave signal, with amplitude within the AVR’s operating voltage ± 0.5V. The diodes will thus clamp the high voltage signal down to the AVR’s operating voltage. Note that the series resistor and the pin input capacitance form an RC filter that will introduce a small phase difference between the square wave and the AC mains signal. The phase difference is insignificant in the current example, see “RC Filter and Delay Between VCC/2 and the Actual Zero Cross” on page 7 for more details. As the square wave signal is in phase with the AC mains, using the falling edge will tell very accurately where the zero crossing happens. By using this signal the AVR can be programmed to be a very accurate zero cross detector with a very small and interrupt- driven code. The square wave is the mains signal with its tops cut off and will have the same voltage from VCC - 0.5V to VCC + 0.5V as the mains signal (see Figure 2). When the square 2 AVR182,
AVR182wave triggers the AVR’s falling edge interrupt at around VCC/2, the mains amplitude will also be at VCC/2 and just before a zero crossing. If this is done on a falling edge the AVR will get an interrupt just before the zero crossing and will have time to start a zero cross- ing action at the actual crossing point. The interrupt will be triggered at around VCC/2, as this is the middle of the AVR’s logical threshold voltage. The signal is connected to the External Interrupt 0-pin which makes it possible to place the zero cross detection routine in an interrupt routine and make the detection fully inter- rupt driven. Figure 3 shows a oscilloscope screenshot of the actual input signal. Note that the Mains signal is scaled and the rising edge of the external int 0-pin is the same edge as for the Mains, because of the scaling, the Mains edge looks like it appears after the external int 0 edge. Figure 2. Square Wave Input Signal on External Interrupt 0-pin VCC + 0.5V VCC + 0.5V 110 - 240 V AC Mains Mains GND VCC + 0.5V Squarewave on External Interrupt 0 AVR GND GND - 0.5V Figure 3. Oscilloscope Screenshot of Square Wave Input on External Interrupt 0-pin, The series input resistor isa1MΩ resistor. It is not recommended that the clamping diodes are conducting more than maximum 1 mA and 1 MΩ will then allow a maximum voltage of approximately 1,000V. Any voltage higher than 1,000V would probably be spikes or surges. The clamping diodes are able to handle spikes for a short period of time but not surges. The applica- tion note will not go into how to protect against surges, but simply recommend implementing protection against surges in the design. Most resistors have an upper maximum voltage limit. Make sure that the resistors used in the application can handle the highest possible AC mains voltage, including high volt- age spikes. For systems with lower mains voltages the resistor value can be changed, but in general it should be able to sense 110 - 240V AC systems without any problems. The 1 MΩ resistor in series to mains GND will ensure a correct ground potential for the application.
Software The external hardware and internal clamping diodes will make a square wave signal onthe AVR’s External Interrupt 0-pin. As described in the hardware section the square wave will have the same frequency as the AC mains. The high period of the signal will be when the AC mains amplitude is above VCC/2. This gives mains zero crossings very close to the edges of the square wave. The rising edge of the square wave is slightly after the crossing and the falling edge is slightly before the crossing. As the falling edge of the square wave is just before a zero crossing, the falling edge interrupt will occur so close to the actual crossing that it immediately can start the zero crossing action. In this application example the zero crossing action will only be to set PB0 high for a short period of time and then immediately start looking for the next falling edge zero crossing. This makes it very easy to check if the zero crossing detection is correct or not. Simply connect an oscilloscope probe to the mains and another to PB0. If the detec- tion is correct this will show PB0 going high for a short period of time at each negative edge zero crossing (See Figure 4 and Figure 5). Figure 4. Screenshoot from Oscilloscope, Mains Input and PB0 Output 4 AVR182,
AVR182Figure 5. Screenshot from Oscilloscope, Mains Input and PB0 Output In a real application the disabling of external interrupt 0 before returning from the inter- rupt routine will make a single detection. To detect a new zero crossing, simply enable the falling edge interrupt again in the main program. To make sure the interrupts are valid and not only products of spikes on the pin, there is a filter implemented in the interrupt routine. The filter samples the level on the interrupt line five times and compares the values to see if the value is stable. If the value is not the same for all the samples, the event is discarded and the routine returns to the main program waiting for a new interrupt (See Figure 6). For more details about the software, please see the comments in the code., Figure 6. Software Flowchart for Main Program and External Interrupt 0 Handling Routine Main Program Start EXT INT0 Handler Routine Enable EXT INT0 (Falling Edge) EXT INT0 Pin Low? no no yes Eternal Loop EXT INT0 Pin Sampled Low 5 Times? yes Set PB0 High Set PB0 Low End EXT INT0 Handler Routine 6 AVR182,
AVR182 Special Applying high voltages to microcontrollers increases the possibility of malfunction or Considerations injury. It is advisable to follow a few special steps as any error can cause severe dam-age to components, emulators or electric shock.
Emulators and Clamp The AVR family is set up with a complete system of emulators, but because of the Diodes nature of the PODs of some of the emulators, they are not equipped with internal clamp-ing diodes. ICE200 and ICE40/50 are the only emulators with clamping diodes. ICE10 and ICE30 do not contain clamping diodes. By adding external clamping diodes these emulators will get the same input as the part. To apply a high AC voltage to an emulator can cause severe damage on the equipment and care should be exercised. It is recommended to use isolation transformers on the mains and galvanic separated RS-232 communication to the PC.
RC Filter and Delay The series resistor and the input pin capacitance will form an RC filter, which will delay Between VCC/2 and the the response compared to the actual zero crossing. Actual Zero Cross The 1 MΩ resistor together with the input capacitance on the AVR introduces a delaythat brings the detection very close to the actual crossing. For other AC voltages or series resistors it is recommended to do a test with an oscilloscope to see how close the detection is to the actual crossing. This makes it very easy to check if the zero crossing detection is correct or not. Connect an oscilloscope probe to the mains and another to PB0. A correct detection will show PB0 going high for a short period of time at each fall- ing edge zero crossing (see Figure 4 and Figure 5). If the detection is after the actual crossing, the next crossing should be targeted by add- ing a delay to the action. The delay should be equal to the time left before the next crossing The series resistor can also be modified somewhat to make the detection closer but note that the maximum current through the AVR’s clamping diode should not be higher than 1 mA.
Ground must Be The mains ground must be symmetrical to the phases in the mains net. As the sensor is Symmetrical only using one phase and ground, this is necessary to detect the actual zero crossingaccording to the three phases in the mains net. If ground is not symmetrical it is not pos- sible to know when the crossing is using only one phase. This can only be a problem in delta shaped mains net. Most countries, except Norway and Albania, use star shaped mains system and will not have this problem.
How to Calculate a Slow The typical use of a zero cross detector can be to control a mains relay. As relays have Switch (Relay) a response time that will be larger than the delay from the zero cross sensing to theactual crossing one technique can be to add a delay to the handling, i.e., sense the crossing on falling edge and make the relay close on rising edge. To do this, the response time of the relay and the frequency of the mains has to be known. These values can either be known from the manufacturer, measured in a lab or by the AVR itself. The measurement can be implemented into the AVR software. By using the zero cross detector it can easily sample the frequency of the signal and with few external compo- nents it can also measure the relay response time. This will give a universal system that can adapt to almost any AC mains frequency and relay response time. It will also con- tinue being correct even if the relay response time or frequency will change over time.,
Atmel Corporation Atmel Operations2325 Orchard Parkway Memory RF/Automotive San Jose, CA 95131, USA 2325 Orchard Parkway Theresienstrasse 2 Tel: 1(408) 441-0311 San Jose, CA 95131, USA Postfach 3535 Fax: 1(408) 487-2600 Tel: 1(408) 441-0311 74025 Heilbronn, Germany Fax: 1(408) 436-4314 Tel: (49) 71-31-67-0 Fax: (49) 71-31-67-2340
Regional Headquarters MicrocontrollersEurope 2325 Orchard Parkway 1150 East Cheyenne Mtn. Blvd. Atmel Sarl San Jose, CA 95131, USA Colorado Springs, CO 80906, USA Route des Arsenaux 41 Tel: 1(408) 441-0311 Tel: 1(719) 576-3300 Case Postale 80 Fax: 1(408) 436-4314 Fax: 1(719) 540-1759 CH-1705 Fribourg Switzerland La Chantrerie Biometrics/Imaging/Hi-Rel MPU/ Tel: (41) 26-426-5555 BP 70602 High Speed Converters/RF Datacom Fax: (41) 26-426-5500 44306 Nantes Cedex 3, France Avenue de Rochepleine Tel: (33) 2-40-18-18-18 BP 123 Asia Fax: (33) 2-40-18-19-60 38521 Saint-Egreve Cedex, France Room 1219 Tel: (33) 4-76-58-30-00 Chinachem Golden Plaza ASIC/ASSP/Smart Cards Fax: (33) 4-76-58-34-80 77 Mody Road Tsimshatsui Zone Industrielle East Kowloon 13106 Rousset Cedex, France Hong Kong Tel: (33) 4-42-53-60-00 Tel: (852) 2721-9778 Fax: (33) 4-42-53-60-01 Fax: (852) 2722-1369 1150 East Cheyenne Mtn. Blvd. Japan Colorado Springs, CO 80906, USA 9F, Tonetsu Shinkawa Bldg. Tel: 1(719) 576-3300 1-24-8 Shinkawa Fax: 1(719) 540-1759 Chuo-ku, Tokyo 104-0033 Japan Scottish Enterprise Technology Park Tel: (81) 3-3523-3551 Maxwell Building Fax: (81) 3-3523-7581 East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743 Literature Requests www.atmel.com/literature Disclaimer: Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company’s standard warranty which is detailed in Atmel’s Terms and Conditions located on the Company’s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel’s products are not authorized for use as critical components in life support devices or systems. © Atmel Corporation 2003. All rights reserved. Atmel® and combinations thereof, AVR®, and AVR Studio® are the registered trademarks of Atmel Corporation or its subsidiaries. Microsoft®, Windows®, Windows NT®, and Windows XP® are the registered trademarks of Microsoft Corpo- ration. Other terms and product names may be the trademarks of others Printed on recycled paper.]
AVR242: 8-bit Microcontroller Multiplexing LED Drive anda4x4Keypad Multiplexing Features reduced to fifteen with a bit of ingenuity,
AVR242: 8-bit Microcontroller Multiplexing LED Drive anda4x4Keypad Multiplexing Features reduced to fifteen with a bit of ingenuity, allowing the smaller 20-pin AVR to be LED Drive and a • 16 Key Pushbutton Pad in4x4Matrix • 4 Digit Multiplexed LED Display with used. The circuit diagram is shown in
8-bit Microcontroller Application Note Rev. 1051B–AVR–05/02 AVR180: External Brown-out Protection Features • Low-voltage Detector • Prevent Register and EEPROM Corruption • Two Discrete Solutions • Integrated IC Solution • Extreme Low-cost Solution • Extreme Low-power Solution • Formulas for Compone
8-bit Microcontroller Application Note Rev. 1259D–AVR–04/05 AVR134: Real Time Clock (RTC) using the Asynchronous Timer Features • Real Time Clock with Very Low Power Consumption (4 µA @ 3.3V) • Very Low Cost Solution • Adjustable Prescaler to Adjust Precision • Counts Time, Date, Month, and Year wit
Wiring Diagram Samsung Electronics 6-1
8-bit Microcntroller Application Note Rev. 2532A–AVR–01/03 AVR243: Matrix Keyboard Decoder Features • 64-key Push-button Keyboard in8x8Matrix • No External Components Required • Wakes Up from Sleep Mode on Keypress • Easily Implemented into Other Applications • Low Power Consumption • Software Conta
Alignment and Adjustments 1. Tuner FM THD Adjustment FMOutput Antenna GND SETSSG FREQ. 98 MHz Terminal Oscilloscope Adjustment FM S.S.G Input point FM DETECTOR COIL Speaker (FM DET) Terminal output Input Output 60 dB Distortion Meter Minumum Distortion (0.4% below) (Figure 1-1) Figure1-1 IF CENTER
8-bit Microcontroller Application Note Rev. 2540A–AVR–07/03 AVR104: Buffered Interrupt Controlled EEPROM Writes Features • Flexible Multi-byte EEPROM Buffer • Power Efficient EEPROM Access • Access Control on Buffers • EEPROM Buffer Rewrite Introduction Many applications use the built-in EEPROM of t
Schematic Diagram - This Document can not be used without Samsung’s authorization - 7-1 MAIN 7-1 Samsung Electronics 7-2 FRONT - This Document can not be used without Samsung’s authorization - Samsung Electronics 7-2 7-3 DSP - This Document can not be used without Samsung’s authorization - 7-3 Sam
TroubleShooting 9-1 Main 9-1 Samsung Electronics Samsung Electronics 9-2 9-3 Samsung Electronics Samsung Electronics 9-4 9-2 DVD Servo parts 9-5 Samsung Electronics Samsung Electronics 9-6 9-7 Samsung Electronics Samsung Electronics 9-8 9-9 Samsung Electronics Samsung Electronics 9-10 9-11 Samsung
AVR054: Run-time calibration of the internal RC oscillator Features • Calibration of internal RC oscillator via UART • LIN 2.0 compatible synchronization/calibration to within +/-2% of target frequency • Alternate run-time synchronization/calibration to within +/-1% of target frequency • Support for
DVD RECEIVER AMP HT-DB120 SERVICE Manual DVD RECEIVER AMP SYSTEM CONTENTS 1. Alignment and Adjustments 2. Exploded Views and Parts List 3. Electrical Parts List 4. Block Diagrams 5. PCB Diagrams 6. Wiring Diagram 7. Schematic Diagrams 8. IC block Diagrams 9.Troubleshooting - Confidential - ELECTRONI
8-bit Microcontroller Application Note Rev. 2542A–AVR–09/03 AVR131: Using the AVR’s High-speed PWM Features • Analog Waveform Generation using PWM • High-speed Prescalable PWM Clock Introduction This application note is an introduction to the use of the high-speed Pulse Width Mod- ulator (PWM) avail
8-bit RISC Microcontroller Application Note Rev. 2521B–AVR–01/04 AVR042: AVR® Hardware Design Considerations Features • Providing Robust Supply Voltage, Digital and Analog • Connecting the RESET Line • SPI Interface for In-System Programming • Using External Crystal or Ceramic Resonator Oscillators
8-bit Microcontroller Application Note AVR240: 4x4Keypad – Wake-up on Keypress Features Introduction
8-bit Microcontroller Application Note AVR240: 4x4Keypad – Wake-up on Keypress Features • 16 Key Pushbutton Pad in4x4Matrix • Very Low Power Consumption • AVR in Sleep Mode and Wakes Up on Keypress • Minimum External Components • ESD Protection Included if Necessary • Efficient Code • Complete Progr
Microcontrollers for Fluorescent and High Intensity Discharge Lamp Ballasts SMARTER, MORE FLEXIBLE LIGHTING SOLUTIONS
LIGHTINGMICROCONTROLLERSMicrocontrollers for Fluorescent and High Intensity Discharge Lamp Ballasts SMARTER, MORE FLEXIBLE LIGHTING SOLUTIONS Developed together with the industry leading lamp ballast manufac- turers, Atmel® microcontrollers are optimized for Linear and Dimmable Fluorescent tubes, as
AVR121: Enhancing ADC resolution by oversampling Features • Increasing the resolution by oversampling • Averaging and decimation • Noise reduction by averaging samples 1 Introduction Atmel’s AVR controller offers an Analog to Digital Converter with 10-bit resolution. In most cases 10-bit resolution
IC Block Diagrams 8-1 Main 8-1-1. FAN8082D 8-1 Samsung Electronics 8-1-2. LC87F66C8A Samsung Electronics 8-2 8-3 Samsung Electronics Samsung Electronics 8-4 8-5 Samsung Electronics 8-1-3. M62446AFP Samsung Electronics 8-6 8-7 Samsung Electronics 8-1-4. M66010FP 8-1-5. SI-8050SE 8-1-6. SI-8090JFE S
AVR053: Calibration of the internal RC oscillator Features • Calibration using STK500, AVRISP, JTAGICE or JTAGICE mkII • Calibration using 3rd party programmers • Adjustable RC frequency with +/-1% accuracy • Tune RC oscillator at any operating voltage and temperature • Tune RC oscillator to any fre
8-bit Microcontroller Application Note Rev. 2541D–AVR–04/05 AVR230: DES Bootloader Features • Fits All AVR Microcontrollers with Bootloader Capabilities • Enables Secure Transfer of Compiled Software or Sensitive Data to Any AVR with Bootloader Capabilities • Includes Easy To Use, Configurable Examp
AVR106: C functions for reading and writing to Flash memory Features • C functions for accessing Flash memory - Byte read - Page read - Byte write - Page write • Optional recovery on power failure • Functions can be used with any device having Self programming Program memory • Example project for us
8-bit Microcontroller Application Note Rev. 1631C–AVR–06/02 AVR201: Using the AVR® Hardware Multiplier Features • 8- and 16-bit Implementations • Signed and Unsigned Routines • Fractional Signed and Unsigned Multiply • Executable Example Programs Introduction The megaAVR is a series of new devices i
Printed Circuit Board Diagram 5-1 MAIN 5-1 Samsung Electronics 5-2 FRONT Samsung Electronics 5-2 5-3 DSP 5-3 Samsung Electronics 5-4 JACK * RCA JACK * SCART JACK Samsung Electronics 5-4 5-5 DVD PACK * TOP VIEW * BOTTOM VIEW 5-5 Samsung Electronics
8-bit Microcontroller Application Note AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory
8-bit Microcontroller Application Note Rev. 2546A–AVR–09/03 AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory Features • Fast Storage of Parameters • High Endurance Flash Storage – 350K Write Cycles • Power Efficient Parameter Storage • Arbitrary Size of Parameters • Semi-redu
8-bit RISC Microcontoller Application Note Rev. 2505A–AVR–02/02 AVR130: Setup and Use the AVR® Timers Features • Description of Timer/Counter Events • Timer/Counter Event Notification • Clock Options • Example Code for Timer0 – Overflow Interrupt • Example Code for Timer1 – Input Capture Interrupt •
8-bit RISC Microcontroller Application Note Rev. 2585A–AVR–11/04 AVR151: Setup And Use of The SPI Features • SPI Pin Functionality • Multi Slave Systems • SPI Timing • SPI Transmission Conflicts • Emulating the SPI • Code examples for Polled operation • Code examples for Interrupt Controlled operati
AVR241: Direct driving of LCD display using general IO Features • Software driver for displays with one common line • Suitable for parts without on-chip hardware for LCD driving • Control up to 15 segments using 16 IO lines • Fully interrupt driven operation Introduction As a low power alternative t
8-bit Microcontroller Application Note Rev. 0938B–AVR–01/03 AVR204: BCD Arithmetics Features • Conversion 16 Bits ↔ 5 Digits, 8 Bits ↔ 2 Digits • 2-digit Addition and Subtraction • Superb Speed and Code Density • Runable Example Program Introduction This application note lists routines for BCD arith
8-bit Microcontroller Application Note Rev. 2530B–AVR–01/04 AVR065: LCD Driver for the STK502 and AVR Butterfly Features • Software Driver for Alphanumeric Characters • Liquid Crystal Display (LCD) Contrast Control • Interrupt Controlled Updating • Conversion of ASCII to LCD Segment Control Codes (S
8-bit Instruction Set Rev. 0856D–AVR–08/02 Instruction Set Nomenclature Status Register (SREG) SREG: Status Register C: Carry Flag Z: Zero Flag N: Negative Flag V: Two’s complement overflow indicator S: N ⊕ V, For signed tests H: Half Carry Flag T: Transfer bit used by BLD and BST instructions I: Gl
8-bit Microcontroller Application Note Rev. 0933B–AVR–05/02 AVR102: Block Copy Routines Features • Program Memory (Flash) to SRAM Copy Routine • SRAM to SRAM Copy Routine • Extremely Code Efficient Routines Flash → SRAM: 6 Words, SRAM → SRAM: 5 Words • Runable Test/Example Program Introduction This