Shake, Rattle and Roll: building machines with a sense of balance

Mammals, birds, flying insects and even plants all have an intrinsic sense of balance. Inspired by examples from nature, students will learn about what it takes to build a machine that can balance itself. We’ll learn how to work with digital accelerometers and gyroscopes, devices that are used in applications from smartphones, rocketry, aircrafts, earthquake detection, vehicle collisions, remote sensing and video games. The goal of the class is to build and program machines that have a sense of balance. In week 1, students will learn about the physics of stability, and be introduced to the Arduino electronics platform. In week 2, they will learn to use accelerometers and gyroscopes to track the orientation of an object. Possible applications include a wearable video game controller. In the third week, they will build basic robots that respond to their orientation, and keep balance. Possible projects include a miniature 'Segway' robot, or a self-stabilizing tray that won't spill drinks when tilted.

Course Plan 

July 2nd - July 20th: Mon, Tues, Thurs, Fri at 10:45am-12:05pm

80 minutes

Arduino: learn by doing

1. Goals of the class:

        a. Learn to program physical devices using Arduino

        b. Use Arduino to sense the world

        c. Respond to your senses: feedback

stability = orientation + response

(where you want to be) = (where you are) + (how to get there)

Strategies of orientation:

orientation in humans - visual feedback, inner ear

orientation in insects - halteres

orientation in machines - smartphones, segway, unipod, bigdog

Related docs and inventory:

Balancing robot instructions: http://www.kerrywong.com/2012/03/08/a-self-balancing-robot-i/

Balancing robot for dummies: http://arduino.cc/forum/index.php/topic,60170.0.html

Accelerometer and Gyro tutorial: http://www.instructables.com/id/Accelerometer-Gyro-Tutorial/

Flying breadboard: http://awesomecopter.nl/

Triple axis accelerometer and gyroscope: http://www.sparkfun.com/products/10121 http://www.sparkfun.com/products/11028

Guide to gyro/accel w/ arduino. Kalman filtering: http://arduino.cc/forum/index.php/topic,58048.msg417140.html#msg417140

Stable tray: http://fsfcayne.free.fr/autre/prog.txt http://www.youtube.com/watch?v=1F1hsDe_HtQ

Course Plan

1 and 2: Topics in Stability

stability = orientation + response

(where you want to be) = (where you are) + (how to get there)

Strategies of orientation:

orientation in humans - visual feedback, inner ear

orientation in insects - halteres

orientation in plants - geotropism http://bit.ly/HmjQzd

orientation in machines - smartphones, segway, unipod, bigdog

Two strategies: Accelerometer vs Gyroscope

a. How to build an accelerometer? What does it do?

b. Gyroscope Demo. Bicycle wheel demo.

How does a gyroscope work? Non-mathematical explanation of precession. http://bit.ly/I2vA5x

Why is it useful?

3 and 4: Introduction to Arduino Programming

Workshops where students work in pairs to program an Arduino in challenges that introduce them to aspects of the programming language.

basic code structure

variables

for loops

outputs: lighting LEDs, moving motors, making sound

inputs: light sensor

plotting sensor input to screen

Comic book guide to Arduino: http://t.co/55efMF2o

5: Where am I?

Real-time plots of angle from sensors

Combining input from gyroscope and acceleration sensor

Gyroscope drift, and how to correct for it

6: Where am I? (continued): Interfacing with machines

Using gyroscope / acceleration in basic projects

Control a motor, control an icon on screen, balancing board, etc.

7. Building a stable bot: the elements

The inverted pendulum problem

Stability and centre of mass

Start building two wheeled robot

8. Building a stable bot: continued

Finish building two wheeled bot

Place accel/gyro on robot

Test locomotion

9. Responding to senses: Feedback

Strategies to avoid toppling (wheel speed proportional to angle)

Anticipating the future: a PID controller (incorporates the slope i.e. angular velocity):

Why is it important?

Write code for PID controller

10. Tuning Feedback

Tune the PID values for smooth motion

Test robot stability

11 and 12. Buffer classes for spillover, testing, or project extensions