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

April 21, 2010

PID Cart Control Works

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

After a bit more experimenting, I ended up eliminating current as a method for controlling the cart.  I couldn’t see any simple relationship between the current and the motion of the cart.  There was so much noise that I couldn’t get as tight of control of speed as I would have liked.  There was also the fact that current measurements were very different depending on the direction of travel.

My current version uses a PID algorithm on the RT side of the cRIO.  The input of the PID is either position or speed, and the output of the PID is the PWM value.  I also added a feed forward algorithm that predicts what the PWM value should be since the relationship between PWM and speed is highly linear.  With the two algorithms combined, the cart can track any desired speed or position almost perfectly.  There is still an issue with the speed oscillation, but that is much smaller when the cart is engaged on the rack.

I set up the test program to generate a sine, triangle, or square (step) setpoint cycling once per second.  The program can control either position or speed.  After trying all the combinations, I am pretty satisfied with this method of control.  If I only had a cart to control, I would probably be done.

Now I need to figure out how the swinging of the pendulum affects the motion of the cart.  When I was originally going to use a force input, I was going to use the standard equations of motion that you find derived in practically every paper about inverted pendulums.  Now that I am using a PWM output to control either speed or position, those equations don’t exactly work.  I can’t measure the force applied – I only see the resulting motion.

One possibility is that the motor is strong enough to control the position of the cart without the pendulum motion affecting it.  If this is true, I will just use PID to control the cart, and the pendulum motion will only depend on the cart acceleration.  I assume this is how systems that use a stepper motor work – the stepper motor moves at whatever speed you provide pulses, and just provides enough force to achieve that speed.

The other possibility is that the pendulum motion will overpower the motor in certain situations.  I suspect this is the case.  I will have to investigate it.

I started looking at the interaction between the pendulum and the cart, but I ended up shredding the brass shim foil that is wrapped around the shaft of the motor to hold the gear in place.  I suspect too much high speed acceleration wore out the foil.  I set a limit on the acceleration, but I think it needs to be a little lower.  I will need to stop by Shaltz to pick up some more foil before I can run the system again.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress