Guidance on making HMC5883L tilt compensated with MPU-6050

Hi I am working on a project that requires that the direction of the compass to be tilt compensated for accuracy. When I bought the compass I also bought a accelerometer/gyro (6 DOF) to be able to do this.

But till now I have no success. I was able to calculate the direction with the compass alone.

Could the problem be that the two devices are not compatible and I should buy one of those 9 DOF modules which comes all included?

The compass is: http://www.robotshop.com/eu/en/parallax-3-axis-hmc5883l-compass-module.html
GY-521 MPU-6050 : Arduino Playground - MPU-6050

the compass to be tilt compensated for accuracy

Not sure what you mean.

It should be possible to do it with separate devices, but the mpu9150 is more compact

Have you tried this code

http://richardstechnotes.wordpress.com/2014/04/22/rtimulib-arduino-9-dof-imu-library-for-the-arduino/

But till now I have no success.

What was the problem?

To implement a tilt-compensated compass, all you need is a compass and an accelerometer. However, they must be solidly linked, either in the same package or on the same PCB, and you have to know the orientation of all the axes.

Here is a particularly simple vector-based approach, which works very well: http://www.pololu.com/file/0J434/LSM303DLH-compass-app-note.pdf and it is hard to beat this $5.95 deal on the sensor: Pololu - LSM303DLM 3D Compass and Accelerometer Carrier with Voltage Regulators

To get the maximum accuracy, you will need to calibrate both the magnetometer and the accelerometer, which removes offset and axial scaling errors. Here is my favorite approach Sailboat Instruments: Improved magnetometer calibration (Part 1)