New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 665547 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 59467
Owner: ----
Closed: Nov 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 1
Type: Bug



Sign in to add a comment

Factory: accelerometer.py: Calibration is not done properly

Project Member Reported by gwendal@chromium.org, Nov 15 2016

Issue description


Looking at https://cs.corp.google.com/chromeos_public/src/platform/factory/py/device/accelerometer.py?rcl=cf788b8deaff3b5cef83fb85cb3455d1cb3d67a1&l=272

I noticed you assume accel data comes to user space in 1/1024G, and in
general this code only work for pre ryu devices, running 3.14.

While _calibias is still in 1/1024G for VPD backward compatibility,
this is not true for the raw data since Ryu (3.18) to match iio sysfs
guideline.
Instead, raw data already integrate _calibbias, raw data must be
multiplied by the scale attribute to get the value in m/s^2.

On Fri, Nov 4, 2016 at 12:38 AM, Ting Shen <phoenixshen@google.com> wrote:
> Hi Gwendal,
>
> We've changed the fix value by parsing specs in scan_elements/*_type, this
> CL just merged into Gru factory branch a couple days ago.
> Implementation here:
> https://cs.corp.google.com/chromeos_public/src/platform/factory/py/device/accelerometer.py?rcl=cf788b8deaff3b5cef83fb85cb3455d1cb3d67a1&l=27
> https://cs.corp.google.com/chromeos_public/src/platform/factory/py/device/accelerometer.py?rcl=cf788b8deaff3b5cef83fb85cb3455d1cb3d67a1&l=244
> Not sure if the calculation is correct, could you confirm this?

This is not correct:
cros_ec_accel can_elements/in_accel_<axis>_type returns a constant:
le:s16/16>>0

So scan_type.shift is 0, and line 244 is a noop.

The code in /accelerometer.py does not seems to have modified for
cros_ec sensor stack in 3.18 kernel and beyond
(https://docs.google.com/a/google.com/document/d/1-ZLlS8oJNkFUA0wCNsPukJOZjwVIWOvs9404ihdEm6M/edit?usp=sharing_

- raw data in the iio buffer is not in 1/1024G unit, but when multiply
by scale attribute, will show the acceleration in m/s^2
- raw data already take in account _calibbias, so we should not call
_CalculateCalibratedValue() to get the calibrated value.

For calibration purposes, you want to keep data in the python code  in
1/1024 units, so in GetRawDataAverage(),  you need to multiply by a
constant C = scale / g * 1024
For instance, when the range is +/-2g, scale is 2g / 2^15, so C = 1/16.

To get uncalibrated data, you can set all _calibbias variables to 0
beforehand, or subtract _calibbias from the results.
 

Comment 2 Deleted

Comment 3 by hungte@chromium.org, Nov 21 2016

Cc: gwendal@chromium.org
Hi Gwendal, I saw you merging this to chromium:59467 instead of chrome-os-partner:59467.

You probably want to remove the duplicate tag?

And I don't know if it's  possible to merge between bugs.chromium.org and code.google.com now...

Sign in to add a comment