The document discusses microelectromechanical systems (MEMS) and describes the MPU6050 accelerometer. Some key points:
1) MEMS have both electrical and mechanical components integrated on a micrometer scale and are used in devices like airbag sensors, printers, and cell phones.
2) The MPU6050 is a 3-axis MEMS accelerometer that uses capacitive sensing to measure linear acceleration along each axis in units of g-force.
3) An Arduino can interface with the MPU6050 over I2C to read acceleration data from its registers and calculate roll, pitch, and yaw angles from the measurements.
2. Micro: Very small in size. Measured in micrometer(μm)
1 μm = 10-6 m
Electro: MEMS have electrical components
Mechanical: MEMS have moving parts
Systems: Refers to integration of components.
We find MEMS in
Automobiles (Air bag sensors)
Computer printers (Ink jet print heads)
Cell phones (RF devices)
Optical devices (Micromirrors)
MEMS
They have also found application in the healthcare domain in devices
such as blood pressure monitors, pacemakers, ventilators, and respirators.
Air bag crash sensors
Active suspension systems
Antilock brake systems
Ride control systems
V K Jadon, Prof., Mechanical Engineering, Chitkara University 2
3. Accelerometer
𝑥, 𝑎
𝑘
𝑚
𝑥, 𝑎
𝑘
𝑚
𝑥, 𝑎
−𝑘𝑥 = 𝑚𝑎
𝑘
𝑚 𝑚𝑎𝑠𝑠 𝑖𝑠 𝑑𝑖𝑠𝑝𝑙𝑎𝑐𝑒𝑑
𝑎 = −
𝑘
𝑚
𝑥
𝑎 = 𝑓(𝑥)
External Force in the direction of
displacement =mass×acceleration
𝑚
𝑘𝑥 𝑎
𝐶 = 𝑓(𝐴/𝑥)
𝐶 = 𝑓(𝐴/𝑎)
Accelerometer measures linear acceleration
Acceleration is opposite to
the displacement
𝐶 = 𝑐𝑎𝑝𝑎𝑐𝑖𝑡𝑎𝑛𝑐𝑒
𝐴 = surface area of
capacitor plates
V K Jadon, Prof., Mechanical Engineering, Chitkara University 3
4. Displacement of the frame changes the differential capacitance
Capacitive accelerometers offer high sensitivities and
are utilized for low-amplitude, low-frequency devices.
Accelerometer
𝒙
𝒛
𝒚
Internal moveable
assembly
Proof mass
Spring
External Fixed assembly
MPU6050 measures linear acceleration in terms of g force
Usefulness of accelerometer in
IMU will be discussed later
V K Jadon, Prof., Mechanical Engineering, Chitkara University 4
5. VCC
GND
SCL
SDA
XDA
XCL
ADO
INT
X
Y
I2C ProtocolGyro Accelerometer
MPU6050 Pinout
Clock pulse for I2C Communication
Data through I2C communication
Data to external sensors
Clock pulse to external sensors
I2C Slave Address
Interrupt digital output
The SCL line is the clock signal which synchronize the
data transfer between the devices on the I2C bus.
Clock signal is generated by the master device.
6. The full scale range of the digital output can be adjusted to ±2g,
±4g, ±8g, or ±16g.
Three-Axis MEMS Accelerometer with 16-bit ADCs and Signal Conditioning
MPU6050: MEMS Accelerometer
The MPU-60X0’s 3-Axis accelerometer uses separate proof masses for
each axis.
Acceleration along an axis induces displacement on the corresponding
proof mass, and capacitive sensors detect the displacement differentially.
When the device is placed on a flat surface, it will measure
0g on the X- and Y-axes and +1g on the Z-axis (upward).
Each sensor has a dedicated ADC for providing digital outputs.
V K Jadon, Prof., Mechanical Engineering, Chitkara University 6
10. I2C Protocol
V K Jadon, Prof., Mechanical Engineering, Chitkara University 10
• Begins with a start bit
• 7 bit Address is transmitted
• 1 control bit to indicate Master to Read from or
write to slave
• If communicated slave send ack bit to Master
• Master to send 8 bit Internal Register Address
• Slave send back ack bit
• Master transmits data in 8 bits chunk
• Write request – Slave sends ack bit to Master
• Read request – Master sends ack bit to Slave
I2C addresses are generally 7 bits, yielding an
address between 0 and 127.
The addresses from 0 to 7 are not used because are
reserved. So, the first address that can be used is 8
S B6 B5 B4 B3 B2 B1 B0 R/W Ack
B7 B6 B5 B4 B3 B2 B1 B0 Ack
B7 B6 B5 B4 B3 B2 B1 B0 Ack S
7 bit Device Address sequence
8 bit internal Register Address sequence
8 bit data sequence
• Ends with a stop bit
11. V K Jadon, Prof., Mechanical Engineering, Chitkara University 11
<Wire.h> Library
Wire.begin(address) function initiates Wire library
Wire.beginTransmission(address) begins transmission to
the particular sensor
Wire.beginTransmission(0b1101000)
Wire.endTransmission(address) Transmits data in
buffer and return a status byte, 0 for success.
Wire.endTransmission(0b1101000)
write() buffers data for sending
Wire.write(value)
Wire.write(string)
Wire.write(data, length)
value: a value to send as a single byte
string: a string to send as a series of bytes
data: an array of data to send as bytes
length: the number of bytes to transmit
write() will return the number of bytes written, though
reading that number is optional
address: the 7-bit slave address (optional);
if not specified, join the bus as a master.
Start condition to the slave device with the given address.
It asks for data from the internal registers of the
slave device
S B6 B5 B4 B3 B2 B1 B0 R/W A B7 B6 B5 B4 B3 B2 B1 B0 A B7 B6 B5 B4 B3 B2 B1 B0 A S
12. V K Jadon, Prof., Mechanical Engineering, Chitkara University 12
<Wire.h> Library
requestFrom() Used by the master to request bytes
from a slave device..
The default value is true.
If true, requestFrom() sends a stop message after the
request, releasing the I2C bus.
If false, requestFrom() sends a restart message after
the request.
Wire.requestFrom(address, quantity)
Wire.requestFrom(address, quantity, stop)
If false, the bus will not be released, which prevents
another master device from requesting between
messages. This allows one master device to send
multiple requests while in control.
The Wire.available() function will return the number
of bytes available for retrieval and if that number
match with our requested bytes
Wire.read() function we will read the bytes from
the two registers of the X axis.
I2C Scanner
15. V K Jadon, Prof., Mechanical Engineering, Chitkara University 15
MPU6050 Setup Read Accelerometer data using Arduino
Start I2C Communication
― Use Wire.begin() to initiate wire.h
― Wire.beginTransmission(SDA)
Slave Device Address (SDA)=1101000 AD0=Low
Slave Device Address (SDA)=1101001 AD0=High
Reference – Product Specifications (Revision 3.4)
Section 9.2 pp33
― Wire.write(0x6B)
Internal Register Address Sequence to
access Power management register (0x6B)
― Wire.write(0b00000000)
Data Transfer Bit Sequence to awake MPU
― Wire.endTransmission(1101000)
16. FS Range AFS_SEL Register Bit LSB Sensitivity ADC Bits
±2g 0 0b00000000 16384 LSB/g 15 bit
±4g 1 0b00001000 8192 LSB/g 14 bits
±8g 2 0b00010000 4096 LSB/g 13 bits
±16g 3 0b00011000 2048 LSB/g 12 bits
𝑥 ≈ 0
𝑦 ≈ 0
𝑧 ≈ 1𝑔
𝑦 ≈ 0
𝑧 ≈ 0
𝑥 ≈ 1𝑔
𝑧 ≈ 0
𝑥 ≈ 0
𝑦 ≈ 1𝑔
V K Jadon, Prof., Mechanical Engineering, Chitkara University 16
Accelerometer Setup
The MPU-60X0 features three 16-bit ADCs for digitizing the accelerometer outputs.
For precision tracking of both fast and slow motions, the parts feature a user-
programmable accelerometer full-scale range of ±2g, ±4g, ±8g, and ±16g.
Reference – Product Specifications (Revision 3.4)
Section 6.2 pp13
― Wire.beginTransmission(0b1101000)
― Wire.write(0b00000000)
― Wire.endTransmission(0b1101000)
― Wire.write(0x1C)Reference – Register Map and Description (Revision 4.2)
Section 4.5 pp15
Reference – Product Specifications (Revision 3.4)
Section 3.1 pp7
17. V K Jadon, Prof., Mechanical Engineering, Chitkara University 17
Read Accelerometer Data
Reference – Register Map (Revision 4.2)
Section 3 pp7
Wire.beginTransmission(0b1101000)
3B and 3C stores Acceleration data along x-axis
3D and 3E stores Acceleration data along y-axis
3F and 40 stores Acceleration data along z-axis
We should give starting Internal Register Address to access
all Read only registers after that.
To transmit all acceleration data, we should write to 0x3B
register.
― Wire.write(0x3B)
Slave device transmit data in 8 bits(1 byte)
Master store integers in 16 bits.
― Wire.endTransmission(0b1101000)
18. V K Jadon, Prof., Mechanical Engineering, Chitkara University 18
Read Accelerometer Data
For getting hold of the data available in buffer, master has to request using Wire.requestFrom(address, quantity)
Wire.requestFrom(0b1101000, 6)Check availability of the data requested by the master Wire.available()
It returns the number of received bytes from receive-buffer.
Reads a byte that was transmitted from a slave device to a master after a call to requestFrom()
using Wire.read() function.
The each acceleration data is stored in two register (2 bytes)
The data read is to be stored in one variable of int datatype.
Every repeated Wire.read() gives the next byte available.
accel_rawX = Wire.read()<<8|Wire.read();
00001010
00001111
00001010-00000000
00001010-00001111
00001010
19. V K Jadon, Prof., Mechanical Engineering, Chitkara University 19
Arduino Pseudo Code
Set-Up MPU6050
Configure Accelerometer
Read Accelerometer Data
Every task starts with beginning communication with slave device
and ends with terminating communication with slave device
begin communication – Slave device address sequence
access power management register – internal register address sequence
Update power management register to disable SLEEP mode – data
transfer sequence
terminate communication – stop bit
(one time execution)
(one time execution)
begin communication – Slave device address sequence
access accelerometer configure register – internal register
address sequence
update accelerometer register to set full scale range – data
transfer sequence
terminate communication – stop bit
(data needed continuously)
Disable SLEEP mode
Set Full Scale range
Read accelerometer data
20. V K Jadon, Prof., Mechanical Engineering, Chitkara University 20
Arduino Pseudo Code
Set-Up MPU6050 Configure Accelerometer
Read Accelerometer Data
Every task starts with beginning communication with slave device
and ends with terminating communication with slave device
(data needed continuously)
Disable SLEEP mode Set Full Scale range
Access Register Read Data
begin communication
stop communication
access accelerometer first data
register
Read accelerometer data
begin communication
stop communication
Request data
Check availability Read 8 bits and
store in 16 bits data
26. 𝝎
𝑿𝒁
𝒀
MEMS gyroscopes measure the angular
rate of rotation of one or more axes
V K Jadon, Prof., Mechanical Engineering, Chitkara University
Gyroscope
𝒗 𝑨 = 𝝎 × 𝒓 𝑨
𝝎
𝒙
𝒛
𝒚
Path of the ball as seen by an
observer moving with table
Path of the ball as
seen from fixed frame
𝒗 𝑪
𝒙
𝒛
𝒚
Position of ball
after some time ∆𝑡
𝒗 𝑩
𝑩
𝑩
Point B after time∆𝑡
𝒗 𝑨
𝒗 𝒃𝒂𝒍𝒍
27. Ball has two velocities
V K Jadon, Prof., Mechanical Engineering, Chitkara University
Gyroscope
𝒗 𝑨 = 𝝎 × 𝒓 𝑨
𝒗 𝒃𝒂𝒍𝒍
𝝎
𝒙
𝒛
𝒚
𝝎 𝒗 𝒃𝒂𝒍𝒍
MEMS gyroscopes use vibrating
mechanical elements (proof-mass) to
sense rotation caused by Coriolis
acceleration.
28. The ADC sample rate is programmable from 8,000 samples per second,
down to 3.9 samples per second, and user-selectable low-pass filters
enable a wide range of cut-off frequencies.
Three-Axis MEMS Gyroscope with 16-bit ADCs and Signal Conditioning
Gyroscope Setup-MPU6050
V K Jadon, Prof., Mechanical Engineering, Chitkara University 28
The MPU-60X0 consists of three independent vibratory MEMS rate
gyroscopes, which detect rotation about the X-, Y-, and Z- Axes.
When the gyros are rotated about any of the sense axes, the Coriolis
Effect causes a vibration that is detected by a capacitive pickoff.
The signal is amplified, demodulated, and filtered to produce a voltage
that is proportional to the angular rate.
This voltage is digitized using individual on-chip 16-bit Analog-to-
Digital Converters (ADCs) to sample each axis.
The full-scale range of the gyro sensors may be digitally programmed
to ±250, ±500, ±1000, or ±2000 degrees per second (dps).
29. 𝑟𝑝𝑚 =
𝑟𝑎𝑛𝑔𝑒(°/𝑠)
360
× 60
Range Condition 𝒅𝒆𝒕𝒆𝒄𝒕𝒂𝒃𝒍𝒆 𝒓𝒑𝒎 Register Bit
±250 0 41.67 0x00000000
±500 1 83.33 0x00001000
±1000 2 166.7 0x00010000
±2000 3 333.3 0x00011000
Gyroscope Setup
V K Jadon, Prof., Mechanical Engineering, Chitkara University 29
30. V K Jadon, Prof., Mechanical Engineering, Chitkara University
For a FS_SEL =1
LSB Sensitivity = 65.5
Register Bit = 0x00001000
𝜔(𝑦𝑎𝑤 𝑟𝑜𝑡𝑎𝑡𝑖𝑜𝑛) = 1 0
𝑠 𝑔𝑦𝑟𝑜 𝑧 = 65.5
𝜔(𝑦𝑎𝑤 𝑟𝑜𝑡𝑎𝑡𝑖𝑜𝑛) = 5 0
𝑠 𝑔𝑦𝑟𝑜 𝑧 = 327.5
At any
particular
time
To convert Gyro values into instantaneous angular rate
𝑖𝑛𝑠𝑡𝑎𝑛𝑡𝑎𝑛𝑒𝑜𝑢𝑠 𝑎𝑛𝑔𝑢𝑙𝑎𝑟 𝑟𝑎𝑡𝑒 =
𝑔𝑦𝑟𝑜 𝑥,𝑦,𝑧
𝐿𝑆𝐵 𝑆𝑒𝑛𝑠𝑖𝑡𝑖𝑣𝑖𝑡𝑦
=
327.5
65.5
= 5 0
𝑠
To measure total angle travelled
add all instantaneous angles obtained for
small time duration, ∆𝑡
𝜔 =
𝑑𝜃
𝑑𝑡
𝑑𝜃 = 𝜔𝑑𝑡 𝜃 =
𝑡1
𝑡2
𝜔𝑑𝑡
Gyroscope Data
31. V K Jadon, Prof., Mechanical Engineering, Chitkara University
𝜃 =
𝑡1
𝑡2
𝜔𝑑𝑡
𝜔
𝑡
𝜔
𝑡
∆𝑒
Drift error
Drift error is gradual divergence between the true
orientation and estimated orientation by gyro due to error
in measurement.
𝑒
𝑡
Use other sensors to bring down the drift error to
zero. Take angles with reference to world frame.
Gradually apply corrections.
• These correction are to be fast enough to fully
compensate the drift error.
• Slow enough to avoid jerky compensations
Tilt Error or (roll and pitch angle error)
Yaw Error
Linear accelerometer
Magnetometer
The noise part is
also integrated
32. V K Jadon, Prof., Mechanical Engineering, Chitkara University
gyro_pitch_angle=gyro_pitch_angle+ gyro_roll_angle * sin(gyro_z)
gyro_roll_angle=gyro_roll_angle- gyro_pitch_angle * sin(gyro_z)
Transfer of Yaw angles
33. V K Jadon, Prof., Mechanical Engineering, Chitkara University
The gyroscope drift is mainly due to the integration of two components: a slow changing, near-dc variable
called bias instability and a higher frequency noise variable called angular random walk (ARW).
The yaw axis is most sensitive to this drift. A good portion of the pitch (attitude) and roll axis gyroscope drift
can be removed within an IMU through the use of accelerometer feedback to monitor position relative to
gravity.
Ideally, two references are needed to correct for gyroscope drift on all axes.
An IMU with nine degrees of freedom typically provides additional magnetometer sensors - about 3 axes.
A magnetometer senses field strength relative to the Earth’s magnetic North. These sensors can be used
together with accelerometer data, as another external reference, to mitigate the impact of gyroscope drift
error on the yaw axis.
34. V K Jadon, Prof., Mechanical Engineering, Chitkara University
However, design of proper spatial magnetometers can be a less reliable vector than an
accelerometer, as there are many things that create magnetic fields within the same order of
magnitude as that of the Earth.
Another one of the more effective methods for cancelling long-term drift is to implement a zero
angular velocity update to the gyroscope. Any time the device is known to be completely stationary,
the gyroscope offset can be nulled to zero for that respective axis.
This opportunity can vary wildly depending on the application. But any instance that the system is at a
recurring resting state can be used for nulling, such as an idling car, a stationary autonomous robot,
or the time between human foot steps.
Of course, using a state-of-the-art IMU that has minimal bias instability within the design at the onset
may offer the most immediate impact on gyroscope drift.
The constant bias error of a gyroscope can be measured by taking the average of the output over a
long period of time while the device is not rotating.
35. Thanks
V K Jadon, Prof., Mechanical Engineering, Chitkara University 35