-
Notifications
You must be signed in to change notification settings - Fork 124
4. Examples
This example is an MPU6050 offset-finder. The sketch has a PID offset generator routine that returns the best offset values according to the measurements, usefully to calibrate the module.
DMP stands for Digital Motion Processor, that executes complex MotionFusion algorithms to combine the measurements from the internal sensors, avoiding the need to perform filtering externally.
The library includes 6 examples to use with the MPU6050 module, these examples can return the MPU6050 data in different formats.
-
Quaternion : mathematical concept that extends the concept of complex numbers into higher dimensions. In simple terms, it is a four-dimensional number that consists of a scalar part and a vector part.
-
Euler : Euler angles are a set of three angles used to represent the orientation or rotation of an object in a three-dimensional space. The three Euler angles, typically denoted as (
$α, β, γ$ ) or ($φ, θ, ψ$ ), represent rotations around three different axes. The most common convention is the “roll-pitch-yaw” convention. -
Yaw/Pitch/Roll : Calculated from the quaternions coming from the FIFO.
-
Real Acceleration : Acceleration components with gravity removed. This acceleration reference frame is not compensated for orientation, so
$+X$ is always$+X$ according to the sensor, just without the effects of gravity. -
World Acceleration : Acceleration components with gravity removed and adjusted for the world frame of reference (yaw is relative to initial orientation, since no magnetometer is present in this case). Could be quite handy in some cases.
Additionally, each example includes different features which can help to calibrate and visualize the data. Here is a list of the features included in the examples:
Feature | DMP6 | DMP6 ESPWiFi | DMP6 Ethernet | DMP6.12 |
---|---|---|---|---|
Processing example | ✅ | ✅ | ❌ | ✅ |
Offset settings | ✅ | ✅ | ✅ | ✅ |
Calibration routine | ✅ | ❌ | ❌ | ❌ |
Communication | Serial | Wi-Fi | Ethernet | Serial |
Note
Offsets are useful to manually calibrate the module.
You can get your modules offsets by using the functions:
getXGyroOffset();
getYGyroOffset();
getZGyroOffset();
getXAccelOffset();
getYAccelOffset();
getZAccelOffset();
- Calibration routine helps to calibrate the module or to set a starting point. This routine is time-based, and can be modified.
Important
You can use the calibration method you prefer, just make sure to use only one or the data will be overwritted.
Note: Processing examples allows users to visualize in a 3D model the MPU6050 data.
If you would like to use the processing examples, follow the next steps to install the ToxicLibs library and use the examples:
Note
Processing is an independent IDE to Arduino that must be installed separately. You can download it from processing.org/download
- Open your DMP example. Verify it has processing support in the above table.
- Look for the Teapot output definition, you can find this definition between lines 115 and 130, depending on the DMP example you are using.
- Uncomment (delete
//
) the code line#define OUTPUT_TEAPOT
. And comment all other output definitions. - Upload the sketch.
- Open the processing sketch (Teapot).
- Download the library from the following repository, refer to the releases section: postspectacular/toxiclibs
- Extract into
[userdir]/Processing/libraries
on Windows,~/sketchbook/libraries/
on Linux. - Run the processing sketch.
Important
YOU MAY NEED TO CLOSE ANY SERIAL MONITOR SO PROCESSING CAN RUN THE SKETCH
- Done! You must see the 3D plane in a new processing window.
The example measure and return the raw acceleration and gyroscope data from the sensor.
Thank you for reading our Wiki!