LIS3DH Accelerometer Sensor
Measure linear acceleration, voltage, and temperature from LIS3DH sensor
- Library:
Simulink Support Package for Arduino Hardware / Sensors
Description
The LIS3DH Accelerometer Sensor block measures linear acceleration, voltages at ADC inputs, and temperature using the LIS3DH Accelerometer sensor interfaced with the Arduino® hardware.
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.
Ports
Output
Acceleration
— Acceleration along each axis as measured by accelerometer
vector
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
ADC1 Voltage
— Voltage on ADC1 pin
vector
The block outputs voltage applied on ADC1 pin 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
ADC2 Voltage
— Voltage on ADC2 pin
vector
The block outputs voltage applied on ADC2 pin 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
ADC3 Voltage
— Voltage on ADC3 pin
vector
The block outputs voltage applied on ADC3 pin 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
— Temperature measured by LIS3DH sensor
scalar
Temperature (in ℃) measured by LIS3DH sensor connected to Arduino board.
Dependencies
This output port appears only if you select
Temperature
for ADC3 input
parameter.
Data Types: single
| double
| int16
Status
— Status of acceleration measurement
2
| 0
| 1
The block outputs the status of acceleration measurement 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 Status parameter.
Data Types: uint8
Samples pending
— Number of pending samples
scalar
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
Parameters
I2C address
— I2C addresses to communicate with sensor peripherals
0x18
(default) | 0x19
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 Name | Pin State | I2C address |
---|---|---|
SA0 | 0 | 0x18 |
1 | 0x19 |
Acceleration (m/s2)
— Set output port for reading acceleration
on
(default) | off
Select this parameter to set Acceleration as one of the output ports.
ADC3 input
— Select output port for reading temperature or voltage
None
(default) | Temperature
| Voltage (external input)
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.
Voltage (external input at ADC1)
— Select output port for reading voltage
off
(default) | on
Select this parameter to set ADC1 Voltage as one of the output ports.
Voltage (external input at ADC2)
— Select output port for reading voltage
off
(default) | on
Select this parameter to set ADC2 Voltage as one of the output ports.
Status
— Set output port for obtaining status of selected outputs
on
(default) | off
Select this parameter to set Status as one of the output ports.
Generate data ready interrupt
— Generate interrupt when data is ready
off
(default) | on
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.
Accelerometer range
— Full scale for measuring linear acceleration
±16g
(default) | ±2g
| ±4g
| ±8g
Select the full scale for measuring linear acceleration (the range of acceleration that the sensor needs to measure).
Accelerometer resolution
— Data register bit resolution
12bit
(default) | 10bit
| 8bit
Select the data register bit resolution for the sensor.
Accelerometer output data rate (Hz)
— Rate at which accelerometer data is sampled
1344 Hz
(default) | 1 Hz
| 10 Hz
| 25 Hz
| 50 Hz
| 100 Hz
| 200 Hz
| 400 Hz
| 1600 Hz
| 5376 Hz
Select the output data rate at which accelerometer data is sampled.
Enable FIFO
— Enable number of samples to read
off
(default) | on
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. When FIFO is enabled, oldest set of samples from the buffer are read first and newest set of samples are read last.
Number of samples to read from FIFO (1-32)
— Number of samples to read
2
(default)
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.
Enable high pass filter
— Enable high pass filter for accelerometer data
off
(default) | on
Enable the high pass filter for reading accelerometer values.
HPF cutoff frequency (Hz)
— Bandwidth of high pass filter
100 Hz
(default) | 12 Hz
| 25 Hz
| 50 Hz
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[2:1] | Acceleration output data rate - 1 Hz | Acceleration output data rate - 10 Hz | Acceleration output data rate - 25 Hz | Acceleration output data rate - 50 Hz | Acceleration output data rate - 100 Hz | Acceleration output data rate - 200 Hz | Acceleration output data rate - 400 Hz | Acceleration output data rate - 1600 Hz | Acceleration output data rate - 5376 Hz |
---|---|---|---|---|---|---|---|---|---|
00 | 0.02 | 0.2 | 0.5 | 1 | 2 | 4 | 8 | 32 | 100 |
01 | 0.008 | 0.08 | 0.2 | 0.5 |
| 2 | 4 | 16 | 50 |
10 | 0.004 | 0.04 | 0.1 | 0.2 | 0.5 | 1 | 2 | 8 | 25 |
11 | 0.002 | 0.02 | 0.05 | 0.1 | 0.2 | 0.5 | 1 | 4 | 12 |
Dependencies
This parameter appears only if you select the Enable high pass filter parameter.
Sample time
— Time interval to read data
-1
(default) | positive integer
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.
Model Examples
Version History
Introduced in R2022b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)