28
Designing An Android Sensor Subsystem Pitfalls and Considerations Jen Costillo [email protected]

Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

  • Upload
    others

  • View
    7

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

Designing An Android

Sensor Subsystem

Pitfalls and Considerations

Jen Costillo

[email protected]

Page 2: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

Simple Choices

User experience

Battery performance

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

Page 3: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

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

Page 4: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

Forsaking Reference Designs

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

Page 5: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

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

Page 6: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

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

Page 7: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

HARDWARE

Hardware

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

Linux Kernel

Libraries

Frameworks

Application

Page 8: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

Hardware Architecture

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

Page 9: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

Sensor Selection

• Limited types

• New type

• Latency

• Power consumption

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

Page 10: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

Sensor Sampling Rate

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

Page 11: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

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

Page 12: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

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

Page 13: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

Interfaces

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

Page 14: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

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

Page 15: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

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

Page 16: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

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

Page 17: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

KERNEL Linux Kernel

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

Hardware

Libraries

Frameworks

Application

Page 18: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

Sensor

Kernel Driver

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

Coprocessor Microcontroller

Application Processor

Peripheral Interface

Shared Memory

Page 19: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

LIBRARIES AND

SERVICES

Libraries

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

Hardware

Frameworks

Application

Linux Kernel

Page 20: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

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

Page 21: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

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

Page 23: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

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

Page 24: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

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

Page 25: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

Calibration

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

Page 26: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

OTHER

CONSIDERATIONS

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

Hardware

Linux Kernel

Libraries

Frameworks

Application

Page 27: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

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

Page 28: Designing An Android Sensor SubsystemAndroid Universe 2/5/2012 Costillo- Android Builders Summit 2012 6 Sensor Hub/ Coprocessor Sensors Interface Kernel Driver Sensor Driver Sensor

QUESTIONS? [email protected]

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