Electromechanical Switch Replacement

Similar documents
AN566. Using the PORTB Interrupt on Change as an External Interrupt USING A PORTB INPUT FOR AN EXTERNAL INTERRUPT INTRODUCTION

Connecting Sensor Buttons to PIC12CXXX MCUs

AN528. Implementing Wake-Up on Key Stroke. Implementing Wake-Up on Key Stroke INTRODUCTION IMPLEMENTATION FIGURE 1 - TWO KEY INTERFACE TO PIC16C5X

Optical Pyrometer. Functions

Electromechanical Timer Replacement Solutions Cubed Real-Time Clock

MCP100/101. Microcontroller Supervisory Circuit with Push-Pull Output FEATURES PACKAGES DESCRIPTION BLOCK DIAGRAM

HCS410/WM. Crypto Read/Write Transponder Module FEATURES PACKAGE TYPES BLOCK DIAGRAM HCS410 IMMOBILIZER TRANSPONDER. Security. Operating.

27C64. 64K (8K x 8) CMOS EPROM PACKAGE TYPES FEATURES DESCRIPTION. This document was created with FrameMaker 404

TC1225 TC1226 TC1227. Inverting Dual ( V IN, 2V IN ) Charge Pump Voltage Converters FEATURES GENERAL DESCRIPTION TYPICAL APPLICATIONS


AN663. Simple Code Hopping Decoder KEY FEATURES OVERVIEW

TC4426 TC4427 TC A DUAL HIGH-SPEED POWER MOSFET DRIVERS GENERAL DESCRIPTION FEATURES ORDERING INFORMATION

TCM828 TCM829. Switched Capacitor Voltage Converters FEATURES GENERAL DESCRIPTION APPLICATIONS ORDERING INFORMATION

AN654. PWM, a Software Solution for the PIC16CXXX METHODS INTRODUCTION

Sensor Interface Using PIC12CXXX as a Sensor Interface for Metal Detection

Using External RAM with PIC17CXX Devices PIC17C42 PIC17C43 PIC17C Microchip Technology Inc. DS91004A-page 1

PIC14C000. Errata Sheet for PIC14C000 Revision A. USING THE I 2 C MODULE IN SMBus MODE USING AN1 AND AN5 AS ANALOG INPUTS

TC4423 TC4424 TC4425 3A DUAL HIGH-SPEED POWER MOSFET DRIVERS GENERAL DESCRIPTION FEATURES ORDERING INFORMATION

HCS509. KEELOQ Code Hopping Decoder* PACKAGE TYPE FEATURES BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications

TC623. 3V, Dual Trip Point Temperature Sensor. Package Type. Features. Applications. General Description. Device Selection Table

M TC3682/TC3683/TC3684

TC643 INTEGRATED FAN / MOTOR DRIVER GENERAL DESCRIPTION FEATURES APPLICATIONS ORDERING INFORMATION

TCM680 +5V TO ±10V VOLTAGE CONVERTER GENERAL DESCRIPTION FEATURES APPLICATIONS ORDERING INFORMATION

AN820. System Supervisors in ICSP TM Architectures CIRCUITRY BACKGROUND INTRODUCTION. MCP120 Output Stage. Microchip Technology Inc.

SUPER CHARGE PUMP DC-TO-DC VOLTAGE CONVERTER

27C K (32K x 8) CMOS EPROM FEATURES PACKAGE TYPES DESCRIPTION

PIC16C65A. PIC16C65A Rev. A Silicon Errata Sheet. 2. Module: CCP (Compare Mode) 1. Module: CCP (Compare Mode) SWITCHING

AN720. Measuring Temperature Using the Watch Dog Timer (WDT) THEORY INTRODUCTION HARDWARE REQUIRED. Equation 1: Microchip Technology Inc.

TC1044S. Charge Pump DC-TO-DC Voltage Converter FEATURES GENERAL DESCRIPTION ORDERING INFORMATION

