80 likes | 295 Views
Pulse Width Modulation (PWM). Digital System Design. เราจะควบคุมความเร็วของมอร์เตอร์ได้อย่างไร ?. PWM. PWM on PIC16xxx. PWM period = [(PR2) + 1] • 4 • TOSC • (TMR2 prescale value). Duty cycle =. CCPxCON<5:4>. CCPRxL. 80% = 819 = 11 0011 0011. Using HW PWM in PIC-C.
E N D
Pulse Width Modulation (PWM) Digital System Design
เราจะควบคุมความเร็วของมอร์เตอร์ได้อย่างไร?เราจะควบคุมความเร็วของมอร์เตอร์ได้อย่างไร?
PWM on PIC16xxx PWM period = [(PR2) + 1] • 4 • TOSC • (TMR2 prescale value) Duty cycle = CCPxCON<5:4> CCPRxL 80% = 819 = 11 0011 0011
Using HW PWM in PIC-C • Enable PWMsetup_ccp1(CCP_PWM); • Setup PWM Period using Timer 2setup_timer_2(mode, period, post-scale)PWM period = (period+1) * 4 * mode * 1/Freqmode = T2_DISABLED, T2_DIV_BY_1, T2_DIV_BY_4, T2_DIV_BY_16period = 0-255*post-scale has no effect • Set PWM Duty set_pwm1_duty(0-1023); 0= 0%, 1023 = 100%