Jump to content
I2Cdevlib Forums

Converting MPU raw data for a single axis


Recommended Posts

Hi -

 

I am looking to use the MPU6050 on a self balancing bicycle. I am using a PIC micro so can't take the code directly from i2Cdevlib.

 

I am only interested in the angle in one axis (I'm only interested in roll). I have some questions I was hoping someone could help with:

 

1. If I'm interested in only one axis and only small angles (+/- 10deg), is it OK to just grab the accelerometer and gyro data for that one axis; or should I still get all 3 and combine for some reason?

 

I have seen posts for other IMUs suggesting that you should combine readings to get the required angle. For example, assume I am interested in only the X angle, then it suggests something like this:

//Convert Accelerometer values to degrees
    AccXangle = (float) (atan2(*(acc_raw_y),*(acc_raw_z))+M_PI)*RAD_TO_DEG;

But what is incorrect with doing:

AccXangle = (float) ((acc_raw_x / 9.81) * RAD_TO_DEG);  // For small angles where sin(theta) is approx equal to theta

Since I am not interested in full 360deg locus but just small angles, will the second method not work?

 

I guess I can use the first method but I was curious; and want to know if I really need the overhead of the more complex atan2 function.

 

2. What is the method to 'zero' the gyro? Since the gyro measures angular velocity, the ang_vel*dt will give change in angle, hence needs summing from a known point. So, do I need to put my bike into a 'zero' position and then start the gyro measurements or is there a cleverer way to do it?

 

If I'm using a complimentary filter in the form:

X_angle = 0.98 * (angle + gyroX_vel * dt) + 0.02 * accXAngle

then if I set X_angle = accXangle for the first loop iteration will that be OK?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...