Jump to content
I2Cdevlib Forums
titous

Another auto-offset calibration sketch

Recommended Posts

Hey everyone!

 

Thought I'd share my version of an auto-offset calibration sketch; it converges all offsets in about 20s or so.  Just upload and watch the serial (at 38400bps)!

 

A note on how it works/converges:

- the code takes an initial guess for each offset (supplied at the top of the sketch), takes a certain number of readings from the MPU-6050 (the # of readings it takes is defined by countMax), and averages those number of readings.  If that average is less than the value errorCheck, it assumes that axis has converged

- if the average isn't less than errorCheck, it will subtract a certain amount from the initial guess

- if the errorCheck you set is too small, or the initial guess is smaller than what the solution is, it wont converge - in this case either choose a larger value for errorCheck or a larger initial guess

 

I've given some initial guesses / settings which should help you get to where you need to be; just watch the serial - it'll tell you what the average reading from the MPU-6050 was for each guess, you'll want that average to be as close to 0 as possible for each axis.

 

Enjoy!

MPU6050_calibration.zip

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×