I’ve been trying to get the correct gyro reading based on the information from the site.
MCU is teensy3.2 and are connected as is supposed.
I calibrated the sensor with the example code from LIS3MDL library.
Then downloaded the the example code from below and changed min. max. values with the ones that I got from the calibration example.
Of course I uncommented //#define IMU_V5.
Then I get propper angle value(-180~180) reading at the third from the serial monitor.
But It is not tilt compensated. As soon as I tilt or roll, the angle goes wrong.
And the both gyro data(roll and pitch) are jumping around.
The accelerometer data is correct.
Will you guide me to solve this problem?
How are you viewing the gyro and acceleration data (the AHRS program does not output those values by default)? Can you run the Serial example sketches from our LSM6 and LIS3MDL Arduino libraries and post the output from each of them?
At first I want to ask you what is the output of the two values from AHRS program. I assumed the first two are absolute values of roll and pitch depending on the angle. If not so, how can I get them?
What I get from the AHRS default setting is continuous but is not absolute angle value that I expected.
You may checkout the video below of the default AHRS program serial output.
Here’s Serial monitor output of LSM6 serial example while the unit stays still.
Thank you for posting the video and output you are getting. The output of the AHRS code is dependent on how PRINT_DCM, PRINT_ANALOGS, and PRINT_EULER are defined. The example AHRS code sets PRINT_DCM and 'PRINT_ANALOGS` to 0 and ‘PRINT_EULER’ to 1, so the output is [roll, pitch, yaw], where roll is rotation about the x-axis, pitch is rotation about the y-axis, and yaw is rotation about the z-axis. You can see the definition of these axes in relation to the board in this picture:
I noticed you have the component-side of the board facing upwards. Did you assign the associated “SENSOR_SIGN” definition for that orientation as described in the comments of the AHRS example code (e.g. commenting out line 41 and uncommenting line 49)? If not, could you try doing that and seeing if that fixes the problem?
Additionally, you should also make sure it is sitting on a level surface and not moving for a few seconds while the AHRS program is starting up.