------=_Part_17977_18202197.1205146411819 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi all I'm fading a 230V bulb. Using zero cross on an interrupt pin. The operation is it starts from full brightness & fades down to zero brightness & starts to increase the brightness to its maximum & continue the operation. I wrote a coding & its works the only problem is when it's reached maximum brightness the bulb is turning off for a moment (its turning off for a very small time) & after its working nicely. When in the next full brightness again bulb is turning off for a moment & after its working nicely. My TRIAC is BT136 on GP0 via 390R resister. Zero cross detecting via 1M resister on GP2 interrupt directly on AC mains. Interrupt on every 10mS for (50Hz) using only positive cycle to trigger the gate. Using 256 steps to dim the bulb [CODE] ;******************** ;detecting zero cross ;******************** org 0004h btfsc INTCON,INTF ;is it a zero cross goto Select ;yes goto Exit ;no ;************************************************************* ;turning on the timer 36uS (Delay) X 255 (Steps) < 10ms (9180) ;************************************************************* Select btfss Change,1 ;select inc or dec the brightness goto Decrease ; goto Increase ; Decrease incfsz S_Count,F ;fade from fully brightness to dim goto $+3 bsf Change,1 goto Increase_L movf S_Count,W ;backup dim level movwf W_Count ;// call Delay decfsz W_Count,F goto $-2 Fire bsf GPIO,GP0 ;makes a short pulse call Delay ;about 33uS delay bcf GPIO,GP0 ;to latcht the triac goto Exit Increase_L movlw .255 movwf S_Count goto Exit Increase decfsz S_Count,F ;fade from dim to fully brightness goto $+3 bcf Change,1 goto Fire movf S_Count,W ;backup dim level movwf W_Count ;// call Delay decfsz W_Count,F goto $-2 goto Fire Exit bcf INTCON,INTF retfie Delay movlw .9 ;36uS delay including call movwf d1 decfsz d1,F goto $-1 nop return [CODE] -- Electronics God ------=_Part_17977_18202197.1205146411819 Content-Type: text/plain; name=code.txt Content-Transfer-Encoding: base64 X-Attachment-Id: f_fdmx1fjo0 Content-Disposition: attachment; filename=code.txt W0NPREVdDQo7KioqKioqKioqKioqKioqKioqKioNCjtkZXRlY3RpbmcgemVybyBjcm9zcw0KOyoq KioqKioqKioqKioqKioqKioqDQoNCgkJb3JnCTAwM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3VudCxGCTtmYWRl IGZyb20gZGltIHRvIGZ1bGx5IGJyaWdodG5lc3MgDQoJCWdvdG8JJCszCQkNCgkJYmNmCUNoYW5n ZSwxDQoJCWdvdG8JRmlyZQ0KCQltb3ZmCVNfQ291bnQsVwk7YmFja3VwIGRpbSBsZXZlbA0KCQlt b3Z3ZglXX0NvdW50CQk7Ly8NCgkJY2FsbAlEZWxheQ0KCQlkZWNmc3oJV19Db3VudCxGDQoJCWdv dG8JJC0yDQoJCWdvdG8JRmlyZQ0KDQpFeGl0CQkNCgkJYmNmCUlOVENPTixJTlRGDQoJCXJldGZp ZQ0KDQpEZWxheQkJDQoJCW1vdmx3CS45CQk7MzZ1UyBkZWxheSBpbmNsdWRpbmcgY2FsbA0KCQlt b3Z3ZglkMQ0KCQlkZWNmc3oJZDEsRg0KCQlnb3RvCSQtMQ0KCQlub3ANCgkJcmV0dXJuCVtDT0RF XQ0KDQo= ------=_Part_17977_18202197.1205146411819 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist ------=_Part_17977_18202197.1205146411819--