Browsing this Thread:
1 Anonymous Users
|
Re: PIC16F877 PWM用熱敏電阻控制讓馬達乘4倍
|
|
新會員
Joined
: 2008/1/12 19:47 最後登入時間
: 2008/1/14 22:26
Group:
註冊會員
Level : 1 HP : 0 / 0 MP : 0 / 33 EXP : 2
|
是的,謝謝你用心看我的問題
發表於: 2008/1/14 22:28
|
|
|
Re: PIC16F877 PWM用熱敏電阻控制讓馬達乘4倍
|
|
新會員
Joined
: 2005/3/31 18:51 最後登入時間
: 2008/1/14 12:30
Group:
註冊會員
Level : 1 HP : 0 / 2 MP : 1 / 154 EXP : 10
|
Hi.. 你寫的主旨有點奇怪..不太懂你所要表達的意思
是指利用熱敏電阻所造成的電壓變化..經由pic內建的ad讀入類比電壓..經過計算將原先pwm的開度..增加到原來的4倍..並輸出至放大電路..推動馬達...是這樣嗎..
發表於: 2008/1/14 12:38
|
|
|
PIC16F877 PWM用熱敏電阻控制讓馬達乘4倍
|
|
新會員
Joined
: 2008/1/12 19:47 最後登入時間
: 2008/1/14 22:26
Group:
註冊會員
Level : 1 HP : 0 / 0 MP : 0 / 33 EXP : 2
|
請問各位先進 我要如何用熱敏控制馬達讓它乘4倍,並且LCD最高顯示到255,以下是我的程式碼,我該如何修改,謝謝
8 BITS A/D(VR) + LCD + PWM ; LIST P=16F877, R=DEC #INCLUDE P16F877.INC CBLOCK 0X20 ENDC ; ; DEFINE RAM ; CBLOCK BCDBFH, BCDBFL ENDC ; ORG 0 NOP GOTO MAIN ; ;
;---------------------------------------------------------------; ; #INCLUDE <LCD.INC> ; ; ; Defines for I/O ports that provide LCD data & control ; ; LCD_DATA equ PORTB ; LCD_CNTL equ PORTB ; ; RS equ 5 ; RS=PORTB,5 ; E equ 4 ; ; ;===============================================================; ; #INCLUDE <HX2BCD.INC> #include <DLY2_5mS.INC> ; ;................................. ;
MAIN: call InitLCD call clrLCD ; ;************************************************ ;* - Initialize the A/D converter * ;* - Left justified * ;* - 1 analog channels, 0 references * ;* - Fosc/8 clock source * ;* - Channel 0 * ;* - Enable A/D * ;************************************************ ; BANKSEL ADCON1 ; ADCON1 is in bank1 MOVLW B'00000100' ; select left(0) justified (d7) ; 1 ch(AN0)/0 refs MOVWF ADCON1 ; BANKSEL ADCON0 MOVLW B'10001001' ; select Fosc/8(01), AN0(000) MOVWF ADCON0 ; a/d done(0), x(0), a/d ON(1) ; ;************************************************ ;* - Initialize the CCP1 Module * ;* - Set the period to FFh * ;* - Make RC2 an output * ;* - Configure CCP1 for PWM (xxxx11xx) * ;* - Initialize Timer2 * ;* - 1:1 Postscale (x0000xxx) * ;* - 1:4 Prescale (xxxxxx01) * ;* - Enable the timer (xxxxx1xx) * ;************************************************
BANKSEL PR2 MOVLW H'FF' MOVWF PR2 BCF TRISC,2 BANKSEL CCP1CON MOVLW B'00001111' MOVWF CCP1CON MOVLW B'00000101' MOVWF T2CON
CALL DLY2_5mS ; wait for input charge MAIN1: BSF ADCON0,GO ; start a/d converting MAIN2: BTFSC ADCON0,GO ; a/d convertion finished? GOTO MAIN2 ; no ; call L2homeLCD MOVF ADRESH,W ; read a/d result ( high byte ) CALL HX2BCD ; convert HEX to BCD ; results in BCDBFH/BCDBFL ; MOVF BCDBFH,W ; output a/d results to LCD CALL putHexLCD ; MOVF BCDBFL,W ADDLW .100 CALL putHexLCD ; MOVF ADRESH,W MOVWF CCPR1L ; Also in Duty cycle ; GOTO MAIN1 ; ; ; END
發表於: 2008/1/12 19:57
|
|
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.