AN562. Using Endurance Predictive Software. Using the Microchip Endurance Predictive Software INTRODUCTION TOTAL ENDURANCE PREDICTIVE SOFTWARE

AN603. Continuous Improvement THE EEPROM TECHNOLOGY TEAM INTRODUCTION TO MICROCHIP'S CULTURE. Continuous Improvement is Essential

TC4467 TC4468 TC4469 LOGIC-INPUT CMOS QUAD DRIVERS GENERAL DESCRIPTION FEATURES APPLICATIONS ORDERING INFORMATION

TC57 Series. Linear Regulator Controller GENERAL DESCRIPTION FEATURES TYPICAL APPLICATIONS ORDERING INFORMATION PART CODE TC57 XX 02 ECT XX

HCS200. KEELOQ Code Hopping Encoder* PACKAGE TYPES FEATURES BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications PDIP, SOIC

TC52. Dual Channel Voltage Detector. Features. General Description. Typical Applications. Functional Block Diagram. Device Selection Table

TC51. 1µA Voltage Detector with Output Delay TC51. General Description. Features. Applications. Device Selection Table. Functional Block Diagram

Using the TC1142 for Biasing a GaAs Power Amplifier. CTL High-Side. FET Switch GND V IN V OUT TC GND. Inductorless Boost/Buck Regulator

FM Tuner Controller for Portable and Car Radios

PIC16C622A PIC16F628 Migration

TC1221/TC1222. High Frequency Switched Capacitor Voltage Converters with Shutdown in SOT Packages. 6-Pin SOT-23A. Features. General Description

Triple Stage Incubator

AN513. Analog to Digital Conversion Using a PIC16C54 INTRODUCTION THEORY OF OPERATION VOLTMETER A/D CONVERTER VOLTMETER MEASUREMENT CYCLE CYCLE

TC mA Charge Pump Voltage Converter with Shutdown. Features. Package Type. Applications. General Description. Device Selection Table

HCS512. Code Hopping Decoder* FEATURES PACKAGE TYPE BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications. Compatible Encoders

AN606. Low Power Design Using PICmicro Microcontrollers INTRODUCTION DESIGN TECHNIQUES RESISTOR TO LOWER POWER IN RC MODE CONTROL CIRCUIT

1.5A Dual Open-Drain MOSFET Drivers. 8-Pin PDIP/SOIC/CERDIP IN A A BOTTOM IN B B TOP A TOP B BOTTOM IN A B TOP IN B

TC620/TC621. 5V, Dual Trip Point Temperature Sensors. Features. Package Type. Applications. Device Selection Table. General Description

2-Wire Serial Temperature Sensor and Thermal Monitor

M TC1426/TC1427/TC1428

rfpic Development Kit 1 Quick Start Guide

TB003. An Introduction to KEELOQ Code Hopping INTRODUCTION. Remote Control Systems. The Solution. Code Scanning. Code Grabbing

FACT003. Care and Feeding of the PIC16C74 and Its Peripherals. A/D Converter Mysteries. Assumptions

AN797. TC4426/27/28 System Design Practice INTRODUCTION. FIGURE 1: TC4426 output. FIGURE 2: Output stage IC layout.

TC7662A. Charge Pump DC-to-DC Converter. Features. Package Type. General Description. Applications. Device Selection Table. 8-Pin PDIP 8-Pin CERDIP

FACT002. Mastering the PIC16C7X A/D Converter BASICS. General. Step by Step. Specifications

AN765. Using Microchip's Micropower LDOs INTRODUCTION APPLICATIONS. Optimizing Output Voltage Accuracy of 1070/1071 Adjustable LDOs

TC652 Fan Control Demo Board User s Guide

HCS509. KEELOQ Code Hopping Decoder* FEATURES PACKAGE TYPE BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications

Discrete Logic Replacement Garage Door Indicator

