• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: 觸摸燈光控制完成啦 ..黑皮黑皮!!!
#9
資深會員
資深會員


查看用戶資訊
3Q 版大 ...嗯... 又有一堆 資料要KK....
目前程式如下, 是有點笨笨啦! 但是可以工作...
請笑納啦!! 希望個位大鍋,大姐,多指正,指導改進, 阿里阿多lor.

; PIC16F505 TOUCH+DIMMER FOR WHITE LED and Incandescent Lamp 03/26/2007
#include <p16F505.inc> ; processor specific variables
; Configure: Controls the reset pin, code protect, oscillator selection, WDT.
__CONFIG _CP_OFF & _MCLRE_OFF & _WDT_OFF & _IntRC_OSC_RB4EN
;-----[Defines & Variable Assignments]---------------------------------------
cblock 0x08 ;
count ; The register counter buffer for delay.
count1 ; Delay loop counter buffer.
count2 ; 1ms delay loop counter buffer.
count3 ;Value for up and down .
count4 ;
count5 ;Loop counter for Persistence of vision.
temp ;Recored Vlaue.
endc
;-----[Reset Vector]---------------------------------------------------------
ORG 0x000 ; PIC goes here (Origin of code) after reset.
movwf OSCCAL ;Load the oscillator calibration factor.
movlw b'11000111' ; Disable pull-ups resister,max pre-scaler.
OPTION ;
movlw b'00001000' ; Set RB3 pin to an input, RB0,1,2,4,5 to outputs.
TRIS PORTB ; RB3 = ZCD , RB5 = TRIAC.
movlw b'00010000' ; Set RC4 an input, RC0,1,2,3,5 to outputs.
TRIS PORTC ; RC0=ON, RC1= UP, RC2= DOWN RC3=OFF,RC4=Feedback.
;*****************************[Main routine]*********************************
init
nop
bcf PORTB,5 ;Clear to 'L' to turn Triac off.
movlw b'00001111' ;
movwf PORTC ;Set to 'H' to turn PAD off.
clrf count3 ;
movlw d'120' ;Minimum power range.
movwf temp ;Put into here.
start
call check_pad ;Check Touch Pad?.
call dly_0.2s ;Standby for 0.2s.
goto start ;
;******************** Going up routine *****************************
on_100
movlw d'5' ;
addwf temp,w ; add 120+5=125 x 54us =6.7ms total delay for min power lighting.
movwf count3 ; put in counter3, total 6.7ms delay.
call triac ; 54us per step up .
movf temp,f ;read temp register.
btfsc STATUS,Z ;Check Z flag,if temp=0 then Z=1 or temp>0 then Z=0.
goto hold ;yes temp = 0.
decfsz temp,f ; No, temp > 0.Brighten Up.
goto on_100 ; If temp > 0.
hold
movlw d'5' ;Maximum power and keeps count3 > 0.
addwf temp,w ;5+0 =5 x 54us = 250us total delay for maximum power lighting.
movwf count3 ;
call triac ;Triac loop.
btfsc PORTC,4 ;Pad touched still?
goto hold ;Yes.
call check_pad ;No.
goto hold ;
;*****************************Power Off routine *****************************
up_on
movlw d'5' ;
subwf temp,w ;
btfss STATUS,C ;Check C flag,if temp<10 then C=0 or temp>=10 then C=1.
goto hold ;If temp <5 .
movlw d'5' ;5 times loop for persistence of vision.
movwf count5 ;
loop_1
movlw d'5' ; Maximum power and keeps count3 > 0. Also for Minimum delay ,
addwf temp,w ; add 5.
movwf count3 ; put in counter3,
call triac ; 54us per step up .
decfsz count5,f ;
goto loop_1 ;
decf temp,f ;Brighten up.
btfsc PORTC,4 ;Pad touched still?
goto up_on ;Yes,
goto hold ;No,
;*******************Power down routine***************************
down
movlw d'120' ; Maximum down value.
subwf temp,w ; temp - 120 = ?
btfsc STATUS,Z ;Check Z flag, if temp =0 then Z=1,if temp><0 then Z=0.
goto hold_1 ;Temp = 120.
movlw d'5' ;5 times loop for persistence of vision.
movwf count5 ;
loop_2
movlw d'5' ;Maximum power lighting and keeps count3 > 0.
addwf temp,w ;
movwf count3 ;
call triac ;
decfsz count5,f ;
goto loop_2 ;
incf temp,f ;Dimming.
btfss PORTC,4 ;Pad touched still?
goto hold ;No.
goto down ;Yes.

