PX4 Firmware
PX4 Autopilot Software http://px4.io
hmc5883 Namespace Reference

Local functions in support of the shell command. More...

Classes

struct  hmc5883_bus_option
 

Functions

static bool start_bus (struct hmc5883_bus_option &bus, enum Rotation rotation)
 start driver for a specific bus option More...
 
static int start (enum HMC5883_BUS busid, enum Rotation rotation)
 Start the driver. More...
 
static int stop ()
 
static struct hmc5883_bus_optionfind_bus (enum HMC5883_BUS busid)
 find a bus structure for a busid More...
 
static int calibrate (enum HMC5883_BUS busid)
 Automatic scale calibration. More...
 
static int temp_enable (enum HMC5883_BUS busid, bool enable)
 enable/disable temperature compensation More...
 
static int info (enum HMC5883_BUS busid)
 Print a little info about the driver. More...
 
static int usage ()
 

Variables

struct hmc5883::hmc5883_bus_option bus_options []
 

Detailed Description

Local functions in support of the shell command.

Function Documentation

◆ calibrate()

static int hmc5883::calibrate ( enum HMC5883_BUS  busid)
static

Automatic scale calibration.

Basic idea:

output = (ext field +- 1.1 Ga self-test) * scale factor

and consequently:

1.1 Ga = (excited - normal) * scale factor scale factor = (excited - normal) / 1.1 Ga

sxy = (excited - normal) / 766 | for conf reg. B set to 0x60 / Gain = 3 sz = (excited - normal) / 713 | for conf reg. B set to 0x60 / Gain = 3

By subtracting the non-excited measurement the pure 1.1 Ga reading can be extracted and the sensitivity of all axes can be matched.

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), e.g. 0x11 or 0x12. Then, by placing the mode register into single-measurement mode (0x01), 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 0x60 (Gain=3), values around +766 LSB (1.16 Ga * 660 LSB/Ga) will be placed in the X and Y data output registers and around +713 (1.08 Ga * 660 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), e.g. 0x10. Using the self test method described above, the user can scale sensor

Definition at line 239 of file hmc5883_main.cpp.

References hmc5883::hmc5883_bus_option::devpath, fd, find_bus(), MAGIOCCALIBRATE, OK, px4_close(), px4_ioctl(), and px4_open().

Referenced by hmc5883_main(), and lis3mdl_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_bus()

static struct hmc5883_bus_option* hmc5883::find_bus ( enum HMC5883_BUS  busid)
static

find a bus structure for a busid

Definition at line 185 of file hmc5883_main.cpp.

References bus_options, hmc5883::hmc5883_bus_option::dev, HMC5883_BUS_ALL, and NUM_BUS_OPTIONS.

Referenced by calibrate(), info(), and temp_enable().

Here is the caller graph for this function:

◆ info()

static int hmc5883::info ( enum HMC5883_BUS  busid)
static

Print a little info about the driver.

Definition at line 301 of file hmc5883_main.cpp.

References hmc5883::hmc5883_bus_option::busid, hmc5883::hmc5883_bus_option::dev, hmc5883::hmc5883_bus_option::devpath, find_bus(), and HMC5883::print_info().

Referenced by hmc5883_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start()

static int hmc5883::start ( enum HMC5883_BUS  busid,
enum Rotation  rotation 
)
static

Start the driver.

This function call only returns once the driver is either successfully up and running or failed to start.

Definition at line 139 of file hmc5883_main.cpp.

References bus_options, hmc5883::hmc5883_bus_option::dev, HMC5883_BUS_ALL, NUM_BUS_OPTIONS, and start_bus().

Referenced by hmc5883_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_bus()

static bool hmc5883::start_bus ( struct hmc5883_bus_option bus,
enum Rotation  rotation 
)
static

start driver for a specific bus option

Definition at line 93 of file hmc5883_main.cpp.

References hmc5883::hmc5883_bus_option::dev, fd, OK, px4_close(), px4_ioctl(), px4_open(), SENSOR_POLLRATE_DEFAULT, and SENSORIOCSPOLLRATE.

Referenced by start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop()

static int hmc5883::stop ( )
static

Definition at line 165 of file hmc5883_main.cpp.

References bus_options, hmc5883::hmc5883_bus_option::dev, NUM_BUS_OPTIONS, and HMC5883::stop().

Referenced by hmc5883_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_enable()

static int hmc5883::temp_enable ( enum HMC5883_BUS  busid,
bool  enable 
)
static

enable/disable temperature compensation

Definition at line 271 of file hmc5883_main.cpp.

References hmc5883::hmc5883_bus_option::devpath, fd, find_bus(), MAGIOCSTEMPCOMP, px4_close(), px4_ioctl(), and px4_open().

Referenced by hmc5883_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usage()

static int hmc5883::usage ( void  )
static

Definition at line 318 of file hmc5883_main.cpp.

References warnx.

Referenced by hmc5883_main().

Here is the caller graph for this function:

Variable Documentation

◆ bus_options

struct hmc5883::hmc5883_bus_option hmc5883::bus_options[]
Initial value:
= {
{ HMC5883_BUS_I2C_EXTERNAL, "/dev/hmc5883_ext", &HMC5883_I2C_interface, PX4_I2C_BUS_EXPANSION, NULL },
}
device::Device * HMC5883_I2C_interface(int bus)
Definition: hmc5883_i2c.cpp:68

Referenced by find_bus(), start(), and stop().