HCS362. HCS362 Data Sheet Errata. Clarifications/Corrections to the Data Sheet: 1. Module: Low Voltage Detector LOW VOLTAGE DETECTOR

1.5A Dual High-Speed Power MOSFET Drivers. Temp. Range

TC1029. Linear Building Block Dual Low Power Op Amp. General Description. Features. Applications. Device Selection Table. Functional Block Diagram

TC Low Power, Quad Input, 16-Bit Sigma-Delta A/D Converter Features Package Type 16-Pin PDIP 16-Pin QSOP TC3402 Applications

HCS300. Code Hopping Encoder* FEATURES PACKAGE TYPES HCS300 BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications

MCP V 10-Bit A/D Converter with SPI Serial Interface FEATURES PACKAGE TYPES APPLICATIONS FUNCTIONAL BLOCK DIAGRAM DESCRIPTION

Voltage-To-Frequency/Frequency-To-Voltage Converters

TC mA Fixed Low Dropout Positive Regulator TC2117. General Description. Features. Applications. Typical Application Device Selection Table

DatasheetDirect.com. Visit to get your free datasheets. This datasheet has been downloaded by

MCP V Dual Channel 12-Bit A/D Converter with SPI Serial Interface PACKAGE TYPES FEATURES APPLICATIONS FUNCTIONAL BLOCK DIAGRAM DESCRIPTION

AN763. Latch-Up Protection For MOSFET Drivers INTRODUCTION. CONSTRUCTION OF CMOS ICs PREVENTING SCR TRIGGERING. Grounds. Equivalent SCR Circuit.

DatasheetDirect.com. Visit to get your free datasheets. This datasheet has been downloaded by

27LV K (32K x 8) Low-Voltage CMOS EPROM FEATURES PACKAGE TYPES DESCRIPTION PDIP

HCS200. Code Hopping Encoder FEATURES PACKAGE TYPES BLOCK DIAGRAM DESCRIPTION. Security. Operating. Other. Typical Applications PDIP, SOIC

Application Note AN-301 Qspeed Family

TC1034/TC1035 Linear Building Block Single Operational Amplifiers in SOT Packages Features General Description Applications Device Selection Table

Linear Building Block Low-Power Comparator with Op Amp and

TB059. Using The MCP2150 Developer s Board With The MCP2155 INTRODUCTION MCP2150 DEVELOPER S BOARD LAYOUT

AN824. KEELOQ Encoders Oscillator Calibration OVERVIEW WHY CALIBRATION? CALIBRATION BASICS. Microchip Technology Inc.

Low-Voltage CMOS Logic HD74LV_A/RD74LVC_B Series

HCS201. Code Hopping Encoder

TC1030. Linear Building Block Quad Low Power Op Amp with Shutdown Modes. General Description. Features. Applications. Device Selection Table

AN867. Temperature Sensing With A Programmable Gain Amplifier INTRODUCTION INTERFACING THE PGA TO THERMISTORS

PROCESS. Object. Block diagram of our design. DISPLAY THE DISTANCE (7 segment display) PIC 16F873

4-1/2 Digit Analog-To-Digital Converter with On-Chip LCD Drivers

Product Introduction. MF2400C Series. Microwave Frequency Counter

Product Introduction. MF2400C Series. Microwave Frequency Counter

MCP3204/ V 4-Channel/8-Channel 12-Bit A/D Converters with SPI Serial Interface FEATURES PACKAGE TYPES APPLICATIONS FUNCTIONAL BLOCK DIAGRAM

AN798. TC4420/4429 Universal Power MOSFET Interface IC INTRODUCTION PARAMETERS AND ATTRIBUTES OF THE TC4420/4429 TIMING. Rise and Fall Times

300mW Audio Power Amplifier with Shutdown Mode

TC Bit Digital-to-Analog Converter with Two-Wire Interface TC1321. General Description. Features. Applications. Device Selection Table

TC115. PFM/PWM Step-Up DC/DC Converter. Package Type. Features. Applications. General Description. Device Selection Table. Functional Block Diagram

