Building an Inverted Pendulum System The Ups and Downs of Defying Gravity…

May 5, 2010

First inversion try

Filed under: Software — Bruce Ammons @ 11:32 pm

I worked a little more on the model, and decided it is probably close enough.  I got tired of waiting and decided to just try the current algorithm on the actual pendulum.

I added the control code to the existing pendulum interface, which wasn’t too difficult to do.  I started running the program and immediately discovered a problem.  The gains I had selected, which worked fine on the ideal model, were way too high for the real system.  The noise in the signals made the cart chatter while just trying to maintain a hanging position.  Moving to a new hanging position made the cart go crazy.  For a quick solution, I reduced the gains to about 1/4 their original value, and it seemed okay.  The chatter went away, but the pendulum wasn’t really staying still.  I could move to different positions without too many problems.

After getting the hanging controls in reasonable shape, I decided to try the swingup and had more problems.  It seems like nothing works as easily on a real system as it does in simulation, not that I am surprised.  In my swingup logic, I was using the angular position of the pendulum to make some decisions on control.  In the simulation, looking at the sign of the angle worked great.  The sign was always either +1 or -1.  However, on the real system the encoder makes it possible to have an angle of exactly zero, which gives a sign of zero.  My swingup kept moving in one direction and never reversed directions.  That just doesn’t work if you want to swing up the pendulum.  I did a quick fix that started the pendulum swinging, but the quick fix only worked until the pendulum was halfway up.  I will have to do a more permanent fix to handle the zero angle situation.

It was nice to see the pendulum doing something other than a sinusoid, even though I didn’t have a lot of success on my first try.

May 3, 2010

Simulation works well

Filed under: Software — Bruce Ammons @ 10:12 pm

I used the cart and pendulum models to update a pendulum simulation program I developed long before I started building the pendulum.  I changed the equations to use PWM instead of force, and modified the control algorithms to match.

The simulation works pretty well.  I can swing up the pendulum pretty quickly and maintain the inverted pendulum.  I am not going to share any of my algorithms at this point since I plan on running a competition to design the best algorithm.  Wouldn’t want to make it too easy, would I?

I will share that I started with PID algorithms to maintain the inverted pendulum, but there was a lot of wobble.  The pendulum would sway back and forth several times before settling into the correct position.  I switched to state space control, and it works much better.  The pendulum immediately moves to the right place with no sway or wobble.  It is the control method I would recommend.  I am still learning how to optimize the method, though.

Now I just need to verify my models by collecting some more data from the actual system, then I will try my pendulum inversion algorithm on the actual system.

« Newer Posts

Powered by WordPress