I run the example for the d2000 magnemeter compass in the ISS IDE. I get the d2000 lined up with north and get a reading of 0 degrees, then for east (90 degree rotation) I get an incorrect reading of 66 degrees (24 degrees wrong), then for south I get a reading of 140 degrees so that's 40 degrees wrong, then bizarrely I get 270 degree for west which is bang on correct.
Any ideas why ?
I have just tested the magnetometer example and I received accurate measurements in every case. Have you already tried to flash your board's ROM to the latest version? In case you haven't, I suggest you to download the latest version of ISSM, flash your board and try again.
Let me know how it goes.
Yes I flashed the ROM (I presumed this would reset all values), maybe I will try it again and see if I get different results again - as this will prove it is at least doing something with the magnet thing).
I was curious how these vales are set in the first place, I know on mobile phones etc you have to calibrate the compass with a figure of 8 movement etc, why is it the d2000 doesnt need this ? Or why at least can't you calibrate it somehow ie North is fixed at 0, rotate the device 90 deg send a signal to a pin, rotate 180 deg send signal to a d2000 digital pin etc.
If it doesnt work I presume I can use some kind of maths conversion to take the values from he maget and map them to degrees ? Or can I send it back ?
I find this behavior strange, as I posted above I am not able to replicate the output. Nevertheless, there might be something that we are overlooking. Could you please tell me more about your setup?
Which OS are you using?
Are you powering the board with the micro USB port? If so, could you please try to change the port or to use an external power supply?
Is it possible for you to download ISSM and install it again? An issue during the installation could be causing this behavior and it would be helpful to determine if this could be it.
There might be an issue with the board, nevertheless, I would like to rule out all the other possibilities first.
I will be waiting for your response.
Ye I power the board with the USB. Even with an external its the same. How on Earth can an issue with the IDE affect the boards output,surely if the board would not function if the upload failed/wasn'tcorrect. The boards compass readings do work for some of the orientations/rotation - see above. functions for some ? But., never the less I did this and lo and behold, it didn't fix it. Incidentally if its a problem with the board can you send me a new one ?
I understand, if you have tried to install the version of ISSM, update the D2000's ROM and the issue persists then the issue might indeed be related to the board.
If that was the case, you will have to contact the place of purchase in order to get a warranty replacement.
I hope this helps.
The compass example simply uses the magnetometer X and Y reading to calculate the angle relative to the magnetic north. There are several things to keep in mind:
- In most cases the magnetic north and geographic north is not the same thing. It could be adjusted using magnetic declination value, which depends on your location on the globe.
- The example code is very simplistic, and it doesn't do tilt compensation (it is possible to do so using built-in accelerometer), or any compensation for distortions (see the next bullet).
- There are magnetic field interferences that could affect compass readings. These are generally called "hard-iron" and "soft-iron" distortions.
The software on the mobile phones or GPS devices would normally do the declination adjustment, tilt compensation, as well as adjustments for hard-iron and soft-iron distortions.