AN677. Designing a Base Station Coil for the HCS410 INTRODUCTION OVERVIEW FEATURES. Overview of Inductive Communication.

HCS300. KEELOQ Code Hopping Encoder DESCRIPTION FEATURES PACKAGE TYPES HCS300 BLOCK DIAGRAM. Security. Operating. Other. Typical Applications

LQA16T300 Qspeed Family

TB081. Soft-Start Controller For Switching Power Supplies IMPLEMENTATION OVERVIEW. Hardware SCHEMATIC. Keith Curtis Microchip Technology Inc.

LQA60A300C Qspeed Family

2SC1345. Silicon NPN Epitaxial. Application. Outline. Absolute Maximum Ratings. REJ03G (Previous ADE A) Rev.3.00 Sep.10.

AN4014 Application Note Adjustable LED blinking frequency using a potentiometer and STM8SVLDISCOVERY Application overview

Application Note. 8-bit Microcontrollers. AVR092: Replacing ATtiny11/12 by ATtiny13. Features. Introduction

PIC16F818/819. PIC16F818/819 Rev. B0 Silicon Errata Sheet

Transcription:

Electromechanical Switch Replacement Electronic Key, Button Dimmer and Potentiometer Dimmer Controller Author: Slav Slavov Ell Sliven, Bulgaria email: ell@sliven.osf.acad.bg APPLICATION OPERATION These three applications are designed to replace AC electromechanical keys. They must not be used for DC because of the use of triacs. All of the applications may be powered directly from AC. Application 1: Electronic Key The application shown in Figure 1 can replace almost all electromechanical keys. It is synchronized with the line voltage so the charge is switched on only in the beginning of the half period. It may be used in drills, fans and many electrical machines used at home. As you can see from Figure 1, the program makes a loop,where it is first waiting for the beginning of the first half period. When this is reached, the button is tested. If it is pushed, it switches on the triac else does not switches on the triac. After that, it waites for, the beginning of the second half period and so on. Application 2: Button Dimmer Controller The application show in Figure 2 may be used as a dimmer or revolution controller. Button 1 increases power and button 2 decreases power. To make the input/output linear, I am using a table to convert the input value. The half period is divided to 64 areas the surface of which are equal: The TMR0 is cleared every time at the beginning of the half period. The Prescaler of the timer is set to divide by 64 so when Fosc = 4MHz, the value that will be in TMR0 at the end of the half period will be: 10ms( half period for 50Hz net) --------------------------------------------------------------------------- = 156 64 1µs The maximum value that is returned from the table is 154. So there is a cycle that compares the value of the timer and the value returned from the table. When the value of the timer goes greater than the output, it is activated, and, in the rest of the time to the end of the half period the buttons are read. If the controller is set to minimum, there will not be time for button read.thats why the table doesn't return 156 as maximum but 154. This is not very important in the beginning and in the end of the half period. When the button is pushed, an action is performed (increase or decrease). If the button is still held down after about 1 second, the second action will be performed. After that, the time to the next action is about 0.1 second. If the max/min value is reached, no action is performed. Application 3: Potentiometer Dimmer Controller The application shown in Figure 3 is similar to application 2, but there is a potentiometer instead of buttons. This uses the A/D converter from the PIC12C671. The A/D conversion is started in the end of the half period and the ADRES register is read when the GO/DOWN bit is down. X( n+ 1) sin( x) Xn = X( n+ 2) X( n+ 1) sin( x) Microchip Technology Incorporated, has been granted a nonexclusive, worldwide license to reproduce, publish and distribute all submitted materials, in either original or edited form. The author has affirmed that this work is an original, unpublished work and that he/she owns all rights to such work. All property rights, such as patents, copyrights and trademarks remain with author. 1997 DS40160A/2_008-page 2-1

