TR-mbed 1.0
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
MPU6050 Class Reference

#include <MPU6050.h>

Public Member Functions

 MPU6050 (uint8_t addr=0x68, AccelScale accelScale=AFS_2G, GyroScale gyroScale=GFS_250DPS, PinName sdaPin=I2C_SDA, PinName sclPin=I2C_SCL, PinName interruptInPin=NC)
 Creates an MPU6050 object.
 
virtual ~MPU6050 ()
 
void rise (Callback< void(void)> func)
 
template<typename T >
void rise (T *tptr, void(T::*mptr)(void))
 
void fall (Callback< void(void)> func)
 
template<typename T >
void fall (T *tptr, void(T::*mptr)(void))
 
bool init ()
 Initializes the MPU6050.
 
bool dataReady ()
 Indicates whether data is available after an interrupt.
 
float * accel ()
 Computes acceleration.
 
float * gyro ()
 Computes gyro.
 
float temp ()
 
void lowPowerAccelOnly ()
 Configures the motion detection control for low power accelerometer mode.
 
void reset ()
 Resets the MPU6050.
 
void calibrate ()
 Calibrates the MPU6050.
 
bool selfTestOK ()
 Performs accelerometer and gyroscope self test.
 
void setGain (float beta, float zeta)
 Adjusts filter gain after device is stabilized.
 
void madgwickFilter (float deltaT)
 Madgwick filter.
 
float yaw ()
 Calculates yaw in degree.
 
float pitch ()
 Calculates pitch in degree.
 
float roll ()
 Claculates roll in degree.
 

Public Attributes

float accelData [3]
 
float & accelX = accelData[0]
 
float & accelY = accelData[1]
 
float & accelZ = accelData[2]
 
float gyroData [3]
 
float & gyroX = gyroData[0]
 
float & gyroY = gyroData[1]
 
float & gyroZ = gyroData[2]
 

Constructor & Destructor Documentation

◆ MPU6050()

MPU6050::MPU6050 ( uint8_t  addr = 0x68,
AccelScale  accelScale = AFS_2G,
GyroScale  gyroScale = GFS_250DPS,
PinName  sdaPin = I2C_SDA,
PinName  sclPin = I2C_SCL,
PinName  interruptInPin = NC 
)

Creates an MPU6050 object.

Note
Default address is 0x68 Default acceleration range 2G Default gyroscope range is 250 dps (degrees per second) I2C_SDA and I2C_SCL pins are used for I2C connection by default Interrupt pin is not connected (NC) by default
Parameters

retval

◆ ~MPU6050()

virtual MPU6050::~MPU6050 ( )
inlinevirtual

Member Function Documentation

◆ accel()

float * MPU6050::accel ( )

Computes acceleration.

Note
Parameters

retval

◆ calibrate()

void MPU6050::calibrate ( )

Calibrates the MPU6050.

Note
Function which accumulates gyro and accelerometer data after device initialization. It calculates the average of the at-rest readings and then loads the resulting offsets into accelerometer and gyro bias registers.
Parameters

retval

◆ dataReady()

bool MPU6050::dataReady ( )

Indicates whether data is available after an interrupt.

Note
The DATA_RDY_INT bit clears to 0 after the INT_STATUS register has been read.
Parameters

retval

◆ fall() [1/2]

void MPU6050::fall ( Callback< void(void)>  func)
Note
Parameters

retval

◆ fall() [2/2]

template<typename T >
void MPU6050::fall ( T tptr,
void(T::*)(void)  mptr 
)
Note
Parameters

retval

◆ gyro()

float * MPU6050::gyro ( )

Computes gyro.

Note
Parameters

retval

◆ init()

bool MPU6050::init ( )

Initializes the MPU6050.

Note
Parameters

retval

◆ lowPowerAccelOnly()

void MPU6050::lowPowerAccelOnly ( )

Configures the motion detection control for low power accelerometer mode.

Note
The sensor has a high-pass filter necessary to invoke to allow the sensor motion detection algorithms work properly Motion detection occurs on free-fall (acceleration below a threshold for some time for all axes), motion (acceleration above a threshold for some time on at least one axis), and zero-motion toggle (acceleration on each axis less than a threshold for some time sets this flag, motion above the threshold turns it off). The high-pass filter takes gravity out consideration for these threshold evaluations; otherwise, the flags would be set all the time!
Parameters

retval

◆ madgwickFilter()

void MPU6050::madgwickFilter ( float  deltaT)

Madgwick filter.

Note
Implementation of Sebastian Madgwick's "...efficient orientation filter for... inertial/magnetic sensor arrays" (see http://www.x-io.co.uk/category/open-source/ for examples and more details) which fuses acceleration and rotation rate to produce a quaternion-based estimate of relative device orientation – which can be converted to yaw, pitch, and roll. Useful for stabilizing quadcopters, etc. The performance of the orientation filter is almost as good as conventional Kalman-based filtering algorithms but is much less computationally intensive—it can be performed on a 3.3 V Pro Mini operating at 8 MHz!
Parameters
deltaTIntegration time in seconds.
Return values

◆ pitch()

float MPU6050::pitch ( )

Calculates pitch in degree.

Note
Parameters

retval

◆ reset()

void MPU6050::reset ( )

Resets the MPU6050.

Note
Parameters

retval

◆ rise() [1/2]

void MPU6050::rise ( Callback< void(void)>  func)
Note
Parameters

retval

◆ rise() [2/2]

template<typename T >
void MPU6050::rise ( T tptr,
void(T::*)(void)  mptr 
)
Note
Parameters

retval

◆ roll()

float MPU6050::roll ( )

Claculates roll in degree.

Note
Parameters

retval

◆ selfTestOK()

bool MPU6050::selfTestOK ( )

Performs accelerometer and gyroscope self test.

Note
Checks calibration wrt factory settings. Should return percent deviation from factory trim values +/- 14 or less deviation is a pass
Parameters

retval true if passed false otherwise

◆ setGain()

void MPU6050::setGain ( float  beta,
float  zeta 
)

Adjusts filter gain after device is stabilized.

Note
Parameters

retval

◆ temp()

float MPU6050::temp ( )
Note
Parameters

retval

◆ yaw()

float MPU6050::yaw ( )

Calculates yaw in degree.

Note
Parameters

retval

Member Data Documentation

◆ accelData

float MPU6050::accelData[3]

◆ accelX

float& MPU6050::accelX = accelData[0]

◆ accelY

float& MPU6050::accelY = accelData[1]

◆ accelZ

float& MPU6050::accelZ = accelData[2]

◆ gyroData

float MPU6050::gyroData[3]

◆ gyroX

float& MPU6050::gyroX = gyroData[0]

◆ gyroY

float& MPU6050::gyroY = gyroData[1]

◆ gyroZ

float& MPU6050::gyroZ = gyroData[2]

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