Testing my code for the HMC5843 turns out that the labeling for the axis may be wrong. The sign directions are different too. I checked against the Board from Sparkfun. Looking at the datasheet, the components axis described there are when you look at the bottom of the device. The schematic pictures is mirrored upside down to show a view from the top.
Yes, I believe you are correct. You're not the first one to find this problem but you are the first one to illustrate it with a picture so clearly! It's up to Jordi to fix this one on an upcoming batch.
Of course I don't know exactly how you're using the compasses, but if you're using Arduino + the AP_Compass library then the orientation can be set with the set_orientation call and there are a bunch of predefined constants for both boards which makes it easy to get it working properly.
I watch the code very close :-)
Honestly, the code for the magnetometer has never been official released yet. There is more than just a readout from the adc.
Can somebody explain me why the X and Z axis in the AP_Compass_HMC5843.cpp has different Signs (-)?
// MSB byte first, then LSB, X,Y,Z
mag_x = -((((int)buff) 8) | buff) * calibration; // X axis
mag_y = ((((int)buff) 8) | buff) * calibration; // Y axis
mag_z = -((((int)buff) 8) | buff) * calibration; // Z axis
last_update = millis(); // record time of update
Is this not covered by the declaration of the orentiation of the sensor?
They are probably aligning the HMC5843 axis to those of the accelerometer and gyro.
Negating X and Z is like making a 180deg rotation around the HMC5843 Y axis.
Ok, I see. It corrects wrong axis when you mount the board direct on the shield (see wiki).
ok - good point about being able to use the orientation instead of the -ve on x & y. Nothing's broken but perhaps it's unnecessarily confusing.
I'll give that a go (unless someone else wants to fix it an send me the changes!).
Jordi is aware of this cosmetic issue and will correct in the next version.
Please put a small note to the current documentation.
Please note, you have v1.1 pic which is also different from the previous ver. which I have that has two removable sides. (4 holes)
Also, did you notice that your right hand digram is inverted? Also in that diagram is an X vs. a Dot which indicates out rather than in... or up vs down I believe.
Thank you for your reply. I´m using the wire.h library (Arduino's regular library).
The code is attached (Compass.txt) that is a modified copy from ArduIMU code (by Jordi Munoz and William Premerlani, Supported by Chris Anderson (Wired) and Nathan Sindle (SparkFun).
I only made small modifcations to run the code alone and no tilt compensated.
During the test I keep HCM5843 board with roll and pitch angles equal to zero and fixed yaw (no movement, static).
I took this board (http://store.diydrones.com/HMC5843_Triple_Axis_Magnetometer_p/br-hm...) because it works with 5V devices, I believe that no level conversion is necessary.