|
Re: Building self balancing scooter- troubles with Integrating Gyro
Another thing you might try that has been very effective for me is oversampling the value before accumulating. Oversampling is much like averaging, except that you don't divide. It's easiest (just like averaging) if you work with powers of 2. Let say you choose to add 4 bits to your measurements by oversampling. That means that for each sample you want to accumulate, you need to actually aquire 2^4 or 16 samples. By doing this, your center value that you subtract off of each value before accumulating can be more accurate.
The way to get the best center value for your accumulator is to average the samples for a long period. Probably at least 1 second. Remember that since your center value is now based on oversampled readings, you need to be averaging oversampled readings to calibrate your center value.
You also noted that you have a 10-bit ADC but are only using 8 bits because at 8 bits, the values don't change. Truncating your values is worse than averaging them. It has the exact opposite effect that oversampling does. You should definitly use all 10 bits plus oversampling and simply average enough points to find the stable value. It is that very noise in the system that makes oversampling possible.
One caveat to oversampling is that you must sample faster to maintain the same bandwidth. Probably the best thing to do is run the ADC as fast as it will go and then oversample as much as you can while still keeping the bandwidth that you need from the gyro. That is, of course, if your processor can keep up.
Another thing you might try to augment the integrated sensor (which will always have some amount of drift) is to use a sensor that can tell you angle statically to help zero the measurements. You could then use even low bandwidth readings from that sensor to correct the integrated value.
Cheers!
-Joe
|