Anda di halaman 1dari 4

THE MPU-6050 GYROSCOPE SENSOR TEST

BY USING ARDUINO PLATFORM AND


MATLAB
HUGO DAVID ENRÍQUEZ ESPINOSA
hdenríqueze@utn.edu.ec
ANGELO FERNANDO FLORES TARAMUEL
afflorest@utn.edu.ec
Ibarra, Ecuador

Abstract: The gyroscope has ability to get same silicon die, together with an onboard
accurate data of motions for space of three Digital Motion Processor™ (DMP™),
dimensions such as axes of x, y and z. Its which processes complex 6-axis
applications are covered very widely such as in MotionFusion algorithms. The device can
mobile phone, consumer electronics, etc. Due to access external magnetometers or other
the robust sense abilities of direction and
sensors through an auxiliary master I²C bus,
motion. In this paper, it is used MPU-6050 to
allowing the devices to gather a full set of
get data from motion with only use gyroscope
and these data are shown in a graphic from sensor data without intervention from the
Matlab Software. The experiment results show system processor. The devices are offered in
that it has good performance. a 4 mm x 4 mm x 0.9 mm QFN package. [2]
For precision tracking of both fast and slow
I. INTRODUCTION motions, the parts feature a user-
The development of MEMS (micro- programmable gyro full-scale range of ±250,
electromechanical system) gyroscope is by ±500, ±1000, and ±2000 °/sec (dps), and a
using the concept of pendulum and vibrating user-programmable accelerometer full-scale
element. The movement which is an action range of ±2g, ±4g, ±8g, and ±16g.
of direct input of controlling but it can also Additional features include an embedded
be an actions of the physical environment temperature sensor and an on-chip oscillator
moving and position. with ±1% variation over the operating
temperature range. [2]
Gyroscopes have ability to sense and
measure the angular rate of an object under
complex and severe operating conditions.
[1]

MPU-6050 Six-Axis (Gyro +


Accelerometer) MEMS Devices.

The MPU-6050 parts are the world’s first


MotionTracking devices designed for the
low power, low cost, and high-performance
requirements of smartphones, tablets and Figure 2. Blocks diagram
wearable sensors.
The MPU-6050 devices combine a 3-axis
gyroscope and a 3-axis accelerometer on the
GYROSCOPE designers can develop their products. It is
very easy to learn and connect to other
 Gyro system with 3 axes, made with devices and sensors. Now it has also become
technology MEMS. a popular test platform to learn, design and
 It can be adjusted to values of ±250, ±500, ± develop any applications.
1000, and ±2000 ° / s.
In this paper, the MPU6050 based Arduino
 Integrates 3 digital analog converters of 16
Test Platform is used to get Yaw Axis data
bit, one for each axis.
then show them in a window with Matlab
 It has a programmable low pass filter software by means of Arduino based on
 Consumed 3.6mA. Atmega 328 microprocessor. [5]
 It has a programmable self-test. [3]
ATMEGA 328 MICROPROCESSOR
ACCELEROMETER The Atmel AVR core combines a rich
instruction set with 32 general purpose
 Accelerometer system in 3 axes, made with working registers. All the 32 registers are
technology MEMS. directly connected to the Arithmetic Logic
 Adjustable to sensitivity values of ± 2g, ± 4g, Unit (ALU), allowing two independent
± 8g and ± 16g. registers to be accessed in a single
 Integrates 3 analog 16-bit digital converters, instruction executed in one clock cycle. The
one per each axis. resulting architecture is more code efficient
 500μA consumption. while achieving throughputs up to ten times
 It has programmable interrupts. faster than conventional CISC
 Detection of free fall, vibration and microcontrollers. [6]
movement 0.
II. METHODOLOGY
 It has a programmable self-test. [3]
CONTROL SYSTEM
COMUNICATION I2C
PID (proportional integral derivative)
control: are the most widely used. He joined
I2C is a bus for transmission of data in series
the proportional control for 2 more terms.
created in 1992 by Philips. The speed of
communication is 100 kbit/s though it can  The integral has a memory effect, by
increase up to 3.4 Mbit/s. It is a widespread integrating the error, longer is you hold this
system in communication between without becoming void, the greater the
microcontrollers and peripherals. signal for action. It affects the proportional
term and does not respond to abrupt changes
Use 2 lines of transmission, SDA (Serial of the error signal.
Data Line) that circulate the data, and SCL
𝑡
(Serial Clock Line) in which the clock signal 𝐼𝑠𝑎𝑙 = 𝐾𝑖 ∫0 𝑒(𝜏)𝑑𝜏 (1)
is sent. Each device connected to the bus has
 The derivative can be interpreted as an
