Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit...

Post on 05-Aug-2020

6 views 1 download

transcript

Designing An Android

Sensor Subsystem

Pitfalls and Considerations

Jen Costillo

jen@rebelbot.com

Simple Choices

User experience

Battery performance

2/5/2012 2 Costillo- Android Builders Summit 2012

Established

or Innovative Product?

Established

• Will I be making another new product in 6 months?

• Is the reference design considered good enough for the application?

Innovation

• Do I have new sensors types?

• Are features more important than release date?

• Are money and resources no problem?

2/5/2012 3 Costillo- Android Builders Summit 2012

Forsaking Reference Designs

2/5/2012 4 Costillo- Android Builders Summit 2012

Going On Your Own

• If you make your own,

– You’re on your own

– Integration pains

– Test time increase

– Gesture testing becomes a challenge

– Calibration blues

– Larger mechanical footprint

• But…

– power ↓

– Control code size

– Control mechanical footprint

– In-house expertise

2/5/2012 Costillo- Android Builders Summit 2012 5

Android Universe

2/5/2012 Costillo- Android Builders Summit 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

HARDWARE

Hardware

2/5/2012 7 Costillo- Android Builders Summit 2012

Linux Kernel

Libraries

Frameworks

Application

Hardware Architecture

2/5/2012 8 Costillo- Android Builders Summit 2012

Sensor Selection

• Limited types

• New type

• Latency

• Power consumption

2/5/2012 9 Costillo- Android Builders Summit 2012

Sensor Sampling Rate

2/5/2012 10 Costillo- Android Builders Summit 2012

Sampling Rates:

The 3 Rates

Under-sampling

• Inaccurate, sluggish response

• Slight power savings

Sampling Rate

Over-sampling

• Accurate, smooth response

• Power-hungry

2/5/2012 11 Costillo- Android Builders Summit 2012

Polling versus Interrupt

Pros:

• Simplicity

• Throttle data throughput

Pros:

• Low power Sleep Mode

• Use fewer timers

Cons:

• Less sleep

• Latency ↑

• Data loss

Cons:

• Complex program structure

2/5/2012 12 Costillo- Android Builders Summit 2012

Interfaces

2/5/2012 Costillo- Android Builders Summit 2012 13

Wake up events and power

considerations

Application Processor only

Internal Coprocessor

External Processor

D C CC Reference supported Most power hungry

Reference supported Most work done for you

More processor selection More outcome control Most customized Footprint impact

2/5/2012 14 Costillo- Android Builders Summit 2012

Sensor Subsystem/Hub

• Separate processor or part of the Application processor

• How to evaluate?

– Latency

– Power consumption

– Low power modes

2/5/2012 15 Costillo- Android Builders Summit 2012

Hardware Summary

Power Consumption = Σ sensorsn + any dedicated

processor

Latency = Max(sensorsn)

+ dedicated processing

time

Sensor Solution

• Use tie-breaker criteria

2/5/2012 Costillo- Android Builders Summit 2012 16

KERNEL Linux Kernel

2/5/2012 17 Costillo- Android Builders Summit 2012

Hardware

Libraries

Frameworks

Application

Sensor

Kernel Driver

2/5/2012 18 Costillo- Android Builders Summit 2012

Coprocessor Microcontroller

Application Processor

Peripheral Interface

Shared Memory

LIBRARIES AND

SERVICES

Libraries

2/5/2012 19 Costillo- Android Builders Summit 2012

Hardware

Frameworks

Application

Linux Kernel

Sensor HAL and Services

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

• Service frameworks/base/services/sensorservice

• Manager frameworks/base/libs/gui

2/5/2012 20

Costillo- Android Builders Summit 2012

Quick HAL Intro

Create:

• List of sensors in sSensorList

• Class for each sensor supporting

• A new sensor instance in sensor.cpp

Update:

• sensors_poll_context_t to handle requests

• Android.mk to build library

2/5/2012 Costillo- Android Builders Summit 2012 21

Gesture Detection Algorithm

Sensors

Sensor Hub

Application Processor

Android SensorService

Co-Processor

MPU with Gyro/Accel

Compass

Barometer Proximity

2/5/2012 23 Costillo- Android Builders Summit 2012

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

2/5/2012 Costillo- Android Builders Summit 2012 24

Calibration

2/5/2012 25 Costillo- Android Builders Summit 2012

OTHER

CONSIDERATIONS

2/5/2012 26 Costillo- Android Builders Summit 2012

Hardware

Linux Kernel

Libraries

Frameworks

Application

Testing Methodologies

• Creating tools • Checkpoints at all levels • Ensure the application processor can see your

sensor • Compatibility Test Suite (CTS) at application level -

/cts/tests/tests/hardware… SensorTest.java • Test services -

/frameworks/base/services/sensorservice/tests • Manufacturing tests

2/5/2012 27 Costillo- Android Builders Summit 2012

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

2/5/2012 28 Costillo- Android Builders Summit 2012