|
|
|
| The feeling of true love is a keeper. |
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#31
|
|||
|
|||
|
Well, I used last year's gyro to successfully integrate the angular position, but I got a weird result. My integration was always approximately 29/36 of what it should be. I simply have to multiply the result by 36/29 in order to correct it, but I would still like to know why it does such a thing. The only thing that I can think of which would cause a proportional discrepancy is that the processor is running slowly. However, my program uses no division or floating point operations, so this makes no sense whatsoever. The only other thing which may mess it up is that I just throw out any gyro values between 6 and -6 (out of a range of -1024 to 1024) to account for the inaccuracy of the gyro when it's sitting still. What could be causing this?
|
|
#32
|
||||||
|
||||||
|
Re: Quick Question
Quote:
I have a few suggestions... 1) First, I would suggest that you not throw out values. The values that you are getting when the gyro is sitting still is just typical noise. When you integrate, these "strange" values will average themselves out to zero, so don't worry about these values. In fact, they can help you out. 2) One possibility is that the gain of the sensor is not at it's nominal value. Most sensors have tolerances of about 5% for the gain. 29/36 is 80% (20% error), so obviously the gain isn't the entire problem (if it's a problem at all). Try the other suggestions. If you get it to within 10%, then I would just multiply by whatever factor that you're consistently off by, since the problem is most likely the gain of the sensor. 3) It is possible that the slow sample rate is also part of the problem. If you are using rectangular integration (simple sum), then your integral will usually be low if the input is a rising signal (which is most likely is for your test). You could try to use trapezoidal integration to help solve some of the problem. To use trapezoidal integration, average the current sample with the previous sample, and then add this to your sum. See the following example code: // start of integral // Remember to initialize GyroSensorPrevious to zero at startup GyroSignal = RawGyroSignal - GyroBias; IntegralInput = (GyroSignal + GyroSignalPrevious)/2; Integral += IntegralInput; // or Integral += IntegralInput*GainFactor GyroSignalPrevious = GyroSignal; // end of integral 4) What are you doing for the sensor bias? You should always perform a sensor bias calculation when you power up your software. In other words, before you start running your integral, you should take an average of a large number of sensor readings. You can start with about 32 samples to see how that works. If your bias is not exact, it's easy for your integral to get off rather quickly. 5) Be sure your variables are scaled appropriately. Make sure you have some fractional-part bits (see my most recent white paper). This is not so important for the integral, but it is important for the bias average and for subracting that average off of the raw A/D value. When you truncate decimal portions, you always floor (i.e. round toward -infinity). Therefore, your integral will always be low. 6) Is your sample rate constant, or does it vary? If your sample rate is not consistent, your integral will not be very accurate, and you will have difficulty determining the problem. 7) When you ran your test, did you run it in both directions (i.e. counterclockwise AND clockwise). If so, do you get the same results? 8) Lastly (and maybe most importantly): You could be saturating the sensor. Are you ABSOLUTELY SURE that you're turning less than 50 deg/sec? I know that the sensor is rated for higher rates, but when you add noise to the signal, you will have problems with your integral. For instance, let's say you're turning at 55 deg/sec and you have 10 deg/sec of noise. The sensor outputs 5 V for 60 deg/sec. That means that the noise peaks will give you 60 deg/sec (it clips the peaks to 60 deg/sec, even though they should be 65 deg/sec), but the noise valleys are at 45 deg/sec. After averaging the noise in the integral, your angular rate appears to be about 52.5 deg/sec rather than 55 deg/sec. That is one of the many reasons why you need to be sure your sensor has adequate "head room" above your peak turning rate. On this same point, if you are turning the sensor at a rate higher than it's peak output, you're integral is going to be low. The peak output can vary due to many reasons (and it can vary more than you would think), so you have to be sure you have headroom. Whew, that was long. If you aswer the questions for each of these points, I can help you pinpoint the problem. Good Luck, Chris |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Quick <hr> question | Jack | Website Design/Showcase | 1 | 31-01-2003 22:19 |
| To all the ladies in the hiz-ous!! lol a quick question | archiver | 2001 | 1 | 24-06-2002 02:12 |
| Quick Question | archiver | 2001 | 5 | 24-06-2002 00:08 |
| A quick question | Joelster | Technical Discussion | 6 | 10-02-2002 09:09 |
| Quick Question, i guess | Andrew Rudolph | Motors | 1 | 12-08-2001 14:39 |