Sensor Subsystem Pitfalls and Considerations Jen Costillo - - PowerPoint PPT Presentation

sensor subsystem
SMART_READER_LITE
LIVE PREVIEW

Sensor Subsystem Pitfalls and Considerations Jen Costillo - - PowerPoint PPT Presentation

Designing An Android Sensor Subsystem Pitfalls and Considerations Jen Costillo jen@rebelbot.com Simple Choices User Battery experience performance 7/15/2012 Costillo- OSCON 2012 2 Established or Innovative Product? Established


slide-1
SLIDE 1

Designing An Android Sensor Subsystem

Pitfalls and Considerations Jen Costillo jen@rebelbot.com

slide-2
SLIDE 2

Simple Choices

User experience Battery performance

7/15/2012 2 Costillo- OSCON 2012

slide-3
SLIDE 3

Established

  • r Innovative Product?

Established

  • Will I be making another

new product in 6 months?

  • Is the reference design

considered good enough for the application? Innovation-Driven

  • Do I have new sensors

types?

  • Are features more

important than release date?

  • Are money and

resources no problem?

7/15/2012 3 Costillo- OSCON 2012

slide-4
SLIDE 4

Forsaking Reference Designs

7/15/2012 4 Costillo- OSCON 2012

slide-5
SLIDE 5

Going On Your Own

  • If you make your own,

– You’re on your own – Integration pains – Test time ↑ – Gesture testing becomes a challenge – Calibration blues – Larger mechanical footprint

  • But…

– power ↓ – Control code size – Control mechanical footprint – In-house expertise

7/15/2012 Costillo- OSCON 2012 5

slide-6
SLIDE 6

Android Universe

7/15/2012 Costillo- OSCON 2012 6

Sensor Hub/ Coprocessor

Sensors Interface Kernel Driver Sensor Driver

Sensor HAL Sensor Service Sensor Manager

Sensor JNI SensorManager Android Application

Hardware Linux Kernel Libraries Frameworks Application

slide-7
SLIDE 7

HARDWARE

Hardware

7/15/2012 7 Costillo- OSCON 2012

Linux Kernel Libraries Frameworks Application

slide-8
SLIDE 8

Hardware Architecture

7/15/2012 8 Costillo- OSCON 2012

slide-9
SLIDE 9

Sampling Rates: The 3 Rates

Under-sampling

  • Inaccurate, sluggish

response

  • Slight power savings

Sampling Rate Over-sampling

  • Accurate, smooth

response

  • Power-hungry

7/15/2012 9 Costillo- OSCON 2012

slide-10
SLIDE 10

Wake up events and power considerations

Application Processor only Internal Coprocessor External Processor

D C

Reference supported Most power hungry Reference supported Most work done for you More processor selection More outcome control Most customized Footprint impact

7/15/2012 10 Costillo- OSCON 2012

slide-11
SLIDE 11

Hardware Summary

Power Consumption = Σ sensorsn + any dedicated processor Latency = Max(sensorsn) + dedicated processing time Sensor Solution

  • Use tie-breaker criteria

7/15/2012 Costillo- OSCON 2012 11

slide-12
SLIDE 12

KERNEL

Linux Kernel

7/15/2012 12 Costillo- OSCON 2012

Hardware Libraries Frameworks Application

slide-13
SLIDE 13

Sensor

Kernel Driver

7/15/2012 13 Costillo- OSCON 2012

Coprocessor Microcontroller Application Processor

Peripheral Interface Shared Memory

slide-14
SLIDE 14

LIBRARIES AND SERVICES

Libraries

7/15/2012 14 Costillo- OSCON 2012

Hardware Frameworks Application Linux Kernel

slide-15
SLIDE 15

Sensor HAL and Services

  • HAL

device/<vendor>/<board name>/libsensors

  • Service

frameworks/base/services/sensorservice

  • Manager

frameworks/base/libs/gui

7/15/2012 15 Costillo- OSCON 2012

slide-16
SLIDE 16

Sensor Fusion

7/15/2012 Costillo- OSCON 2012 16

Sensors Linux Kernel Libraries Sensor Hub

http://en.wikipedia.org/wiki/Sensor_fusion https://www.llnl.gov/news/newsreleases/2010/NR-10-01-06.html

slide-17
SLIDE 17

Gesture Detection Algorithm

Sensors Sensor Hub Application Processor

Android SensorService Co- Processor

MPU with Gyro/Accel Compass Barometer Proximity

7/15/2012 17 Costillo- OSCON 2012

slide-18
SLIDE 18

Gesture Detection Comparison

Make Buy

Complete solution Already Tested &tuned Minimal Schedule Impact Compact code In-house expertise Off-load AppPro

Application

  • Powerful processor

Sensor hub

  • Off-load to cheaper

power

  • Wake up Event

Handling

