Saturday, January 24, 2015

CT406 : proximity and light sensor on MotoG

The CT406 module is both an Ambient Light Sensor (ALS) and a proximity sensor.

There are not much documentation on this product so here is what i understood from my research:

CT406 TLS2772 Ambient Ligt Sensor and Proximity sensor on MotoG XT1032
the above picture is a macro-picture of the ALS/prox sensor of my MotoG (MotoE has exact same module, but on the left side of the screen)

  • On the left we can see a InfraRed LED (near IR range since we can see a little reddish light in the dark, but my camera catches part of IR spectrum and displays some kind of purple)
  • In the middle there is a black spacer.
  • On the right this looks like to be the sensor itself (from here, we know that the sensor is only an ALS that works as proximity sensor when coupled to an external IR-LED)
Here is the TAOS TSL277x chip that seems to be the base of the CT406.
TAOS (Texas Advanced Optoelectronic Solutions) brand is now known as ams.
CT406 TLS2772 Ambient Ligt Sensor and Proximity sensor on MotoG XT1032 (artwork)

Superposing my picture and that artwork: Pretty identical, right?

CT406 TLS2772 Ambient Ligt Sensor and Proximity sensor on MotoG XT1032 superposed with TLS2772 artwork

The pins are arranged this way (scheme is rotated 90° right compared to my picture):

Vdd, SCL, GND, LDR, INT, SDA pins of TLS277x ALS of MotoG XT1032

How does the proximity sensor works?

IR reflection...

The IR-LED emits Red-InfraRed lights and the right part detects if it is reflected or not (reflected == near; non-reflected == far)

To test this, it would be nice to use an external IR-LED and hide the embedded one to see if the sensor still say "far" when under IR light and "near" when IR light is turned OFF.

On our devices, the ALS sensor can only response a "high/low" output, but without the glass panel (that filter some IR) and a reworked program it could be used as presence detection (longuer range) [Source]

Proximity sensing scheme of TLS277x

How does the ALS sensor works?
Wide range light detection, IR detection, and human sight.

The chip features 2 photodiodes (one responds to wide range light: ch0; the other only gets IR: ch1)
Responsivity of sensor LEDs of TLS277x (CT406)
In the above diagram we see ch0 respond to light from 300 (near UV) to about 1000nm (IR)
Humans see light from 390nm to 700nm (about, this means from deep-blue/ultra-violet to deep red/infrared), 
Visible light spectrum

Humans don't see IR, therefore, light emitted from 700 to 1000nm produces a response from the light sensor (ch0) but Humans are actually in the dark, that would scale up light intensity of the device screen for no "human understandable reason".

That's what the IR sensor (ch1) is used for: the chip calculates something like ch0-ch1= actual human visible light intensity. Actually this is more complicated than this [Source, page 8&9]
The ALS operations have for duty to calculate what a real human would see (so, a spectrum without IR) in order to light the screen at the right human friendly level.


ALS outputs Lux that are then used by the device

The ch0 could give directly the light intensity with no real calculation if the system was open (no glass, whatsoever), and if there were no IR sensor. [See more page 10]

Real Life

How does it work inside the MotoG?

Basically, the CT406 contains the following components :

  • a sensor that is made of 2 photodiodes, one is wide range and reacts to human visible spectrum + IR; the second one reacts to IR only.
  • an Infrared Light Emitting Diode (IR-LED)
The light sensor "reacts" to visible spectrum by using the signal coming from the wide range photodiode minus the IR one.
The proximity sensor is basically the IR photodiode reacting to IR light emitted by the IR-LED and reflected by a near surface.

The module speaks to the device using i2c protocol.

Proximity sensor has two states : 

  • near (what the devices call "3cm") and 
  • far (what the device calls "100cm")

The ALS has the following working range: 

  • 2 lux (the light intensity is lower than sensor threshold)
  • 65535 lux (fully saturated)

"The device can saturate if the light is brighter than can be accumulated with the light−to−frequency conversion. The full scale value for saturation will depend upon the integration time programmed into the device. In saturation, the device accumulates 1024 counts for each 2.72 ms of integration time programmed. For each ATIME programmed, the maximum count (saturation level) is the lesser of (1024 * (256 − ATIME)) or 65,535."

This explains a few things about why the screen is not at the intended brightness level.

  • If the light isn't a wide range one; like a "white LED" which is actually a blue led with phosphor coating == the blue shift will saturate the sensor despite the "real" (== human felt) brightness is much lower.
  • If the light is PWM controlled == is being lighten ON/OFF at high frequency to get desired "global" intensity : it would saturate the sensor  regarding sampling.
  • if the light is a fluorescent light (same as for PWM controlled ones)

Thursday, January 8, 2015

CM12 and MotoG

First overview Tip and Tricks

Here are some things i found after playing a little with CM12-20150108 Nightly :

How to get root ?
  1. Enable Dev settings (multiple tap on "Build Number" in /settings/about phone/)
  2. Go to Dev settings
  3. Root access : Change to Apps and ADB

How to get Terminal app back?

It is now disabled by default, simple enable it in Dev Settings by toggling "Local Terminal"

That's all for today folks!

This blog might be totally reworked in the coming months but i don't have much time at the moment...