• 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: PIC16F877 PWM 設計???
#7
高級會員
高級會員


查看用戶資訊
我也想知道PWM如何產生50HZ的方法

不然自己用TIMER寫有點麻煩

發表於: 2006/11/6 15:33
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC16F877 PWM 設計???
#6
新會員
新會員


查看用戶資訊
因為這個問題我沒找出產生低頻PWM的硬體信號的方法.能否提供參考資料.或提供範例的程式碼.

發表於: 2006/11/6 14:08
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC16F877 PWM 設計???
#5
資深會員
資深會員


查看用戶資訊
參照:

mecch 寫到:
T=20ms ==> F=1/20e-3=50 Hz
這是伺服機的信號.用PWM是無法產生.但是可以用CCP產生
請參考microchip的app note
PICMicro CCP and ECCP Tips 'n Tricks


用PWM沒有問題。

發表於: 2006/11/6 8:35
不要問我哪裡來,我只是個流浪天涯的工程師
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC16F877 PWM 設計???
#4
新會員
新會員


查看用戶資訊
T=20ms ==> F=1/20e-3=50 Hz
這是伺服機的信號.用PWM是無法產生.但是可以用CCP產生
請參考microchip的app note
PICMicro CCP and ECCP Tips 'n Tricks

發表於: 2006/11/5 22:52
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC16F877 PWM 設計???
#3
資深會員
資深會員


查看用戶資訊
振盪晶體4MHz 要產生 500 Hz 沒問題阿
ye_yuli710 兄妳datasheet 沒看清楚喔
#define XTAL_FREQ 4000000
#define ICLK (XTAL_FREQ/4) // crystal is divided by four
#define PWM_FREQ 500 //Hz

#define T2CKPS1_VAL 1
#define T2CKPS0_VAL 1

#if T2CKPS1_VAL < 0
#if T2CKPS0_VAL < 0
#define T2CKPS 1
#else
#define T2CKPS 4
#endif
#else
#define T2CKPS 16
#endif

#define PR2_VAL (ICLK/T2CKPS/PWM_FREQ-1)

T2CON=
(0x0 <<7)| // 0 =Unimplemented
(0xF <<3)| // F =TOUTPSx,Timer2 Output Postscale Select 1:16 Postscale
(0x1 <<2)| // 1 =TMR2ON,Timer2 is on
(T2CKPS1_VAL << 1)|
(T2CKPS0_VAL << 0); // 0 =T2CKPS1:T2CKPS0 Timer2 Clock Prescale Select 1:16

PR2= PR2_VAL;
CCPR1L=PR2_VAL/2;
TRISC &= ~0x04; // Set TRISC2/CCP1 Output

發表於: 2006/7/30 1:49
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC16F877 PWM 設計???
#2
高級會員
高級會員


查看用戶資訊
這位兄台...

你犯了我以前犯的錯誤 ^________^

1249 太大了吧 只能255而已

那你可能會問我說 那該怎麼辦??

我的回答是 要自己用TIMER做PWM

希望對你有幫助

發表於: 2006/7/29 20:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


PIC16F877 PWM 設計???
#1
初級會員
初級會員


查看用戶資訊
請教各位前輩…我在RC2/CCP1模組上設定一PWM,想產生一組Period為20ms,Duty Cycle為2ms的波形。
設定預除器1:16,振盪晶體4MHz,「CCPR1L=125」
公式解:「PWM 週期 = [(PR2+1)]x4xToscx(預除器)」
解出「PR2=1249」
程式:
PWM_INITIAL:
BANKSEL PR2
MOVLW .1249
MOVWF PR2

BANKSEL CCPR1L
MOVLW .125
MOVWF CCPR1L

BANKSEL T2CON
MOVLW B'00000110'
MOVWF T2CON

MOVLW 0X0C
MOVWF CCP1CON
RETURN

為何所量測出來的不是我想要的波形,是PR2的值算錯了嗎?還是程式設定上有了問題?
先謝謝您的指教…

發表於: 2006/7/29 15:59
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... ]

教育訓練中心

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