Accelerometer Bias

I’ve made our own gyro/accelerometer code because I wanted to do some various things other than what Kevin Watson’s code (which is excellently made) did. The gyro code works fine now, however because of the accelerometers’ extreme sensitivity, I was wondering how you can make a code to remove the accelerometer bias. My code gets it between 511-512… but since it’s an int it goes one way or the other… and by having it at 511… it is enough to quickly make the robot velocity appear as though it is getting negative.

Has anyone else made their own accelerometer code and found a way to fix this? Thanks!

This is one of the reasons I oversample the gyro and accelerometer outputs. If you look at my gyro code you’ll notice that I sum GYRO_SAMPLES_PER_UPDATE samples and treat that value as though it was a single sample. It’s a simple way to get a little more accuracy in your calculations.

-Kevin

Hey Kevin,
I havn’t looked at your code, but wouldn’t you need to divide SUM_OF_SAMPLES by NUMBER_OF_UPDATES, so you would get an avereage value?

I know theres nothing wrong with it, i mean… hundreds of teams use it, just wondering what exactly you ment…

Thanks,
-Leav :slight_smile:

Yes, you can do this or just change the units (e.g., volts per eight samples rather than volts per sample).

-Kevin