# Inverted Pendulum For The Control Enthusiast

Once you step into the world of controls, you quickly realize that controlling even simple systems isn’t as easy as applying voltage to a servo. Before you start working on your own bipedal robot or scratch-built drone, though, you might want to get some practice with this intricate field of engineering. A classic problem in this area is the inverted pendulum, and [Philip] has created a great model of this which helps illustrate the basics of controls, with some AI mixed in.

Called the ZIPY, the project is a “Cart Pole” design that uses a movable cart on a trolley to balance a pendulum above. The pendulum is attached at one point to the cart. By moving the cart back and forth, the pendulum can be kept in a vertical position. The control uses the OpenAI Gym toolkit which is a way to easily use reinforcement learning algorithms in your own projects. With some Python, some 3D printed parts, and the toolkit, [Philip] was able to get his project to successfully balance the pendulum on the cart.

Of course, the OpenAI Gym toolkit is useful for many more projects where you might want some sort of machine learning to help out. If you want to play around with machine learning without having to build anything, though, you can also explore it in your browser.

## 21 thoughts on “Inverted Pendulum For The Control Enthusiast”

1. BillSF9c says:

Ok… help me out. Application? Writing upside down, in space? (Almost an oxymoron, eh?) So.. we did thus, w a pencil, as kids. Now, try to find a pencil… Now we will be able to entertain Martians via Virtual Presence? (See also, K. Dean Stephens.) C’mon… before I have to look for a pencil sharpener. (Pentel no longer produces the one I loved.) Yes… a fInger ???? of speech. I use a knife. If in ‘Frisco, see the nice big one that runs a tallll clock at the Exploritorium. Take the kids. (Robot jugglers? Will they semi-commit “errors” as they tell jokes which are simoultaneously PG and PG17 rated.?)

1. Jeffo says:

What?

2. JJ says:

Drugs are a hell of a drug.

3. snaslund says:

Best application of the upside down pendulum guidance that I have seen would be the Segway. Its pretty much the same logic that stabilizes a Segway.

2. Peter A Neilson says:

Okayyyyy, let’s add another degree of freedom, like when I balance a broom (the longer the easier) on one fingertip.

1. Any significantly advanced technology is indistinguishable from magic…

3. Clara says:

Hackaday folks, please stop using animated GIFs and use HTML5 video instead. Real video looks better, compresses better (that GIF is 1.6 MB, a low-resolution three-second video would be super tiny by comparison), and can be paused. Surely WordPress supports it, since HTML5 video has been around for several years.

1. Cknopp says:

Modern internet speeds have been around even longer. Get some.

1. Queeg says:

You should try getting some modern internet speed in an airliner. There’s a reason ‘gogo’ is known as ‘no go.’

2. Clara says:

There are plenty of problems with using GIFs for video other than loading time, some of which I outlined above. Heck, thee are problems with file size other than loading time: not everyone can afford an unlimited data plan. Also, there are hackers in less privileged areas where high speeds aren’t available.

3. Hank R Hill says:

I am terribly sorry for living in a country without real mobile flatrates. There are many occasions where two megabgtes over my 4G-connection is a lot. Therefore I hate webpages with “mandatory” animated GIFs.
ym2c.

2. Daniel Dunn says:

Unlimited data plans are expensive, and a lot of people use phones on the bus.

“We don’t need to optimize this software because hardware is getting better all the time” is usually not all that true.

4. Paul says:

I saw an inverted pendulum done in 1978 with just four op-amps, two potentiometers and a plane-jane DC brushed motor. No computer, no encoders, DACs, ADCs, or code. No simulations. Just a controls engineer guy who knew what he was doing. I was blown away. I’ve been trying to do it off-and-on ever since, but I can’t replicate that wizard’s feat. I did it digitally with a 25 MHz ‘486 around 1993, but that’s cheating. I think throwing even an Arduino at the problem is still cheating.

I’m still trying to figure out how to do it with only 4 opamps. Maybe now that the Great Google is here I should look there for some inspiration.

1. W says:

I think you can control one with nested PID loops or similar. If you need non-zero I and D terms then that’s about 3 op-amps without even applying some cleverness; I expect you could do it with two.

5. BillSF9c says:

How about using the nano-copter accelerometer than a fellow here recently used on a paper airplane?

6. Ryan says:

Aren’t single inverted pendulums like a second year undergrad controls lab?

7. Smorges Borges says:

My college roommate could balance just about anything on his nose.
While waiting in line at the grocery we’d ask him to balance random stuff. Umbrellas, VHS tapes, etc. It was a hoot.
It was an interesting talent. I wonder why and how his brain and body were able to do that?

1. bob says:

It’s probably a human skill from prehistory that hasn’t been lost. It’s common still for africans to carry water pots on their heads for long distances. I guess keeping the spine straight is important to avoid back injury which could occur by carrying with one hand.

8. Now do this with a trombone and you will have musicians mesmerized for huge amounts of time … then you can pick their pockets … “Bender: (Just a head; his body is gone) It’s me bender. I’m being entertaining. [Sings] La la la. Look at my head. It’s okay to look at my head. I’ve got big old head and hey hoo. (Bender’s body steals Amy’s wallet) Okay show’s over I’m tired.” :-) ????

9. Giant animated gifs are painfully slow to load on raspberry pis as well. No need to be so unnecessarily elitist about bandwidth. You are not the person we all strive to be.

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.