Archive for May, 2010

still need loctite

Wednesday, May 26th, 2010

I thought that maybe with the new set screw, I could get it tight enough that it would not come loose.  After playing with the pendulum tonight, I realized the set screw still gets loose after a lot of fast back and forth motion.  Once I have decided that I have the best set screw I am going to find, I will add some loctite to make it stay tight.  The new screw is still way easier to tighten, if nothing else.  I am also pretty sure I could loosen it after using loctite if I need to.

I also found a very minor bug in my speed calculation for the pendulum.  After sitting still for several seconds, one of my counters rolled over and looked like a sudden burst of speed.  The cart would shimmy a little bit, then return to a still position.  The fix was pretty simple – I thought I had already done it, actually.

Started coding challenge

Friday, May 21st, 2010

The coding challenge has officially started.  All the rules are posted on the NI website here: http://decibel.ni.com/content/message/16920#16920.  Entries have to be submitted by the Sunday before NI Week.

The main challenge is to swing up the pendulum as quickly as possible and move to different points.  Swinging it down is also a bit of a challenge, because if you don’t do anything to stop the swing it will swing for a long, long time.  All the coding for the challenge will use the simulation model I created, but the winning entry will be implemented on the physical system.

I am not going to talk about the challenge much here, but I will be involved in the official discussion on the NI website.  I do encourage anybody that is interested to try the challenge.  You get to play with LabVIEW and the Control Design and Simulation toolkit for free for a few months, and the winner gets a sbRIO evaluation kit, which is just like the sbRIO board I am using to run the pendulum.  All entries that meet the requirements will get a cool prize too.  We haven’t figured out exactly what the prize will be yet, though.

BIG set screw

Wednesday, May 19th, 2010

I tried a bunch of different screws and found out that the set screw is a 6-32 screw.  This is the same size screw thread that is used to hold the wall plate around light switches.  First I tried using a light switch screw, but the head was much too large since the set screw hole is pretty close to the side of the gear.  I wasn’t able to find anything else useful in my collection of screws and bolts, so I went to the hardware store.  I was looking for a fairly short screw with a small head.  I found a couple that looked good that had small round heads.  One uses a regular flat blade screwdriver, and the other has a phillips head.  I tried the phillips head screw first because it was shorter and easier to turn, but the head was still too large.  It rubbed against the gear as I turned it.  Next I tried the other screw, and it worked pretty well.  It doesn’t rub on the gear at all.  It was almost too long, though.  After I tightened the screw, which was very easy and nothing stripped, I put the cart back on the rack.  As the gear rotates, the screw barely clears the rack.  I think this screw will do the job, but I am going to look for a shorter screw with a small head just for appearances.

New set screw

Friday, May 14th, 2010

I did a little research to figure out how to remove a screw that has been secured with Loctite.  The two answers I came up with are (1) heat and (2) drill.

First I tried heat by using my soldering iron on high.  It got the screw pretty hot, but it still wouldn’t budge.  It almost seemed like it moved one time, but I couldn’t repeat the feat.   The socket was pretty well stripped to begin with, so the lack of success did not surprise me.

Next I tried the drill.  I started with a bit the same size as the socket hole and ended up going all the way through the set screw.  Next I went one size larger drill bit.  It looked like the bit got stuck in the hole and started turning the screw, because most of the screw went through the hole and into the middle of the gear.  I pulled it out and tried another set screw, which appears to work fine.  It doesn’t look like I damaged the threads at all.  I put new shim foil in (again) and it looks like everything is fine.  I am going to make sure this shim foil is settled, then I will probably loctite it again.

I am wondering what size thread a standard set screw is.  It may be easier to replace the set screw with an ordinary screw.  I wouldn’t mind a screw head sticking out if it made it easier to adjust the screw.  This is the second set screw socket I have stripped, and the new one is already started.  I think my allen wrench is a little worn around the edges as well, which isn’t helping either.

First Videos

Wednesday, May 12th, 2010

I did a little experimenting with my wife’s Canon camera that also shoots video, and I made some pretty decent videos of the pendulum in action.

These are links to WMV files.  They should start playing in a separate window when you click on them.  These are much smaller and faster than the original versions that I posted.

This first video shows a swing up, stable inversion, and a swing down.  In the hanging position, it is programmed to move to the center with no pendulum swing.

Pendulum Swing Up Video

Pendulum Swing Up Video