FIGURE 1: POWERING WITHOUT TRANSFORMER VCC 3.3 KΩ 470 KΩ SYNC Signal NPN 220 nf 220V AC 1KΩ, 1W VCC = 5V Vz = 5V 100 nf + GP0 GP2 SYNC 100 Ω OUT 240 Ω 100 nf GP3 PIC12C508 SW1 DS40160A/2_008-page 2-2 1997

FIGURE 2: BUTTON DIMMER CONTROLLER + GP0 GP2 SYNC 100 Ω OUT GP1 GP3 PIC12C508 SW1 SW2 100 nf FIGURE 3: POTENTIOMETER DIMMER CONTROLLER + GP3 GP2 SYNC 100 Ω OUT VCC 100 nf GP0 PIC12C671 10K 1997 DS40160A/2_008-page 2-3

FIGURE 4: APPLICATION 1 ELECTRONIC KEY Begin FIGURE 5: APPLICATION 2 AND 3 BUTTON DIMMER AND POTENTIOMETER CONTROLLERS Begin Initialization Initialization Sync = 0? No Sync = 0? No Yes Yes Sync = 1? No Sync = 1? No Yes Yes Yes Key pressed? No Phase = f(dimmer) Out = 1 Out = 2 IMR0 < Phase? Yes No Out = 1 Sync = 0? No Yes Read Buttons Yes Key pressed? No Increase/ Decrease Dimmer Out = 1 Out = 2 Make second half period MICROCHIP TOOLS USED: Development Tools: PICSTART Plus V1.20 Assembler/Compiler Version: MPLAB V3.22, MPASM V1.5 DS40160A/2_008-page 2-4 1997

APPENDIX A: SOURCE CODE ;**************************************************************** ; Figure1.ASM ; ;**************************************************************** LIST p=12c508 #include "inc\p12c508.inc" config _WDT_ON & _IntRC_OSC & _MCLRE_OFF & _CP_OFF Sync equ 0 In equ 3 Out equ 2 org 0x00 OSCCAL ;calibrating the internal oscillator clrf movlw TRIS movlw OPTION GPIO B'00111011' GPIO B'01000010' GPIO,Sync $-1 loop clrwdt btfss GPIO,Sync $-1 btfss bsf GPIO,In GPIO,In clrwdt GPIO,Sync $-1 btfss bsf GPIO,In GPIO,In loop end ;**************************************************************** ; Figure2.ASM ; ; This application is made for power nets AC220V 50Hz 1997 DS40160A/2_008-page 2-5

; Don't use it on 60Hz! ; It has not back reference to control the current in the triac ; so it should not be used to drive reactive charges (solenoids etc.), ; where there is big phase difference between the ; voltage and the current! ; ;**************************************************************** LIST p=12c508 #include "inc\p12c508.inc" config _WDT_ON & _IntRC_OSC & _MCLRE_OFF & _CP_OFF RAM equ 0x07;Begining of RAM Sync equ 0 Btn1 equ 1 Btn2 equ 3 Out equ 2 cblock endc org RAM BtnCount1 BtnCount2 Phase Dimmer Flag 0x00 ;Counters used to delay when buton is pushed ;The value got from the Table OSCCAL ;calibrating the internal oscillator main ;---------------------------------------------------------- ; This table makes the dependence y=sin(x) linear so, if you ; use this program to control dimmers and if you increment x by 1 ; up to 63 (0-0x3F) and measure the light with luxmeter the dependence ; will be linear ; Table: andlw.63 addwf PCL,F retlw.154 retlw.151 retlw.146 retlw.141 retlw.136 retlw.132 retlw.129 retlw.125 retlw.122 retlw.119 retlw.117 retlw.114 retlw.112 retlw.110 retlw.108 retlw.107 retlw.105 DS40160A/2_008-page 2-6 1997

