Open Honest-Objections opened 6 years ago
Any solution ?
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
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!
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
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:
3) 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
Closing old issue
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:
So the heading seems fine, I don't know what's going on with the rest of it.