1 minute read
7.7 DC Motor
Program:
#include <xc.h> void main (void) {
Advertisement
TRISC2 = 0; //configure CCP1 pin an output
PR2 = 249; T2CON = 0b00000001; //Timer2, 4 prescale, no postscaler CCP1CON=0b00001100; //PWM mode, DC1B1=0, DC1B0=0 TMR2=0; //clear Timer2 TMR2ON=1; //turn on Timer2
while(1) {
CCPR1L=250 //100% duty cycle delay_ms(1000); //delay 1s CCPR1L=125 //50% duty cycle delay_ms(1000); //delay 1s
7.7 DC Motor
A DC motor is a rotary electrical machine used to convert electrical energy into mechanical
energy. In the DC motor we have only + and – leads. Connecting them to a DC voltage source
moves the motor in one direction. By reversing the polarity, the DC will move in the opposite
direction. See Figure 7.10. An H Bridge could be used to this end.
Figure 7.10: DC Motor (https://electrosome.com)