retlw.103 retlw.102 retlw.100 retlw.99 retlw.97 retlw.96 retlw.94 retlw.93 retlw.92 retlw.90 retlw.89 retlw.88 retlw.87 retlw.85 retlw.84 retlw.83 retlw.82 retlw.80 retlw.79 retlw.78 retlw.77 retlw.76 retlw.74 retlw.73 retlw.72 retlw.71 retlw.69 retlw.68 retlw.67 retlw.66 retlw.64 retlw.63 retlw.62 retlw.60 retlw.58 retlw.56 retlw.54 retlw.52 retlw.50 retlw.48 retlw.45 retlw.42 retlw.38 retlw.34 retlw.30 retlw.21 retlw.0 main clrf movlw TRIS GPIO B'00111011' GPIO movlw B'01000101' ;clockout/64 OPTION ;--------------------------------------- ; When 50Hz net is used the period is 20ms and ; the half period is 10ms. 64us X 156 =9.984ms ; the maximum value that the table gives is 154 movlw.100 1997 DS40160A/2_008-page 2-7

BtnCount1 ;Initialize the button counters BtnCount2 ;there will be about 1 sec delay when you ;push some button. When you hold the putton ;the output will change within about 0.1 sec GPIO,Sync $-1 loop clrwdt btfss GPIO,Sync ;loops while Sync=0 $-1 clrf TMR0 ; First half period movf Dimmer,w call Table ;converts the value in Dimmer to Phase Phase La1 movf Phase,w ;compares the Phase with the timer subwf TMR0,w ;when the time has come swithes the ouput on STATUS,C Lb1 bsf ;output on ;Button 1 Btna1 GPIO,Btn1 ;skip if button 1 is pushed else Btn1Enda ;inicializes the BtnCount1 decfsz BtnCount1,F ;if the button was held down for about 1 sec BtnEnda ;(when pushed) or 0.1 sec (after the movlw.10 ;first sec) the value of Dimmer is BtnCount1 ;incremented incf ;if the highest value (0x3F) is reached Dimmer,6 ;no more incrementation is done decf BtnEnda Btn1Enda movlw.100 ;if the button was not pushed BtnCount is BtnCount1 ;inicialized BtnEnda ;the algorythm downwards is like the above ;Button 2 Btna2 GPIO,Btn2 Btn2Enda decfsz BtnCount2,F BtnEnda movlw.10 BtnCount2 DS40160A/2_008-page 2-8 1997

decf incf Dimmer,6 BtnEnda Btn2Enda movlw.100 BtnCount2 BtnEnda clrwdt ;Second half period GPIO,Sync ;loops while Sync=1 $-1 Lb1 Btnb1 clrf movf call movf subwf bsf TMR0 Dimmer,w Table Phase Phase,w TMR0,w STATUS,C Lb1 GPIO,Btn1 Btn1Endb decfsz BtnCount1,F BtnEndb movlw.10 BtnCount1 incf decf Dimmer,6 BtnEndb Btn1Endb movlw.100 BtnCount1 Btnb2 GPIO,Btn2 Btn2Endb decfsz BtnCount2,F BtnEndb movlw.10 BtnCount2 decf incf Dimmer,6 BtnEndb 1997 DS40160A/2_008-page 2-9

Btn2Endb movlw.100 BtnCount2 BtnEndb loop end ;**************************************************************** ; Figure3.ASM ; ; This application is made for power nets AC220V 50Hz ; Don't use it on 60Hz! ; It has not back reference to control the current in the triac ; so it should not be used to drive reactive charges (solenoids etc.), ; where there is big phase difference between the ; voltage and the current! ; ;**************************************************************** LIST p=12c671 #include "inc\p12c671.inc" config _WDT_ON & _IntRC_OSC & _MCLRE_OFF & _CP_OFF RAM equ 0x07 ;Begining of RAM In equ 0 Sync equ 3 Out equ 2 cblock endc org RAM BtnCount1 BtnCount2 Phase Dimmer Flag 0x00 ;Counters used to delay when buton is pushed ;The value got from the Table call EndAdd OSCCAL ;calibrating the internal oscillator main ;---------------------------------------------------------- ; This table makes the dependence y=sin(x) linear so, if you ; use this program to control dimmers and if you increment x by 1 ; up to 63 (0-0x3F) and measure the light with luxmeter the dependence ; will be linear ; DS40160A/2_008-page 2-10 1997

