Adding Movement to Projects with Servos

This blog post on working with servos is an excerpt from Lesson C-7 of our Intro to Robotics program. Level C is the third level in Intro to Robotics and covers working with complex electrical components, writing advanced-level code commands in Python, and using a Raspberry Pi to control your electronics projects with the code you write. It contains 18 lessons including 30+ videos and 54 projects and activities. Sample lessons and a full scope and sequence for Level C can be found here.

 

What Are Servos?

Servomechanisms, more commonly referred to as servos, are used in electronic projects and toys to create motion. A servo contains a small motor, some drive circuitry, and multiple gears that increase the amount of work that can be done with the servo. Work that can be done by a servo might be moving steering linkage in a remote-controlled car, positioning the axes of a pan/tilt camera mount, or any other place where motion is required in a project.

Servo parts diagram 

 

Driving a Servo

Servos are driven using a PWM signal with varying duty cycles. You may remember this image from Lesson B-4 about Pulse Width Modulation:

Pulse Width Modulation Duty Cycle for Servos 

Servos can be driven with a PWM signal running at 50 Hz. For a positional servo, varying the duty cycle on the drive signal between 2.5% and 12.5% will command the servo to move to the corresponding position in its 180° range:

Servo position and duty cycle diagram 

 

Using Servos in Projects

One thing most positional servos lack is any physical marking to indicate which direction the output shaft is currently pointed. The internal electronics of the servo will drive the output shaft to point a certain direction when powered up and driven by a neutral 7% duty cycle. This means that you will not know which direction the servo neutral position is until it has been powered up and driven into neutral.

Working with servos safely diagram 

Since software PWM is being used to drive the servo in this lesson, you may see slight servo jitter when the Raspberry Pi is busy with other program or operating system tasks. These tasks momentarily take resources away from the software that's trying to generate the PWM signal. This will result in the servo moving back and forth slightly around its intended position. While this behavior might negatively impact some applications, software PWM still works well enough for many applications, like those in the activities section of this lesson.

Breadboard circuit with servo, amplifier, and speaker 

This blog post on working with servos is an excerpt from Lesson C-7 of our Intro to Robotics program. Level C is the third level in Intro to Robotics and covers working with complex electrical components, writing advanced-level code commands in Python, and using a Raspberry Pi to control your electronics projects with the code you write. It contains 18 lessons including 30+ videos and 54 projects and activities. Sample lessons and a full scope and sequence for Level C can be found here.
Older Post
Newer Post
Close (esc)

Popup

Use this popup to embed a mailing list sign up form. Alternatively use it as a simple call to action with a link to a product or a page.

Age verification

By clicking enter you are verifying that you are old enough to consume alcohol.

Search

Your cart is currently empty.
Shop now