Lesson plan

Build a boat autopilot lesson plan

A tiller pilot for the simulator: a tilt-compensated compass with declination, a limited rudder, a PID heading loop that knows 359 from 1 and ignores waves, and great-circle navigation to GPS waypoints. Never for real navigation.

3 chapters, 6 lessons, about 7 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

The unit

Objectives and materials

By the end, students can

  • Heading from a three-axis compass, declination, and tilt compensation for a heeling boat.
  • A rudder with limits, and a PID heading loop that wraps, recovers and does not hunt.
  • Great-circle distance and bearing to waypoints, then the whole route.

Materials for the whole unit

  • Accelerometer and compass, LSM303AGR
  • Arduino Uno R3
  • GPS module, NEO-6M
  • Hobby servo
  • Rotary encoder, KY-040

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 2 h 20 min

Which way is north

Heading from a three-axis compass, declination, and tilt compensation for a heeling boat.

LessonTimeWhat students do
Heading from a compassAn LSM303AGR measures the Earth’s field in three axes. Turn two of them into a heading with atan2, keep it in 0 to 360, and correct magnetic north to true north with the declination.80 min
  1. A pilot for the simulator
  2. Two axes and atan2
  3. Keep it in 0 to 360
  4. Magnetic is not true
  5. Somewhere else
Tilt compensationA sailboat heels. Tip a flat compass and the vertical field leaks into its reading. Heel 20 degrees and watch north read 329, then see how the accelerometer puts it back.60 min
  1. Heel it
  2. Gravity says which way is down
  3. Rotate the field back
  4. Without it

Materials

  • Accelerometer and compass, LSM303AGR
  • Arduino Uno R3
  • GPS module, NEO-6M
  • Hobby servo
  • Rotary encoder, KY-040

Check for understanding

Each student finishes "Tilt compensation" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Without it".

Chapter 2. About 2 h 35 min

Steer

A rudder with limits, and a PID heading loop that wraps, recovers and does not hunt.

LessonTimeWhat students do
A rudder servoThe rudder is a servo with limits: 30 degrees each way and 40 degrees a second. Steer by hand in standby, hit the stop, watch the modeled boat turn, and slow the rudder to a real ram’s speed.60 min
  1. Hand steering
  2. The stop
  3. The boat turns
  4. A slower rudder
A PID heading loopClose the loop: AUTO holds a course with a PID on the heading error. Turn to a new course, fall into the 359 to 1 trap and out of it, ride out a knock, and stop the rudder hunting in waves.95 min
  1. AUTO
  2. A new course
  3. The 359 to 1 trap
  4. A knock
  5. Hunting in waves
  6. A deadband

Materials

  • Accelerometer and compass, LSM303AGR
  • Arduino Uno R3
  • GPS module, NEO-6M
  • Hobby servo
  • Rotary encoder, KY-040

Check for understanding

Each student finishes "A PID heading loop" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A deadband".

Chapter 3. About 2 h

Navigate

Great-circle distance and bearing to waypoints, then the whole route.

LessonTimeWhat students do
GPS waypointsFrom holding a heading to going somewhere. Get a fix, work out great-circle distance and bearing to a waypoint, steer to it, and switch to the next one inside an arrival radius.60 min
  1. A fix
  2. Distance and bearing
  3. Arrive
  4. A bigger circle
Project: hold a courseSail the whole route, add a leg of your own, steer it from the knob, and write up the pilot with its limits.60 min
  1. The whole route
  2. A leg of your own
  3. The knob
  4. Write it up

Materials

  • Accelerometer and compass, LSM303AGR
  • Arduino Uno R3
  • GPS module, NEO-6M
  • Hobby servo
  • Rotary encoder, KY-040

Check for understanding

Each student finishes "Project: hold a course" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Write it up".

Your class

Teach this unit as a class

Start a class from this course and its 6 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.