PWM Speed & Direction Control of DC Motor: Objective
PWM Speed & Direction Control of DC Motor: Objective
OBJECTIVE :
The objective of this experiment is to design a speed control system of DC Motor by
using PIC16F877A microcontroller.
THEORY :
With the help of PWM it is possible to control the average power delivered to
a load and by thus we can easily regulate the speed of the DC Motor. When the
width of pulse is high, the motor will rotate with full speed. And with low pulse
width, speed of motor gets reduced. In both cases full current reaches the motor and
only the average power changes, thus we get better torque in each case.
PWM Mode -
PWM output -
Since the. CCP1 pin is multiplexed with the PORTC data latch, the TRISC<2>
bit must be cleared to make the CCP1 pin as output.
Tosc = 1/4M
(PR2)+1 = 100
PR2 = 99 d
Also ,
50*4 = (CCPR1L:CCP1CON<5:4>)
(CCPR1L:CCP1CON<5:4>) = 200 d
PROGRAM :
; Oscillator : 4 MHz
#INCLUDE <P16F877A.INC>
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _RC_OSC
& _WRT_OFF & _LVP_ON & _CPD_OFF
ORG 0X00
GOTO MAIN
MAIN:
BCF STATUS,RP0
CLRF TRISC
MOVWF PR2
BCFSTATUS,RP0
MOVLW B'00110010';50%
;MOVLW B'01010000';80%
MOVWF CCPR1L
BCF CCP1CON,5
BCF CCP1CON,4
BSFSTATUS,RP0
BCFSTATUS,RP0
MOVLW B'00000100'
BSF CCP1CON,2
END
Figure 1.1 : PICSIM LAB Virtual Board