Shop OBEX P1 Docs P2 Docs Learn Events
Theory of operation of HM55B Compass Module — Parallax Forums

Theory of operation of HM55B Compass Module

ichoelichoel Posts: 17
edited 2009-06-27 03:37 in Accessories
Hi, i need to know thoroughly about hm55b. After having some reading, i just come up with questions.
From datasheet HM55B Compass module (29123), there is theory of operation saying that "
The Hitachi HM55B chip on the Compass Module reports its x and y axis measurement in terms
of microteslas in 11 bit signed values. The HM55B is designed to return a value of 1 for
north magnetic field of 1 uT parallel to one of its axes. If the magnetic field is south,
the value will be -1."
My questions : a. the returned value for north is 1, and south is -1. What value is it? x or y?
b. how do you describe the returned value in 11 bit signed values?
c. what value represented by the 11 bit signed values ?

I'm sorry for the questions. It's just confusing confused.gif

-ichoel-

"There is sky over the sky"

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-24 13:14
    a) There are effectively two sensors in the HM55B at right angles to each other. Each sensor returns a value between 1 and -1 that represents the magnetic field strength along that axis. A value of 1 represents a magnetic field strength of 1uT north while a value of -1 represents a magnetic field strength of 1uT south. The documentation for the HM55B shows the X and Y axes for the module.

    b) For each axis (X and Y), an 11 bit 2's complement value is provided. 11111111111 would represent -1uT while 01111111111 would represent +1uT. The Stamp programs show in the documentation use these values to calculate the angle of the sensor to the local magnetic field. They read the two values from the HM55B, extend the sign to 16 bits since the Stamps do all arithmetic in 16 bit values, then they use an arctangent function to calculate the angle.
  • cessnapilotcessnapilot Posts: 182
    edited 2009-06-25 12:11
    Mike Green said...
    ...·Each sensor returns a value between 1 and -1 that represents the magnetic field strength along that axis. ..
    ichoel
    I would better say that each sensor·might return·a value between -1024 and 1024. The linear measurement range is, however, between 180 and -180. The values are represented in 11-bit signed values (10 bits·+ sign bit as MSB).
    The horizontal component of the geomagnetic field is somewhere 10 to 50 uT (or so) depending on location.· Let us suppose that this horizontal component is 22. When the sensitivity of the sensor is the nominal 1 uT then, the·horizontally kept sensor·will return a value between +22 and -22. When the sensitivity is only 1.6 uT, then the neasured values are between somewhere +14 and -14.
    When you put a small magnet close to the sensor you can·have higher readings, of course, but you can easily get out from the linear measurement range (+180, -180 uT). Be carefull with strong magnets, some types of magnetic sensors can be destroyed with high magnetic fields. For the HM55B, I don't know. Better not to try. Or let us know, what happened.
    If the MSB of the reading is 1, put as many 1-s before that as necessary to fill up the 16 bit (or 32 bit) register. If you are only measuring the Earth's magnetic field (+50 to -50), enough to·chop the lower 8 bits into a byte, and then to treat is as a signed byte.

    István
  • cessnapilotcessnapilot Posts: 182
    edited 2009-06-25 14:29
    Hi ichoel

    I looked up in the datasheet of HM55B that field strength of 300 uT or more can permanently destroy the sensor. So, we don't have to figure out. Small permanent magnets, found sometimes in computer disk drives, can have several hundreds of mT field strength in their vicinity. They are definitely an overkill for HM55B. These rare earth (SmCo) magnets are extremely strong for their small size and too dangerous just to play with. Handle them with extreme care.

    Istv
  • ichoelichoel Posts: 17
    edited 2009-06-27 02:32
    I have more questions, from the compass code :
    ....
    NegMask CON %1111100000000000
    ....
    IF (y.BIT10 = 1) THEN y = y | NegMask ' Store 11-bits as signed word
    IF (x.BIT10 = 1) THEN x = x | NegMask
    ....

    a. It's explained that this code is intended to convert 11 bit to 16 bit signed word. But, how? Is it addition operation (y = y | NegMask) ?
    b. And how about if y.bit10 = 0 or x.bit10 = 0, dont you have to convert them as well?


    -ichoel-

    "There is sky over the sky"
  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-27 03:37
    Whenever you see a statement or an operator you don't know or don't understand, read the manual (Parallax Stamp Basic Syntax and Reference Manual). That's what the manual is for.

    In this particular case, this code extends the sign bit to higher order bits in the 16 bit result using a bit logical or operation. If the sign bit of the 11 bit signed value is zero, then the value is already a correct 11 bit or 16 bit positive number.

    Try doing some examples on a piece of paper.
Sign In or Register to comment.