Inverted Pendulum, Automation

TOTA42

Junior Member
Oct 16, 2004
13
0
0
Hey guys, I was just wondering if some guys could help me with our group's senior design. Our project is to design and build an inverted pendulum. I think I made a thread a while back talking about H-bridges, which is to be the motor's driver. We are using an arm assembly which one end is attached to the DC motor's shaft and the other end holding the pendulum. We managed to get the pendulum to balance in the upright position using a PID controller, but one of our other project specifications is to start in the downright position and use the motor to swing the pendulum until it gets upright and balance it there. We tried a few techniques using P, PD controllers but couldn't get it quite there. We managed to get it roughly 20 degrees above the x-axis plane if you look at it from the front, but still too low for the PID controller to takeover and balance. Anybody have some algorithms that they could suggest?
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Originally posted by: TOTA42
Hey guys, I was just wondering if some guys could help me with our group's senior design. Our project is to design and build an inverted pendulum. I think I made a thread a while back talking about H-bridges, which is to be the motor's driver. We are using an arm assembly which one end is attached to the DC motor's shaft and the other end holding the pendulum. We managed to get the pendulum to balance in the upright position using a PID controller, but one of our other project specifications is to start in the downright position and use the motor to swing the pendulum until it gets upright and balance it there. We tried a few techniques using P, PD controllers but couldn't get it quite there. We managed to get it roughly 20 degrees above the x-axis plane if you look at it from the front, but still too low for the PID controller to takeover and balance. Anybody have some algorithms that they could suggest?

Is it a control issue, or does your motor & assembly just not have enough oomph to get it there?
 

TOTA42

Junior Member
Oct 16, 2004
13
0
0
I'm thinking it's a control issue, if we don't pay attention to the system, the motor spins helluva quick that it occassionally rips the cable that connects to the optical encoder that the pendulum is attached. The only downside I can say about this motor is that it doesn't have a great "jerk" function, something our prof said called when the motor tries to change direction in small delta time. But even so, it changes direction fairly quick. Right now our algorithm to swing it upright is for the motor to swing in one direction, once the pendulum slows/stops and starts to change direction, get the motor to swing in the other direction, and repeat. This works great for the pendulum to get to the x-axis, but we're not too sure how to get the pendulum to be around roughly 45 degrees to the y-axis, so that the PID controller can take over. Our design looks similar to the one in this link, if it helps.

We're using a DC motor that operates btw 8-21V, but we're running it at 10V, in which the only other thing that we found out about it is that it's made from Italy, no manf. name model #..... We're also using the Motorola 6812 Microcontroller for most of the system.
 

FrankSchwab

Senior member
Nov 8, 2002
218
0
0
Even a relatively small motor should be able to get the pendulum up to vertical - it's simply a matter of continuing to add energy to the system on each swing. If the friction (air resistance/mechanical friction) dissipates more energy on each swing than the motor adds, you'll reach a steady-state condition that can only be broken by:
1. Adding more energy on each swing, i.e. a bigger motor or higher voltage, or
2. Reducing friction

Check the motor drive relative to the position of the pendulum - perhaps you have a firmware bug where you start driving the pendulum back down before it has reached the top of it's swing. Two LEDs across the motor leads would be a pretty good debugging addition - orient them (with an appropriate current limiting resistor) such that one (say a red one) lights when the motor is driving one way, and the other (say, a green one) lights when the motor is driving the other way. You'll immediately be able to tell if your timing is off. It'll be pretty cool when the pendulum is balancing also.

Is the motor directly driving the pendulum, or do you have a gear train/chain between the two? The gear train/chain could add significant friction to the system.

Good luck,

/frank
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Ah, ic, now that I look at the link. I had a different picture in my head of an inverted pendulum. Was thinking kind of a platform on a lead screw or such.
 

TOTA42

Junior Member
Oct 16, 2004
13
0
0
The motor is directly attached to the pendulum via a arm assembly, similar to the link I posted above. There is no gear train/chain, we avoided making an inverted pendulum via a pendulum attached to a toy car just because of that reason. I'll add the LEDs Monday, when the lab open, and see if something odd is going on. I can easily swing the pendulum upright if my hand directly moves the arm assembly, but I'm having a heck of a time translating what I do into code.
 

FrankSchwab

Senior member
Nov 8, 2002
218
0
0
Ah, I understand now - I didn't realize how this was constructed. I thought the thing out at the end of the arm was the motor. I realize now that it is the encoder.

Perhaps you need an algorithm modification - I would look at what happens when the pendulum goes above horizontal. Perhaps in that scenario you need to do something different. I have a couple of guesses, but physics has been too many years ago to speak authoritatively.

How is energy transferred from the motor to the pendulum? I would think of the arc of the pendulum as being in four quadrants - divided at, say, 12:00, 3:00, 6:00, and 9:00. Or maybe 1:30, 4:30, 7:30, and 10:30? How can you transfer energy to the pendulum in each of these quadrants?

/frank
 

Shalmanese

Platinum Member
Sep 29, 2000
2,157
0
0
Inverted pendulums are non-linear systems and cannot be solved with a PID controller. Take a look at some non-linear control, particularly fuzzy control.
 

FrankSchwab

Senior member
Nov 8, 2002
218
0
0
Hey, kids! Publish your work! It sounds like you've solved a previously insoluble problem:

We managed to get the pendulum to balance in the upright position using a PID controller,

against:

Inverted pendulums are non-linear systems and cannot be solved with a PID controller.
 
Sep 26, 2004
28
0
0
It sounds like you are dealing with a hyperbola equation. Gravity of course will be the key factor in how to calculate push intervals to create enough momentum to bring the arm into a perpendicular position to the ground.

Perpendicular up or down require zero energy. The key is to figure out energy requirements which means you will have to also calculate the weight of the arm.

Could you give us more detailed information. Eg. Weight of arm. Pulse energy of motor. etc.

Thanks.

:)
 

TOTA42

Junior Member
Oct 16, 2004
13
0
0
The reason why we can use PID control for an inverted pendulum is because the problem can be linearized, found this in a guy's thesis in our engineering library. We used the LEDs to see if there was anything odd/wrong with our timing, and we found out there was. There were some brief moments in which the motor goes in the opposite direction that we wanted to, which we fixed by changing about 2 lines of code. :(

IKnowNothing, there's not a whole lot that I can give about the motor. The only thing that the DC motor states is that it can take 5-21 V DC. When we were running at 10 V and a 95% duty cycle, it takes in about 2.3 A. There's no model #, or manufacturer anywhere on the motor. The weight of the arm is a ballpark range, because in the entire lab, the closest thing to a decent scale was a mechanical postage meter (the labs aren't known for their abundance of tools). The arm weighed around 3/16 lb and the pendulum weighed about 1/16. The length of the arm is 21.2 cm. From motor shaft to pendulum is 24 cm. The optical encoder is 2.8 cm. and the pendulum length is 22cm. We're going to be taking pictures/video of our project sometime this week, I can post a link later on if you guys really want to see the thing.

Basically for our digital system, we're using a Motorola 6812 A4 microcontroller. The microcontroller sends two signals to an inverter which is then sent to an OPAMP, so that we can boost the voltage from 5V logic high to 10V logic high. This 10V is then sent to the gate of an H-bridge.

The system runs fairly smoothly, the only thing that's inconsistent is that when the pendulum initially swings upright, it may swing around too quick in which the PID controller doesn't have time to react and the pendulum makes a 360. Thanks guys for putting in comments.