Public Types | Public Member Functions | Public Attributes | Static Public Attributes
BMC050 Class Reference

a bmc050 driver that implements the device's main capabilities. More...

#include <bmc050.hpp>

Inheritance diagram for BMC050:
Inheritance graph
[legend]

List of all members.

Public Types

enum  accel_mode { accel_suspend_, accel_normal_, accel_low_power_ }
enum  compass_mode { compass_suspend_, compass_sleep_, compass_normal_, compass_forced_ }

Public Member Functions

 BMC050 (bosch_hardware_interface *hw)
bool changeAccelBandwidth ()
 changes the accelerometer's bandwidth by writing to the appropriate sensor register. The bandwidth is specified by the setAccelBandwidth(bandwidth) method in the inheritted parameters class.
bool changeAccelRange ()
 a method that changes the accelerometer's range by writing to the appropriate sensor register. The range is specified by the setAccelRange(range) in the inheritted parameter's class.
bool changeCompassRate ()
 change the output-data rate of the compass to the value specified in the parameters.
bool changeNumRepetitionsXY ()
 change the number of samples that the compass averages for the X and Y-axis data before outputting a value.
bool changeNumRepetitionsZ ()
 change the number of samples that the compass averages for the X and Y-axis data before outputting a value.
bool enterForcedModeCompass ()
bool enterLowPowerModeAccel ()
bool enterNormalModeAccel ()
bool enterNormalModeCompass ()
bool enterSleepModeCompass ()
bool enterSuspendModeAccel ()
bool enterSuspendModeCompass ()
bool filterData (bool request)
 writes to the sensor's register in memory to choose whether or not to filter the accelerometer data.
bool getAccelData ()
 retrieves all available raw accelerometer data and stores the calculated value to class variables: AccelX_, AccelY_, AccelZ_, Temperature_.
double getAccelX ()
 retrieves the raw accelerometer x-axis data and stores the calculated value to the class variable: AccelX_
double getAccelY ()
 retrieves the raw accelerometer y-axis data and stores the calculated value to the class variable: AccelY_
double getAccelZ ()
 retrieves the raw accelerometer z-axis data and stores the calculated value to the class variable: AccelZ_
bool getCompassData ()
 take a full measurement from the compass sensor through a generic hardware interface.
double getCompassX ()
double getCompassY ()
double getCompassZ ()
uint8_t getDeviceAddress ()
 An invalid request. It is necessary, since this driver inherits from the sensor_driver class. See the getAccelAddress() and getCompassAddress() methods in the corresponding parameters class.
uint16_t getRHall ()
double getTemperature ()
 retrieves the raw accelerometer temperature data and stores the calculated value to a class variable. If the application requires more than just one axis of data, use the getAccelData() instead, as it is much more efficient.
double getUncompensatedYaw ()
 a simple test method to get the orientation of the sensor assuming that the sensor is perfectly flat.
bool initialize ()
 initializes the sensor with all user-defined preferences indicated in the parameters.
bool printOffsets ()
bool readRegAccel (uint8_t reg, uint8_t *value)
bool readRegCompass (uint8_t reg, uint8_t *value)
bool readRegistersAccel ()
 reads important accelerometer registers for a local copy. This method is needed for changing between modes, which determine values in multiple registers.
bool readRegistersCompass ()
 reads important compass registers for a local copy. This method is needed for changing between modes, which determine values in multiple registers.
void simpleCalibrationAccel ()
 calibrates the sensor assuming it is in a static, flat, level, face-up position (ON EARTH!).
bool softResetAccel ()
 resets the accelerometer, putting it back into normal mode and clearing its image.
bool softResetCompass ()
 resets the compass, putting it back into "suspend" mode.
bool takeMeasurement ()
 perform two separate readings, one for each device.
bool writeToAccelReg (uint8_t reg, uint8_t value)
bool writeToAccelRegAndVerify (uint8_t reg, uint8_t value, uint8_t expected)
bool writeToCompassReg (uint8_t reg, uint8_t value)
bool writeToCompassRegAndVerify (uint8_t reg, uint8_t value, uint8_t expected)
 ~BMC050 ()

Public Attributes

accel_mode accel_mode_
double AccelX_
double AccelY_
double AccelZ_
compass_mode compass_mode_
double CompassX_
double CompassY_
double CompassZ_
uint8_t modechange_accel_
bandwidth prev_bw_reg_
uint8_t rate_compass_
uint8_t RawData [13]
uint16_t RHall_
double SensitivityXY_
double SensitivityZ_
uint8_t set_filter_
uint8_t softreset_
double StaticPitch_
double StaticRoll_
double Temperature_
double TempSlope_

