Hitachi HM55B strange behaviour of x,y
toshio88
Posts: 3
Hi, I'm using an Arduino Duemilanove board with the ATMega328 chip installed, and I'm having some issues with component values that I'm getting.
The value returned by the compass for the x-axis is mysteriously always negative. The other day the y-axis was mysteriously always negative. I've read around a few forum posts and I haven't been able to find anyone with a similar issue yet. I've thought tilting could be the cause, so I've tried tilting it around to see if I can produce correct behaviour of the x and y values. Strangely, I can get positive x values when the compass is tilted at an impractical angle like 45 degrees. Needless to say, I'm pretty sure tilt isn't the cause, but I thought this strange behaviour might catch someone's attention.
The compass is currently mounted with about a considerable tilt which will be fixed, but currently the angle values I'm getting range from 180~130, and -180~-130. As stated previously, if I tilt the compass absurdly I can get angles that read below 130, positive or negative.
The work is mainly done in a room full of electronic instruments, like function generators and oscilloscopes and the like, but for the most part they are turned off when I'm testing the compass. Also, form my understanding of the module documentation, after the compass returns 1100 to indicate its completion, the next bit to follow is supposed to be the MSB of the x-data, which is valid on the next positive clock edge. This bit is intended to be the sign bit, and the next 10 bits that follow are the rest of the x-data, then the y-data comes in with its own 11 bits. This understanding is correct, right? Is there any possibility there's an issue in retrieving data after the 1100 is sent by the compass?
I'm quite new at this, and I'm pretty confused as to the values I'm getting. Could anyone shed some much needed light on this? If it helps, I can post the code I've written. It's been based off of www.arduino.cc/playground/Main/HM55B, although there were things I had issues with so I've made adjustments.
The value returned by the compass for the x-axis is mysteriously always negative. The other day the y-axis was mysteriously always negative. I've read around a few forum posts and I haven't been able to find anyone with a similar issue yet. I've thought tilting could be the cause, so I've tried tilting it around to see if I can produce correct behaviour of the x and y values. Strangely, I can get positive x values when the compass is tilted at an impractical angle like 45 degrees. Needless to say, I'm pretty sure tilt isn't the cause, but I thought this strange behaviour might catch someone's attention.
The compass is currently mounted with about a considerable tilt which will be fixed, but currently the angle values I'm getting range from 180~130, and -180~-130. As stated previously, if I tilt the compass absurdly I can get angles that read below 130, positive or negative.
The work is mainly done in a room full of electronic instruments, like function generators and oscilloscopes and the like, but for the most part they are turned off when I'm testing the compass. Also, form my understanding of the module documentation, after the compass returns 1100 to indicate its completion, the next bit to follow is supposed to be the MSB of the x-data, which is valid on the next positive clock edge. This bit is intended to be the sign bit, and the next 10 bits that follow are the rest of the x-data, then the y-data comes in with its own 11 bits. This understanding is correct, right? Is there any possibility there's an issue in retrieving data after the 1100 is sent by the compass?
I'm quite new at this, and I'm pretty confused as to the values I'm getting. Could anyone shed some much needed light on this? If it helps, I can post the code I've written. It's been based off of www.arduino.cc/playground/Main/HM55B, although there were things I had issues with so I've made adjustments.
Comments
Tilting the compass chip shouldn't make any difference except for the effect of external magnetic fields.
The sample Stamp code does work and I've used the HM-55B with a Propeller as well and it works fine that way. You might look at the sample Stamp code and compare it to the Arduino code to see what's different about the timing.
Alright, I'll keep that bit of info in mind. If there are external magnetic fields, about how far is "far"? Is about 1m away safe enough? I guess it depends on whatever device is causing the field, but is there a general rule of thumb you follow?
I see, I will definitely look into examining the code, I'm suspecting timing issues with how my shiftin/shiftout is implemented. Another quick question, should both axes report positive values for two quadrants each and negative values for the other two quadrants?
Thanks for the insight and response.
Awesome, thanks for the much appreciated and needed clarifications.