an assigned address.
anticipatory effect, improves the stability of
An advantage of this method of connection
the system at the expense of introducing
to the sensor is the existence for Arduino
some delay. Does not affect static errors or
library Wire, which includes functions for
that they change very slowly and is very
this type of communication. [4]
sensitive to noise.
𝑑𝑒
The Arduino introduced in 2005 is a free 𝐷𝑠𝑎𝑙 = 𝐾𝑑 𝑑𝑡 (2)
used software and hardware tool such that all
OBTAINING AND RESULT OF DATA obtained by the accelerometer and another
For the initialization of the program is must for them of the gyro.
include several libraries as are:
 Accelerometer: this sensor we
 #include "I2Cdev.h" obtain information affects how
gravity shafts, formed angle is
That serves for the type of communication
calculated from a trigonometric
between the atmega328 and the sensor
relationship between the values
MPU6050
obtained.
 #include "MPU6050.h"  Gyro: it provides measures of
angular velocity, angle obtaining
That serves for the recognition, initialization will require a function that
and operation of the sensor MPU6050 integrates these values.
 #include "Wire.h" [7] Used only the gyroscope, so the integral
Establishes the communication using I2C must be used.
with devices slaves. After making the As the sensor just gives us velocity then the
respective connection, the first program integration of the angular velocity, gets the
which consists of establishing angular displacement or degrees that has
communication with the sensor, activating, moved. [7]
and reading the registers in which the
obtained data is stored. ∫ 𝛼 𝑑𝑡 = 𝜔 → ∫ 𝜔 𝑑𝑡 = 𝜃 (3)
𝛼 = 𝐴𝑛𝑔𝑢𝑙𝑎𝑟 𝑎𝑐𝑐𝑒𝑙𝑒𝑟𝑎𝑡𝑖𝑜𝑛
𝜔 = 𝐴𝑛𝑔𝑢𝑙𝑎𝑟 𝑣𝑒𝑙𝑜𝑐𝑖𝑡𝑦
𝜃 = 𝑑𝑒𝑔𝑟𝑒𝑒𝑠

1. This comand read the angular


velocity:
sensor.getRotation(&girox,
&giroy, &giroz);
Figure 2. Data acquisition with static sensor. 2. Calculate the angles of rotation with
the integral:
dt = millis()-tiempo_previo;
tiempo_previo=millis();
ang_y = (giroy/131)*dt/1000.0 +
ang_y_previo;
ang_y_previo=ang_y;

3. The similar process to angle in z

Figure 3. Data acquisition with moving


sensor.

OBTAINING THE ANGLE

For the obtaining of the angle is developed 2


new functions, one to transform the data
Figure 4. Angles obtained with gyroscopes
MATLAB GRAPHIC [7] L. F. B. Bozal, "Diseño y fabricación de
una tarjeta PCB (“Shield”) para el control
MATLAB is a programming environment de un robot autobalanceado basado en
with infinite possibilities, which helps us Arduino," Pamplona, 2014.
solve our technical calculation problems
even faster than other programming
languages. MATLAB is extremely
powerful, so it can be built with it, here we
will perform the script for serial IV. ATTACHMENTS
communication with Arduino in real time
 FLOWCHART
Initialize the communication through the
following statements.

 fopen(puerto_serial);

Create a while loop that performs the


sampling and represents it in a graph.

At the end, we have to close the


communication with Arduino. We use the
command:

 fclose(puerto_serial);

III. REFERENCES

[1] Y.-J. Mon, "The Gyroscope Sensor Test by


Using Arduino," 2015.

[2] I. Inc, "Invensense," [Online]. Available:


https://www.invensense.com/products/moti
on-tracking/6-axis/mpu-6050/.

[3] InverSense.Inc, "InverSense.com," 08


Agosto 2013. [Online]. Available:
https://www.invensense.com/wp-
content/uploads/2015/02/MPU-6000-
Datasheet1.pdf.

[4] Prometec, "PROMETEC.COM," [Online].


Available: http://www.prometec.net/bus-
 CIRCUIT
i2c/.

[5] D. Titello, "Arduino Guide using MPU-


6050," Suwon, South Korea, 2015.

[6] ATMEL, "ATMEL 8-Bit AVR


Microcontrollers - ATmega328," [Online].
Available:
http://www.atmel.com/Images/Atmel-
42735-8-bit-AVR-Microcontroller-
ATmega328-328P_Summary.pdf.