;***************************************************************************
off
movlw d'120' ;Maximum down value.
subwf temp,w ;temo - 120 = ?
btfsc STATUS,C ;Check C flag, if temp <120 then C=0,if temp >= 120 then Z=1,
goto hold_1 ;Yes,Temp = 120.
movlw d'5' ;Maximum power lighting and keeps count3 > 0.
addwf temp,w ;
movwf count3 ;
call triac ;
incf temp,f ;Dimming.
goto off ;
hold_1
bcf PORTB,5 ;Clear to 'L' to turn Triac off
btfsc PORTC,4 ;Pad touched still?
goto hold_1 ;yes.
goto start ;No.
;*****************************************************************************
triac
btfsc PORTB,3 ;Line status check.
goto H ; If Line input = H.
goto L ;If line input = L.
H
btfsc PORTB,3 ;Zero voltage crossing yet?
goto H ;No.
goto triac_1 ;Yes,H->L.
L
btfss PORTB,3 ;Zero voltage crossing yet?
goto L ;No.
goto triac_1 ;Yes,L->H.
triac_1
movlw d'16' ;For 50 us delay.
movwf count ;
keep
decfsz count,f ;
goto keep ;
decfsz count3,f ;
goto triac_1 ; 54us delay loop or 54us per step up .
bsf PORTB,5 ;Turn Triac on.
movlw d'33' ;For 10-us delay.
movwf count ;
keep_1
decfsz count,f ;
goto keep_1 ;
bcf PORTB,5 ;Turn Triac off.
retlw 0 ;
;*************************************************************************
check_pad
movlw b'00001111' ;Set to H to turn PAD off.
movwf PORTC ;
bcf PORTC,0 ;Turn on pad_on.
call dly_200us ;Wait a while.
btfsc PORTC,4 ; Pad touched yet?
goto on_100 ;Yes.
bsf PORTC,0 ;No,Turn off pad ON.
bcf PORTC,1 ;Turn on Pad UP .
call dly_200us ;Wait a while.
btfsc PORTC,4 ; Pad touched yet?
goto up_on ;Yes.
bsf PORTC,1 ;No,Turn off pad UP.
bcf PORTC,2 ;Turn on Pad DOWN .
call dly_200us ;Wait a while.
btfsc PORTC,4 ; Pad touched yet?
goto down ;Yes.
bsf PORTC,2 ;No,Turn off pad DOWN.
bcf PORTC,3 ;Turn on pad_off.
call dly_200us ;Wait awhile.
btfsc PORTC,4 ; Pad touched yet?
goto off ;Yes.
bsf PORTC,3 ;No,Turn off pad OFF.
retlw 0 ;
;*****************************[Sub routine]*************************************
dly_200us
movlw d'70' ;
movwf count ;
keep_2
decfsz count,f ;(1us+2us)x70+1us+1us=212us
goto keep_2 ;
retlw 0 ;
dly_0.2s
movlw d'200' ;1ms 200 =0.2s loop.
movwf count1 ;
goto dly_2 ;
dly_1ms
movlw d'1' ; 3250us X 1 =3.25 ms loop.
movwf count1 ;
goto dly_2 ;
dly_2 ;1ms delay loop.
movlw d'250' ;
movwf count2 ;
dly_1 ;
nop ;1us
decfsz count2,F ; 1us.
goto dly_1 ; (1us+1us+2us) x 250 =1ms.
decfsz count1,F ;
goto dly_2 ;
retlw 0
end


發表於: 2007/4/21 0:56
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 觸摸燈光控制完成啦 ..黑皮黑皮!!!
#8
資深會員
資深會員


查看用戶資訊
負載是鎢絲燈泡或是LED燈組.
線路是延伸去年的發表,追加感應 觸摸電路.
相位控制是用Delay方式 Trigger Triac.
所以有一隻腳是 Zero Cross Detect .
請參考AN521 ,AN958 , and PICREF-4 有詳細說明.
也就是說在每一個 Crossover 後Dealy trigger Triac.
Trigger pulse width =50us.
100us delay = ON , 7ms delay = OFF.
50us step up or down for dimming.

發表於: 2007/4/21 0:32
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 觸摸燈光控制完成啦 ..黑皮黑皮!!!
#7
版主
版主


查看用戶資訊
感謝duck的熱情分享!

有關I2C系列的讀寫,有現成的APPLICATION NOTE:

http://www.microchip.com/stellent/idc ... eId=1824&appnote=en022920

發表於: 2007/4/20 14:27
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 觸摸燈光控制完成啦 ..黑皮黑皮!!!
#6
資深會員
資深會員


查看用戶資訊
感謝鴨大的分享,請問您的相位控制的範圍有多寬?負載是鎢絲燈泡嗎?

發表於: 2007/4/20 12:11
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 觸摸燈光控制完成啦 ..黑皮黑皮!!!
#5
資深會員
資深會員


查看用戶資訊
忘了一件事,, 我應該說已經完成了一半;
因為LED 顯示程式還沒有完成,
最重要的是... 如何將資料存入 S-EEPROM 24C01去.
以便處理在停電後覆電時回到最後設定值.
我重新估算了一下, 可能有要儲存2-3 Byte data.
16F505 還有 RB4 , RB5 可以用在 SCL and SDA 傳資料..

所以啦... 有沒有人可以教我...
如何讀寫24C01的程式呢 ??

My E-MAIL
-------- duck288@yahoo.com ------------

發表於: 2007/4/20 2:12
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 觸摸燈光控制完成啦 ..黑皮黑皮!!!
#4
資深會員
資深會員


查看用戶資訊
No ............ problem lar ! Hahaha .

有很多實驗的細節與心得可以分享...

伊媚兒 me any... time and I am always .....available ...


這兒也可以呀????

其實最大的心得是如何處理感應觸摸電路(74HC14),
絕緣厚度可以在0.5mm左右 ..
其他PIC程式部份... 我想大家應該都比我強多啦 !!!

發表於: 2007/4/19 4:40
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 觸摸燈光控制完成啦 ..黑皮黑皮!!!
#3
版主
版主


查看用戶資訊
Duck,

如果有網友想分享你的成果,是否可以留下 E-mail 跟你連絡。

恭喜! 恭喜

發表於: 2007/4/18 8:24
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 觸摸燈光控制完成啦 ..黑皮黑皮!!!
#2
高級會員
高級會員


查看用戶資訊
這張圖 最下面部分看不到 不知道是本來就這樣 還是我的關係

蠻想看完整的線路

發表於: 2007/4/18 3:04
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


觸摸燈光控制完成啦 ..黑皮黑皮!!!
#1
資深會員
資深會員


查看用戶資訊
Dear All;

It's working lor !!!! Hahaha... happy happy ...
分享一下成果 .....


[/img]縮圖

發表於: 2007/4/18 0:50
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------