How iPhone detects movement using sensors

Post on 15-Jul-2015

256 views 1 download

Tags:

Transcript of How iPhone detects movement using sensors

Motion Sensing

& Fitness

TrackingAccelerometer & M7/M8 Chip

● Motion sensing in the iPhone is

usually thought of as the

Accelerometer

Intro

● Motion sensing in the iPhone is

usually thought of as the

Accelerometer (and that’s

probably the most-used sensor)

Intro

● But there are actually 3 sensors in

the iPhone:

● Accelerometer

● Gyroscope

Intro

● But there are actually 3 sensors in

the iPhone:

● Accelerometer

● Gyroscope

● Compass

Intro

● There are 4 sensors in the iPhone

6:

● Accelerometer

● Gyroscope

● Compass

● Barometer

Intro

● Apps can access raw data from

any of the sensors individually

Intro

● But a lot more interesting stuff can

happen when the data from

multiple sensors is combined

Intro

● Sometimes the app must combine

or analyze the data itself

Intro

● Other times the phone will

combine or analyze the signals

automatically

Intro

● The M7 chip in the iPhone 5s is

one example of the phone doing

some processing before passing

info on to an app

Intro

● The iPhone 6 has the next-

generation chip, the M8, and it

does the same thing

Intro

● The M7/M8 chip is mainly geared

toward all-day activity tracking in

the background, particularly

fitness activity

Intro

1. Accelerometer

● The accelerometer measures

acceleration in any of 3 directions

Accelerometer Overview

● The accelerometer measures

acceleration in any of 3 directions

● Note that it measures

acceleration, not movement

Accelerometer Overview

● So an app can usually tell if the phone has moved in a direction by looking

at whether it accelerated in that direction

Measuring Movement

● But it can’t tell how far it moved in that direction just from the

accelerometer data

Measuring Movement

Accelerometer Details

● The accelerometer works like a little mass suspended inside the phone by

springs

Accelerometer Details

● When the phone accelerates, the springs temporarily get stretched

different amounts

Accelerometer Details

● When the phone accelerates, the springs temporarily get stretched

different amounts

● By measuring the different amount of stretching, the phone can tell how

fast the phone has accelerated

Accelerometer Details

● The accelerometer inside the

iPhone is not actually a tiny box

with a ball inside, but it’s not

actually all that different

Accelerometer Details

● The accelerometer inside the

iPhone is not actually a tiny box

with a ball inside, but it’s not

actually all that different

● It’s made of silicon instead of

metal, but it still has one part that

is stationary and another part that

is relatively free-floating, and the

phone measures when these two

parts move relative to each other

Accelerometer & Gravity

● When the phone is motionless but

not falling, the weight hangs down

toward to the bottom of the phone

Accelerometer & Gravity

● When the phone is motionless but

not falling, the weight hangs down

toward to the bottom of the phone

● This causes the accelerometer to

register the force holding the

phone up against gravity as

acceleration

Accelerometer & Gravity

● The accelerometer only shows 0

acceleration in all 3 directions is

when the phone is in free-fall

Accelerometer & Gravity

● The phone can use this

information to detect the force of

gravity on the phone and

determine which way is “up”

Accelerometer & Gravity

● The phone can use this

information to detect the force of

gravity on the phone and

determine which way is “up”

● This is then used for things like

switching around the screen

display orientation

Using Accelerometer Data

● When an app wants to start using

accelerometer data, it tells the

phone to start start sending

updates at given intervals

Using Accelerometer Data

● When an app wants to start using

accelerometer data, it tells the

phone to start start sending

updates at given intervals

● Then it processes each update as

it comes in or saves them and

analyzes them to suit its needs

Accelerometer Sensitivity

● The accelerometer is extremely

sensitive

Accelerometer Sensitivity

● The accelerometer is extremely

sensitive

● Any amount of movement at all

will be picked up

Accelerometer Sensitivity

● The accelerometer is extremely

sensitive

● Any amount of movement at all

will be picked up

● This results in a noisy signal that

usually needs to be processed in

order to be useful

Accelerometer Frequency

● The accelerometer’s response rate is also extremely fast

Accelerometer Frequency

● The accelerometer’s response rate is also extremely fast

● An app can get updates from the accelerator as often as 100 times a

second

Accelerometer Frequency

● The accelerometer’s response rate is also extremely fast

● An app can get updates from the accelerator as often as 100 times a

second

● The amount of data available, combined with the noisiness, makes working

with the raw accelerometer data fairly complex and not for the faint of heart

2. Gyroscope

● The Gyroscope detects spinning

or rotating motion of the phone

Gyroscope Overview

● The Gyroscope detects spinning

or rotating motion of the phone

● The Accelerometer won’t pick this

up except as noise

Gyroscope Overview

● If the phone rotates, the

accelerometer won’t pick up the

movement except as noise

● The Gyroscope detects this kind

of spinning or rotation

● The Gyroscope has 3 axes just

