hmc5883l digital compass for yaw angle of my quadcopter

Hello,
i'm designing a software for my quadcopter.I have two sensors on this quadcopter.One is MPU6050(accelerometer + gyroscope) and the other is hmc5883l(digital compass).
I can measure the pitch and roll angles of the quadcopter with the MPU6050 by using this complementary filter;

pitchAngle=0.998*(pitchAngle+GyroXdt1)+(0.002)(AccX);
rollAngle=0.998*(rollAngle+GyroYdt1)+(0.002)(AccY);

This part is done.It is working...

But !!!
For the yaw angle,i will use GyroZ and hmc5883l sensor.Here is the my question for the hmc5883l:

-----I can get the raw values of the x,y,z magnetic fields by using hmc5883l but How can i apply these raw values to my complementary filter for the yaw angle.

This application note describes how to make a tilt-compensated compass.

In my humble opinion...

I agree that the forum should not ask how to do something, but give ideas how.

But I think the answers should be the same caliber.

Example:

Question: Who was Moses?

If they ask for help on how to make the yaw angle of a quadcopter, it makes no sense to pass a document of 22 pages with mathematical formulas that talks about magnetic fields, quaternions and other math beyond the reach of the average human being.

But again, it is my humble opinion ...

it makes no sense to pass a document of 22 pages

It makes perfect sense. The application note uses ordinary trigonometry, which is required for making a tilt-compensated compass. The document does not mention quaternions.

The final answer for the yaw angle is equation 22 and the result cannot be further simplified.

If this is beyond your capabilities, choose a project which is less challenging.

JotaStar:
If they ask for help on how to make the yaw angle of a quadcopter, it makes no sense to pass a document of 22 pages with mathematical formulas that talks about magnetic fields, quaternions and other math beyond the reach of the average human being.

You are of course free to offer, what you consider is, a more appropriate reply.

The BNO055 does computes yaw using its various sensors. It's a relatively easy way to determine yaw. I've been very impressed with the sensor myself.

Thanks for the link to the document jremington. It's very interesting. I've played with the HMC5883L and accelerometers but I was at a loss at coming up with how to compensate for tilt. Seeing equation 22 of the app note made me not feel so bad for not being able to come up with the equation myself.

This sort of question reminds me of "how do I use inverse kinematics?" type questions I'd see in a robot forum I used to frequent. There are lots of questions which don't have simple answers.

Incidentally, there is a much, much easier way to implement a tilt compensated compass, using vector math. The Pololu engineers provided some simple C code to do that.

Also, an application note from ST Micro describes the trigonometric method a bit more clearly and goes into more details about calibration of the magnetometer and accelerometer. See https://www.pololu.com/file/0J434/LSM303DLH-compass-app-note.pdf

JotaStar:
In my humble opinion...

I agree that the forum should not ask how to do something, but give ideas how.

But I think the answers should be the same caliber.

Example:

Question: Who was Moses?