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

論壇索引


Board index » All Posts




瘦身完成....
資深會員
資深會員


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: 版主你说的USB教程什么时候能放上?
中級會員
中級會員


你不是說 9月 15 日有教才能下載嗎?

快 11 月了,不學了~~

發表於: 2005/10/18 3:59
頂部


程式Complier後,若HEX超過
新會員
新會員


請教各位大大,程式Complier後,若HEX超過PIC身ROM的上限(假設上限32K,而我需要35K,假設我的程式會比較大),是否像89C51一樣可以擴充ROM或RAM呢?我在MicroChip的websit找不到相關的文章,是否可以指引小弟一下.

發表於: 2005/10/17 21:45
頂部


Re: PIC18F6490 LCD設定
版主
版主


換一顆新的看看。

發表於: 2005/10/17 18:02
頂部


Re: RA4當IO的問題....
中級會員
中級會員


謝謝版大回覆~~~
我猜也是這樣~~~
只是不知為何只有RA4要做這樣的設計???

發表於: 2005/10/17 18:01
頂部


Re: pic16f917如何省電?
版主
版主


在LCD控制暫存器 LCDCON 的 bit6 是否有打開?

bit 6 SLPEN: LCD Driver Enable in Sleep mode bit
1 = LCD driver module is disabled in Sleep mode
0 = LCD driver module is enabled in Sleep mode

在 LCD Clock drive 裡有說明,你可以用外接 Timer1 32768Hz 或是使用內建的 31KHz RC震盪器,這樣在Sleep Mode 下 LCD 能可正常工作。

The first clock source is the system clock divided by
8192 (FOSC/8192). This divider ratio is chosen to
provide about 1 kHz output when the system clock is
8 MHz. The divider is not programmable. Instead, the
LCD prescaler bits, LCDPS<3:0>, are used to set the
LCD frame clock rate.
The second clock source is the T1OSC/32. This also
gives about 1 kHz when a 32.768 kHz crystal is used
with the Timer1 oscillator. To use the Timer1 oscillator
as a clock source, the T1OSCEN (T1CON<3>) bit
should be set.
The third clock source is the 31 kHz LFINTOSC/32,
which provides approximately 1 kHz output.
The second and third clock sources may be used to
continue running the LCD while the processor is in
Sleep.
Using the bits, CS<1:0> (LCDCON<3:2>), any of these
clock sources can be selected.

發表於: 2005/10/17 17:58
頂部


Re: 關於QEI
版主
版主


計算馬達的轉動角度,也就是紀錄馬達的正反轉,轉的角度到運轉速度,也就是馬達的動作回授偵測。一般可以用QEI做伺服控制及Close Loop控制。

發表於: 2005/10/17 17:47
頂部


Re: RA4當IO的問題....
版主
版主


RA4 是 Open Drain 設計,如要當一般的I/O 設計的要接提升電阻。

發表於: 2005/10/17 17:42
頂部


RA4當IO的問題....
中級會員
中級會員


請問一下個位高手一個問題~~~
我使用APP001 REV.2的模擬板~~~
發覺如果RA4要當IO時~~~
要將DSW1的RA4切到ON~~~
如果切到OFF時~~~
IO的功能就無法使用~~~
有人可以幫我解答嗎??
謝謝~~~

發表於: 2005/10/17 16:08
頂部


關於QEI
初級會員
初級會員


Dear All:
  我想請問一下到底PIC18Fxx31的QEI有何用途啊..DATA SHEET 看不太懂...如果設為QEI模式有何幫助咧!!

發表於: 2005/10/17 14:10
頂部



« 1 ... 6897 6898 6899 (6900) 6901 6902 6903 ... 7522 »



:::

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

教育訓練中心

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