top of page

PID controller

Individual project. Programmed a self-balancing dancing Segway for the Advanced Electronics module using Python.

Program a mini-Segway to self-balance and dance to live music on two wheels using a PID controller. Self-balancing is achieved by using feedback control. Instead of using motor speed as the control variable, the pitch angle is used. The pitch angle is measured with an inertia measurement unit using a complementary filter and then, is compared to the set point. In this case the set-point is zero if the Segway is upright. The controller output value w(t) is derived with all PID terms of the pitch angle.

The PID controller algorithm diagram is attached below. This unit used is a PyBench Board (designed by Professor Peter Cheung, Imperial College London); an electronic workbench which is programmed using MicroPython (uPy), and controlled via the USB serial port. The PyBench board has many functions and can produce signals as well as capturing signals. The various components on the PyBench board uses a microcontroller known as the PYB v1.1. It is an ARM processor board that runs MicroPython.

bottom of page