Main Content

LIS3DH Accelerometer Sensor

Measure linear acceleration, voltage, and temperature from LIS3DH sensor

Since R2022b

  • block icon for LIS3DH Accelerometer Sensor

Libraries:
C2000 Microcontroller Blockset / Sensors

Description

The LIS3DH Accelerometer Sensor block measures linear acceleration, voltages on external input pins (ADC1, ADC2 and ADC3) of the sensor, and temperature using the LIS3DH Accelerometer sensor interfaced with the C2000 board.

The block also provides the option to enable the high pass filter, FIFO and FIFO interrupt. An interrupt is generated if Generate data ready interrupt is selected. After selecting Generate data ready interrupt, if FIFO is disabled data ready interrupt is generated and if FIFO is enabled FIFO interrupt is generated.

The block outputs status of acceleration measurement, specified as a value 0, 1, or 2. The value 0 indicates that the data read is new, 1 indicates that the data read is not new, and 2 indicates that the data is overwritten.

The block outputs single / double click axis as a 1-by-3 vector. The click axis provides information of the axis, on which click is detected. The axis value displays 1 when a click is detected otherwise it displays 0.

The block supports inertial wake-up, free-fall, 6D position, 6D movement, 4D position and 4D movement recognition. The block outputs inertial wake-up axis as a 1-by-3 vector. This provides information of the axis, on which inertial wake-up is detected. The 6D position axis and 6D movement axis are of size 1-by-6. The 4D position and 4D movement axis are of size 1-by-4. The status contains the information about the axis, on which the detection is recognized. The status value displays 1 when the configured detection is recognized on the selected axis, otherwise it displays 0.

Examples

Ports

Output

expand all

The block outputs acceleration as a 1-by-3 vector when FIFO is disabled. When FIFO is enabled, the block outputs n-by-3 vector, where n is the number of samples. Each value represents the measurement of acceleration in m/s^2 along the X, Y, and Z axes.

Dependencies

This output port appears only if you select the Acceleration (m/s2) parameter.

Data Types: single | double | int16

The block outputs voltage applied on external pin ADC1 of the LIS3DH sensor.

Dependencies

This output port appears only if you select the Voltage (external input at ADC1) parameter.

Data Types: single | double | int16

The block outputs voltage applied on external pin ADC2 of the LIS3DH sensor.

Dependencies

This output port appears only if you select the Voltage (external input at ADC2) parameter.

Data Types: single | double | int16

The block outputs voltage applied on external pin ADC3 of the LIS3DH sensor.

Dependencies

This output port appears only if you select Voltage (external input) for ADC3 input parameter.

Data Types: single | double | int16

Temperature (in ℃) measured by LIS3DH sensor connected to C2000 board.

Dependencies

This output port appears only if you select Temperature for ADC3 input parameter.

Data Types: single | double | int16

Status of acceleration measurement, specified as a value 0, 1, or 2. The value 0 indicates that the data read is new, 1 indicates that the data read is not new, and 2 indicates that the data is overwritten.

If Enable FIFO is selected, then 0 indicates that the specified samples are collected, 1 indicates that specified number of samples are not collected, and 2 indicates that the data is overwritten.

Dependencies

This output port appears only if you select the Acceleration data ready Status parameter.

Data Types: uint8

The block outputs the number of pending samples to be read as a value ranging from 0-32.

Dependencies

This output port appears only if you select the Enable FIFO parameter.

Data Types: uint8

The block outputs the Click status of axes as a 1-by-3 vector (x,y,z) indicating on which axis the click has been detected. The axis value 1 indicates that the click is detected on that axis and 0 indicates that the click is not detected.

Dependencies

This output port appears only if you select the click status parameter.

Data Types: uint8

The block outputs inertial wake-up status as a 1-by-3 vector. This provides information of the axis, on which inertial wake-up is detected. The value 1 indicates that the inertial wake-up event is detected on the selected axis and value 0 indicates the event is not detected.

Dependencies

This parameter appears only if you select Inertial wake-up from Detect parameter and select Detection status parameter.

Data Types: uint8

The block outputs free-fall status. The value 1 indicates that the free-fall is detected on the selected axis and 0 indicates the interrupt is not detected.

Dependencies

This parameter appears only if you select Free-fall from Detect parameter and select Detection status parameter.

