Friday 19 April 2013

A Compass that points me in the right direction... yay...

I Received an email the other day regarding one of my posts from 14th Sept 2012, regarding my troubles with a compass IC that i had planned to use on a project.. the person doesn't want to be named but i must thank them for their assistance.. for now they will be known as Anonymous Genius #102 ...Thanks..


It may look like a simple solution, the addition of 12 chars, but it had me stumped for a while..
to solve this what you need to do is, open up the HCM5883L.h find the lines below..


struct MagnetometerRaw
{
    int XAxis;
    int YAxis;
    int ZAxis;
};

and make it look like this :-


struct MagnetometerRaw
{
    int16_t XAxis;
    int16_t YAxis;
    int16_t ZAxis;
};

add the 16_t to the keyword int this will force the compiler to use a 16bit signed int. the problem is that gcc  (for the PIC32 uP) sees it as a 32bit int. this would be causing all sorts of troubles when you start shifting buts around expecting it to behave one way and it doing its own thing...


the HCM5883L.h file is stored in the resources folder, you only need to edit the one under the PIC32 folder. in OSX the path is..
/Applications/Mpide.app/Contents/Resources/Java/hardware/pic32/libraries/HMC5883L/HCM5883L.h

now when i run my code i get 0-360'..... now to intergrate this code into the other half of the project code... fun times ahead.. 

No comments:

Post a Comment