請教10F220的A/D功能??
|
||||
---|---|---|---|---|
資深會員
|
又有個笨笨問題要請教大哥大姐....
如果10F220是用 5V電池供電, GP0設定為 A/D input; 請問是否可以用GP0腳來監測自己的電池電壓呢? 又因為電池電壓會慢慢改變, (VDD在改變) 是否會影響到實際要監測的電壓點呢? 我想設定三個監測的電壓點, 5-4.5V亮GREEN LED , 4.5-4V Yellow LED , 4V以下 Red LED. 3Q lor! Happy Halloween... Booooo
發表於: 2005/11/1 3:50
|
|||
|
Re: 瘦身完成....
|
||||
---|---|---|---|---|
資深會員
|
哈哈 ... 居然會工作耶 !!!
不過程式有小修改一下 請參考啦 !!!! Happy Happy ......
發表於: 2005/10/26 7:29
|
|||
|
有沒有人可以教我...
|
||||
---|---|---|---|---|
資深會員
|
有沒有人可以教我用10F220的A/D功能寫程式讀電池電壓呢?我之所以選10F220是它看起來比較簡單.
W100 的 16F877實在看不懂?? 還好又有新產品來給笨鴨偶使用,, HAHA.. Happy 我想用如此設定 GP0 = A/D Input , GP1 = Green LED , GP2=Red LED , 5.5V 以上 = Green LED On . 5.2-5.49V = Green LED Blinking. 4.9-5.19V=Green+Red LED On, 4.5-4.89V=Green+Red+Blinking. 4.1-4.49V=Red LED On . 4.09V 以下 = Red LED Blinking. LED部份我用10F200& 12F508 練習過 , 但是A/D功能寫程式 無完全不會, 不懂, 也不知如何下手??? Dear abewu 大哥 是否有空可以教我呢? My e-mail address ... duck288@yahoo.com 阿里阿多+ 謝謝+ 葛雷西雅 +當懇+ 多蝦啦….
發表於: 2005/10/22 3:41
|
|||
|
Re: 瘦身完成....
|
||||
---|---|---|---|---|
資深會員
|
Dear abewu , 3Q lar ,
我是以 AN958 修改來用的, ZCD 部份是用74HC14轉換成兩個同步訊號, 每8.26ms一次, 再用delay方式來Trigger Triac ; AN958 提供的Dimmer asm, 我看不懂 ??? 只好用硬體方式來解決, 笨鴨用笨方法啦 ,哈哈.. 應該是行的通的 …I hope so???? 謝謝 您的提醒.. 笨鴨會小心試驗... 因為5V電源來自110Vac , 怕怕呦,, haha. 如果有問題再請教您囉 3Q Again lor!
發表於: 2005/10/20 1:36
|
|||
|
Re: 瘦身完成....
|
||||
---|---|---|---|---|
資深會員
|
3Q... Ryang 版主提示 ....
在Build 時,的確出現一些問題 , 已經修正;看起來好像問題解決了; 待我燒個來試試看 ,是甚麼咚咚囉??
發表於: 2005/10/19 2:09
|
|||
|
瘦身完成....
|
||||
---|---|---|---|---|
資深會員
|
Yeih ...piiii ... My science project is ready to go .Hahaha.
Basically , it is just a dimmer + PIR ... 人接近時由暗變亮 反之由亮變暗; AN954的 dimmer.asm 笨鴨偶看不懂?? 只好自己瞎掰一個囉! 原本程式有6-700條; 在此多謝 abewu 大哥的教導, 程式一下瘦身成下列程式... 關於常數宣告的方式 笨鴨偶還不會用, 只好在程式中, 多下些註解啦 ! Sorry lar. abewu 大哥. 程式...[code] ; PIC12F508 PIR+DIMMER #include <p12F508.inc> ; processor specific variables ; Configure: Controls the reset pin, code protect, oscillator selection, WDT. __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF &_IntRC_OSC ;-----[Defines & Variable Assignments]--------------------------------------- cblock 0x08 ; GP2=ZVS,GP5=TRIAC,GP3=SW1,GP4=PIR,GP1=SW2, GP0=MODE1-2 count ; count buffer count1 ; count buffer count2 ; count buffer count3 ;total delay buffer count4 ;max delay buffer count5 ; loop buffer endc ;-----[Reset Vector]--------------------------------------------------------- ORG 0x000 ; PIC goes here (Origin of code) after reset. movwf OSCCAL ; Load the oscillator calibration factor. movlw b'00000111' ; wake on pion change,pull-ups resister,max pre-scaler OPTION ; movlw b'00011111' ; Set GP0,1,2,3,4, to an input, GP5 to outputs. TRIS GPIO ; Register 06h goto init ;-----------------------------[Sub routine]----------------------------------- dly_100us movlw d'33' movwf count keep decfsz count,f goto keep retlw 0 step_up call dly_100us decfsz count3 ; goto step_up ; retlw 0 step_down call dly_100us ; incfsz count3 ; goto step_down ; retlw 0 ;-----[Main routine]--------------------------------------------------------- init btfsc GPIO,0 ; Mode A or Mode B goto mode_A goto hold ; mode B mode_A btfss GPIO,4 ; PIR ready yet ?????? goto mode_A ; no goto up hold ;---------------- Minimum power routine.------------------- btfsc GPIO,4 ; Check PIR Yes= H = SET. goto up ; Go up routine . btfsc GPIO,2 ; Zero Voltage crossing yet ?8.26ms for half cycle. goto hold movlw d'45' ; 5ms total delay. movwf count3 ; call step_up ; 100us per step up to increase light. bsf GPIO,5 ; Set GP5 to trigger Triac . call dly_100us ; Trigger width 100us . bcf GPIO,5 ; Clear trigger. goto hold up ;---------------- Going up routine ----------------------------- movlw d'40' ; total delay 40+5= 4.5ms. movwf count4 ; loop movlw d'10' ;10 times loop ,8.26msX10=0.0826s movwf count5 ; zcd btfsc GPIO,2 ; Zero Voltage crossing yet ? goto zcd ; No, check again .. movlw d'5' ; Min delay 500us. addwf count4,w ; add 45+5=50=5ms. movwf count3 ; put in counter3 call step_up ; bsf GPIO,5 ; set GP5 to triger Triac. call dly_100us ; set triger width =100us. bcf GPIO,5 ; Clear triger decfsz count5,f ; loop counter for persistence of vision. goto zcd ; decfsz count4,f ; goto loop ; goto pw_100 ; pw_100 btfsc GPIO,3 ; Hold on 10S or 30S. goto next goto hold_10s ; next btfsc GPIO,1 ; Hold on 30S or 60S goto hold_30s goto hold_60s ; hold_10s movlw d'12' ; 12 times loop. N=12 movwf count1 goto wait hold_30s movlw d'40' ; 40 times loop. N=40 movwf count1 goto wait hold_60s movlw d'160' ; 160 times loop. N=160 movwf count1 goto wait wait movlw d'100' ; 100 times loop. movwf count2 wait_1 btfsc GPIO,2 ; Zero Voltage crossing yet ? goto wait_1 call dly_100us call dly_100us call dly_100us call dly_100us ; Total delay for 400us. bsf GPIO,5 ; set GP5 to trigger Triac. call dly_100us ; set trigger width = 0.1ms. bcf GPIO,5 ; decfsz count2,f ; goto wait_1 ; 100 times loop = 8.26msX100=0.826s. decfsz count1,f ; yes. goto wait ; N times loop = 0.826s X N = N sec. btfss GPIO,4 ; Has PIR still there. goto down ; no goto pw_100 ; yes down ;-------------------- Going down routine ------------------------------ movlw d'40' movwf count4 ; loop_1 movlw d'10' ; movwf count5 ; zcd_1 btfsc GPIO,2 ; Zero Voltage crossing yet ? goto zcd_1 ; movlw d'210' ; addwf count4,w ; movwf count3 ; call step_down ; bsf GPIO,5 ; set GP5 to trigger Triac. call dly_100us ; bcf GPIO,5 ; decfsz count5,f ; goto zcd_1 ; decfsz count4,f ; goto loop_1 ; goto init ; end
發表於: 2005/10/18 7:27
|
|||
|
Re: 偶又碰到問題啦....
|
||||
---|---|---|---|---|
資深會員
|
大哥知了 3Q a lot.....笨鴨偶受益多多
發表於: 2005/10/12 0:22
|
|||
|
Re: 偶又碰到問題啦....
|
||||
---|---|---|---|---|
資深會員
|
研究了一下午, 重新整理如下, 不知道有沒有對耶?
好像有給它懂一點點 , 程式一下子 瘦了100Kg...hahaha 用我的程式可以寫爆 12F508, 哈哈..真是有夠笨瓜耶.. 待笨鴨偶重新整理整理, 在燒來試看看囉...3q lar. ;-----[Main routine]--------------------------------------------------------- start movlw d'30' ; movwf chDelay ; sync_1 btfss GPIO,0 ; 等同步訊號 goto sync_1 ; No, check again .. goto loop_1 ; Yes.. loop_1 movlw d'10' ; addwf chDelay,w ; movwf chInner_delay ; call fnDelayNx100us ; bsf GPIO,1 ; set GP1 to triger call fnDelay100us ; set triger width =100us. bcf GPIO,1 ; Clear triger decfsz chDelay,1 ; goto loop_1 ; goto strart ; ;-----------------------------[Sub routine]----------------------------------- fnDelay100us movlw d'33' movwf count keep_1 decfsz count1,f goto keep_1 ; Total delay 100us.. retlw 0 fnDelayNx100us call fnDelay100us decfsz chInner_delay ; goto fnDelayNx100us ; retlw 0
發表於: 2005/10/11 6:49
|
|||
|
Re: 偶又碰到問題啦....
|
||||
---|---|---|---|---|
資深會員
|
3Q 3Q +阿里阿多 ,abewu...
笨鴨我 了解程式能力還很低... 也沒學過組合語言,玩PIC純粹是興趣, 所以會問一些很笨, 很好笑的問題; 在這兒還真是能得到很多幫助.... thanks lar! 希望有機會能回台北參加教育訓練課程... Well....我需要好好研究一陣子您的程式... 也就是說會有更多很笨, 很好笑的問題要請教,,lor ,hahaha..
發表於: 2005/10/11 1:17
|
|||
|