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

Erroneous Arduino values #11

Open
Honest-Objections opened this issue Mar 28, 2018 · 5 comments
Open

Erroneous Arduino values #11

Honest-Objections opened this issue Mar 28, 2018 · 5 comments

Comments

@Honest-Objections
Copy link

While I may just be misunderstanding entirely, I would expect the Arduino code to spit out degrees between 0-360. When running on the GPS-IMU V2 I get:

#AccX	0.96	###  AccY  -88.85  ###  GyrX	41642.30  ###  GyrY  	2140885.00   ###  GyrZ	44169.29     ######    CFangleX	3.62   ######  CFangleY   	2874.74   ######  heading   	2.94    --Loop Time--	20
#AccX	0.70	###  AccY  -88.86  ###  GyrX	41642.38  ###  GyrY  	2140976.75   ###  GyrZ	44169.33     ######    CFangleX	3.62   ######  CFangleY   	2874.74   ######  heading   	2.75    --Loop Time--	20
#AccX	1.01	###  AccY  -88.86  ###  GyrX	41642.47  ###  GyrY  	2141068.50   ###  GyrZ	44169.37     ######    CFangleX	3.62   ######  CFangleY   	2874.73   ######  heading   	2.53    --Loop Time--	20
#AccX	0.75	###  AccY  -88.86  ###  GyrX	41642.56  ###  GyrY  	2141160.25   ###  GyrZ	44169.42     ######    CFangleX	3.62   ######  CFangleY   	2874.73   ######  heading   	2.54    --Loop Time--	20
#AccX	0.78	###  AccY  -88.84  ###  GyrX	41642.64  ###  GyrY  	2141252.00   ###  GyrZ	44169.46     ######    CFangleX	3.61   ######  CFangleY   	2874.72   ######  heading   	2.57    --Loop Time--	20
#AccX	0.78	###  AccY  -88.85  ###  GyrX	41642.72  ###  GyrY  	2141343.75   ###  GyrZ	44169.50     ######    CFangleX	3.61   ######  CFangleY   	2874.72   ######  heading   	2.54    --Loop Time--	20
#AccX	0.79	###  AccY  -88.86  ###  GyrX	41642.81  ###  GyrY  	2141435.50   ###  GyrZ	44169.55     ######    CFangleX	3.61   ######  CFangleY   	2874.72   ######  heading   	3.06    --Loop Time--	20

So the heading seems fine, I don't know what's going on with the rest of it.

@Honest-Objections Honest-Objections changed the title Erroneous values Erroneous Arduino values Mar 28, 2018
@vbahtev
Copy link

vbahtev commented Aug 2, 2018

Any solution ?

@vbahtev
Copy link

vbahtev commented Aug 10, 2018

After hard iron calibration code work perfectly.

Before use values from heading, first make 360 degree horizontal rotation.

In gits can see: arduino-BerryIMU code with hard iron calibration.

https://gist.github.com/vbahtev/b05f1895776cec5828db6746d5ba9a11

@Honest-Objections
Copy link
Author

In my case it turned out to be bit shifting with assumption that the Arduino would be 16bit where as the zero was 32bit (from what I remember). Never got it working though, thanks for sharing the code!

@aaron9412
Copy link

aaron9412 commented Nov 4, 2018

I've gotten similar results. Like @Honest-Objections stated I believe it is a calculation error, solutions may be unique depending on the board. Please let us know what board this was designed using, and if there are any known solutions. I will be trying to correct it for an SAMD (ItsyBitsy M0 Express). Thank you for the nice library. -Aaron

