liveBook · Manning

Actuation range

As explained in Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi

The actuation range is the permitted interval of physical positions through which a servo can move.

An actuation range sets the real physical angle interval a servo is allowed to travel. A servo may accept angles up to 180 in software while its mechanism moves through a smaller interval. For a pan servo that physically travels from 0 to 142 degrees, set its actuation range to 142 so angle values match the measured movement. section 8.4.1

>>> crickit.servo_1.angle = 0
>>> crickit.servo_1.actuation_range = 142

Move the servo to its lowest position, then configure the measured 142-degree range before sending later angle commands. section 8.4.1

After configuration, use angles within the configured interval: 0 is the low end, 142 is the high end, and 71 is the midpoint. Sending an angle beyond the configured range, such as 180 for this servo, raises a ValueError instead of driving the servo past its allowed range. section 8.4.1

Keep two related limits separate when controlling a moving camera:

  • The servo’s actuation range describes its measured physical travel and is assigned to the servo object. section 8.4.1
  • Application min and max angles define the smaller operating window used for a particular motion, such as panning from 30 to 110 degrees. section 8.4.2
  • A starting angle gives each servo a known position when the program begins. section 8.4.2

For repeatable pan-and-tilt control, store each servo, its operating minimum and maximum, start angle, and actuation range in a configuration dictionary. During initialization, assign each servo’s actuation range and then move it to its start angle. A movement function can calculate a proposed new angle from a fixed step and apply it only when that angle remains between the configured minimum and maximum. section 8.4.2

Listing 8.3 pan.py: Performing pan and tilt movements with the servo motors
#!/usr/bin/env python3
from adafruit_crickit import crickit
import time
 
ANGLE_STEP = 2
PAN = dict(servo=crickit.servo_1, min=30, max=110, start=70, range=142)
TILT = dict(servo=crickit.servo_2, min=90, max=180, start=180, range=180)
MOVE = dict(left=(PAN, -1), right=(PAN, 1), up=(TILT, -1), down=(TILT, 1))
 
def move_motor(direction):
    motor, factor = MOVE[direction]
    new_angle = motor['servo'].angle + (ANGLE_STEP * factor)
    if motor['min'] <= new_angle <= motor['max']:
        motor['servo'].angle = new_angle
 
def init_motors():
    for motor in [PAN, TILT]:
        motor['servo'].actuation_range = motor['range']
        motor['servo'].angle = motor['start']
 
def main():
    init_motors()
 
    for i in range(20):
        print('moving left and up')
        move_motor('left')
        move_motor('up')
        time.sleep(0.1)
 
    for i in range(20):
        print('moving right and down')
        move_motor('right')
        move_motor('down')
        time.sleep(0.1)
 
if __name__ == "__main__":
    main()

The complete pan-and-tilt script configures ranges during startup and rejects movement steps outside each servo’s application limits. section 8.4.2

Pan-and-tilt sweep

A camera mount uses a pan servo with a 142-degree physical actuation range but restricts normal panning to 30–110 degrees. Its tilt servo uses a 180-degree range and operates from 90–180 degrees. Repeated left-and-up commands move by two degrees until the configured limits are reached; right-and-down commands return the camera through the allowed window. section 8.4.2

How Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi covers it

How deep it goes
Demonstrates range assignment, midpoint movement, out-of-range errors, and bounded step-by-step control without explaining servo internals.
Examples
Uses a 0–142-degree pan servo, a 90–180-degree tilt window, and a repeated two-degree camera sweep.
What it assumes
Introduces servo angle control through CRICKIT commands and Python configuration dictionaries without requiring prior electronics knowledge.
What you can do after
Operate/configure it by calibrating servo travel and enforcing safe application movement limits in a CRICKIT Python script.
How it connects
Connects servo motors, CRICKIT, camera pan-and-tilt control, angle values, ValueError, and Python dictionaries.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi. The section links point to the parts of the book it draws on.