Static Public Attributes

static const uint8_t ADDRESS_ACC_X_LSB = 0x02
static const uint8_t ADDRESS_ACC_X_MSB = 0x03
static const uint8_t ADDRESS_ACC_Y_LSB = 0x04
static const uint8_t ADDRESS_ACC_Y_MSB = 0x05
static const uint8_t ADDRESS_ACC_Z_LSB = 0x06
static const uint8_t ADDRESS_ACC_Z_MSB = 0x07
static const uint8_t ADDRESS_ACCEL_RANGE = 0x0F
static const uint8_t ADDRESS_ACCLXYZ = 0x02
static const uint8_t ADDRESS_COMPASS_REPXY = 0x52
static const uint8_t ADDRESS_COMPASS_REPZ = 0x51
static const uint8_t ADDRESS_COMPASS_X_LSB = 0x42
static const uint8_t ADDRESS_COMPASS_X_MSB = 0x43
static const uint8_t ADDRESS_COMPASS_XYZ = 0x42
static const uint8_t ADDRESS_COMPASS_Y_LSB = 0x44
static const uint8_t ADDRESS_COMPASS_Y_MSB = 0x45
static const uint8_t ADDRESS_COMPASS_Z_LSB = 0x46
static const uint8_t ADDRESS_COMPASS_Z_MSB = 0x47
static const uint8_t ADDRESS_ENABLE_CALIBRATION = 0x36
static const uint8_t ADDRESS_OFFSET_TARGET = 0x37
static const uint8_t ADDRESS_RHALL = 0x48
static const uint8_t ADDRESS_RHALL_LSB = 0x48
static const uint8_t ADDRESS_RHALL_MSB = 0x49
static const uint8_t ADDRESS_TEMPERATURE = 0x08
static const uint8_t BANDWIDTH_REG = 0x10
static const uint8_t DATA_HIGH_BW = 7
static const uint8_t Data_Rate = 3
static const uint8_t FLAG_R = 0x80
static const uint8_t hp_x_en = 0
static const uint8_t hp_y_en = 1
static const uint8_t hp_z_en = 2
static const uint8_t LOWPOWER_EN = 0x06
static const uint8_t MODECHANGE_ACCEL = 0x11
static const uint8_t OFFSET_FILT_X = 0x38
static const uint8_t offset_target_x = 1
static const uint8_t offset_target_y = 3
static const uint8_t offset_target_z = 5
static const uint8_t OFFSET_UNFILT_Z = 0x3D
static const uint8_t OPMODE = 0x01
static const uint8_t POWER_CONTROL_BIT = 0x00
static const uint8_t RATE_COMPASS = 0x4C
static const uint8_t SET_FILTER = 0x13
static const uint8_t SET_OPMODE_FORCED = 0x01
static const uint8_t SET_OPMODE_SLEEP = 0x03
static const uint8_t SLEEP_DUR = 0x01
static const uint8_t SOFTRESET_ACCEL = 0x14
static const uint8_t SOFTRESET_ACCEL_CMD = 0xB6
static const uint8_t SOFTRESET_COMPASS_CMD = 0x82
static const uint8_t SOFTRESET_COMPASS_REG = 0x4B
static const uint8_t SUSPEND = 0x07

Detailed Description

a bmc050 driver that implements the device's main capabilities.

This class provides access to the acceleration temperature, and Magnetic field data. Routines have been written to change settings on both sensors, such as bandwidth and range. Routines have also been written to change modes.

Note:
Not all capabilities of the sensors have been implemented. For example, the user cannot directly implement the accelerometer's built-in slope-detection routines. However, these routines may be implemented using several of the existing methods.
This class implements its methods through a generic hardware interface.

Definition at line 83 of file bmc050.hpp.


Member Enumeration Documentation

Enumerator:
accel_suspend_ 
accel_normal_ 
accel_low_power_ 

Definition at line 143 of file bmc050.hpp.

Enumerator:
compass_suspend_ 
compass_sleep_ 
compass_normal_ 
compass_forced_ 

Definition at line 135 of file bmc050.hpp.


Constructor & Destructor Documentation

Parameters:
hwA pointer to the hardware interface that the device is connected to.

Definition at line 55 of file bmc050.cpp.

Definition at line 69 of file bmc050.cpp.


Member Function Documentation