This second video shows how stable the pendulum is while inverted.  It recovers quickly from small pushes and allows the pendulum to swing down and back up if the push is large.  It also tries to stay close to the center of the track.

Inverted Pendulum Stability Video

Inverted Pendulum Stability Video

This third video shows how stable the pendulum is while hanging.  Notice the pendulum stops swinging quickly and moves to back to center when pushed.

Hanging Pendulum Stability Video

Hanging Pendulum Stability Video

Loctite works – kind of

Tuesday, May 11th, 2010

Well, the good news is that the Loctite holds very well during the motion of the pendulum.  I put the system through its paces and the set screw has not budged.

The bad news is that the shim foil under the set screw did move.  During motion, the foil must have been compressed or bent.  The gear is now slightly loose and will rotate a small amount back and forth.

The problem is that the Loctite is working too well.  I tried to adjust the set screw, but couldn’t get it to move at all.  The allen wrench appears to have stripped out the hole in the set screw now, so I don’t have any way to turn it.  I am pretty sure I can slide the gear off the shaft, but I wouldn’t be able to get it back on without doing something about the set screw.  I am hoping the guys at Shaltz have some ideas for me.

Added Loctite

Saturday, May 8th, 2010

I bought some blue Loctite 242, which is supposed to have “medium” holding power, and put it on the set screw.  I also replaced the shim foil, since half the old foil was neatly removed by the spinning set screw.  The set screw also gouged a small notch all the way around the shaft at one point.  Hopefully the Loctite will hold the set screw in place and I won’t have to worry about it again.  I will find out next time I try running the system.  It takes 24 hours for Loctite to completely cure, so I am going to let it sit for a little while.

I tried another approach on the modeling of the system.  Looking at the NI System Identification tools, I found one that allows you to define the model of your system in terms of constants, and it also allows non-linear systems.  The vi I used was “SI Estimate User-Defined Model.vi”, which uses a template that defines the actual system.  I used the MIMO template with arrays.  The system input was the PWM values, and the system output was the position and velocity of the cart and pendulum.  My variables were the coefficients A, B, C, D, and E from earlier equations.  The template takes an entire array of PWM values and produces arrays of output values.  The Estimate function kept iterating and adjusting the coefficients until the best values were obtained.  I don’t know exactly how it works, but it produced estimated curves that were very, very close to the actual output curves.  Of course, I put the values into my simulation and tried out my control algorithms.  The numbers didn’t really change too much, so the algorithms worked about the same.  I suspect I am close enough to the real system that it is just finding values that are close to the true values.  I don’t think it is possible to get much closer to the real values, so it is probably time to quit perfecting the model and call it good.

Success!!

Thursday, May 6th, 2010

I couldn’t wait to blog this one, so sleep will wait a little longer.

I recalculated the gains using a less aggressive setting, and came up with coefficients that are about an order of magnitude smaller.  In the simulation, things move a little slower but everything runs very smoothly.  The transition between swingup and a stable inverted pendulum looks a lot smoother also.  I also fixed the issues in the control algorithm from yesterday.

I tried out the new stuff on the real hardware.  First I tried moving from one position to another while hanging.  It moves less smoothly than the simulation (kind of jerky), but it gets there and keeps the pendulum from swinging.  Then I tried inverting the pendulum… (drum roll, please) and it worked great!  The swingup didn’t quite get it all the way up, so I had to tweak the algorithm a little bit.  Once it was inverted, it did a really good job of keeping it inverted.  I can tell it to move to different positions, and it keeps it inverted while moving to those positions.  I also tried tapping the pendulum lightly with my finger, and it recovered nicely.  It is a little slow and kind of jerky, but it is still a success and a great second try.

The cart tends to oscillate while balancing the pendulum.  It isn’t very large, and I guess it is to be expected.  Every now and then, the cart stops completely and the pendulum stays balanced for a second or two, then it starts to fall and the cart zigs out to keep it upright.  When the set screw is tight, the cart oscillates less.

One of my big problems right now is the set screw.  I haven’t done anything about it yet, so it keeps coming lose after running for about a minute.  Right now I just tighten it back up and restart the system.  I really need to decide how to keep it in place and do it.  If I don’t, I am going to shred all the pieces of shim foil that I have.  I would feel silly if I had to go ask for more foil again.

I also want to work on the gains.  I plan on gradually increasing the gains (and system speed) until I reach the limits of the system.  I am just happy I have something that works at the moment.