Watch An Inverted Pendulum - Arduino-Driven

### New Book Reviews!

 Watch An Inverted Pendulum - Arduino-Driven
Written by Mike James
Saturday, 02 June 2018

If you have never seen an inverted pendulum in action - it's fun. What is even more fun is implementing one. Is it IoT? Is it control theory? Is it AI? It can be any and all - and did I mention it's fun?

What is an inverted pendulum?

Well if you pick up a stick and try and balance it on your finger you have the right idea. Most inverted pendulums are implemented as a small driven cart with a lever pivoted at a hinge on the cart. The cart can move left and right and by doing so it can apply an acceleration  - or if you like a force - to the end of the pendulum:

There are a number of variations on the basic idea - the one in the video, for example, has a 360 degree pivot and so starts from a hanging down position.

This is a classic problem in control theory and it was one of the first problems I solved using reinforcement learning - but it was only a simulated inverted pendulum, the real thing is so much better.

Ben Wiener and Philip Zucker built ZIPY - Zippy Inverted Pendulum Yakshave -  after taking a course in under-actuated robots and wanted something that wasn't just a "lame simulation".

The real world also has a way of making things more difficult than a simulation. The hardware is a 3D printed cart with a DC motor and belt drive. The pendulum, a paint stirrer, is hinged on a rotary encoder which measures the angle. A second rotary encoder is attached to the belt and gives the position of the cart. The controller is an Arduino Uno, which limited the precision to 600 positions per revolution.

The software implements two controllers - one to get the pole swung up into position and another to keep it there. The balancing controller is based on a linear quadratic regulator (LQR) implemented in Python.

You can see the results:

So far it is interesting to discover what didn't work. Monitoring the position using markers and OpenCV vision system sort of worked, but was more difficult than expected due to spurious objects in the frame and the processing delay. So far they haven't implemented a reinforcement learning algorithm.

If you fancy trying your hand all of the code and the 3D printer files are available. It is worth doing projects like this just to find out what the world is really like.

ZIPY — A Homebrew Inverted Pendulum and Control System

#### Related Articles

Worm Balances A Pole On Its Tail

The Amazing Dr Guero And His Walking Robots

Cubli - A Reaction Wheel Drive Robot

 Node.js Even Its Creator Thinks Its Flawed15/06/2018You have to admire Ryan Dahl for creating node.js, even if you don't like it - and there are plenty of people who don't. Now he is back with  an admission that node.js isn't as good as it co [ ... ] + Full Story Apple Launches JavaScript Map Kit13/06/2018Apple has released a beta version of a JavaScript library for working with interactive maps on web pages. MapKit JS provides map rendering that is optimized for various browsers and devices, and suppo [ ... ] + Full Story More News