Constructor & Destructor Documentation
Default constructor, uses default I2C address.
- See also:
- HMC5843_DEFAULT_ADDRESS
HMC5843::HMC5843 |
( |
uint8_t |
address | ) |
|
Specific address constructor.
- Parameters:
-
- See also:
- HMC5843_DEFAULT_ADDRESS
-
HMC5843_ADDRESS
Member Function Documentation
uint8_t HMC5843::getDataRate |
( |
| ) |
|
Get data output rate value. The Table below shows all selectable output rates in continuous measurement mode. All three channels shall be measured within a given output rate.
Value | Typical Data Output Rate (Hz) ------+------------------------------ 0 | 0.5 1 | 1 2 | 2 3 | 5 4 | 10 (Default) 5 | 20 6 | 50 7 | Not used
- Returns:
- Current rate of data output to registers
- See also:
- HMC5843_RATE_10
-
HMC5843_RA_CONFIG_A
-
HMC5843_CRA_RATE_BIT
-
HMC5843_CRA_RATE_LENGTH
uint8_t HMC5843::getGain |
( |
| ) |
|
Get magnetic field gain value. The table below shows nominal gain settings. Use the Gain column to convert counts to Gauss. Choose a lower gain value (higher GN#) when total field strength causes overflow in one of the data output registers (saturation). The data output range for all settings is 0xF800-0x07FF (-2048 - 2047).
Value | Field Range | Gain (LSB/Gauss) ------+-------------+----------------- 0 | +/- 0.7 Ga | 1620 1 | +/- 1.0 Ga | 1300 (Default) 2 | +/- 1.5 Ga | 970 3 | +/- 2.0 Ga | 780 4 | +/- 3.2 Ga | 530 5 | +/- 3.8 Ga | 460 6 | +/- 4.5 Ga | 390 7 | +/- 6.5 Ga | 280 (Not recommended)
- Returns:
- Current magnetic field gain value
- See also:
- HMC5843_GAIN_1300
-
HMC5843_RA_CONFIG_B
-
HMC5843_CRB_GAIN_BIT
-
HMC5843_CRB_GAIN_LENGTH
void HMC5843::getHeading |
( |
int16_t * |
x, |
|
|
int16_t * |
y, |
|
|
int16_t * |
z |
|
) |
| |
Get 3-axis heading measurements. In the event the ADC reading overflows or underflows for the given channel, or if there is a math overflow during the bias measurement, this data register will contain the value -4096. This register value will clear when after the next valid measurement is made. Note that this method automatically clears the appropriate bit in the MODE register if Single mode is active.
- Parameters:
-
x | 16-bit signed integer container for X-axis heading |
y | 16-bit signed integer container for Y-axis heading |
z | 16-bit signed integer container for Z-axis heading |
- See also:
- HMC5843_RA_DATAX_H
int16_t HMC5843::getHeadingX |
( |
| ) |
|
Get X-axis heading measurement.
- Returns:
- 16-bit signed integer with X-axis heading
- See also:
- HMC5843_RA_DATAX_H
int16_t HMC5843::getHeadingY |
( |
| ) |
|
Get Y-axis heading measurement.
- Returns:
- 16-bit signed integer with Y-axis heading
- See also:
- HMC5843_RA_DATAY_H
int16_t HMC5843::getHeadingZ |
( |
| ) |
|
Get Z-axis heading measurement.
- Returns:
- 16-bit signed integer with Z-axis heading
- See also:
- HMC5843_RA_DATAZ_H
uint8_t HMC5843::getIDA |
( |
| ) |
|
Get identification byte A
- Returns:
- ID_A byte (should be 01001000, ASCII value 'H')
uint8_t HMC5843::getIDB |
( |
| ) |
|
Get identification byte B
- Returns:
- ID_A byte (should be 00110100, ASCII value '4')
uint8_t HMC5843::getIDC |
( |
| ) |
|
Get identification byte C
- Returns:
- ID_A byte (should be 00110011, ASCII value '3')
bool HMC5843::getLockStatus |
( |
| ) |
|
Get data output register lock status. This bit is set when this some but not all for of the six data output registers have been read. When this bit is set, the six data output registers are locked and any new data will not be placed in these register until one of three conditions are met: one, all six bytes have been read or the mode changed, two, the mode is changed, or three, the measurement configuration is changed.
- Returns:
- Data output register lock status
- See also:
- HMC5843_RA_STATUS
-
HMC5843_STATUS_LOCK_BIT
uint8_t HMC5843::getMeasurementBias |
( |
| ) |
|
Get measurement bias value.
- Returns:
- Current bias value (0-2 for normal/positive/negative respectively)
- See also:
- HMC5843_BIAS_NORMAL
-
HMC5843_RA_CONFIG_A
-
HMC5843_CRA_BIAS_BIT
-
HMC5843_CRA_BIAS_LENGTH
uint8_t HMC5843::getMode |
( |
| ) |
|
Get measurement mode. In continuous-measurement mode, the device continuously performs measurements and places the result in the data register. RDY goes high when new data is placed in all three registers. After a power-on or a write to the mode or configuration register, the first measurement set is available from all three data output registers after a period of 2/fDO and subsequent measurements are available at a frequency of fDO, where fDO is the frequency of data output.
When single-measurement mode (default) is selected, device performs a single measurement, sets RDY high and returned to idle mode. Mode register returns to idle mode bit values. The measurement remains in the data output register and RDY remains high until the data output register is read or another measurement is performed.
- Returns:
- Current measurement mode
- See also:
- HMC5843_MODE_CONTINUOUS
-
HMC5843_MODE_SINGLE
-
HMC5843_MODE_IDLE
-
HMC5843_MODE_SLEEP
-
HMC5843_RA_MODE
-
HMC5843_MODEREG_BIT
-
HMC5843_MODEREG_LENGTH
bool HMC5843::getReadyStatus |
( |
| ) |
|
Get data ready status. This bit is set when data is written to all six data registers, and cleared when the device initiates a write to the data output registers and after one or more of the data output registers are written to. When RDY bit is clear it shall remain cleared for 250 us. DRDY pin can be used as an alternative to the status register for monitoring the device for measurement data.
- Returns:
- Data ready status
- See also:
- HMC5843_RA_STATUS
-
HMC5843_STATUS_READY_BIT
bool HMC5843::getRegulatorEnabledStatus |
( |
| ) |
|
Get regulator enabled status. This bit is set when the internal voltage regulator is enabled. This bit is cleared when the internal regulator is disabled.
- Returns:
- Regulator enabled status
- See also:
- HMC5843_RA_STATUS
-
HMC5843_STATUS_REN_BIT
void HMC5843::initialize |
( |
| ) |
|
Power on and prepare for general usage. This will prepare the magnetometer with default settings, ready for single- use mode (very low power requirements). Default settings include 8-sample averaging, 15 Hz data output rate, normal measurement bias, a,d 1090 gain (in terms of LSB/Gauss). Be sure to adjust any settings you need specifically after initialization, especially the gain settings if you happen to be seeing a lot of -4096 values (see the datasheet for mor information).
void HMC5843::setDataRate |
( |
uint8_t |
rate | ) |
|
Set data output rate value.
- Parameters:
-
rate | Rate of data output to registers |
- See also:
- getDataRate()
-
HMC5843_RATE_10
-
HMC5843_RA_CONFIG_A
-
HMC5843_CRA_RATE_BIT
-
HMC5843_CRA_RATE_LENGTH
void HMC5843::setGain |
( |
uint8_t |
gain | ) |
|
Set magnetic field gain value.
- Parameters:
-
gain | New magnetic field gain value |
- See also:
- getGain()
-
HMC5843_RA_CONFIG_B
-
HMC5843_CRB_GAIN_BIT
-
HMC5843_CRB_GAIN_LENGTH
void HMC5843::setMeasurementBias |
( |
uint8_t |
bias | ) |
|
Set measurement bias value.
- Parameters:
-
bias | New bias value (0-2 for normal/positive/negative respectively) |
- See also:
- HMC5843_BIAS_NORMAL
-
HMC5843_RA_CONFIG_A
-
HMC5843_CRA_BIAS_BIT
-
HMC5843_CRA_BIAS_LENGTH
void HMC5843::setMode |
( |
uint8_t |
newMode | ) |
|
Set measurement mode.
- Parameters:
-
newMode | New measurement mode |
- See also:
- getMode()
-
HMC5843_MODE_CONTINUOUS
-
HMC5843_MODE_SINGLE
-
HMC5843_MODE_IDLE
-
HMC5843_MODE_SLEEP
-
HMC5843_RA_MODE
-
HMC5843_MODEREG_BIT
-
HMC5843_MODEREG_LENGTH
bool HMC5843::testConnection |
( |
| ) |
|
Verify the I2C connection. Make sure the device is connected and responds as expected.
- Returns:
- True if connection is valid, false otherwise
The documentation for this class was generated from the following files: