Lecture 5
Lecture 5
MOBILE COMPUTING
Lecture 5 Sensors and actuators
2
Mobile Sensing
• Smartphones (and tablets, etc.) not only serve as a key
computing and communication device, but also comes
with a rich set of embedded sensors
• Which enables new applications across a wide variety of
domains, such as transportation, social networks,
environmental monitoring, healthcare, etc.
• Giving rise to new research areas such as mobile
sensing, crowdsensing, mobile data mining, etc.
3
Basic Terms
• Transducer: a device which converts one form of energy
to another
Actuator
• The following are the main category of actuators:
• Pneumatic: These actuators convert energy from
compressed air (at high pressure) to either linear or
rotary motion. Examples include valve controls of
liquid or gas pipes.
• Electric: These actuators convert electrical energy
to mechanical energy. An example would be an
electric water pump pumping water out of well.
• Mechanical: These actuators convert mechanical
energy into some form of motion. An example
would be a simple pulley used to pull weights.
6
Sensor/Actuator System
8
Sensor Types
9
• Modulating
• Also known as Active Sensors
• They need auxiliary power to perform functionality
• Self-Generating
• Also known as Passive Sensors
• They derive the power from the input
10
• Null
• Applies the counter force
• To balance the deflection from
the null point (balance condition)
• Can be more accurate but slow
11
Sensor List
Sensor Function Type Software-based or
Hardware-based
Accelerometer Motion Sensor Hardware-based
Gyroscope Motion Sensor Hardware-based
Gravity Motion Sensor Software-based
Rotation Vector Motion Sensor Software-based
Magnetic Field Position Sensor Hardware-based
Proximity Position Sensor Hardware-based
GPS Position Sensor Hardware-based
Orientation Position Sensor Software-based
Light Environmental Sensor Hardware-based
Thermometer Environmental Sensor Hardware-based
Barometer Environmental Sensor Hardware-based
Humidity Environmental Sensor Hardware-based
15
Smartphone Sensing
• Light
• Proximity
• Cameras (multiple)
• Microphones (multiple)
• Touch
• Position
• GPS, Wi-Fi, cell, NFC, Bluetooth
• Accelerometer
• Gyroscope
• Magnetometer
• Pressure
• Temperature
• Humidity
• Fingerprint sensor
16
GPS in Smartphones
• Location service using GPS in Android consists of five
architectural components
18
GPS in Smartphones
• GPS chip: Radio frequency receiver that directly
communicates with GPS satellites
19
GPS in Smartphones
• GPS driver communicates with GPS chip, provides low-
level APIs to high-level software
20
GPS in Smartphones
• GPS engine: The heart of the system; uses configuration parameters
to configure GPS; instructs GPS driver to detect satellites; gets timing
data from NTP servers (fast) or Internet (slow)
21
GPS in Smartphones
• Android Location Service: consists of Android framework classes like
Location Manager that provides data/services to applications
• Also integrations location data from multiple sources (Wi-Fi, cellular,
etc.)
22
GPS in Smartphones
• Applications: Location-based applications and services (Google
Maps, navigation, location tagging, etc.)
23
Sensor: Accelerometer
• Measure proper acceleration (acceleration it experiences
relative to freefall)
• Units: g
26
Sensor: Accelerometer
• Acceleration is measured on 3 axes
• Note that the force of gravity is always included in
the measured acceleration
• When the device is sitting on the table stationary, the
accelerometer reads a magnitude of 1g
• When the device is in free fall, the accelerometer reads
a magnitude of 0g
• To measure the real acceleration of the device,
the contribution of the force of gravity must be
removed from the reading, for example, by
calibration
27
Sensor: Accelerometer
• When the device is lying flat
• gives +1g (gravitational force) reading on Z axis
• Stationary device, after 45 degree rotation
• Same magnitude, but rotated
28
Pitch () is the angle between the forward axis Xs and the horizontal plane.
Roll (β) is the angle between the Ys-axis and the horizontal plane.
29
On applying the acceleration, the beams deflect and cause the change
in capacitance.
32
Accelerometer
Mass on spring
-1g
1g
MEMS Accelerometer
Sensor: Gravity
• Gravity sensor is not a separate hardware
• It is a virtual sensor based on the accelerometer
• It is the result when real acceleration component is
removed from the reading
37
Sensor: Gyroscope
• Measures the rate of rotation (angular speed) around an axis
• Speed is expressed in rad/s on 3 axis
• When the device is not rotating, the sensor values will be zeros
• It gives us 3 values
• Pitch value (rotation around X axis)
• Roll value (rotation around Y axis)
• Yaw value (rotation around Z axis)
Gyroscope
MEMS Gyroscope
Magnetometer Measurement
• There are two basic types of magnetometer
measurement:
• Vector magnetometers measure the vector components of a
magnetic field.
• Total field magnetometers or scalar magnetometers measure the
magnitude of the vector magnetic field.
• Magnetometers used to study the Earth's magnetic field
may express the vector components of the field in terms
of declination (the angle between the horizontal
component of the field vector and magnetic north) and the
inclination (the angle between the field vector and the
horizontal surface)
• Magnetic declination varies both from place to place and
with the passage of time.
43
Compass
• Magnetic field sensor (magnetometer)
Z Y
Y X
X Z
Geographi
c Magnetic
north north Horizontal
Magnetic
field
Gravity
vector
MEMS Compass
• Most use Lorentz Force
• A current-carrying wire in a magnetic field experiences a
perpendicular force
45
Sensor: Proximity
• A proximity sensor can detect the presence of nearby objects without
physical contact
• It often emits an electromagnetic field (e.g., infrared) and looks for
changes in the field or return signal
• It is usually used by mobile device
to determine how far a person’s
head is from the face of a handset
• E.g., a user is making a phone call
Sensor: Light
• It gives a reading of the light level detected by the light sensor of the device
• Located at front of mobile device near to front facing camera
• The units are in SI lux units
• The device uses the data to adjust the display’s brightness automatically
• When ambient light is plentiful, the screen’s brightness is pumped up and when it is
dark, the display is dimmed down
• High-end Samsung galaxy phones use an advanced light sensor that can measure
white, red, green, and blue light independently to fine tune image representation
48
Sensor: Thermometer
• Ambient temperature outside of the device
Sensor: Pressure
• A pressure sensor is a device that can measure pressure
(mainly of liquids and gases) as force/unit area.
• Some higher-end mobile devices have a built-in pressure
sensor (barometer) which can measure atmospheric
pressure
• The data is used to determine how high the device is
above sea level, which in turn can help improve GPS
accuracy
• This sensor, while acting as transducer, generates a
signal in response to the pressure applied to the sensor.
50
Piezoelectric Sensors
• Device that measures changes in pressure, strain, force,
etc. by converting them to an electrical charge.
• Typically crystals or ceramics.
53
Tactile Perception
• Touch is considered one of the five senses of the human body.
It is also referred to as tactile perception.
• The sense of touch can be perceived in several ways, like
pressure, skin stretch, vibration, and temperature.
• Touch includes three main sensory systems:
• Touch/physical stimulus: This is also referred to as a somatosensory
system or tactile perception and it consists both of sensory receptors
and sensory (afferent) neurons in the periphery (skin, muscle, organs)
and neurons within the central nervous system.
• Proprioception: This means “movement sense,” which refers to the
sense of position of different body parts relative to each other and the
amount of force involved in the movement.
• Haptic perception refers to the sense/perception obtained through use
of or exploration by body parts/sensors. Exploration can be done
through motion, pressure, enclosure, or mapping the contours of the
object.
54
Sensor: Sound
• A microphone is an acoustic to electric transducer that
converts sound into an electrical signal.
• Microphones capture sound waves with a thin, flexible
diaphragm. The vibrations of this element are then
converted by various methods into an electrical signal that
is an analog of the original sound.
• Most microphones in use today use electromagnetic
generation (dynamic microphones), capacitance change
(condenser microphones) or piezo-electric generation
to produce the signal from mechanical vibration.
56
• Since the plates are biased with a fixed charge (Q), the voltage
maintained across the capacitor plates changes with the
vibrations in the air.
57
Dynamic Microphones
• In a dynamic microphone, a small
movable induction coil, positioned
in the magnetic field of a
permanent magnet, is attached to
the diaphragm.
• When sound enters through the
windscreen of the microphone, the
sound wave vibrations move the
diaphragm.
• When the diaphragm vibrates, the
coil moves in the magnetic field,
producing a varying current in the
coil through electromagnetic
induction.
58
Microphones in Smartphones
• Almost all new handsets use MEMS microphones (often
plural!)
• Two conducting membranes, one on top of the other,
acting as a capacitor
• Vibrations cause the capacitance to change
59
Sensor: Cameras
• These vary, but more and more make use of MEMS for
(auto)focus
• The underlying light sensor is no different from 'normal'
cameras
• However the small, cheap lenses inevitably suffer from
distortion
60
Distortion Correction
• Calibrate lens -> Remove distortion
• But this is a costly process
61
Camera Sensor
• With such small apertures, longer exposures are
needed to get good output
• Hence phone cameras suffer from extensive
noise in low light levels
• Photon shot noise
62
Usage in Smartphones
• Accelerometers
• Tilt estimation, orientation, shaking
• Gyroscopes
• Smooth rotation tracking
• Magnetometers
• Global orientation (maps)
• Barometer
• GPS height hint
• Light sensor
• Proximity Detection
• Camera
• Imaging
• Microphone
• Speech capture
63
Continuous Sensing
• Most of the smartphone OSes assume you don’t want to
register for 24/7 sensing events
• If you do, watch out that the OS doesn't require some
extra action on your part
• e.g., some versions of Android put the CPU into a low power state
after a certain time of screen inactivity. The lowest power states
preclude polling the sensor data...!
• You might have to hold a wake lock on the CPU if you
want to do this (which means the battery will deplete
faster!)
65
Nominal Rates
• The sensor hardware samples at a constant
('nominal’) rate but timestamping is error-prone
• Hence most smartphone APIs shy away from
numerical rates. Android uses:
66
Sampling
• Smartphone OSes are not real-time. Most sensors
regularly update a register with values. The updates
produce interrupts and eventually the OS gets around to
collecting the value.
• If the OS is busy already, a new value could come in
before we've read the last!
• Dropped readings...
• More recent sensors use a ring buffer so we don’t drop
any, but...
• The timestamps are currently of the time the datum was
collected and not the instant it was created...
67
Sensor Filtering
• Warning: sometimes getting a higher sampling rate is
pointless
• More and more sensors now have built-in low-pass
filtering, which limits the max. frequency present. So high
sampling rates might just result in oversampling!
• Normally not an issue (in fact a good thing) but wastes
power and performance
70
Process Interference
• Sampling consistency can also be affected by high priority
resource-intensive processes. In Android 2.3, the garbage
collector ran with a higher priority than sensing...
• And other processes may request a higher rate for the
same sensor at the same time! The logical thing is to run
at the highest requested rate, but this might mean your
app sees significant jumps in the rate of events.
71
Derived Sensors
• Initially the sensor access was raw, but now we have
derived sensor types that fuse raw data to estimate other
quantities. E.g., in Android:
• TYPE_GRAVITY – Estimates the gravity vector by low pass
filtering the accelerometers
• TYPE_LINEAR_ACCELERATION – Estimates the acceleration
having subtracted gravity
• TYPE_ROTATION_VECTOR – Estimates the full rotational pose of
the sensor in a world frame
• Specific implementation details vary (e.g.
software/hardware, gyroscope for rotation or not)
• Can ignore and fuse ourselves of course...
72
Inertial Tracking
• It is very tempting to fuse the sensors together to track the
phone’s trajectory → Inertial Measurement Unit
• Such tracking is relative. Errors accrue over time (so
called 'drift')
73
s=∬(a−g)dt
• Error grows quadratically over time
• End result is a fast (and unlimited) accrual of error
74
Sensor Alignment
• It can be dangerous to assume the three sensors in a 3-D
sensor are:
• Perfectly orthogonal
• Perfectly parallel to those of other sensors
75
Activity Recognition
• Sensors can collect data about users and their
surroundings
Accelerometer data can be used to classify a user’s
movement:
Running
Walking
Stationary
Combining motion classification with GPS tracking can
recognize the user’s mode of transportation:
Subway, bike, bus, car, walk…
77
Activity Recognition
• Phone cameras can be used to track eye movements
across the device for accessibility
• Microphone can classify surrounding sound to a particular
context (ATM, conversation, elevator, driving, particular
type of store/restaurant, …)
78
Custom Sensors
Device sensors are becoming common, but lack special
capabilities desired by researchers:
Blood pressure, heart rate, EEG
Barometer, temperature, humidity
Air quality, pollution, Carbon Monoxide
Specialized sensors can be embedded into peripherals:
Earphones
Dockable accessories / cases
Prototype devices with embedded sensors
79
Sensing Scale
• Sensing Scale
• Personal sensing
• Group sensing
• Community sensing
• Participatory sensing
• User takes out phone to take a reading
• Users engaged in activity, requires ease of use and incentive
• Opportunistic sensing
• Minimal user interaction
• Background data collection
• Constantly uses device resources
80
Sensing Paradigms
Participatory Opportunistic
Sensing Paradigms
• Participatory Sensing
• Users actively engage in the “sensing process”
• Human intelligence can be leveraged for complex tasks
• More costs or incentives are needed to keep humans involved
• Privacy issues
• Opportunistic Sensing
• Fully automated and no user involvement
• Less burden and costs on the user
• Detect the phone context
• Humans are underutilized
• Privacy and energy issues
82
Personal Sensing
Personal Sensing
• Tracking exercise routines
• Automated diary collection
• Health & wellness apps
Group Sensing
Group Sensing
• Sensing tied to a specific group
• Users share common interest
• Results shared with the group
• Limited access
Community Sensing
Community Sensing
• Larger scale sensing
• Open participation
• Users are anonymous
• Privacy must be protected
Examples:
• Tracking bird migrations, disease spread, congestion
patterns
• Making a noise map of a city from user contributed sound
sensor readings
85
Pulse Oximeter
• Non-invasive technology used to measure the
heart rate (HR) and blood oxygen saturation
(SpO2)
• Project infrared and near-infrared light
through blood vessels near the skin
• Detect the amount of light absorbed by
hemoglobin in the blood at two different
wavelengths to help determine level of
oxygen
• Blood vessels contract and expand with the
patient’s pulse which affects the pattern of
light absorbed over time
• Computation of HR and SpO2 from the light
transmission waveforms can be performed
using standard DSP algorithms