On Wed, 18 Oct 2023 01:37:12 +0530
Jagath Jog J <jagathjog1996@xxxxxxxxx> wrote:
I think you are right. Looks like I misinterpreted the meaning of IIO_VAL_INT_PLUS_MICRO when I took my first tour in the IIO with this driver. The comment above the scale table does support that assumption ... 10^6 would match such a brainfart. (This is my first thought. I will take better look at this later today and see if I can come up with a fix if no-one else has sent a patch already).Hi Matti,
On Mon, Oct 24, 2022 at 6:10 PM Matti Vaittinen
<mazziesaccount@xxxxxxxxx> wrote:
KX022A is a 3-axis accelerometer from ROHM/Kionix. The sensor features
include variable ODRs, I2C and SPI control, FIFO/LIFO with watermark IRQ,
tap/motion detection, wake-up & back-to-sleep events, four acceleration
ranges (2, 4, 8 and 16g), and probably some other cool features.
This is a nice driver, and I found it very helpful as a reference.
One question regarding scale please see below.
+ * range is typically +-2G/4G/8G/16G, distributed over the amount of bits.
+ * The scale table can be calculated using
+ * (range / 2^bits) * g = (range / 2^bits) * 9.80665 m/s^2
+ * => KX022A uses 16 bit (HiRes mode - assume the low 8 bits are zeroed
+ * in low-power mode(?) )
+ * => +/-2G => 4 / 2^16 * 9,80665 * 10^6 (to scale to micro)
+ * => +/-2G - 598.550415
+ * +/-4G - 1197.10083
+ * +/-8G - 2394.20166
+ * +/-16G - 4788.40332
+ */
+static const int kx022a_scale_table[][2] = {
+ { 598, 550415 },
+ { 1197, 100830 },
+ { 2394, 201660 },
+ { 4788, 403320 },
+};
Given that the integer part is non-zero, and
IIO_VAL_INT_PLUS_MICRO is returned for read_scale,
As raw value will never be fractional how does this
correspond to a reading of 9.8 m/s² for the Z-axis?
Definitely suspicious as should be in m/s^2 for an acceleration and
it should be
9.8*16/2^bits
So I think these are out by a factor of 10^6