JM9 XRCU Board 0.1.0
Libraries API Reference
Loading...
Searching...
No Matches
Mpu_6050_dmp Class Reference

MPU-6050 Accel and Gyro with DMP Driver for XRCU. More...

#include <Mpu_6050_dmp.h>

Inheritance diagram for Mpu_6050_dmp:
Heading_sensor Supported_sensor Supported_module

Public Member Functions

 Mpu_6050_dmp (const uint32_t init_port)
 Creates a new MPU-6050 object.
 
 ~Mpu_6050_dmp ()
 Destroys this MPU-6050 object.
 
bool begin (const uint8_t init_i2c_address=DEFAULT_I2C_ADDRESS)
 Configures the settings of the I2C bus and this MPU sensor.
 
bool begin (const Mpu_6050_cal_vals_t mpu_cal_values, const uint8_t init_i2c_address=DEFAULT_I2C_ADDRESS)
 Configures the settings of the I2C bus and this MPU sensor.
 
void end ()
 Releases the resources used by this object.
 
uint8_t who_am_i ()
 Gets the WHO_AM_I value of this MPU sensor.
 
bool is_gyro_present ()
 Checks for the presence of of MPU sensor.
 
Mpu_6050_cal_vals_t get_prev_caled_vals ()
 Gets the previously calibrated values of the MPU sensor.
 
Mpu_6050_cal_vals_t cal (const uint8_t sampling_amount=20)
 Calibrates this MPU sensor.
 
void save_caled_vals ()
 Saves the calibrated values into our local EEPROM in this XRCU.
 
void reset ()
 Resets the MPU (including yaw pitch roll orientations).
 
bool reset_heading ()
 Takes the current heading of sensor as zero.
 
double get_yaw (const bool ask_for_update=true)
 Gets the heading of gyroscope in degrees [ 0.00 : 359.99 ].
 
double get_pitch (const bool ask_for_update=true)
 Gets the pitch of gyroscope in degrees [ -90.00 : +90.00 ].
 
double get_roll (const bool ask_for_update=true)
 Gets the roll of gyroscope in degrees [ -180.00 : +180.00 ].
 
uint16_t get_heading ()
 Gets the heading in degrees.
 

Additional Inherited Members

- Protected Member Functions inherited from Heading_sensor
 Heading_sensor ()
 Creates a Heading_sensor object.
 
- Protected Member Functions inherited from Supported_sensor
 Supported_sensor ()
 Creates an object of a supported sensor.
 
- Protected Member Functions inherited from Supported_module
 Supported_module ()
 Creates an object of a supported module.
 

Detailed Description

MPU-6050 Accel and Gyro with DMP Driver for XRCU.

MPU-6050 is a 6-axis motion and orientation sensor, with 3 axis accelerometer and 3 axis gyroscope.

MPU-6050 has an on-board Digital Motion Processor (DMP) that can perform synchronized orientation calculations based on the continuous data from the accelerometer and gyroscope reading. This driver uses the DMP to calculate the complicated maths for us.

Author
YH Choi @ JM9

Constructor & Destructor Documentation

◆ Mpu_6050_dmp()

Mpu_6050_dmp::Mpu_6050_dmp ( const uint32_t init_port)

Creates a new MPU-6050 object.

Parameters
init_portthe I2C port hooked up to the MPU

Member Function Documentation

◆ begin() [1/2]

bool Mpu_6050_dmp::begin ( const Mpu_6050_cal_vals_t mpu_cal_values,
const uint8_t init_i2c_address = DEFAULT_I2C_ADDRESS )

Configures the settings of the I2C bus and this MPU sensor.

Parameters
mpu_cal_valuesthe calibration values to be applied to this MPU sensor
init_i2c_addressthe 7-bit I2C address of this MPU sensor
Returns
true if sensor is successfully activated, false if activation failed

◆ begin() [2/2]

bool Mpu_6050_dmp::begin ( const uint8_t init_i2c_address = DEFAULT_I2C_ADDRESS)

Configures the settings of the I2C bus and this MPU sensor.

Previously calibrated values of the MPU sensor (that are stored in this XRCU) is passed to this MPU sensor.

Parameters
init_i2c_addressthe 7-bit I2C address of this MPU sensor
Returns
true if sensor is successfully activated, false if activation failed

◆ cal()

Mpu_6050_cal_vals_t Mpu_6050_dmp::cal ( const uint8_t sampling_amount = 20)

Calibrates this MPU sensor.

Only call this function when the MPU sensor is placed on a stable surface with any physical interference.

Parameters
sampling_amountthe number of samples to be taken for calibration, increase this value to sample a few more times if you want higher accuracy
Returns
the calibrated values of the MPU sensor (* note that they are not stored in this XRCU, hence do not overwrite stored calibrated values)

◆ end()

void Mpu_6050_dmp::end ( )

Releases the resources used by this object.

Resets this MPU sensor and stop the angle calculations to reduce power consumption.

◆ get_heading()

uint16_t Mpu_6050_dmp::get_heading ( )
virtual

Gets the heading in degrees.

Returns
the heading in degrees [ 0 : 359 ]

Implements Heading_sensor.

◆ get_pitch()

double Mpu_6050_dmp::get_pitch ( const bool ask_for_update = true)

Gets the pitch of gyroscope in degrees [ -90.00 : +90.00 ].

Parameters
ask_for_update=trueThis function updates yaw, pitch and roll values all at a time. true to get the updated value; false to use previously updated value
Returns
the pitch of gyroscope in degrees

◆ get_prev_caled_vals()

Mpu_6050_cal_vals_t Mpu_6050_dmp::get_prev_caled_vals ( )

Gets the previously calibrated values of the MPU sensor.

These values are those that are stored in this XRCU.

Returns
the previously calibrated values of the MPU sensor, stored in this XRCU

◆ get_roll()

double Mpu_6050_dmp::get_roll ( const bool ask_for_update = true)

Gets the roll of gyroscope in degrees [ -180.00 : +180.00 ].

Parameters
ask_for_update=trueThis function updates yaw, pitch and roll values all at a time. true to get the updated value; false to use previously updated value
Returns
the roll of gyroscope in degrees

◆ get_yaw()

double Mpu_6050_dmp::get_yaw ( const bool ask_for_update = true)

Gets the heading of gyroscope in degrees [ 0.00 : 359.99 ].

Parameters
ask_for_updateThis function updates yaw, pitch and roll values together. true to get the updated value; false to use previously updated value
Returns
the heading of gyroscope in degrees

◆ is_gyro_present()

bool Mpu_6050_dmp::is_gyro_present ( )

Checks for the presence of of MPU sensor.

The presence is checked on the declared I2C bus with the given I2C address.

Returns
true if the MPU-6050 (or its series chips) is found on the I2C bus, false otherwise

◆ reset_heading()

bool Mpu_6050_dmp::reset_heading ( )
virtual

Takes the current heading of sensor as zero.

Returns
true if sensor heading is resetted, false otherwise.

Implements Heading_sensor.

◆ who_am_i()

uint8_t Mpu_6050_dmp::who_am_i ( )

Gets the WHO_AM_I value of this MPU sensor.

The obtained value is very useful in distinguishing MPU-6500 and MPU-9250.

Returns
the WHO_AM_I value of this MPU sensor (0x68 indicates MPU-6050; 0x70 indicates MPU-6500; 0x71 indicates MPU-9250)

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