changes the accelerometer's bandwidth by writing to the appropriate sensor register. The bandwidth is specified by the setAccelBandwidth(bandwidth) method in the inheritted parameters class.

Note:
the bandwidth will be changed to the default bandwidth if the user has not specified a bandwidth.
Returns:
a boolean indicating whether or not the sensor register has adjusted to reflect the requested bandwidth.

Definition at line 489 of file bmc050.cpp.

a method that changes the accelerometer's range by writing to the appropriate sensor register. The range is specified by the setAccelRange(range) in the inheritted parameter's class.

The range will be changed to the default range if the user has not specified a range.

Returns:
a boolean indicating success

Definition at line 380 of file bmc050.cpp.

change the output-data rate of the compass to the value specified in the parameters.

Note:
if no value has been specified in the parameters, the value will be changed to the default value.
this function is called when initialize() is called.
Returns:
a boolean indicating that the compass output-data rate has been changed on the compass.

Definition at line 193 of file bmc050.cpp.

change the number of samples that the compass averages for the X and Y-axis data before outputting a value.

Returns:
a boolean indicating success.

Definition at line 526 of file bmc050.cpp.

change the number of samples that the compass averages for the X and Y-axis data before outputting a value.

Returns:
a boolean indicating success.

Definition at line 553 of file bmc050.cpp.

Definition at line 1248 of file bmc050.cpp.

Definition at line 1029 of file bmc050.cpp.

Definition at line 1095 of file bmc050.cpp.

Definition at line 1210 of file bmc050.cpp.

Definition at line 1165 of file bmc050.cpp.

Definition at line 1062 of file bmc050.cpp.

Definition at line 1129 of file bmc050.cpp.

bool BMC050::filterData ( bool  request)

writes to the sensor's register in memory to choose whether or not to filter the accelerometer data.

Parameters:
requesta boolean indicating the user's choice of filtered (true) or unfiltered (false).
Note:
The data will be set as unfiltered if the user has not specified an alternate request.
Returns:
a boolean indicating whether or not the sensor register has adjusted to reflect the request.

Definition at line 447 of file bmc050.cpp.

retrieves all available raw accelerometer data and stores the calculated value to class variables: AccelX_, AccelY_, AccelZ_, Temperature_.

Returns:
a boolean indicating success.

Definition at line 671 of file bmc050.cpp.

double BMC050::getAccelX ( )

retrieves the raw accelerometer x-axis data and stores the calculated value to the class variable: AccelX_

If the application requires more than just one axis of data, use the getAccelData() instead, as it is much more efficient.

Returns:
a boolean indicating success.

Definition at line 706 of file bmc050.cpp.

double BMC050::getAccelY ( )

retrieves the raw accelerometer y-axis data and stores the calculated value to the class variable: AccelY_

If the application requires more than just one axis of data, use the getAccelData() instead, as it is much more efficient.

Returns:
a boolean indicating success.

Definition at line 739 of file bmc050.cpp.

double BMC050::getAccelZ ( )

retrieves the raw accelerometer z-axis data and stores the calculated value to the class variable: AccelZ_

Note:
if the application requires more than just one axis of data, use the getAccelData() instead, as it is much more efficient.
Returns:
a boolean indicating success.

Definition at line 772 of file bmc050.cpp.

take a full measurement from the compass sensor through a generic hardware interface.

Returns:
accel_sensitivity_

Definition at line 838 of file bmc050.cpp.

double BMC050::getCompassX ( )

Definition at line 874 of file bmc050.cpp.

double BMC050::getCompassY ( )

Definition at line 908 of file bmc050.cpp.

double BMC050::getCompassZ ( )

Definition at line 942 of file bmc050.cpp.

uint8_t BMC050::getDeviceAddress ( ) [virtual]

An invalid request. It is necessary, since this driver inherits from the sensor_driver class. See the getAccelAddress() and getCompassAddress() methods in the corresponding parameters class.

The user does not need to use this method.

Returns:
0 An invalid address, since each sensor has its own address.

Implements bosch_drivers_common::sensor_driver.

Definition at line 1018 of file bmc050.cpp.

uint16_t BMC050::getRHall ( )

Definition at line 975 of file bmc050.cpp.

retrieves the raw accelerometer temperature data and stores the calculated value to a class variable. If the application requires more than just one axis of data, use the getAccelData() instead, as it is much more efficient.

Returns:
a boolean indicating success.

Definition at line 805 of file bmc050.cpp.

a simple test method to get the orientation of the sensor assuming that the sensor is perfectly flat.

Returns:
a double indicating the orientation in degrees.

