ADXL313 driver
This driver supports Analog Device's ADXL313 on SPI/I2C bus.
1. Supported devices #
The ADXL313is a low noise density, low power, 3-axis accelerometer with selectable measurement ranges. The ADXL313 supports the ±0.5 g, ±1 g, ±2 g and ±4 g ranges.
2. Device attributes #
Accelerometer measurements are always provided.
Each IIO device, has a device folder under /sys/bus/iio/devices/iio:deviceX, where X is the IIO index of the device. Under these folders reside a set of device files, depending on the characteristics and features of the hardware device in questions. These files are consistently generalized and documented in the IIO ABI documentation.
The following tables show the adxl313 related device files, found in the specific device folder path /sys/bus/iio/devices/iio:deviceX.
|
3-Axis Accelerometer related device files |
Description |
|
in_accel_scale |
Scale for the accelerometer channels. |
|
in_accel_x_calibbias |
Calibration offset for the X-axis accelerometer channel. |
|
in_accel_x_raw |
Raw X-axis accelerometer channel value. |
|
in_accel_y_calibbias |
y-axis acceleration offset correction |
|
in_accel_y_raw |
Raw Y-axis accelerometer channel value. |
|
in_accel_z_calibbias |
Calibration offset for the Z-axis accelerometer channel. |
|
in_accel_z_raw |
Raw Z-axis accelerometer channel value. |
|
Miscellaneous device files |
Description |
|
name |
Name of the IIO device. |
|
in_accel_sampling_frequency |
Currently selected sample rate. |
|
in_accel_sampling_frequency_available |
Available sampling frequency configurations. |
The iio event related settings, found in /sys/bus/iio/devices/iio:deviceX/events.
|
in_accel_mag_adaptive_falling_period |
AC coupled inactivity time. |
|
in_accel_mag_adaptive_falling_value |
AC coupled inactivity threshold. |
|
in_accel_mag_adaptive_rising_value |
AC coupled activity threshold. |
|
in_accel_mag_falling_period |
Inactivity time. |
|
in_accel_mag_falling_value |
Inactivity threshold. |
|
in_accel_mag_rising_value |
Activity threshold. |
|
in_accel_x&y&z_mag_adaptive_falling_en |
Enable or disable AC coupled inactivity events. |
|
in_accel_x|y|z_mag_adaptive_rising_en |
Enable or disable AC coupled activity events. |
|
in_accel_x&y&z_mag_falling_en |
Enable or disable inactivity events. |
|
in_accel_x|y|z_mag_rising_en |
Enable or disable activity events. |
The default coupling is DC coupled events. In this case the threshold will be in place as such, where for the AC coupled case an adaptive threshold (described in the datasheet) will be applied by the sensor. In general activity, i.e. ACTIVITY or ACTIVITY_AC and inactivity i.e. INACTIVITY or INACTIVITY_AC, will be linked with auto-sleep enabled when both are enabled. This means in particular ACTIVITY can also be linked to INACTIVITY_AC and vice versa, without problem.
Note here, that ACTIVITY and ACTIVITY_AC are mutually exclusive. This means, that the most recent configuration will be set. For instance, if ACTIVITY is enabled, and ACTIVITY_AC will be enabled, the sensor driver will have ACTIVITY disabled, but ACTIVITY_AC enabled. The same is valid for inactivity. In case of turning off an event, it has to match to what is actually enabled, i.e. enabling ACTIVITY_AC and then disabling ACTIVITY is simply ignored as it is already disabled. Or, as if it was any other not enabled event, too.
Channels processed values #
A channel value can be read from its _raw attribute. The value returned is the raw value as reported by the devices. To get the processed value of the channel, apply the following formula:
processed value = (_raw + _offset) * _scale
Where _offset and _scale are device attributes. If no _offset attribute is present, simply assume its value is 0.
The ADXL313 driver offers data for a single types of channels, the table below shows the measurement units for the processed value, which are defined by the IIO framework:
|
Channel type |
Measurement unit |
|
Acceleration on X, Y, and Z axis |
Meters per Second squared |
Usage examples #
Show device name:
Show accelerometer channels value:
The accelerometer values will be:
-
X-axis acceleration = in_accel_x_raw * in_accel_scale = 0.0191536 m/s^2
-
Y-axis acceleration = in_accel_y_raw * in_accel_scale = -0.5458779 m/s^2
-
Z-axis acceleration = in_accel_z_raw * in_accel_scale = 0.0191536 m/s^2
Set calibration offset for accelerometer channels. Note, that the calibration will be rounded according to the graduation of LSB units:
Set sampling frequency:
3. Device buffers and triggers #
This driver supports IIO buffers.
All devices support retrieving the raw acceleration measurements using buffers.
Usage examples #
Select channels for buffer read:
Set the number of samples to be stored in the buffer:
Enable buffer readings:
Obtain buffered data:
||
||
||
||
||
||
||
||
||
||
||
Enabling activity detection:
<only while ||)
||)
||)
Disabling activity detection:
<nothing>
Enabling inactivity detection:
&&)
&&)
&&)
<every Now, enabling activity, e.g. the AC coupled counter-part ACTIVITY_AC
<some ||)
<5&&)
<some ||)
<again, &&)
<stays Note, when AC coupling is in place, the event type will be of mag_adaptive. AC- or DC-coupled (the default) events are used similarly.
4. IIO Interfacing Tools #
See Documentation/iio/iio_tools.rst for the description of the available IIO interfacing tools.