-
Notifications
You must be signed in to change notification settings - Fork 24
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
Accelerometer and Gyroscope are switched #2
Comments
Hello Cacciuc, the answer ist no, because of multiple reasons: If you look inside
So the function does everything correct If you mount the MPU6050 sensor on your table and fix them with simple tape, then only the z-Acceleration should be unequal to zero.
After setting these properties you need to calculate the Offset. For that read out 1000 datapoints. Then calculate the Offset with the code. Note I don't use the first 400 values. Thats only for safety, because I found out that the the first values are garbage. To be sure to not get garbage values, I dont care about the first 400 values.
After that you can read out new datapoints and subtract them with you offset values. You should get nearly zeros on x and y acceleration axis and 16384 on the z-axis. This is because the z-axis measures the gravity. So long story short: The function works as expected and you your assumption is wrongIn a few weeks I will fork this repo and add a complementary filter to calculate the angle. And some others improvements of this repo/code. [1] https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6000-Register-Map1.pdf |
When using just the simplest implementation, it seems that the accelerometer values and the gyroscope values are switched.
My implementation in main
`
.
.
. //initialisations from CubeMx
SD_MPU6050 mpu;
if (SD_MPU6050_Init(&hi2c1, &mpu, SD_MPU6050_Device_1,
SD_MPU6050_Accelerometer_4G, SD_MPU6050_Gyroscope_1000s)
!= SD_MPU6050_Result_Ok) {
LedRed(1);
asm("nop");
return -1;
}
/* USER CODE END 2 */
}`
![mpu6050](https://user-images.githubusercontent.com/43413216/70724288-9d9dfd00-1cfa-11ea-8bc9-affb70c15cd0.PNG)
In the STMStudio the values are shown in a bar graph. This is a screenshot of the MPU6050 sitting still in a weird angle. All values are stable.
I will switch the accelerometer and gyroscope variables in my Code, but since no one else has the same error, i will not make a pull request.
The text was updated successfully, but these errors were encountered: