Jump to content
I2Cdevlib Forums

JohnOakley

Members
  • Posts

    1
  • Joined

  • Last visited

  • Days Won

    1

JohnOakley last won the day on September 3 2015

JohnOakley had the most liked content!

JohnOakley's Achievements

Newbie

Newbie (1/14)

1

Reputation

  1. Hi group, iam hoping someone can enlighten me regarding an issue iam having with my MPU6050 on by balancing robot. Ive tore the web apart pulled data sheets apart and also forums for an answer and done numerous tests but maybe iam missing something: in brief, the MPU module is fitted with the the Y axis facing the direction of travel, Below is a few lines of code used to fuse the accelerometer and gyro using the complimentary filter, for reference: Accel_result[0] is X axis Accel_result[1] is Y axis Accel_result[2] is Z axis Gyro_result[0] is X axis Gyro_result[1] is Y axis code: //GET PITCH AND ROLL CONVERTED TO DEGREES * 180/PI Pitch = atan2(Accel_result[0],Accel_result[2])*57.2957; Roll = atan2(Accel_result[1],Accel_result[2])*57.2957; //FUSE GYRO AND ACCELEROMETER USING COMP FILTER Angle_x = 0.97*(Angle_x +(Gyro_result[0]*0.01) +(0.03*Pitch)); Angle_y = 0.97*(Angle_y +(Gyro_result[1]*0.01) +(0.03*Roll)); Looking at the Pitch and Roll values on a terminal program and looking at it on a graphical program, when the bot it tilted forward, i get the Y angle value, when its tilted sideways i get the X angle, also Pitch and Roll shown are correct, so i know the sensor is functioning ok. Fusing it into the comp filter seems to be where iam baffled at its behaviour. Using the code as is above, the bot will stand up as planned but gradually leans over as the zero point changes. If i swap the Pitch and Roll round: Angle_x = 0.97*(Angle_x +(Gyro_result[0]*0.01) +(0.03*Roll)); Angle_y = 0.97*(Angle_y +(Gyro_result[1]*0.01) +(0.03*Pitch)); the bot functions as normal and stays vertical with no drift or leaning as it should. I was under the belief that X was the Pitch and Y was the Roll. Q) Why changing them round could this make a difference to the changing vertical zero point?? secondly, if i turn the module 90deg so the X axis is now facing forward and use Angle_y in the PID routine in place of Angle_x, the bot will not stand, even if switching the Pitch and Roll back as before, it behaves totally different but will never stand up. nothing i do will make the bot work with the module in this orientation, Q) Any ideas?? as the X axis is kind of defunc. Tried a second module but just the same Q) Again i was under the belief that the MPU6050 should be able to be used with either axis, but clearly something is not adding up, Anyone come accross this or have any idea why??? Am i missing something in regards to Pitch and Roll on gyroscopes? Extensive reading seems to prove nothing. Appologies its a long post but hoping that the more detail i can give, the better the hope some light may be shed on it. Many thanks John
×
×
  • Create New...