Servo Position Control with Python and micro:bit

What it’s About

A servo is a motor device that turns to and holds a position.  The servo you will be working with in these activities is the kind that steers small remote controlled cars, boats, and planes.  They are also found in products like copy machines and the mechanical lens auto-focus in some high-end cameras.  Stage animators use large ones to move props and mannequins.  Larger versions of the servo are also used by this robot to manipulate a gripper it uses to pick up objects.

       TSJC Robotics Team entry in the  COSGC’s Robotics Challenge, source: YouTube

TSJC Robotics Team entry in the COSGC’s Robotics Challenge, source: YouTube

 

In these activities, you will build circuits and write scripts that make the micro:bit:

  • Measure the servo’s battery supply to make sure the batteries are good
  • Control angles where it positions and holds an armature called a servo horn
  • Calculate values to position the servo horn based on a given angle
  • Guide the servo horn position by typing values into a terminal
  • Control servo horn position with pushbuttons
  • Control servo horn position with tilt
  • Measure servo signals with the CYBERscope’s oscilloscope feature

Before you Start

Here is a list of items you will need and tutorials we recommend you complete before continuing with these activities.

You will need:

Complete these tutorials first:


After You Finish

You will be able to:

  • Measure a supply with a voltmeter and make sure the alkaline batteries are not dead
  • Calculate a value for making a servo motor hold certain degree positions
  • Use two equations in two unknowns to convert a position angle into a value the micro:bit can use
  • Rearrange an equation to calculate a servo angle position in degrees given a value the micro:bit used
  • Understand the difference between an angle and angular velocity
  • Understand how an object’s orientation in space can be measured as an angle in relation to the force of gravity
  • Measure servo control signals for period, frequency, and control pulse width

These skills become important in robotics projects where you have to achieve a certain goal by monitoring sensors and using the measurements to make motors do things like pick items up, position them, and more.  These skills are also used in factory settings where motors are expected to position items during assembly.  Of course, if you want to invent your own radio controlled car, boat, plane, or other remotely operated vehicle (ROV), these activities contain some important basics to help get you started.