# Inverted Pendulum Simulation

1. Jan 16, 2009

### collinpetty

Hello,

I am attempting to build a single axis inverted pendulum using a PID system to keep the rod balanced. I am interested in writing a program to simulate the rod tipping over and the effects of moving the base (pivot point) left or right to counter the tipping effect. I can't quite figure out the math to model a rod of uniform density that is standing on end falling over. I remember learning formulas for pendulums in physics class but it was for pendulums that swing less than 15 or so degrees (assuming that for values close to 0 sin(x)=x). Also, I'm not sure I know how to model a scenario where the base of the rod that is tipping over is pushed quickly back "under" the rod (beneath and actually slightly past the center of mass of the rod). Any and all help would be appreciated.

Collin

2. Jan 16, 2009

### Dr.D

Before you can worry about making a simulation, you need to get the correct mathematical model, including large angle motion, as you noted. You will need to settle upon an approach to the problem, either by using Newton's Second Law, or by using the Lagrange formulation, if you are familiar with that method. You need to give some thought to what you will include in your model. Will you model only the motion of the pendulum itself, or do you also need to model the motion of the cart (slider, or whatever you want to call it) that carries the pivot point? For a complete system model, you will need to include both, which means that you will need to develop equations of motion for both the pendulum and the cart, so that there will be 2 degrees of freedom. Begin by carefully defining your variables, drawing free body diagrams if you are going to use Newton's second law, and then put together the equations of motion. Good luck.