Archive for the ‘Software’ Category

Installed limit switches

Tuesday, June 8th, 2010

For a while, I thought I could get away with not installing the limit switches.  As long as I start the pendulum in the center, it does a very good job avoiding the ends.  The problem is when I keep the pendulum inverted and it gets “bumped” repeatedly.  While it is correcting for the bumps, it tends to get close to the end of the rack.  Sometimes it will hit the end pretty hard while trying to correct for a bump.  Once it hits the end, it loses the center reference and continues to get worse.  I decided it was time to install the limit switches.

Soldering the wires for the limit switches was a minor hassle.  It wouldn’t have been too bad to solder three wires for each switch (GND, 5V, signal), but I needed a 1k ohm pull-up resistor between the 5V and the signal.  It starts to be a large number of wires in each hole for the connector, and it is kind of difficult to work around the resistors.  After the first try, I assembled the connector case and realized one wire was loose, so I had to take the connector case apart and resolder it.  After the second try, I managed to get everything connected securely.  Each signal turns off when the limit switch is obstructed, so I change the PWM limit in that direction to zero.  It takes about the width of the limit switch for the cart to decelerate from full speed.  If I position the limit switches just a short distance from the end, it will work well.  Right now the switches are just taped in place, but I am working on permanently mounting them.  My original plan was to drill holes and screw them down tight, but to do that I would probably have to move hardware out of the way to get the drill in place.  It looks like it would be much easier to mount them with thick double sided tape.  Not as pretty, but a heck of a lot easier.

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.