Table: andlw.63 addwf PCL,F retlw.154 retlw.151 retlw.146 retlw.141 retlw.136 retlw.132 retlw.129 retlw.125 retlw.122 retlw.119 retlw.117 retlw.114 retlw.112 retlw.110 retlw.108 retlw.107 retlw.105 retlw.103 retlw.102 retlw.100 retlw.99 retlw.97 retlw.96 retlw.94 retlw.93 retlw.92 retlw.90 retlw.89 retlw.88 retlw.87 retlw.85 retlw.84 retlw.83 retlw.82 retlw.80 retlw.79 retlw.78 retlw.77 retlw.76 retlw.74 retlw.73 retlw.72 retlw.71 retlw.69 retlw.68 retlw.67 retlw.66 retlw.64 retlw.63 retlw.62 retlw.60 retlw.58 retlw.56 retlw.54 retlw.52 retlw.50 retlw.48 retlw.45 retlw.42 retlw.38 retlw.34 retlw.30 retlw.21 1997 DS40160A/2_008-page 2-11

retlw.0 main clrf clrf bsf movlw GPIO INTCON STATUS,RP0 B'00111011' TRIS movlw B'01000101' ;clockout/64 OPTION_REG movlw B'00000110' ADCON1 STATUS,RP0 ;--------------------------------------- ; When 50Hz net is used the period is 20ms and ; the half period is 10ms. 64us X 156 =9.984ms ; the maximum value that the table gives is 154 movlw.100 BtnCount1 ;Initialize the button counters BtnCount2 ;there will be about 1 sec delay when you ;push some button. When you hold the putton ;the output will change within about 0.1 sec movlw B'01000001' ;Inicializes ADC cnannel 0 (GP0) ADCON GPIO,Sync $-1 loop clrwdt ; First half period btfss GPIO,Sync ;loops while Sync=0 $-1 clrf TMR0 movf Dimmer,w call Table ;converts the value in Dimmer to Phase Phase La1 movf Phase,w ;compares the Phase with the timer subwf TMR0,w ;when the time has come swithes the ouput on STATUS,C Lb1 bsf ;output on bsf ADCON,GO DS40160A/2_008-page 2-12 1997

ADCON,GO $-1 rrf rrf clrwdt STATUS,C ADRES,W Dimmer STATUS,C ;Algorythm for second half period is the same as in the first half period ;Second half period GPIO,Sync ;loops while Sync=1 $-1 Lb1 clrf movf call movf subwf bsf TMR0 Dimmer,w Table Phase Phase,w TMR0,w STATUS,C Lb1 bsf ADCON,GO ADCON,GO $-1 rrf rrf STATUS,C ADRES,W Dimmer STATUS,C loop IFDEF 12C671 EndAdd org 0x3FF ELSE IFDEF 12C672 EndAdd org 0x7FF ENDIF end 1997 DS40160A/2_008-page 2-13

NOTES: DS40160A/2_008-page 2-14 1997

NOTES: 1997 DS40160A/2_008-page 2-15