Definition at line 1008 of file bmc050.cpp.

initializes the sensor with all user-defined preferences indicated in the parameters.

Returns:
a boolean indicating success

Definition at line 77 of file bmc050.cpp.

Definition at line 1447 of file bmc050.cpp.

bool BMC050::readRegAccel ( uint8_t  reg,
uint8_t *  value 
)

Definition at line 1285 of file bmc050.cpp.

bool BMC050::readRegCompass ( uint8_t  reg,
uint8_t *  value 
)

Definition at line 1316 of file bmc050.cpp.

reads important accelerometer registers for a local copy. This method is needed for changing between modes, which determine values in multiple registers.

Returns:
a boolean indicating success.

Definition at line 279 of file bmc050.cpp.

reads important compass registers for a local copy. This method is needed for changing between modes, which determine values in multiple registers.

Returns:
a boolean indicating success.

Definition at line 324 of file bmc050.cpp.

calibrates the sensor assuming it is in a static, flat, level, face-up position (ON EARTH!).

A calibration should be necessary only if the accelerometer does not produce accurate measurements. The sensor should already come from the factory with well-defined pre-calibrated constants.

Note:
This calibration does NOT permanently override the sensor's pre-calibrated constants.

Definition at line 580 of file bmc050.cpp.

resets the accelerometer, putting it back into normal mode and clearing its image.

Returns:
a boolean indicating whether or not the hardware sent the reset command.

Definition at line 150 of file bmc050.cpp.

resets the compass, putting it back into "suspend" mode.

If this method is called after the initialize method, the user must put the compass into normal mode before data other settings can be changed. Use: the enterNormalModeCompass() method.

Returns:
a boolean indicating whether or not the hardware has sent the reset command.

Definition at line 169 of file bmc050.cpp.

perform two separate readings, one for each device.

Returns:
a boolean indicating success

Definition at line 657 of file bmc050.cpp.

bool BMC050::writeToAccelReg ( uint8_t  reg,
uint8_t  value 
)

Definition at line 1346 of file bmc050.cpp.

bool BMC050::writeToAccelRegAndVerify ( uint8_t  reg,
uint8_t  value,
uint8_t  expected 
)

Definition at line 1427 of file bmc050.cpp.

bool BMC050::writeToCompassReg ( uint8_t  reg,
uint8_t  value 
)

Definition at line 1376 of file bmc050.cpp.

bool BMC050::writeToCompassRegAndVerify ( uint8_t  reg,
uint8_t  value,
uint8_t  expected 
)

Definition at line 1406 of file bmc050.cpp.


Member Data Documentation

Definition at line 459 of file bmc050.hpp.

Definition at line 442 of file bmc050.hpp.

Definition at line 443 of file bmc050.hpp.

Definition at line 444 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_ACC_X_LSB = 0x02 [static]

Definition at line 398 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_ACC_X_MSB = 0x03 [static]

Definition at line 399 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_ACC_Y_LSB = 0x04 [static]

Definition at line 400 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_ACC_Y_MSB = 0x05 [static]

Definition at line 401 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_ACC_Z_LSB = 0x06 [static]

Definition at line 402 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_ACC_Z_MSB = 0x07 [static]

Definition at line 403 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_ACCEL_RANGE = 0x0F [static]

Definition at line 427 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_ACCLXYZ = 0x02 [static]

Definition at line 397 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_COMPASS_REPXY = 0x52 [static]

Definition at line 425 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_COMPASS_REPZ = 0x51 [static]

Definition at line 424 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_COMPASS_X_LSB = 0x42 [static]

Definition at line 413 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_COMPASS_X_MSB = 0x43 [static]

Definition at line 414 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_COMPASS_XYZ = 0x42 [static]

Definition at line 412 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_COMPASS_Y_LSB = 0x44 [static]

Definition at line 415 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_COMPASS_Y_MSB = 0x45 [static]

Definition at line 416 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_COMPASS_Z_LSB = 0x46 [static]

Definition at line 417 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_COMPASS_Z_MSB = 0x47 [static]

Definition at line 418 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_ENABLE_CALIBRATION = 0x36 [static]

Definition at line 407 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_OFFSET_TARGET = 0x37 [static]

Definition at line 408 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_RHALL = 0x48 [static]

Definition at line 420 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_RHALL_LSB = 0x48 [static]

Definition at line 421 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_RHALL_MSB = 0x49 [static]

Definition at line 422 of file bmc050.hpp.

const uint8_t BMC050::ADDRESS_TEMPERATURE = 0x08 [static]

