• slider image 442
  • slider image 492
  • slider image 493
  • slider image 494
  • slider image 495
  • slider image 496
  • slider image 488
  • slider image 491
:::

論壇索引


Board index » All Posts (duck288)




Re: 請教10F220的A/D功能??
資深會員
資深會員


哎....呀....呀.... 忙了半天, 原來10F220 還沒上市呀????
也好!!! 那就先規劃程式憋 ...
基本上我是不懂A/D程式 所以就東抄西湊 完成下面的程式 希望Dear 大哥哥大姐姐幫忙看一看 行不行的通囉!!

; PIC10F220 A/D TEST
#include <p10F220.inc> ; processor specific variables
; Configure: Controls the reset pin, code protect, oscillator selection, WDT.
__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _MCPU_ON & _IOFSCS_4MHZ
;-----[Defines & Variable Assignments]---------------------------------------
cblock 0x08 ; GP0=AN0,GP1=GREEN LED ,GP2=RED LED,,
count ; count buffer

;-----[Reset Vector]---------------------------------------------------------
ORG 0x000 ; PIC goes here (Origin of code) after reset.
movwf OSCCAL ; Load the oscillator calibration factor.
movlw b'10001111' ; Disable wake on pin change, Enable pull-up.
OPTION
movlw b'00001001' ; Set GP0=AN0 ,GP1,GP2=O/P, GP3 to an input .
TRIS GPIO ; Register 06h
movlw b'01000001' ; GP0 to an A/D input , ADC ON
movwf ADCON0 ;
goto init
;-----------------------------[Sub routine]-----------------------------------
dly_25us
movlw d'8'
movwf count
keep
decfsz count,f
goto keep
retlw 0


;-----[Main routine]---------------------------------------------------------
init
call dly_25us ; Wait for AN0 to set up .
bsf ADCON0, GO ; start A/D conversion for AN0
call dly_25us ; Wait for coversion .
wait
btfsc ADCON0,GO ; Conversion complete yet? GO=0= Done.
goto wait ; No,
movf ADRESH,W ; write A/D result into W.
sublw b'11100101' ; 4.5V- BATT ,
btfsc STATUS,Z ; If Z=1 then BATT = 4.5V
goto ....... ; goto Yellow LED routine.
btfss STATUS,C ; If C=0 then BATT > 4.5V,
goto...... ; goto Green LED routine.
sublw b'11001100' ; 4.0V- BATT ,
btfsc STATUS,Z ; If Z=1 then BATT = 4.0V
goto ....... ; goto Red LED routine.
btfss STATUS,C ; If C=0 then BATT > 4.0V,
goto...... ; goto Yellow LED routine.
goto..... ; If C=1 ,so , BATT < 4.0v then goto Red LED routine.
end

發表於: 2005/11/2 1:18
頂部


請教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
頂部



« 1 ... 26 27 28 (29) 30 31 32 »



:::

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... ]

教育訓練中心

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