M WORLDWIDE SALES & SERVICE AMERICAS Corporate Office 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 602-786-7200 Fax: 602-786-7277 Technical Support: 602 786-7627 Web: http://www.microchip.com Atlanta 500 Sugar Mill Road, Suite 200B Atlanta, GA 30350 Tel: 770-640-0034 Fax: 770-640-0307 Boston 5 Mount Royal Avenue Marlborough, MA 01752 Tel: 508-480-9990 Fax: 508-480-8575 Chicago 333 Pierce Road, Suite 180 Itasca, IL 60143 Tel: 630-285-0071 Fax: 630-285-0075 Dallas 14651 Dallas Parkway, Suite 816 Dallas, TX 75240-8809 Tel: 972-991-7177 Fax: 972-991-8588 Dayton Two Prestige Place, Suite 150 Miamisburg, OH 45342 Tel: 937-291-1654 Fax: 937-291-9175 Los Angeles 18201 Von Karman, Suite 1090 Irvine, CA 92612 Tel: 714-263-1888 Fax: 714-263-1338 New York 150 Motor Parkway, Suite 416 Hauppauge, NY 11788 Tel: 516-273-5305 Fax: 516-273-5335 San Jose 2107 North First Street, Suite 590 San Jose, CA 95131 Tel: 408-436-7950 Fax: 408-436-7955 Toronto 5925 Airport Road, Suite 200 Mississauga, Ontario L4V 1W1, Canada Tel: 905-405-6279 Fax: 905-405-6253 ASIA/PACIFIC Hong Kong Microchip Asia Pacific RM 3801B, Tower Two Metroplaza 223 Hing Fong Road Kwai Fong, N.T., Hong Kong Tel: 852-2-401-1200 Fax: 852-2-401-3431 India India Liaison Office No. 6, Legacy, Convent Road Bangalore 560 025, India Tel: 91-80-229-4036 Fax: 91-80-559-9840 Korea Microchip Technology Korea 168-1, Youngbo Bldg. 3 Floor Samsung-Dong, Kangnam-Ku Seoul, Korea Tel: 82-2-554-7200 Fax: 82-2-558-5934 Shanghai Microchip Technology RM 406 Shanghai Golden Bridge Bldg. 2077 Yan an Road West, Hong Qiao District Shanghai, PRC 200335 Tel: 86-21-6275-5700 Fax: 86 21-6275-5060 Singapore Microchip Technology Taiwan Singapore Branch 200 Middle Road #07-02 Prime Centre Singapore 188980 Tel: 65-334-8870 Fax: 65-334-8850 Taiwan, R.O.C Microchip Technology Taiwan 10F-1C 207 Tung Hua North Road Taipei, Taiwan, ROC Tel: 886 2-717-7175 Fax: 886-2-545-0139 EUROPE United Kingdom Arizona Microchip Technology Ltd. Unit 6, The Courtyard Meadow Bank, Furlong Road Bourne End, Buckinghamshire SL8 5AJ Tel: 44-1628-851077 Fax: 44-1628-850259 France Arizona Microchip Technology SARL Zone Industrielle de la Bonde 2 Rue du Buisson aux Fraises 91300 Massy, France Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79 Germany Arizona Microchip Technology GmbH Gustav-Heinemann-Ring 125 D-81739 Müchen, Germany Tel: 49-89-627-144 0 Fax: 49-89-627-144-44 Italy Arizona Microchip Technology SRL Centro Direzionale Colleoni Palazzo Taurus 1 V. Le Colleoni 1 20041 Agrate Brianza Milan, Italy Tel: 39-39-6899939 Fax: 39-39-6899883 JAPAN Microchip Technology Intl. Inc. Benex S-1 6F 3-18-20, Shinyokohama Kohoku-Ku, Yokohama-shi Kanagawa 222 Japan Tel: 81-45-471-6166 Fax: 81-45-471-6122 8/29/97 All rights reserved. 1997, Microchip Technology Incorporated, USA. 9/97 Printed on recycled paper. Information contained in this publication regarding device applications and the like is intended for suggestion only and may be superseded by updates. No representation or warranty is given and no liability is assumed by Microchip Technology Incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rights arising from such use or otherwise. Use of Microchip s products as critical components in life support systems is not authorized except with express written approval by Microchip. No licenses are conveyed, implicitly or otherwise, under any intellectual property rights. The Microchip logo and name are registered trademarks of in the U.S.A. and other countries. All rights reserved. All other trademarks mentioned herein are the property of their respective companies. DS40160A/2_008-page 2-16 1997