Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calibration function is wrong #54

Closed
MArimont3 opened this issue Jun 21, 2024 · 7 comments
Closed

Calibration function is wrong #54

MArimont3 opened this issue Jun 21, 2024 · 7 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@MArimont3
Copy link

Hi, I think your calibration function is very wrong.
You initialize the calibration values to zero. Ok.
But then in a loop, you

  • read values -> this method is using the calibration values !
  • set the calibration values to the values read

So you are getting some random values out...

Also: the example GY521_performance_calibrate.ino has a method test with an argument, but this is never used. It is hardcoded the test should run 100 times.

@RobTillaart RobTillaart self-assigned this Jun 21, 2024
@RobTillaart RobTillaart added the question Further information is requested label Jun 21, 2024
@RobTillaart
Copy link
Owner

RobTillaart commented Jun 21, 2024

@MArimont3
Thanks for the issue.

Hi, I think your calibration function is very wrong.

Can you explain or show why you think it is wrong?
Do you have investigated the cause and do you have a proposal how to solve the problem?
(just asking as time is my most scarce)

The idea of the calibration is to have the sensor in a stable, horizontal, non moving position.
Then you make multiple measurements and these should in theory (ideal sensor) read zero however in practice you read noise.
The calibration routine sums this noise per axis and averages them with a factor float factor = 1.0 / times;.
Yes I know this is only a first order correction at best.

The underlying assumption is that this average error at the "no movement" level is the same as when the sensor is undergoing movements and accelerations in XYZ planes. I am no physicist, and I know the correction needed will probably be acceleration dependent and the three axis might even affect each other. However investigating a more elaborated (2nd or more order) calibration is outside my scope.


Also: the example GY521_performance_calibrate.ino has a method test with an argument, but this is never used. It is hardcoded the test should run 100 times.

I will have a look in that one asap.

@RobTillaart
Copy link
Owner

Also: the example GY521_performance_calibrate.ino has a method test with an argument, but this is never used. It is hardcoded the test should run 100 times.

Error confirmed, I will update this example right away (will not publish a new release for it)

@RobTillaart
Copy link
Owner

@MArimont3
Pushed a new version of the example in the master branch. I do not have a hardware setup nearby to test it on at the moment.
If you have time please post the output of the "fixed" example.

@jens-kuerten
Copy link

jens-kuerten commented Jun 22, 2024

@RobTillaart

The issue with the calibration function is that you are modifying the errors while you are performing the calibration.

That breaks the averaging, because you are only measuring the "full" error on the first iteration.

@RobTillaart
Copy link
Owner

RobTillaart commented Jun 22, 2024

@jens-kuerten

OK, that gives some information where to look, I'll dive into it asap.

Thanks!

@RobTillaart RobTillaart added the bug Something isn't working label Jun 22, 2024
@RobTillaart
Copy link
Owner

@jens-kuerten @MArimont3

Aha, stupid me, I see the problem, will create a develop branch for a fix.
and need to find some hardware to verify :).

RobTillaart added a commit that referenced this issue Jun 22, 2024
@RobTillaart
Copy link
Owner

Created develop branch + PR - #55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants