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

April 26, 2010

Pendulum model

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

I am still having trouble figuring out how to model the cart.  I have one equation that relates the PWM output to the torque, which can easily be converted to force.  I have a second equation that relates force to the motion of the cart.  If I knew all the coefficients in the equations, it would be pretty easy, but most of the coefficients are unknown at this point.  Another problem is that the two equations are in different forms (Laplace and differential), so I can’t just set them equal to each other.

I decided to look at the pendulum side of the model.  I added a little code to the sine program to record data and oscillated the cart at 1600 msec/cycle, which appears to be close to the natural frequency of the pendulum.  The pendulum alternated between large and small oscillations several times.

From the recorded data, I have cart position (x), cart speed (dx), pendulum position (T), and pendulum speed (dT).  My first step was to heavily filter the data to eliminate noise, then calculate the accelerations of both (ddx, ddT).  I also converted the units from counts to meters and radians.

The equilibrium equation for the pendulum is:  ddT = 1/(I+L^2m) [Lm(ddx cosT – g sinT) – c dT]

Since I don’t care about the individual constants, I simplified it to:  ddT = A (ddx cosT – g sinT) + B dT]

Using the collected data, I rearranged it to get a curve for (ddx cosT – g sinT), then used linear regression to get the best fit for the constants A and B.  It gives me values of A=1.9217 and B=-0.024.

The fit worked really well and the best fit curve almost exactly matches the ddT curve.  I was going to post a plot comparing the fit data to actual data, but they were so close that you can’t see the difference.  This makes me pretty confident in this part of the model.  It should be plenty close to the actual system for testing algorithms.  Now I just need to figure out the cart model.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress