Professional Documents
Culture Documents
com/tutorial
s/servo_motor/data.html
Hi-Tec Servo Motors have three wires coming out of them.
The power & ground wires are hooked directly up to whatever battery or power
supply you are using to power the servos. The Signal wire will be hooked up to the
microcontroller used to control the servo, in our case the PIC. A noticeable first
impression, the servo only requires 1 pin from the pic.
The PWM Signal
The signal that we need to create inorder to control the servos is called a Pulse
With Modulation signal or PWM for short. The general requirements are:
Frequency: 50Hz
Up-time: 0.9mS->2.1mS
Down-time: 19.1mS-17.9mS
At first glance these definitions & numbers might make little or no sense. So
lets look at a simple PWM wave at 50Hz.
So a PWM wave is just a signal that changes between 0 volts & 5 volts (digital
logic 0 and 1). We see that the wave is symmetrical; uptime is 10mS & downtime is
10mS which when added together give us the period (10mS + 10mS = 20mS).
You may have noticed that the servos we're using are rated at 4.8v & 6v. We're
hooking 5v to the servos in this tutorial just to make things easier. This will not harm
the servos in any way. They can be safely operated between 4.8 and 6 volts. The
increase in voltage gives the servos more torque.
The Multi Servo Schematic
One thing about robotics is that you are never ever doing only 1 thing at a time.
When it comes to using servos in robotics it is very common that your project will
have 2, 3 or even 4 servos that need to be operated at once. The multi servo schematic
below is not very different from the single servo schematic above, but the software
method for controlling the 3 servos simultaneously is intuitively different. We'll go
over this in detail in the next section.
Click to Enlarge:
3 Pins are used to output control PWM signals to the 3 servos. RB0, RB1 &
RB2. Don't forget these names because in the next section we'll see them again.
Now that we know the necessary delays to create inorder to get a proper servo
PWM input signal, let's look at the code. The code is fairly long so I'll go over the
most important part.
Download The Entire Program Here: servo_single.c
Begin Code
for(count=0;count<50;count++) //50 * 0.020 Seconds = 1 Second
{
PORTB = 0x01;
//PortB Pin 0 = 5v (logic 1)
Delay1KTCYx(7); //Delay 1.5mS
Delay100TCYx(5);
PORTB = 0x00;
//PortB Pin 0 = 0v (logic 0)
Delay1KTCYx(92);//Delay 18.5mS
Delay100TCYx(5);
}
End Code
This little chunk of code will move the servo to a 45 angle and hold there for
1 second. The servos are very strong so for that 1 second try as you might but you
won't be able to change the angle it's at.
Motor Servo
3:
Servo Motor. : 90 -> 45 -> 0 .
:
inorder
PWM , .
' .
: servo_single.c
(count = 0? <50? + +) / / 50 * 0,020 = 1
{
PORTB = 0x01? / / PORTB Pin 0 = 5V ( 1)
Delay1KTCYx (7)? / / 1.5mS
Delay100TCYx (5)?
Motor Servo
. & servos
.
9 servos .
servos .
: multi_servo.c
,
,
, . PIC
.
.
Previous Page
Servo Motor:
Servo Motor
Servo Motors
. .
,
.
,
servos .
servos . Hi-Tec,
Futaba, airtronics .
PWM .
servos .
servos .
servos PIC AMD
,
.
servos
.
servos
.
DC Motors &
Servo Motors stepper
.
, stepper
.
, servo!