Title: Microprocessoren lesson 6. PWM motor controlservo
1Microprocessorenlesson 6.PWM /motor
control/servo
2PWM
- Power control
- Motor control
- Light Dimmer
3PWM 2
4PWM 3
5PWM 4Equations
6PWM 5setup
1. Configure the PWM pins P1A and P1B (and P1C
and P1D, if used) as inputs by setting the
corresponding TRISC bits. 2. Set the PWM period
by loading the PR2 register. 3. Configure the
ECCP module for the desired PWM mode and
configuration by loading the CCP1CON register
with the appropriate values Select one of the
available output configurations and direction
with the P1Mlt10gt bits. Select the polarities
of the PWM output signals with the CCP1Mlt30gt
bits. 4. Set the PWM duty cycle by loading the
CCPR1L register and CCP1CONlt54gt bits. 5. For
Half-bridge Output mode, set the dead band delay
by loading PWM1CONlt60gt with the appropriate
value. 6. If auto-shutdown operation is required,
load the ECCPAS register Select the
auto-shutdown sources using the ECCPASlt20gt
bits. Select the shutdown states of the PWM
output pins using PSSAClt10gt and
PSSBDlt10gtbits. Set the ECCPASE bit
(ECCPASlt7gt). Configure the comparators using
the CMCON0 register (Register 8-1). Configure
the comparator inputs as analog inputs. 7. If
auto-restart operation is required, set the PRSEN
bit (PWM1CONlt7gt). 8. Configure and start TMR2
Clear the TMR2 interrupt flag bit by clearing the
TMR2IF bit (PIR1lt1gt). Set the TMR2 prescale
value by loading the T2CKPS bits (T2CONlt10gt).
Enable Timer2 by setting the TMR2ON bit
(T2CONlt2gt). 9. Enable PWM outputs after a new PWM
cycle has started Wait until TMR2 overflows
(TMR2IF bit is set). Enable the CCP1/P1A, P1B,
P1C and/or P1Dpin outputs by clearing the
respective TRISCBits Clear the ECCPASE bit
(ECCPASlt7gt).
7Servo
8Servo 2
- Controlled by sending a pulse of variable width
- Maximum and minimum pulse width to give the angle
(1.5 ms neutral position) - Repetition rate (20ms)
- The pulse must repeated till angle is reached ,
after that to stay in that position it has to
repeated too - lt 1.5ms counterclockwise
- gt 1.5 ms clockwise
- Pulse is generally between 1 and 2 ms
- Turn rate time it takes from one position to
another. This can take seconds.
9Servo 3
10Servo 4
11Servo specifications
Control System Pulse Width Control 1500usec
NeutralRequired Pulse 3-5 Volt Peak to Peak
Square WaveOperating Voltage 4.8-6.0
VoltsOperating Temperature Range -20 to 60
Degree COperating Speed (4.8V) 0.16sec/60
degrees at no loadOperating Speed (6.0V)
0.13sec/60 degrees at no loadStall Torque
(4.8V) 76.37 oz/in. (5.5kg.cm)Stall Torque
(6.0V) 94.43 oz/in. (6.8kg.cm)Operating Angle
45 Deg. one side pulse traveling 400usec360
Modifiable YesDirection Clockwise/Pulse
Traveling 1500 to 1900usecCurrent Drain (4.8V)
8.8mA/idle and 400mA no load operatingCurrent
Drain (6.0V) 9.1mA/idle and 500mA no load
operatingDead Band Width 8usecMotor Type 3
Pole FerritePotentiometer Drive Indirect Drive
Bearing Type Dual Ball BearingGear Type 3
Metal Gears and 1 Resin Metal GearConnector Wire
Length 11.81" (300mm)Dimensions 1.59" x 0.77"x
1.48" (40.6 x 19.8 x 37.8mm)Weight 1.94oz.
(55.2g)
12Practical lesson 7
Assignment 5
- Choice 1 or 2
- 1.Write a program which turns over the analogue
value of a pot meter into the speed of an engine
using PWM. - 2. Write a program which turns over the analogue
value of a pot meter into the position of a
servo-engine using PWM. Build the circuit
yourself.
13End of the module