Datasheet

HMC5883L
www.honeywell.com 19
SELF TEST OPERATION
To check the HMC5883L for proper operation, a self test feature in incorporated in which the sensor offset straps are
excited to create a nominal field strength (bias field) to be measured. To implement self test, the least significant bits (MS1
and MS0) of configuration register A are changed from 00 to 01 (positive bias) or 10 (negetive bias).
Then, by placing the mode register into single or continuous-measurement mode, two data acquisition cycles will be made
on each magnetic vector. The first acquisition will be a set pulse followed shortly by measurement data of the external
field. The second acquisition will have the offset strap excited (about 10 mA) in the positive bias mode for X, Y, and Z
axes to create about a 1.1 gauss self test field plus the external field. The first acquisition values will be subtracted from
the second acquisition, and the net measurement will be placed into the data output registers.
Since self test adds ~1.1 Gauss additional field to the existing field strength, using a reduced gain setting prevents sensor
from being saturated and data registers overflowed. For example, if the configuration register B is set to 0xA0 (Gain=5),
values around +452 LSb (1.16 Ga * 390 LSb/Ga) will be placed in the X and Y data output registers and around +421
(1.08 Ga * 390 LSb/Ga) will be placed in Z data output register. To leave the self test mode, change MS1 and MS0 bit of
the configuration register A back to 00 (Normal Measurement Mode). Acceptable limits of the self test values depend on
the gain setting. Limits for Gain=5 is provided in the specification table.
Below is an example of a positive self test process using continuous-measurement mode:
1. Write CRA (00) send 0x3C 0x00 0x71 (8-average, 15 Hz default, positive self test measurement)
2. Write CRB (01) send 0x3C 0x01 0xA0 (Gain=5)
3. Write Mode (02) send 0x3C 0x02 0x00 (Continuous-measurement mode)
4. Wait 6 ms or monitor status register or DRDY hardware interrupt pin
5. Loop
Send 0x3D 0x06 (Read all 6 bytes. If gain is changed then this data set is using previous gain)
Convert three 16-bit 2’s compliment hex values to decimal values and assign to X, Z, Y, respectively.
Send 0x3C 0x03 (point to first data register 03)
Wait about 67 ms (if 15 Hz rate) or monitor status register or DRDY hardware interrupt pin
End_loop
6. Check limits
If all 3 axes (X, Y, and Z) are within reasonable limits (243 to 575 for Gain=5, adjust these limits basing on the
gain setting used. See an example below.) Then
All 3 axes pass positive self test
Write CRA (00) send 0x3C 0x00 0x70 (Exit self test mode and this procedure)
Else
If Gain<7
Write CRB (01) send 0x3C 0x01 0x_0 (Increase gain setting and retry, skip the next data set)
Else
At least one axis did not pass positive self test
Write CRA (00) send 0x3C 0x00 0x70 (Exit self test mode and this procedure)
End If
Below is an example of how to adjust the “positive self test limits basing on the gain setting:
1. If Gain = 6, self test limits are:
Low Limit = 243 * 330/390 = 206
High Limit = 575 * 330/390 = 487
2. If Gain = 7, self test limits are:
Low Limit = 243 * 230/390 = 143
High Limit = 575 * 230/390 = 339