University of Melbourne · FACULTY OF ENGINEERING

ENGR10006 Chap.8 Servo Motors, PWM and Finite State Machines

- one subject, every graph, every model, every mark
8 Chapters3-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 8 of 13 · ENGR10006

Servo Motors, PWM and Finite State Machines

The robot's outputs and its decision logic are the subject of Workshops 3 to 6. This chapter explains pulse-width modulation, where the high time within each period sets the average voltage and carries the servo command, and the two servo types on the robot: continuous-rotation wheels that stop at a 1500 microsecond pulse and turn faster as the pulse moves away from it, and a standard gripper servo that holds an angle between 0 and 180 degrees with no angle feedback.

It then defines finite state machines by their states, initial state, transitions, triggering conditions and outputs, covers guards and Boolean operators in Stateflow, Moore outputs, stuck and unreachable states, and the readability habits the demonstration rubric rewards. Worked examples turn the behaviour table into wheel commands.

In this chapter

What this chapter covers

  • 01

    PWM, duty cycle and average voltage

  • 02

    Continuous-rotation wheel servos

  • 03

    Wheel pulse-width table

  • 04

    Servo transfer characteristic

  • 05

    Standard gripper servo

  • 06

    Finite state machine definition

  • 07

    Guards and Boolean operators

  • 08

    Stuck and unreachable states

Worked example · free

Checking a five-state collection cycle for faults

Q [4 marks]. A robot chart has five states: Calibrate, Follow line, Grip object, Return and Drop object. The guards are samples done, object near, gripped, T-junction and released, and the arrow with no source points at Calibrate. Identify the initial state, check every state for an entry and an exit, and describe the object-near guard using a distance variable d and a threshold variable dGrip. Marks are AskSia practice weightings, not a University scheme.
This original collection cycle has five states joined by guarded transitions; the short arrow entering Calibrate from nowhere marks the initial state, and each This original collection cycle has five states joined by guarded transitions; the short arrow entering Calibrate from nowhere marks the initial state, and each label names the condition that must be true.CalibrateFollow lineGrip objectReturnDrop objectsamples doneobject neargrippedT-junctionreleased
This original collection cycle has five states joined by guarded transitions; the short arrow entering Calibrate from nowhere marks the initial state, and each label names the condition that must be true.
  • +1The arrow with no source marks Calibrate as the initial state.
  • +1Follow line is entered from Calibrate and from Drop object and leaves to Grip object; Grip object leaves to Return, Return to Drop object, and Drop object back to Follow line.
  • +1Every state has at least one entry and one exit, so none is stuck and none is unreachable; Calibrate is entered only by the initial arrow, which is correct for a start-up state.
  • +1Guard for object near: the less-than test of distance d against threshold dGrip, with dGrip set in the initial transition rather than typed as a number.
Initial state Calibrate; no stuck or unreachable states; the object-near guard tests d less than dGrip, with dGrip as a variable.
Sia tip — Trace one full lap of the cycle with your finger; any state your finger cannot leave is a stuck state.
Glossary

Key terms

Pulse-width modulation
Control by an on-off signal whose high time within each period is adjusted.
Continuous-rotation servo
A servo whose pulse width sets speed and direction rather than angle.
Standard servo
A servo that holds a commanded angle between 0 and 180 degrees, used for the gripper.
Transfer characteristic
The measured relation between pulse width and wheel speed for one servo.
Guard
A condition that must be true for a state transition to occur.
Moore machine
A state machine whose outputs depend only on the current state.
Superstate
A parent state that groups substates to make a chart easier to read.
Temporal logic
Timing conditions written in transitions, such as waiting a set time before moving on.
FAQ

Servo Motors, PWM and Finite State Machines FAQ

Why do the two wheels need different pulse widths to drive straight?

The wheel servos are mounted facing opposite directions, so to move the robot forward one must turn clockwise and the other counter-clockwise. The behaviour sheet therefore gives 1400 µs to the right wheel and 1600 µs to the left wheel for full speed forward.

What makes a state stuck or unreachable?

The Workshop 5 slides define a state with no exits as stuck, because the machine can never leave it until reset, and a state with no entries as unreachable, because no transition ever leads there. Check every state for at least one way in and one way out.

Where should timing go in a Stateflow chart?

The troubleshooting notes warn that time statements inside a state are ignored. Put timing in transition guards with temporal logic, and keep thresholds as variables set in the initial transition, which also earns readability marks at the demonstration.

How does the gripper servo differ from the wheel servos?

The gripper uses a standard servo that can sit at any angle from 0 to 180 degrees, set by 0.75 to 2.25 ms pulses every 20 ms, and gives no feedback on its current angle. The wheels use continuous-rotation servos, where the pulse width sets speed and direction instead.

Study strategy

Assessment move

Learn the wheel table by reasoning rather than memory: start from 1500 for stationary, then decide which wheel must turn and in which direction for each manoeuvre. Measure your own servos' transfer characteristics carefully, avoiding long runs at 1450 and 1550 microseconds where the motors are known to stick or jitter, and use your measurements rather than generic values.

For PWM, always compute the fraction of the period spent high before multiplying by the high voltage. For state machines, sketch the chart on paper first, mark the initial state, write every guard as a Boolean expression with brackets, and check that each state has an entry and an exit. Replace every repeated number with a variable set in the initial transition and group related states into superstates.

Then read your chart against the demonstration rubric's readability criterion before the final submission. Save a screenshot of the chart after each workshop so the report can show how it evolved.

A+Everything unlocked
Unlocks this Bible + all 181 of your University of Melbourne subjects - and 1,000+ Bibles across every Australian university.
Sia - your ENGR10006 tutor, unlimited, worked the way the exam marks it
The full 3-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works