iio: adis16201: Correct accelerometer scale factor
Subsystems (3)
PATCH 1/1 iio: adis16201: Correct accelerometer scale factor
The IIO_CHAN_INFO_SCALE previously reported for accelerometer channels used 0.4624 mg/LSB. This value matches the datasheet specification for the offset calibration registers (X/YACCL_OFFS_REG, pg 18).
However, the scale should reflect the sensor output data registers (X/YACCL_OUT, pg 15, Tables 7 & 8), which use 0.4625 mg/LSB. This is also consistent with the typical sensitivity in Table 1 (1 / 2.162 ≈ 0.4625).
--- drivers/iio/accel/adis16201.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/adis16201.c +1 -1
@@ -133,7 +133,7 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,* 1 LSB represents 0.244 mg. */ *val =0 ; - *val2 =IIO_G_TO_M_S_2 (462400 ); + *val2 =IIO_G_TO_M_S_2 (462500 );return IIO_VAL_INT_PLUS_NANO ;case IIO_INCLI : *val =0 ;
Signature · 1 line
2.43.0
LGTM. Minor comments inline.
Quoted 22 lines · Gabriel Shahrouzi
The
IIO_CHAN_INFO_SCALEpreviously reported for accelerometer channels used 0.4624 mg/LSB. This value matches the datasheet specification for the offset calibration registers (X/YACCL_OFFS_REG, pg 18).However, the scale should reflect the sensor output data registers (X/YACCL_OUT, pg 15, Tables 7 & 8), which use 0.4625 mg/LSB. This is also consistent with the typical sensitivity in Table 1 (1 / 2.162 ≈ 0.4625).
Fixes 57f9386405a2 ("Staging: iio: accel: adis16201: Add comments about units in read_raw()")Signed-off-by Gabriel Shahrouzi <[email protected]>---
drivers/iio/accel/adis16201.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/accel/adis16201.c +0
-0
drivers/iio/accel/adis16201.c static int adis16201_read_raw(struct iio_dev *indio_dev, · line 133
Quoted 1 line
drivers/iio/accel/adis16201.c +0
-0@@ -133,7 +133,7 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,* 1 LSB represents 0.244 mg.
Maybe also update the comment?
drivers/iio/accel/adis16201.c static int adis16201_read_raw(struct iio_dev *indio_dev, · line 136
Quoted 4 lines
drivers/iio/accel/adis16201.c +1
-1*/ *val =0 ; - *val2 =IIO_G_TO_M_S_2 (462400 ); + *val2 =IIO_G_TO_M_S_2 (462500 );
If we do the math with more decimal digitis we have 1 / 2.162 == 0.46253469010176 Would it make sense to do
*val2 = IIO_G_TO_M_S_2(462535);
?
Quoted 3 lines
drivers/iio/accel/adis16201.c +0
-0return IIO_VAL_INT_PLUS_NANO ;case IIO_INCLI : *val =0 ;
Quoted 21 lines · Marcelo Schmitt
LGTM. Minor comments inline.
Quoted 17 lines · Gabriel Shahrouzi
The
IIO_CHAN_INFO_SCALEpreviously reported for accelerometer channels used 0.4624 mg/LSB. This value matches the datasheet specification for the offset calibration registers (X/YACCL_OFFS_REG, pg 18).However, the scale should reflect the sensor output data registers (X/YACCL_OUT, pg 15, Tables 7 & 8), which use 0.4625 mg/LSB. This is also consistent with the typical sensitivity in Table 1 (1 / 2.162 ≈ 0.4625).
Fixes 57f9386405a2 ("Staging: iio: accel: adis16201: Add comments about units in read_raw()")Signed-off-by Gabriel Shahrouzi <[email protected]>---
drivers/iio/accel/adis16201.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 7 lines
drivers/iio/accel/adis16201.c static int adis16201_read_raw(struct iio_dev *indio_dev, · line 133
Quoted 6 lines
drivers/iio/accel/adis16201.c +0
-0@@ -133,7 +133,7 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,* 1 LSB represents 0.244 mg. Maybe also update the comment?
Good catch. I will update that for v2.
Quoted 9 lines
drivers/iio/accel/adis16201.c static int adis16201_read_raw(struct iio_dev *indio_dev, · line 136
Quoted 5 lines
drivers/iio/accel/adis16201.c +1
-1*/ *val =0 ; - *val2 =IIO_G_TO_M_S_2 (462400 ); + *val2 =IIO_G_TO_M_S_2 (462500 );If we do the math with more decimal digitis we have 1 / 2.162 == 0.46253469010176 Would it make sense to do
*val2 = IIO_G_TO_M_S_2(462535);?
Since the datasheet lists the scale factor as 0.4625 mg, I believe using *val2 = IIO_G_TO_M_S_2(462500); is correct. However, I'm not sure so I'll postpone v2.
Quoted 4 lines
Quoted 4 lines
drivers/iio/accel/adis16201.c +0
-0return IIO_VAL_INT_PLUS_NANO ;case IIO_INCLI : *val =0 ;