Download presentation
Presentation is loading. Please wait.
Published byKevin Crawford Modified over 9 years ago
1
PWM Test 2 UNIT 20 로봇 SW 교육원 조용수
2
학습 목표 PWM Servo 제어 2
3
PWM Servo Motor 제어 RC Servo 제어 3
4
PWM Servo Motor 제어 RC Servo 의 주기 20ms (CNR + 1) = 22118400 / [( 7 + 1) * (1) *(50Hz)]; CNR : 55295 0.7 ~ 1ms : CW –Duty Ratio : 3.5 ~ 5% 1.5ms : Center –Duty Ratio : 7.5% 1.7 ~ 2ms : CCW –Duty Ratio : 8.5 ~ 10 % 4
5
PWM Init PWM Port Setting 5 void SYS_Init(void) { SYS_UnlockReg(); CLK->APBCLK = CLK_APBCLK_UART0_EN_Msk; SystemCoreClockUpdate(); SYS->P3_MFP = SYS_MFP_P30_RXD0 | SYS_MFP_P31_TXD0; CLK_EnableModuleClock(PWM45_MODULE); CLK_SetModuleClock(PWM45_MODULE, CLK_CLKSEL2_PWM45_S_HIRC, 0); SYS->P2_MFP = SYS_MFP_P25_PWM5 ; /* Lock protected registers */ SYS_LockReg(); }
6
PWM Init 6 void PWMInit() { /* Config PWM generator and get the nearest frequency in edge aligned auto-reload mode */ PWM_ConfigOutputChannel(PWMB, 1, 50, 10); /* PWMA pin output enabled */ PWM_EnableOutput(PWMB, 0x2); /* Start PWMA module */ PWM_Start(PWMB, 0x2); }
7
PWM Init 7 int main(void) { int delay; SYS_Init(); PWMInit(); while(1){ PWM_ConfigOutputChannel(PWMB, 1, 50, 3); delay = 10000; while(delay--){ int delay2 = 100; while(delay2--); } PWM_ConfigOutputChannel(PWMB, 1, 50, 8); delay = 10000; while(delay--){ int delay2 = 100; while(delay2--); } PWM_ConfigOutputChannel(PWMB, 1, 50, 11); delay = 10000; while(delay--){ int delay2 = 100; while(delay2--); }
8
PWM LED 제어 가변 저항 값으로 PWM RC Servo 제어 8
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.