Definition at line 405 of file bmc050.hpp.

const uint8_t BMC050::BANDWIDTH_REG = 0x10 [static]

Definition at line 433 of file bmc050.hpp.

Definition at line 458 of file bmc050.hpp.

Definition at line 449 of file bmc050.hpp.

Definition at line 450 of file bmc050.hpp.

Definition at line 451 of file bmc050.hpp.

const uint8_t BMC050::DATA_HIGH_BW = 7 [static]

Definition at line 121 of file bmc050.hpp.

const uint8_t BMC050::Data_Rate = 3 [static]

Definition at line 123 of file bmc050.hpp.

const uint8_t BMC050::FLAG_R = 0x80 [static]

Definition at line 118 of file bmc050.hpp.

const uint8_t BMC050::hp_x_en = 0 [static]

Definition at line 128 of file bmc050.hpp.

const uint8_t BMC050::hp_y_en = 1 [static]

Definition at line 127 of file bmc050.hpp.

const uint8_t BMC050::hp_z_en = 2 [static]

Definition at line 126 of file bmc050.hpp.

const uint8_t BMC050::LOWPOWER_EN = 0x06 [static]

Definition at line 106 of file bmc050.hpp.

const uint8_t BMC050::MODECHANGE_ACCEL = 0x11 [static]

Definition at line 431 of file bmc050.hpp.

Definition at line 99 of file bmc050.hpp.

const uint8_t BMC050::OFFSET_FILT_X = 0x38 [static]

Definition at line 409 of file bmc050.hpp.

const uint8_t BMC050::offset_target_x = 1 [static]

Definition at line 131 of file bmc050.hpp.

const uint8_t BMC050::offset_target_y = 3 [static]

Definition at line 132 of file bmc050.hpp.

const uint8_t BMC050::offset_target_z = 5 [static]

Definition at line 133 of file bmc050.hpp.

const uint8_t BMC050::OFFSET_UNFILT_Z = 0x3D [static]

Definition at line 410 of file bmc050.hpp.

const uint8_t BMC050::OPMODE = 0x01 [static]

Definition at line 112 of file bmc050.hpp.

const uint8_t BMC050::POWER_CONTROL_BIT = 0x00 [static]

Definition at line 113 of file bmc050.hpp.

Definition at line 460 of file bmc050.hpp.

const uint8_t BMC050::RATE_COMPASS = 0x4C [static]

Definition at line 436 of file bmc050.hpp.

Definition at line 101 of file bmc050.hpp.

uint8_t BMC050::RawData[13]

Definition at line 440 of file bmc050.hpp.

uint16_t BMC050::RHall_

Definition at line 452 of file bmc050.hpp.

Definition at line 454 of file bmc050.hpp.

Definition at line 455 of file bmc050.hpp.

const uint8_t BMC050::SET_FILTER = 0x13 [static]

Definition at line 434 of file bmc050.hpp.

Definition at line 102 of file bmc050.hpp.

const uint8_t BMC050::SET_OPMODE_FORCED = 0x01 [static]

Definition at line 111 of file bmc050.hpp.

const uint8_t BMC050::SET_OPMODE_SLEEP = 0x03 [static]

Definition at line 110 of file bmc050.hpp.

const uint8_t BMC050::SLEEP_DUR = 0x01 [static]

Definition at line 107 of file bmc050.hpp.

Definition at line 100 of file bmc050.hpp.

const uint8_t BMC050::SOFTRESET_ACCEL = 0x14 [static]

Definition at line 432 of file bmc050.hpp.

const uint8_t BMC050::SOFTRESET_ACCEL_CMD = 0xB6 [static]

Definition at line 117 of file bmc050.hpp.

const uint8_t BMC050::SOFTRESET_COMPASS_CMD = 0x82 [static]

Definition at line 116 of file bmc050.hpp.

const uint8_t BMC050::SOFTRESET_COMPASS_REG = 0x4B [static]

Definition at line 437 of file bmc050.hpp.

Definition at line 446 of file bmc050.hpp.

Definition at line 447 of file bmc050.hpp.

const uint8_t BMC050::SUSPEND = 0x07 [static]

Definition at line 105 of file bmc050.hpp.

Definition at line 445 of file bmc050.hpp.

Definition at line 456 of file bmc050.hpp.


The documentation for this class was generated from the following files:


bmc050_driver
Author(s): Joshua Vasquez, Philip Roan. Maintained by Philip Roan
autogenerated on Mon Oct 6 2014 10:09:40