RC Servo Motor Control Using PWM
RC Servo Motor Control Using PWM
RC Servo Motor Control Using PWM
PROJECT REPORT
ON
SUBMITTED BY
Introduction:
Servo motors (or servos) are self-contained electric devices that rotate
or push parts of a machine with great precision. Servos are found in
many places: from toys to home electronics to cars and airplanes. If you
have a radio-controlled model car, airplane, or helicopter, you are using
at least a few servos. In a model car or aircraft, servos move levers back
and forth to control steering or adjust wing surfaces. By rotating a shaft
connected to the engine throttle, a servo regulates the speed of a fuel-
powered car or aircraft. Servos also appear behind the scenes in devices
we use every day. Electronic devices such as DVD and Blu-ray
Disc players use servos to extend or retract the disc trays. In 21st-
century automobiles, servos manage the car's speed. The gas pedal,
similar to the volume control on a radio, sends an electrical signal that
tells the car's computer how far down it is pressed. The car's computer
calculates that information and other data from other sensors and sends a
signal to the servo attached to the throttle to adjust the engine speed.
Commercial aircraft use servos and a related hydraulic technology to
push and pull just about everything in the plane.
When the user will press P0.1 the Pulse width will be 1ms, and similarly
when the user presses P0.2, P0.3, P0.4 the Pulse Width will change to
1.25ms, 1.5ms and 1.75ms respectively and hence Servo will change its
position correspondingly.
ARM PERIPHERALS USED
Pulse width modulation (PWM) is a powerful technique for
controlling analog circuits with a processor's digital outputs.
PWM is employed in a wide variety of applications, ranging
from measurement and communications to power control and
conversion.
A period of a pulse consists of an ON cycle (HIGH) and
an OFF cycle (LOW). The fraction for which the signal is ON over
a period is known as duty cycle.
1) Single Edge PWM – Pulse starts with new Period i.e. pulse is always
at the beginning.
2) Double Edge PWM – Pulse can be anywhere within the Period
Registers Description of PWM
VPBDIV=0x00 APB bus clock (PCLK) is one fourth of the processor clock (CCLK)
VPBDIV=0x01 APB bus clock (PCLK) is the same as the processor clock (CCLK)
VPBDIV=0x02 APB bus clock (PCLK) is one half of the processor clock (CCLK)
void setupPLL0(void)
{
PLL0CON = 0x01; // PPLE=1 & PPLC=0 so it will be enabled
// but not connected after FEED sequence
PLL0CFG = 0x24; // set the multipler to 5 (i.e actually 4)
// i.e 12x5 = 60 Mhz (M - 1 = 4)!!!
// Set P=2 since we want FCCO in range!!!
}
void feedSeq(void)
{
PLL0FEED = 0xAA;
PLL0FEED = 0x55;
}
void connectPLL0(void)
{
// check whether PLL has locked on to the desired freq by reading the lock bit
// in the PPL0STAT register
while( !( PLL0STAT & PLOCK ));
// now enable(again) and connect
PLL0CON = 0x03;
}
OUTPUT:
Conclusion: