Changes between Version 3 and Version 4 of accelerometer


Ignore:
Timestamp:
02/26/2020 12:17:32 AM (4 years ago)
Author:
Tim Harvey
Comment:

refactor page adding IIO subsystem usage

Legend:

Unmodified
Added
Removed
Modified
  • accelerometer

    v3 v4  
    11[[PageOutline]]
    22
    3 = Accelerometer and Magnetometer =
     3= Accelerometer and Magnetometer
    44Many Gateworks board families including ventana and newport come standard with either an Accelerometer, Magnetometer, or other inertial measurement unit (IMU) on a single IC.
    55
    6 == Supported Devices ==
     6== Supported Devices
    77The specific IMUs used on our boards are described by the following table:
    88
     
    2828See examples below for more information.
    2929
    30 == OS Support ==
    31 The FXOS8700 used on many Ventana boards is supported in the following ways:
    32 ||= OpenWrt =||= Yocto =||= Android ||
    33 || i2c/input || i2c/input || i2c/input/sensor HAL ||
    34 
    35 == Android use via the Android sensor HAL ==
    36 The Android BSP will register an accelerometer and a magnetometer sensor with the OS and therefore can be used with apps conforming the the Android sensor API.
     30== Software Support
     31The API used to access these devices varies depending on the device and sometimes the kernel version.
     32
     33||= '''Device''' =||= Kernel API =||
     34|| LIS2DE12       || iio ||
     35|| LSM9DS1        || iio ||
     36|| FXOS8700       || input (3.14/4.4 kernel) / iio (4.19+ kernels) ||
     37
     38
     39
     40[=#iio]
     41=== Linux industrial I/O (newer kernels)
     42The modern approach to IMU devices is to use the [https://www.kernel.org/doc/html/v4.12/driver-api/iio/index.html Linux IIO subsystem]. IIO aims to fill the gap between the somewhat similar {{{hwmon}}} and {{{input}}} subsystems. While the {{{hwmon}}} API is directed at low sample rate sensors (like fan speed control or temperature measurement) the {{{input}}} API is focused on human interaction input devices (keyboard, mouse, touchscreen). In some cases there is considerable
     43overlap between these and the {{{iio}}} API.
     44
     45Userspace applications can interact with an IIO driver via either:
     461. {{{/sys/bus/iio/devices/iio:deviceX/}}} - represents a hardware sensor and groups
     47together the data channels. Common attributes are {{{name}}}, {{{dev}}},
     48{{{sampling_frequency_available}}}, and standard attributes. See [https://elixir.bootlin.com/linux/latest/source/Documentation/ABI/testing/sysfs-bus-iio sysfs-bus-iio] for details.
     49 * Example (GW54xx with FXOS8700)
     50{{{#!bash
     51# cat /sys/bus/iio/devices/iio\:device0/in_accel_sampling_frequenc
     52y_available
     531.5625 6.25 12.5 50 100 200 400 800
     54# echo 100 > /sys/bus/iio/devices/iio\:device0/in_accel_sampling_f
     55requency
     56# for i in `seq 1 10`; do cat /sys/bus/iio/devices/iio\:device0/in
     57_accel_x_raw ; done
     5870
     5970
     6070
     6170
     6290
     6390
     6490
     6590
     6690
     6790
     68}}}
     69
     702. {{{/dev/iio:deviceX}}} - character device node interface used for buffered data transfer and for event information retrieval
     71
     723. [https://github.com/analogdevicesinc/libiio libiio] - library for interfacing with Linux IIO devices (Ubuntu: libiio-utils iiod, OpenWrt: iio-utils iiod):
     73 * Example (GW54xx with FXOS8700)
     74{{{#!bash
     75# cat "/sys/bus/iio/devices/iio:device0/in_accel_sampling_frequenc
     76y"
     77cat: read error: Invalid argument
     78root@OpenWrt:/# iio_info
     79Library version: 0.18 (git tag: v0.18)
     80Compiled with backends: local
     81IIO context created with local backend.
     82Backend version: 0.18 (git tag: v0.18)
     83Backend description string: Linux OpenWrt 4.19.106 #0 SMP Tue Feb 25 22:49:24 2020 armv7l
     84IIO context has 1 attributes:
     85    local,kernel: 4.19.106
     86IIO context has 1 devices:
     87    iio:device0: fxos8700
     88        6 channels found:
     89                accel_y:  (input)
     90                5 channel-specific attributes found:
     91                        attr  0: raw value: -256
     92                        attr  1: sampling_frequency ERROR: Invalid argument (-22)
     93                        attr  2: sampling_frequency_available value: 1.5625 6.25 12.5 50 100 200 400 800
     94                        attr  3: scale value: 0.000244
     95                        attr  4: scale_available value: 0.000244 0.000488 0.000976
     96                magn_z:  (input)
     97                5 channel-specific attributes found:
     98                        attr  0: raw value: 0
     99                        attr  1: sampling_frequency ERROR: Invalid argument (-22)
     100                        attr  2: sampling_frequency_available value: 1.5625 6.25 12.5 50 100 200 400 800
     101                        attr  3: scale value: 0.000244
     102                        attr  4: scale_available value: 0.000001200
     103                accel_z:  (input)
     104                5 channel-specific attributes found:
     105                        attr  0: raw value: 0
     106                        attr  1: sampling_frequency ERROR: Invalid argument (-22)
     107                        attr  2: sampling_frequency_available value: 1.5625 6.25 12.5 50 100 200 400 800
     108                        attr  3: scale value: 0.000244
     109                        attr  4: scale_available value: 0.000244 0.000488 0.000976
     110                magn_x:  (input)
     111                5 channel-specific attributes found:
     112                        attr  0: raw value: -1660
     113                        attr  1: sampling_frequency ERROR: Invalid argument (-22)
     114                        attr  2: sampling_frequency_available value: 1.5625 6.25 12.5 50 100 200 400 800
     115                        attr  3: scale value: 0.000244
     116                        attr  4: scale_available value: 0.000001200
     117                accel_x:  (input)
     118                5 channel-specific attributes found:
     119                        attr  0: raw value: 82
     120                        attr  1: sampling_frequency ERROR: Invalid argument (-22)
     121                        attr  2: sampling_frequency_available value: 1.5625 6.25 12.5 50 100 200 400 800
     122                        attr  3: scale value: 0.000244
     123                        attr  4: scale_available value: 0.000244 0.000488 0.000976
     124                magn_y:  (input)
     125                5 channel-specific attributes found:
     126                        attr  0: raw value: 12800
     127                        attr  1: sampling_frequency ERROR: Invalid argument (-22)
     128                        attr  2: sampling_frequency_available value: 1.5625 6.25 12.5 50 100 200 400 800
     129                        attr  3: scale value: 0.000244
     130                        attr  4: scale_available value: 0.000001200
     131        1 device-specific attributes found:
     132                        attr  0: current_timestamp_clock value: realtime
     133
     134}}}
    37135
    38136References:
    39  * ​http://www.tutorialspoint.com/android/android_sensors.htm
    40 
    41 
    42 == Linux input device access ==
    43 The ​[https://www.kernel.org/doc/Documentation/input/input.txt Linux input device API] provides access to devices through a {{{/dev/input/event<n>}}} interface. Currently the above IMU's are supported via a linux input driver on all of the Gateworks BSP's.
     137 * https://wiki.analog.com/software/linux/docs/iio/iio
     138 * https://elinux.org/images/a/ac/Clausen.pdf
     139
     140[=#input]
     141=== Linux input device access (older kernels)
     142The ​[https://www.kernel.org/doc/Documentation/input/input.txt Linux input device API] provides access to devices through a {{{/dev/input/event<n>}}} interface. Some of the older kernel's support IMU's via a linux input driver.
    44143
    45144The {{{/sys/class/input/input<n>/name}}} directories will show the device name responsible for the events within that directory which correspond to matching {{{/dev/input/event<n>}}} entries.
     
    109208
    110209
    111 == Direct i2c Access ==
     210[=#android]
     211=== Android support via the Android sensor HAL
     212The Android BSP will register an accelerometer and a magnetometer sensor with the OS and therefore can be used with apps conforming the the Android sensor API.
     213
     214References:
     215 * ​http://www.tutorialspoint.com/android/android_sensors.htm
     216
     217
     218[=#i2cget]
     219=== Direct i2c Access
    112220This section provides examples for some typical methods of communicating with the IMUs on the i2c bus. The FXOS8700 information will be used but can be adjusted to match the address of the device present on your board. Refer to the linked datasheets to see more detailed register information.
    113221