7/15/2012 Costillo- OSCON 2012 18

slide-19
SLIDE 19

Calibration

7/15/2012 19 Costillo- OSCON 2012

Use of Calibration Gesture in the Compass App By Catch.com

slide-20
SLIDE 20

FRAMEWORKS

7/15/2012 20 Costillo- OSCON 2012

Hardware Application Linux Kernel Libraries Frameworks

slide-21
SLIDE 21

Virtual Sensors

  • Leverages 1+ physical or other virtual

sensors

  • Multiple Options

–Google (version 3) –Reference Vendor –Sensor Vendors

7/15/2012 Costillo- OSCON 2012 21

slide-22
SLIDE 22

Android Virtual Sensors

Gravity Accel Linear Accel Accel Gravity

7/15/2012 Costillo- OSCON 2012 22

slide-23
SLIDE 23

Android Virtual Sensors

Gyro Accel

Orientation

Compass

Accel

Rotation

7/15/2012 Costillo- OSCON 2012 23

slide-24
SLIDE 24

Virtual Sensors Challenges

  • Garbage In- Garbage Out
  • Latency
  • Non-Synchronized

samples

  • Implementation

Dependencies

  • Multi-vendor problems,

verify Vendor ID

http://www.invensense.com/midc/presentations/James%20Lim.pdf

7/15/2012 24 Costillo- OSCON 2012

Sensor 1 Sensor 2 Virtual Output Sensor 1 Sensor 2 Virtual 1 Virtual 2

slide-25
SLIDE 25

APPLICATIONS

7/15/2012 25 Costillo- OSCON 2012

Hardware Linux Kernel Libraries Application Frameworks

slide-26
SLIDE 26

Using Sensors

7/15/2012 Costillo- OSCON 2012 26

mSensorManager = getSystemService(Context.SENSOR_SERVICE); mSensorManager.registerListener( mSensorListener, mSensorManager.getDefaultSensor( Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); void onSensorChanged(SensorEvent event) { // get sensor data float x = event.values[SensorManager.DATA_X]; }

slide-27
SLIDE 27

Using Sensor (Continued)

SensorManager.getRotationMatrix( m_rotationMatrix, null, m_Mag, m_Accels); SensorManager.getOrientation( m_rotationMatrix, m_orientation); float yaw_deg = m_orientation[0] * 57.2957795f; float pitch_deg = m_orientation[1] * 57.2957795f; float roll_deg = m_orientation[2] * 57.2957795f;

7/15/2012 Costillo- OSCON 2012 27

slide-28
SLIDE 28

Types of Sensor Problems

  • Bias
  • Drift
  • Settling Time
  • Jitter/Noise
  • Environmental

Interference

7/15/2012 Costillo- OSCON 2012 28

slide-29
SLIDE 29

Bias

  • Problem: Data is off

by a constant value.

  • Sources:

– static calibration failure

  • Solutions:

– Calculate linear

  • ffset at start of

application – Recalibrate locally

7/15/2012 Costillo- OSCON 2012 29

slide-30
SLIDE 30

Drift

  • Problem: Shift of

data without cause

  • Sources:

– Magnetic interference – Poor HW calibration

  • Solutions:

– Increase smoothing techniques

7/15/2012 Costillo- OSCON 2012 30

slide-31
SLIDE 31

Settling Time

  • Problem: Extended

time before finalized steady data.

  • Sources:

– Latency – Sensitivity

  • Solutions:

– Limit additional processing

7/15/2012 Costillo- OSCON 2012 31

slide-32
SLIDE 32

Noise

  • Problem: Data jumps

around constantly

  • Sources:

– Sensor – Calibration – Poor filtering

  • Solutions:

– High pass filter – Linear averaging – FFT

7/15/2012 Costillo- OSCON 2012 32

slide-33
SLIDE 33

Environmental Interference

  • Problem: Inconsistent

results

  • Sources:

– Magnetometer – EMI

  • Solutions:

– Reference Device – Calibration gesture

7/15/2012 Costillo- OSCON 2012 33

slide-34
SLIDE 34

Best Practices in Application Development

  • Select the right sensor for the job.
  • Use the Correct Data Rate.

– UI or GAMING are the most common.

  • Use Sensor In Context
  • Customize for your hardware and system

capabilities

  • Magnetometer-based sensors are the most

touchy.

  • Keep the Gesture UI simple.

7/15/2012 34 Costillo- OSCON 2012

slide-35
SLIDE 35

QUESTIONS?

JEN@REBELBOT.COM

Additional resources http://processors.wiki.ti.com/index.php/Android_Sensor_PortingGuide http://www.kandroid.org/online-pdk/guide/sensors.html http://invensense.com/midc/ http://developer.android.com/reference/android/hardware/SensorEvent.html

7/15/2012 35 Costillo- OSCON 2012