1 / 14

Example 12 Pulse-Width Modulation (PWM): Motors and Servos

Example 12 Pulse-Width Modulation (PWM): Motors and Servos. Lecture L8.1. PIM_9DP256 Block Diagram. PWM Port. PWM Pins PP0 – PP7. Pins 4,3,2,1, 112,111,110,109. PWM Pins PP0 – PP7. Pins 4,3,2,1, 112,111,110,109. Motor Driver Circuit. Solid-state relay. MOS FET Relays. G3VM-61B1.

Download Presentation

Example 12 Pulse-Width Modulation (PWM): Motors and Servos

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Example 12 Pulse-Width Modulation (PWM):Motors and Servos Lecture L8.1

  2. PIM_9DP256 Block Diagram PWM Port

  3. PWM Pins PP0 – PP7 Pins 4,3,2,1, 112,111,110,109

  4. PWM Pins PP0 – PP7 Pins 4,3,2,1, 112,111,110,109

  5. Motor Driver Circuit Solid-state relay

  6. MOS FET Relays G3VM-61B1

  7. Motor – Generator Experiment

  8. Using an AC Relay

  9. Pulse-Width Modulation

  10. // Example 12a: Motor demo #include <hidef.h> /* common defines and macros */ #include <mc9s12dp256.h> /* derivative information */ #include "main_asm.h" /* interface to the assembly module */ #pragma LINK_INFO DERIVATIVE "mc9s12dp256b" void main(void) { int val; int speed; PLL_init(); // set system clock frequency to 24 MHz ad0_enable(); // enable a/d converter 0 lcd_init(); // enable lcd motor1_init(); // enable 8-bit pwm1 for motor while(1) { val = ad0conv(7); // 0 - 1023 speed = val >> 2; // 0 - 255 set_lcd_addr(0x40); // 2nd line of lcd display write_int_lcd(speed); // display speed motor1(speed); // set motor speed ms_delay(100); // delay 100 ms } }

  11. Controlling the Position of a Servo using PWM

  12. // Example 12b: Servo demo #include <hidef.h> /* common defines and macros */ #include <mc9s12dp256.h> /* derivative information */ #include "main_asm.h" /* interface to the assembly module */ #pragma LINK_INFO DERIVATIVE "mc9s12dp256b" void main(void) { int val; int width; PLL_init(); // set system clock frequency to 24 MHz ad0_enable(); // enable a/d converter 0 lcd_init(); // enable lcd servo1_init(); // enable pwm1 for servo while(1) { val = ad0conv(7); // 0 - 1023 width = (val << 1) + 3536; // width: 3536 - 5582 set_lcd_addr(0x40); // line 2 of lcd display write_int_lcd(width); // display width on lcd set_servo1(width); // move servo to pos width ms_delay(100); // delay 100 ms } }

More Related