like the accelerometer

Gyroscope Overview

● Apps use the gyroscope just like

they use the accelerometer

Using Gyroscope Data

● Apps use the gyroscope just like

they use the accelerometer

● When an app wants to start using

gyroscope data, it tells the phone

to start start sending updates at

given intervals

Using Gyroscope Data

● Apps use the gyroscope just like

they use the accelerometer

● When an app wants to start using

gyroscope data, it tells the phone

to start start sending updates at

given intervals

● Then it processes each update as

it comes in or saves them an

analyzes them to suit its needs

Using Gyroscope Data

● Detecting turning motion is

especially important for video

games on mobile devices

Gyroscope for Video Games

4. Compass

Compass

● The compass in the iPhone works

just like a traditional compass

Compass

● The compass in the iPhone works

just like a traditional compass

● It just shows which direction the

phone is pointing

Compass

● The compass in the iPhone works

just like a traditional compass

● It just shows which direction the

phone is pointing

● Technical name is the

magnetometer

Compass

● The compass in the iPhone works

just like a traditional compass

● It just shows which direction the

phone is pointing

● Technical name is the

magnetometer (because it works

by detecting the presence of a

magnetic field in 3 dimensions)

Compass Limitations

● It’s the least accurate and reliable

of the 3 sensors

Compass Limitations

● It’s the least accurate and reliable

of the 3 sensors

● Susceptible to inference from

other electronics nearby

Compass Limitations

● It’s the least accurate and reliable

of the 3 sensors

● Susceptible to inference from

other electronics nearby

● That’s why the Apple Compass

app needs calibration

5. Barometer

Barometer Intro

● Only available in iPhone 6 and 6

Plus

Barometer Intro

● Only available in iPhone 6 and 6

Plus

● Calculates elevation by

measuring air pressure

Barometer Intro

● Only available in iPhone 6 and 6

Plus

● Calculates elevation by

measuring air pressure

● Lower air pressure indicates

higher elevation

Barometer Intro

● Only available in iPhone 6 and 6

Plus

● Calculates elevation by

measuring air pressure

● Lower air pressure indicates

higher elevation

● Accurate to within 3-5 meters

Reliability

● Reliable method of calculating

elevation

Reliability

● Reliable method of calculating

elevation (used by airplanes)

Reliability

● Reliable method of calculating

elevation (used by airplanes)

● But weather also causes changes

in air pressure

Reliability

● Reliable method of calculating

elevation (used by airplanes)

● But weather also causes changes

in air pressure

● Pressure at one spot on the

ground is not constant

Changes in Elevation

● Phone does NOT provide

absolute elevation (“above sea

level”)

Changes in Elevation

● Phone does NOT provide

absolute elevation (“above sea

level”)

● Phone only provides CHANGES

in elevation over time

● Apps use the barometer just like

they use the accelerometer and

other sensors

Using Barometer Data

● Apps use the barometer just like

they use the accelerometer and

other sensors

● When an app wants to start using

barometer data, it tells the phone

to start start sending updates

Using Barometer Data

● Apps use the barometer just like

they use the accelerometer and

other sensors

● When an app wants to start using

barometer data, it tells the phone

to start start sending updates

● The phone sends an update

whenever it detects a change in

elevation

Using Barometer Data

6. M7/M8 Chip

M7 Chip

● It’s not an additional sensor

M7 Chip

● It’s not an additional sensor

● It’s just the phone looking at

existing sensors and packaging

up that data in an easy-to-use

format

Separate Processor

● It’s an additional low-power

processor dedicated to gathering

data from the motion sensors

Separate Processor

● It’s an additional low-power

processor dedicated to gathering

data from the motion sensors

● Totally separate from the phone’s

main processor

M7 Data Provided

● M7 offers 2 things to apps

M7 Data Provided

● M7 offers 2 things to apps

● 1. Motion Activity

M7 Data Provided

● M7 offers 2 things to apps

● 1. Motion Activity -- is the iPhone

user

● Walking

● Running

● In a moving vehicle

● Stationary

M7 Data Provided

● M7 offers 2 things to apps

● 1. Motion Activity

● 2. Step Counter

M7 Data Provided

● M7 offers 2 things to apps

● 1. Motion Activity

● 2. Step Counter

● Count how many steps the iPhone users

takes

Background Running

● It’s separate and smaller so it can

run in the background when the

phone’s screen is off and no apps

are running

Background Running

● It’s separate and smaller so it can

run in the background when the

phone’s screen is off and no apps

are running

● It analyzes the data and stores

the stats for apps to access later

Background Running

● It’s separate and smaller so it can

run in the background when the

phone’s screen is off and no apps

are running

● It analyzes the data and stores

the stats for apps to access later

● Aimed at providing data for all-day

fitness trackers

For more information on iPhone development and general tech concepts

explained in plain English, check out Technerva

Please submit feedback to technerva@gmail.com

Fin.

Glossary