Shop OBEX P1 Docs P2 Docs Learn Events
5dof with Kalman Filter gyro problem — Parallax Forums

5dof with Kalman Filter gyro problem

waterloggedwaterlogged Posts: 12
edited 2010-05-04 09:47 in Propeller 1
I'm somewhat new to all of this, so I apologize if this problem is already dealt with, or just a dumb mistake on my part.

I'm trying to get the 5dof with kalman filter object from the Object Exchange to work. I've had a couple of troubles (mostly related to my relative newness to microcontrollers), but there's one I just can't seem to fix. When I turn the IMU board a couple of degrees, then stop, I end up with a signal that spikes a a certain value, then exponentially decays back to zero over about a minute. It's a stupid question, but is this normal? It doesn't seem too useful for me, especially as I'm trying for a basic autopilot and need some rather quick and accurate sensor readings.

Thanks again,

Justin

PS: The code I'm using is attached, and all of the objects are either defaults off the object exchange, or unrelated to the sensing.

Comments

  • simonlsimonl Posts: 866
    edited 2010-04-18 02:03
    Hi Justin,

    Not sure if what you describe is exactly what I had, but it sure sounds like it. I found that one of the solder joints on the gyro wasn't properly soldered. Although it's really tiny, I took a chance and gave it a little heat with the smallest solder iron tip I could find. It's been steady ever since.

    With the "XR" legend on the left, the pin I soldered was one of the ones on the botom-right of the gyro (biggest chip on the board).

    HTH.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
  • waterloggedwaterlogged Posts: 12
    edited 2010-04-18 02:18
    Simonl --

    Thank you very much for the quick reply. The setup I have is the sparkfun 5dof board... I think that's what you were talking about, but I just want to make sure. Could it instead be one of the joints on the header pins? I'm no expert with the soldering iron, and I'd believe it if one of those was off. I'll check out both when I get back to the house.
  • waterloggedwaterlogged Posts: 12
    edited 2010-04-18 02:54
    Actually, come to think of it, I remember testing the gyros with a quick multimeter, and they didn't seem to display the same problems, so I think there's a possibility that it might be software. Anybody else have this problem?

    Post Edited (waterlogged) : 4/18/2010 3:01:15 AM GMT
  • simonlsimonl Posts: 866
    edited 2010-04-18 03:25
    Hi Justin,

    Yup - any bad solder joint could be the problem. I discovered it by pressing various parts of the 5DOF's components (an old trick from my BBC microcomputer days!).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
  • waterloggedwaterlogged Posts: 12
    edited 2010-04-29 07:57
    Ok, I'm back again.

    I tried simonl's suggestion and soldered the connection on the gyro he said might help. No such luck. If anyone has any ideas, I'd be really grateful, as I have a presentation that would be greatly improved by having the gyros working.

    I was also able to tease out one other little hint... The roll gyro and the pitch gyro tend to be almost exactly the same. They rarely differ by more than a single unit. Both respond to both axes, which I'm guessing means there must be some sort of cross talk. They also require a good jerk to get going, in fact if I rotate it gently (not all that slowly, the sensitivity is poor) I can go without it being detected.

    I've also attached a sample of the signal that's coming out. The vertical red lines are approximately where I rotated it, and the blue line is the response. Notice that if I hold it at a certain angle, it'll decay back to zero. I'm guessing this is the kalman filter thinking there's some bias? It's a slow process, but will go all the way back to zero.

    Thank you all very much.
    485 x 293 - 11K
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-04-29 18:20
    waterlogged,

    I'm curious, are you taking into consideration that the rotation of the Earth could be causing your drift? 'Normal' drift would be about 1/4 of a Deg per minute (15 Deg per hour). A kalman filter and/or PID would integrate time into the equation to compensate for this amount of drift.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • waterloggedwaterlogged Posts: 12
    edited 2010-04-29 21:34
    Beau -- Yep, the signal decays from about 20 degrees/sec down to 0 in about 2min, so the decay is far too fast for that. I'm actually already using the kalman filter that was included in the object exchange code, and the data that it gives out for the roll or pitch (the most important data for me) is from both the accelerometers and the gyros. This value seems to be very off, and displays some of the characteristics of the gyro data, while the accelerometer data is fine.

    Any help would be greatly appreciated. The project is working as is, but the performance would be greatly improved if the gyros could also contribute.
  • simonlsimonl Posts: 866
    edited 2010-04-29 22:26
    Hmmm, this is curious. Do you get a decay if you graph the direct output - i.e. with no filter in place? If you do, is it quicker or slower? I'm not sure where I'm going with this line of questioning, other than to eliminate the KF as being the problem. Beau's correct though, gyro's do drift - hence the need for accelerometers to help correct... but I guess you knew that already!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
  • smbakersmbaker Posts: 164
    edited 2010-04-29 23:34
    waterlogged, It might be handy to have some more data in that plot. From your description it sounds like this plot is of the output of the kalman filter? or is it the output of the gyro itself? If we could see the output of the gyro, accel, and kalman at the same time it might give some insight as to where the problem lies.

    Not sure if you're using viewport or not, but I found it pretty helpful while diagnosing issues when I was setting up a gyro and accelerometer. The ability to see multiple variables at once was helpful.
  • waterloggedwaterlogged Posts: 12
    edited 2010-04-30 07:53
    When I get back to running the system, I'll see if I can get that set up. I've had some odd luck running viewport before, I'll see if I can give it another shot.

    Thanks again everyone for helping out. Hopefully this should be cleared up soon.
  • waterloggedwaterlogged Posts: 12
    edited 2010-05-01 03:23
    Well, here is the output I'm getting. The green is the accelerometer for that axis, and it was able to follow me tossing this thing around rather well, so you can pretty much assume that is the signal I gave it, with only a bit of noise here and there. The long period right after the starting point is where the thing is roughly level.
    The red signal is the gyro, and you can see some of the problems. There are several moments where the gyros don't track the same motions the accelerometer does, and this gets reflected in the blue signal, which is the output of the Kalman filter. In fact, you can see that although the kalman filtered output shares some of the same features as the accelerometer, it misses several of the main features.

    Look familiar to anyone? Do I need to tune or replace something? Maybe a filter?
    871 x 293 - 78K
  • smbakersmbaker Posts: 164
    edited 2010-05-01 17:32
    I spent a few hours last night tinkering with a kalman filter, gyro, and accelerometer myself. All different devices than you're using so my observations should probably be taken with a grain of salt. The biggest difference that I see is that my gyro always trended back to a steady state after a motion (I think it trended back to zero, but a night's sleep has made me forget the specifics).

    The thing that I see wrong with your results is that the gyro seemed to get into progressively negative territory.·It also looks pretty noisy with big spikes, some of which are not reflected in the acceleration data. I'm fortunate that the devices I used both had digital outputs (GWS PG-03 and LIS03LV02DQ), so I didn't have to worry much about analog circuitry. As I understand the 5DOF sparkfun module that you're using has analog outputs? How are getting these analog signals into the prop, and are you sure that whatever A/D technique you're using isn't injecting this noise?

    One of the more frustrating problems I had to diagnose one time was a bad filter capacitor in a circuit. Unclean supply can cause all sorts of unpredictable problems in analog circuits and is one of the last things one thinks to check.

    Of course, like I said, I have no experience with the particular devices you're using so my advice may be completely wrong.
  • waterloggedwaterlogged Posts: 12
    edited 2010-05-01 17:58
    smbaker - The signal comes out analog, then goes directly into the same ADC as the accelerometer output. I've tried replacing the ADC (and everything but the IMU and the code), with no difference. I've thought of adding a filter, but I thought I'd get this up and running first.

    I'm starting to think there's something wrong with the code I'm using. If you look at the output of the kalman filter, the roll variable seems to really only "like" two values, which is definitely not right.
  • waterloggedwaterlogged Posts: 12
    edited 2010-05-03 22:32
    as much as I hate it when people do this to their own threads, solving this would help my project a great deal, so....

    bump
  • TimmooreTimmoore Posts: 1,031
    edited 2010-05-03 22:47
    One thing to look at is this thread http://forums.parallax.com/forums/default.aspx?f=25&m=386061
    I started with the 5DoF code but switched it to fixed point maths and to do 3 axis. You could try this and see if it has the same problems.
  • waterloggedwaterlogged Posts: 12
    edited 2010-05-04 09:47
    Tim -- Good suggestion. I went over there and tried a couple of things discussed there, and still no luck. Now I've tried four different versions of the same code, all with the same result. The filtered roll and pitch outputs just jump between two different values. I'm thinking something happened to my gyros at some point. It's killer, though, because the outputs of the gyro look promising, just a bit too small. I'll see if I can upload anything new when I get back to it, but at this point I'm pretty sure that the gyros must be dead.
Sign In or Register to comment.