> 21:33:40.650 -> #AccX	88.83	###  AccY  -88.83  ###  GyrX	1183149.00  ###  GyrY  	1168714.50   ###  GyrZ	1184804.12     ######    CFangleX	3053.96   ######  CFangleY   	2877.29   ######  heading   	73.58    --Loop Time--	20
> 21:33:40.697 -> #AccX	88.83	###  AccY  -88.83  ###  GyrX	1183240.75  ###  GyrY  	1168806.25   ###  GyrZ	1184895.87     ######    CFangleX	3053.97   ######  CFangleY   	2877.28   ######  heading   	73.36    --Loop Time--	20
> 21:33:40.697 -> #AccX	88.83	###  AccY  -88.83  ###  GyrX	1183332.50  ###  GyrY  	1168898.00   ###  GyrZ	1184987.62     ######    CFangleX	3053.97   ######  CFangleY   	2877.29   ######  heading   	73.23    --Loop Time--	20
> 21:33:40.744 -> #AccX	88.82	###  AccY  -88.82  ###  GyrX	1183424.25  ###  GyrY  	1168989.75   ###  GyrZ	1185079.37     ######    CFangleX	3053.97   ######  CFangleY   	2877.29   ######  heading   	73.98    --Loop Time--	20
> 21:33:40.744 -> #AccX	88.83	###  AccY  -88.83  ###  GyrX	1183516.00  ###  GyrY  	1169081.50   ###  GyrZ	1185171.12     ######    CFangleX	3053.98   ######  CFangleY   	2877.29   ######  heading   	73.56    --Loop Time--	20
> 21:33:40.744 -> #AccX	88.83	###  AccY  -88.83  ###  GyrX	1183607.75  ###  GyrY  	1169173.25   ###  GyrZ	1185262.87     ######    CFangleX	3053.97   ######  CFangleY   	2877.29   ######  heading   	73.50    --Loop Time--	20
> 21:33:40.791 -> #AccX	88.83	###  AccY  -88.83  ###  GyrX	1183699.50  ###  GyrY  	1169265.00   ###  GyrZ	1185354.62     ######    CFangleX	3053.98   ######  CFangleY   	2877.29   ######  heading   	73.16    --Loop Time--	20
> 21:33:40.791 -> #AccX	88.82	###  AccY  -88.82  ###  GyrX	1183791.25  ###  GyrY  	1169356.75   ###  GyrZ	1185446.37     ######    CFangleX	3053.97   ######  CFangleY   	2877.29   ######  heading   	73.10    --Loop Time--	20
> 21:33:40.838 -> #AccX	88.83	###  AccY  -88.83  ###  GyrX	1183883.00  ###  GyrY  	1169448.50   ###  GyrZ	1185538.12     ######    CFangleX	3053.98   ######  CFangleY   	2877.30   ######  heading   	73.09    --Loop Time--	20
> 21:33:40.838 -> #AccX	88.83	###  AccY  -88.83  ###  GyrX	1183974.75  ###  GyrY  	1169540.25   ###  GyrZ	1185629.87     ######    CFangleX	3053.98   ######  CFangleY   	2877.30   ######  heading   	73.95    --Loop Time--	20
> 21:33:40.885 -> #AccX	88.82	###  AccY  -88.82  ###  GyrX	1184066.50  ###  GyrY  	1169632.00   ###  GyrZ	1185721.62     ######    CFangleX	3053.97   ######  CFangleY   	2877.29   ######  heading   	73.20    --Loop Time--	20
> 21:33:40.885 -> #AccX	88.83	###  AccY  -88.83  ###  GyrX	1184158.25  ###  GyrY  	1169723.75   ###  GyrZ	1185813.37     ######    CFangleX	3053.97   ######  CFangleY   	2877.30   ######  heading   	73.51    --Loop Time--	20
> 21:33:40.885 -> #AccX	88.82	###  AccY  -88.83  ###  GyrX	1184250.00  ###  GyrY  	1169815.50   ###  GyrZ	1185905.12     ######    CFangleX	3053.96   ######  CFangleY   	2877.29   ######  heading   	73.36    --Loop Time--	20

@aaron9412
Copy link

The issue is that 32 bit processors create 32 bit signed integers when "int" is called. The LMD9DS sensors are set up to output information into 16 bit signed integers, which the author has exemplified for us well:

  1. The values are expressed in 2’s complement (MSB for the sign and then 15 bits for the value) so we need to combine;
    block[0] & block[1] for X axis
    block[2] & block[3] for Y axis
    block[4] & block[5] for Z axis

Quoted from: http://ozzmaker.com/compass1/

The Arduino example code should work nicely with no modifications on a 16 bit processor and 16 bit Arduino. For a 32 bit or other processor, simply change all the "int" calls to "int16_t" and the issue will be solved. (Do not use "uint16_t" as this is unsigned, eg: cannot be negative). "int" calls and "int16_t" calls both natively use 2's compliment to store their numbers, so conversion to decimal is not necessary.

-Aaron

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants