I'm currently writing code to make a PID controller to stabilize an aircraft. The accelerometer i'm currently using (mpu9250) gives me raw accelerometer data, but I don't know where to go from here to make a controller. Is there any way to convert the raw data from the board to degrees of movement, or is there any other way to go about this project?
Acceleration != Degrees.
Use a gyro.
How would I get degrees of movement from a gyroscope? Doesnt a gyroscopes data go back down to 0 after there's no movement?
correct me if i'm wrong, but accelerometer measures acceleration, correct? So It also measures the earths/gravitational acceleration and can determine tilt from that.
Gyroscope measures G's from its rotational energy, right? So when you tilt it, it measures how fast it is turning, and when you are done tilting to, say, 33 degrees to the left, it outputs a data of 0. How would I be able to get degrees from that?
A gyroscope measures angular acceleration [rad / s²]. Integrate it once to get the angular velocity [rad / s], integrate it twice to get the rotation [rad]. But expect it to drift over time.
Pieter
An accelerometer can be used to measure tilt, if it is being held still and not otherwise accelerating.
A gyroscope can be used to measure the rate of rotation, but drifts with changes in temperature and may not be accurate when accelerated.
Usually the two types of sensors are combined with a software filter, to get approximate orientations.
Madgwick's argorithm. There's even a library for it in the IDE's Library Manager.
You can also look into 3D compass chips.
OhItsTarik:
correct me if i'm wrong, but accelerometer measures acceleration, correct? So It also measures the earths/gravitational acceleration and can determine tilt from that.
Not when it's mounted to an aircraft. Then it measures the amount of lift that the wings are generating. It cannot know which direction the wings are pointing.
There must be a zillion Arduino autopilot projects out there on the internet. Is Google broken today?
Google is the new dictionary and IIRC not looking things up is most people for as long as I've been around.
When you start complaining about people not Googling this what people see when they Google.
So, today, 2 years after the fact, when Googling the problem, instead of the solution I get complaints about OP not Googling.
See how retarded that is?
PS: And so that someone in the future doesnt lose their time with this stupidity :
From
Widgets and Gizmos - Wizmoz: Simple Accelerometer Data Conversion to Degrees
double xyz[3];
double ax, ay, az;adxl.get_Gxyz(xyz);
ax = xyz[0];
ay = xyz[1];
az = xyz[2];
double xAngle = atan( ax / (sqrt(square(ay) + square(az))));
double yAngle = atan( ay / (sqrt(square(ax) + square(az))));
double zAngle = atan( sqrt(square(ax) + square(ay)) / az);xAngle *= 180.00; yAngle *= 180.00; zAngle *= 180.00;
xAngle /= 3.141592; yAngle /= 3.141592; zAngle /= 3.141592;
OhItsTarik:
I'm currently writing code to make a PID controller to stabilize an aircraft. The accelerometer i'm currently using (mpu9250) gives me raw accelerometer data, but I don't know where to go from here to make a controller. Is there any way to convert the raw data from the board to degrees of movement, or is there any other way to go about this project?
Couple of good videos here on the 6050 but theory still the same.
He also has a web site for further info.
The formulas given in reply #9 and below do not conform to any standard 3D angular system, and are not recommended.
double xAngle = atan( ax / (sqrt(square(ay) + square(az))));
double yAngle = atan( ay / (sqrt(square(ax) + square(az))));
double zAngle = atan( sqrt(square(ax) + square(ay)) / az);
The formulas in the following tutorial are correct for one of the standard Euler 3D angular systems: How_to_Use_a_Three-Axis_Accelerometer_for_Tilt_Sensing-DFRobot
Comprehensive reference on tilt sensing: https://cache.freescale.com/files/sensors/doc/app_note/AN3461.pdf
SilentWarrior:
When you start complaining about people not Googling this what people see when they Google.So, today, 2 years after the fact, when Googling the problem, instead of the solution I get complaints about OP not Googling.
See how retarded that is?
Not as retarded as not reading the conversation but instead making a snap judgement on the first thing you see.
Get the context and see how off the wall you are.
What I wonder is just what GENIUS search words got you my one post and didn't present you with many good answers as well.
GoForSmoke:
Not as retarded as not reading the conversation but instead making a snap judgement on the first thing you see.
Get the context and see how off the wall you are.What I wonder is just what GENIUS search words got you my one post and didn't present you with many good answers as well.
Yeah... no. Be gone troll.
Anyway, I have tested this and it works flawlessly, thanks. Modified a bit for my use case but this works straight away
// from How_to_Use_a_Three-Axis_Accelerometer_for_Tilt_Sensing-DFRobot
int x, y, z; //three axis acceleration data
double roll = 0.00, pitch = 0.00; //Roll & Pitch are the angles which rotate by the axis X and yvoid RP_calculate(){
double x_Buff = float(x);
double y_Buff = float(y);
double z_Buff = float(z);
roll = atan2(y_Buff , z_Buff) * 57.3;
pitch = atan2((- x_Buff) , sqrt(y_Buff * y_Buff + z_Buff * z_Buff)) * 57.3;
}
SilentWarrior:
Yeah... no. Be gone troll.
You've made 2 posts here and can't be bothered with context to pull a stupid judgement warrior stunt and you call ME a troll?
Up yours, clown!
Try searching the web for the works of James Locke, see what fallacies steer your short-attention life.