Data Types: uint8

The block outputs 6D position status as a 1-by-6 vector. The value 1 indicates that the 6D position interrupt is detected on the selected axis and 0 indicates the interrupt is not detected.

Dependencies

This parameter appears only if you select 6D position from Detect parameter and select Detection status parameter.

Data Types: uint8

The block outputs 6D movement status as a 1-by-6 vector. The value 1 indicates that the 6D movement interrupt is detected on the selected axis and 0 indicates the interrupt is not detected.

Dependencies

This parameter appears only if you select 6D movement from Detect parameter and select Detection status parameter.

Data Types: uint8

The block outputs 4D position status as a 1-by-4 vector. The value 1 indicates that the 4D position interrupt is detected on the selected axis and 0 indicates the interrupt is not detected.

Dependencies

This parameter appears only if you select 4D position from Detect parameter and select Detection status parameter.

Data Types: uint8

The block outputs 4D movement status as a 1-by-4 vector. The value 1 indicates that the 4D movement interrupt is detected on the selected axis and 0 indicates the interrupt is not detected.

Dependencies

This parameter appears only if you select 4D movement from Detect parameter and select Detection status parameter.

Data Types: uint8

Parameters

expand all

Main

Specify the module on the board that you are using for I2C communication.

The I2C addresses to communicate with the accelerometer peripheral on the LIS3DH sensor are decided by the state of the SA0 pin on the hardware board. This table provides the I2C addresses corresponding to the pin and their state.

Pin NamePin StateI2C Address
SA000x18
10x19

Select this parameter to set Acceleration as one of the output ports.

Select Temperature to set Temperature as one of the output ports or select Voltage (external input) to set ADC3 Voltage as one of the output port.

Select this parameter to set ADC1 Voltage as one of the output ports.

Select this parameter to set ADC2 Voltage as one of the output ports.

Select this parameter to set Acceleration status as one of the output ports.

Select the data register bit resolution for the sensor.

Select the output data rate at which accelerometer data is sampled.

Select the full scale for measuring linear acceleration (the range of acceleration that the sensor needs to measure).

Select this option to enable the option Number of samples to read from FIFO (1-32), which allows you to set the number of samples to be read.

Enter a value for number of samples (1-32) to be read from FIFO.

Dependencies

This parameter appears only if you select the Enable FIFO parameter.

Select this option to receive an interrupt if the FIFO buffer gets filled and the first sample is overwritten.

Dependencies

This parameter appears only if you select the Enable FIFO parameter.

Enable the high pass filter for reading accelerometer values.

Select the required bandwidth of the high pass filter for reading accelerometer values. The HPF cutoff frequency depends on the Accelerometer output data rate (Hz). The HPF cutoff frequencies for the selected Accelerometer output data rate (Hz) are shown in this table. The values 00, 01, 10, and 11 are the HPF mode configurations.

HPF cutoff frequency

HPF cutoff frequency[2:1]Acceleration output data rate - 1 HzAcceleration output data rate - 10 HzAcceleration output data rate - 25 HzAcceleration output data rate - 50 HzAcceleration output data rate - 100 HzAcceleration output data rate - 200 HzAcceleration output data rate - 400 HzAcceleration output data rate - 1600 HzAcceleration output data rate - 5376 Hz
000.020.20.5124832100
010.0080.080.20.51241650
100.0040.040.10.20.512825
110.0020.020.050.10.20.51412

Dependencies

This parameter appears only if you select the Enable high pass filter parameter.

If this option is selected, an interrupt is generated on pin INT1 of the sensor when data is ready, allowing you to trigger other subsystems to perform any action.

Specify the output data type for the values read from lis3dh sensor. The default data type for C2000 board is single. Use this parameter to change the values to double or int16, if required.

Specify how often this block reads the data from the LIS3DH sensor. When you set this parameter to -1, Simulink determines the best sample time for the block based on the block context within the model.

Click detection

Select this parameter to enable click detection.

Select the type of click to be detected. The available options are Single click and Double click.

Dependencies

This parameter appears only if you select Enable click detection parameter.

Specify the threshold for detecting single click or double click. When the value crosses the specified threshold value, click is detected.

Dependencies

This parameter appears only if you select Enable click detection parameter.

Specify the time limit value in seconds for detecting single click or double click. The click must occur during the specified time limit for detecting single click or double click.

