The digital output ADXL355 is low noise density, low 0 g offset drift, low power, 3-axis accelerometer with selectable measurement ranges. The ADXL355 supports the ±2 g, ±4 g, and ±8 g ranges. The ADXL355 offer industry leading noise, minimal offset drift over temperature, and long-term stability enabling precision applications with minimal calibration.
Highly integrated in a compact form factor, the low power ADXL355 is ideal in an Internet of Things (IoT) sensor node and other wireless product designs.
The ADXL355 multifunction pin names may be referenced by their relevant function only for either the serial peripheral interface (SPI) or I2C interface.
The goal of ADI Microcontroller No-OS is to be able to provide reference projects for lower end processors, which can't run Linux, or aren't running a specific operating system, to help those customers using microcontrollers with ADI parts. ADI No-OS offers generic drivers which can be used as a base for any microcontroller platform and also example projects which are using these drivers on various microcontroller platforms.
For more information about ADI No-OS and supported microcontroller platforms see: no-OS
The source code for ADXL355 driver can be found here:
The driver also uses the ADI util library, so make sure you also add the necessary files in your project. The source code for the util library can be found here:
In order to be able to use this driver you will have to provide the specific implementation for the communication APIs and the specific types they use. If the SPI communication is chosen, there are three functions which are called by the ADXL355 driver and have to be implemented:
And there are two data types that have to be defined:
If the I2C communication is chosen, there are four functions which are called by the ADXL355 driver:
And there are two data types that have to be defined:
An example of a header file containing the prototypes of the functions which have to be implemented, along with some generic data types they are using can be found below:
Source code documentation for the driver is automatically generated using the Doxygen tool and it is available below:
In order to be able to use the device, you will have to provide the support for the communication protocol (SPI or I2C) as mentioned above. The first API to be called is adxl355_init. Make sure that it returns 0, which means that the driver was initialized correctly. After, it is recommended to perform a soft reset, by calling adxl355_soft_reset, in order to put the device in a known state.
By default, the device uses +/- 2g range configuration. You may modify this value to +/- 4g or +/- 8g by using adxl355_set_range API.
The ADXL355 uses an analog, low-pass, antialiasing filter to reduce out of band noise and to limit bandwidth. The ADXL355 provides further digital filtering options to maintain optimal noise performance at various output data rates (ODRs). The default configuration for output data rate and low-pass filter corner is 4000Hz and 1000 Hz respectively. You may modify the ODR and low-pass filter configuration using adxl355_set_odr_lpf API.
The ADXL355 also includes an optional digital high-pass filter with a programmable corner frequency. By default, the high-pass filter is disabled. You may enable it with the desired configuration by using adxl355_set_hpf_corner API.
You may set an offset for each axis for calibration purposes by using adxl355_set_offset. The offset is disabled by default. The data provided in adxl355_set_offset all be in two's complement format. The offset is added after all other signal processing is taking place.
There are 96 locations in the FIFO. Each location contains an acceleration data point on an axis. In case you want to use the FIFO, you are able to modify the number of FIFO samples to be stored in the FIFO. The default and maximum value is 96, but can be modified using adxl355_set_fifo_samples API.
In case you want to use the activity detection algorithm, you can enable this feature on any axis using adxl355_conf_act_en API. By default the activity detection feature is disabled. If activity detection feature is enabled, you will also have to specify a threshold for the activity detection using adxl355_conf_act_thr API and a number of consecutive measurements above the threshold which would trigger the detection of an activity. This number has to be set using adxl355_set_act_cnt_reg. The default value is 1.
The device allows the usage of interrupts which can be mapped to INT1 or INT2 pins. In case you want to use interrupts, make sure you configure the interrupt map by using adxl355_config_int_pins API. You may also configure the polarity of the interrupt, whether is active high or active low, by using adxl355_set_int_pol API.
The following events can be mapped to the interrupt pins:
After the specific configuration was performed as mentioned above, you can set the device in the desired measurement mode, using adxl355_set_op_mode API. The available operation modes for measurement are as follows:
In case the operation mode selected includes the temperature measurement, then data can be obtained by calling adxl355_get_temp API. The temperature is in millidegrees Celsius, with scaling already applied.
If you want to obtain the raw temperature data without any scaling applies, simply call adxl355_get_raw_temp API.
If you want to obtain a single data set, you may use adxl355_get_xyz API to obtain the data converted to g, or adxl355_get_raw_xyz API to obtain the raw data. The raw data is in two's complement format and it does not have the scaling applied.
If you want to read from the FIFO, you may use adxl355_get_fifo_data API to obtain the data converted to g, or adxl355_get_raw_fifo_data api to obtain the raw data. The raw data is in two's complement format and it does not have the scaling applied. The parameter fifo_entries shows the number of valid measurements in the FIFO which were read.
struct adxl355_dev *adxl355; // Particular SPI configuration struct no_os_spi_init_param sip = { .max_speed_hz = 10000000, .bit_order = SPI_BIT_ORDER_MSB_FIRST, .mode = SPI_CPOL0_SPI_CPHA0, }; struct adxl355_init_param init_data_adxl355 = { .comm_init.spi_init = sip, .comm_type = ADXL355_SPI_COMM, }; ret = adxl355_init(&adxl355, init_data_adxl355); if (ret < 0) goto error; ret = adxl355_soft_reset(adxl355); if (ret < 0) goto error; ret = adxl355_set_odr_lpf(adxl355, ADXL355_ODR_4000HZ); if (ret < 0) goto error; ret = adxl355_set_op_mode(adxl355, ADXL355_MEAS_TEMP_ON_DRDY_OFF); if (ret < 0) goto error; // Read single accel data struct adxl355_frac_repr x; struct adxl355_frac_repr y; struct adxl355_frac_repr z; ret = adxl355_get_xyz(adxl355,&x[0], &y[0], &z[0]); if (ret < 0) goto error; // Read FIFO accel data struct adxl355_frac_repr x[32] = {0}; struct adxl355_frac_repr y[32] = {0}; struct adxl355_frac_repr z[32] = {0}; uint8_t fifo_entries = 0; ret = adxl355_get_fifo_data(adxl355, &fifo_entries, &x[0], &y[0], &z[0]); if (ret < 0) goto error; // Read temperature data struct adxl355_frac_repr temp; ret = adxl355_get_temp(adxl355, &temp); if (ret < 0) goto error;
Below you can find Application Example Projects for ADXL355 driver: Evaluating the ADXL355
The ADXL355 IIO driver comes on top of ADXL355 driver and offers support for interfacing IIO clients through IIO lib.
The source code for ADXL355 driver can be found here:
Source code documentation for the IIO driver is automatically generated using the Doxygen tool and it is available below:
ADXL355 IIO device does not have any device specific attributes.
ADXL355 IIO device has 0 output channels and 4 input channels: 3 acceleration channels and 1 temperature channel.
The acceleration channels are:
Each acceleration channel has 7 attributes. 5 of these attributes are shared in value with the other acceleration channels and 2 of these attributes can have different values for each channel.
The attributes are:
Sampling frequency (Hz) | High Pass Filter Corner Frequency available values (Hz) | ||||||
---|---|---|---|---|---|---|---|
4000.000000 | 0.000000 | 9.880000 | 2.483360 | 0.621800 | 0.154480 | 0.038160 | 0.009520 |
2000.000000 | 0.000000 | 4.940000 | 1.241680 | 0.310900 | 0.077240 | 0.019080 | 0.004760 |
1000.000000 | 0.000000 | 2.470000 | 0.620840 | 0.155450 | 0.038620 | 0.009540 | 0.002380 |
500.000000 | 0.000000 | 1.235000 | 0.310420 | 0.077725 | 0.019310 | 0.004770 | 0.001190 |
250.000000 | 0.000000 | 0.617500 | 0.155210 | 0.038862 | 0.009655 | 0.002385 | 0.000595 |
125.000000 | 0.000000 | 0.308750 | 0.077605 | 0.019431 | 0.004827 | 0.001192 | 0.000297 |
62.500000 | 0.000000 | 0.154375 | 0.038802 | 0.009715 | 0.002413 | 0.000596 | 0.000148 |
31.250000 | 0.000000 | 0.077187 | 0.019401 | 0.004857 | 0.001206 | 0.000298 | 0.000074 |
15.625000 | 0.000000 | 0.038593 | 0.009700 | 0.002428 | 0.000603 | 0.000149 | 0.000037 |
7.813000 | 0.000000 | 0.019298 | 0.004850 | 0.001214 | 0.000301 | 0.000074 | 0.000018 |
3.906000 | 0.000000 | 0.009647 | 0.002425 | 0.000607 | 0.000150 | 0.000037 | 0.000009 |
converted_accel [m/s^2] = (raw + calibbias << 4) * scale converted_accel [m/s^2] = (raw + calibbias << 4) * 0.000038245
The temperature channel is:
The channel has 3 attributes, as follows:
converted_temp [degrees Celsius] = (raw + offset) * scale converted_temp [degrees Celsius] = (2111.25 - raw) * 110.497238
The ADXL355 IIO devices driver supports the usage of a data buffer for reading purposes.
#define DATA_BUFFER_SIZE 400 uint8_t iio_data_buffer[DATA_BUFFER_SIZE*4*sizeof(int)]; struct adxl355_iio_dev *adxl355_iio_desc; struct adxl355_iio_init_param adxl355_init_par; // Particular SPI configuration struct no_os_spi_init_param sip = { .max_speed_hz = 10000000, .bit_order = SPI_BIT_ORDER_MSB_FIRST, .mode = SPI_CPOL0_SPI_CPHA0, }; struct iio_data_buffer accel_buff = { .buff = (void *)iio_data_buffer, .size = DATA_BUFFER_SIZE*4*sizeof(int) }; struct adxl355_init_param init_data_adxl355 = { .comm_init.spi_init = sip, .comm_type = ADXL355_SPI_COMM, }; ret = adxl355_iio_init(&adxl355_iio_desc, &adxl355_init_par); if (ret != SUCCESS) return ret; struct iio_app_device iio_devices[] = { { .name = "adxl355", .dev = adxl355_iio_desc, .dev_descriptor = adxl355_iio_desc->iio_dev, .read_buff = &accel_buff, .write_buff = NULL } }; return iio_app_run(iio_devices, NO_OS_ARRAY_SIZE(iio_devices));
Below you can find an Application Example Project for ADXL355 IIO driver: Evaluating the ADXL355