Dependencies

This parameter appears only if you select Enable click detection parameter.

Specify the time latency value in seconds for detecting double click. The second click must occur after the specified time latency period for detecting a double click.

Dependencies

This parameter appears only if you select Enable click detection parameter and select Double click option for Type parameter.

Specify the time window value in seconds for detecting double click. The second click must occur before the time window period expires for detecting double click.

Dependencies

This parameter appears only if you select Enable click detection parameter and select Double click option for Type parameter.

Select this option to enable click detection along X axis. The value 1 indicates that the click is detected and 0 indicates that the click is not detected

Dependencies

This parameter appears only if you select Enable click detection parameter.

Select this option to enable click detection along Y axis. The value 1 indicates that the click is detected and 0 indicates that the click is not detected

Dependencies

This parameter appears only if you select Enable click detection parameter.

Select this option to enable click detection along Z axis. The value 1 indicates that the click is detected and 0 indicates that the click is not detected

Dependencies

This parameter appears only if you select Enable click detection parameter.

Select the option to generate an interrupt if a click is detected.

Dependencies

This parameter appears only if you select Enable click detection parameter.

If this option is selected, an interrupt is generated on pin INT1 or IN2 of the sensor when data is ready, allowing you to trigger other subsystems to perform any action.

Dependencies

This parameter appears only if you select Generate click interrupt parameter.

Select this parameter to set Click status [X,Y,Z] as one of the output ports.

Dependencies

This parameter appears only if you select Enable click detection parameter.

Configurable detections

Select the required option for the number of configurable detections.

Configurable detections 1

Select the required feature of the sensor. (Inertial wake-up, Free-fall, 6D position, 6D movement, 4D position, 4D movement).

Dependencies

This parameter appears only if you select 1 or 2 from Configurable detections parameter.

Select this option to enable the configurable event detection status on X axis. The value 1 indicates that the event is detected and 0 indicates that the event is not detected.

Dependencies

This parameter appears only if you select Inertial wake-up or 6D position or 6D movement or 4D position or 4D movement from Detect parameter.

Select this option to enable the configurable event detection status on Y axis. The value 1 indicates that the event is detected and 0 indicates that the event is not detected.

Dependencies

This parameter appears only if you select Inertial wake-up or 6D position or 6D movement or 4D position or 4D movement from Detect parameter.

Select this option to enable the configurable event detection status on Z axis. The value 1 indicates that the event is detected and 0 indicates that the event is not detected.

Dependencies

This parameter appears only if you select Inertial wake-up or 6D position or 6D movement from Detect parameter.

Select this option to enable the configurable event detection status on -X axis. The value 1 indicates that the event is detected and 0 indicates that the event is not detected.

Dependencies

This parameter appears only if you select 6D position or 6D movement or 4D position or 4D movement from Detect parameter.

Select this option to enable the configurable event detection status on -Y axis. The value 1 indicates that the event is detected and 0 indicates that the event is not detected.

Dependencies

This parameter appears only if you select 6D position or 6D movement or 4D position or 4D movement from Detect parameter.

Select this option to enable the configurable event detection status on -Z axis. The value 1 indicates that the event is detected and 0 indicates that the event is not detected.

Dependencies

This parameter appears only if you select 6D position or 6D movement from Detect parameter.

Specify the threshold for detecting the selected configurable detection. When the acceleration value crosses the specified threshold value, the event is detected.

Dependencies

This parameter appears only if you select 1 or 2 from Configurable detections parameter.

Specify the time limit for detecting the configurable event. To detect an event, the Threshold criteria must be satisfied for a minimum time equal to Duration.

Dependencies

This parameter appears only if you select 1 or 2 from Configurable detections parameter.

If this option is selected, an interrupt is generated for the selected configurable detection.

Dependencies

This parameter appears only if you select 1 or 2 from Configurable detections parameter.

If this option is selected, an interrupt is generated on pin INT1 or IN2 of the sensor when the configurable event is detected, allowing you to trigger other subsystems to perform any action.

Dependencies

This parameter appears only if you select the Generate interrupt parameter.

Note

Parameters for Configuration detections 2 are similar to Configuration detections 1. For information to configure these parameters, see Configurable detections 1.

Version History

Introduced in R2022b