LSM303C IMU Sensor
Measure linear acceleration, magnetic field strength, and temperature from LSM303C sensor
Since R2021a
Add-On Required: This feature requires the Simulink Support Package for Arduino Hardware add-on.
Libraries:
Simulink Support Package for Arduino Hardware /
Sensors
Description
The LSM303C IMU Sensor block outputs the values of linear acceleration and magnetic field strength along x-, y- and z- axes as measured by the LSM303C sensor connected to Arduino board. The block also outputs the temperature as read by the LSM303C sensor.
Ports
Output
Acceleration — Linear acceleration measured by LSM303C sensor
row vector
Linear acceleration (in m/s2) measured by LSM303C
sensor connected to Arduino board, along the x-, y- and z- axes, specified as a
n
-by-3 vector, where n
is the
value specified as Samples per frame.
Dependencies
This output port appears only if you select the Acceleration (m/s2) parameter.
Data Types: double
Magnetic Field — Magnetic field strength measured by LSM303C sensor
row vector
Magnetic field strength (in µT) measured by LSM303C sensor connected to Arduino
board, along the x-, y- and z- axes, specified as a n
-by-3
vector, where n
is the value specified as Samples per frame.
Dependencies
This output port appears only if you select the Magnetic Field (µT) parameter.
Data Types: double
Temperature — Temperature measured by LSM303C sensor
scalar
Temperature (in ℃) measured by LSM303C sensor connected to Arduino board.
Dependencies
This output port appears only if you select the Temperature (℃) parameter.
Data Types: double
Acceleration Status — Status of acceleration value
0
| 1
Status of acceleration value along the three axes, specified as a row vector in
the order [z,y,x], to indicate if the data read is the new value or not.
0
indicates that the data read is new and 1
indicates that the data read is not new.
Dependencies
This output port appears only if you select the Acceleration Status parameter.
Data Types: Boolean
Magnetic Field Status — Status of magnetic field value
0
| 1
Status of magnetic field value along the three axes, specified as a row vector in
the order [z,y,x], to indicate if the data read is the new value or not.
0
indicates that the data read is new and 1
indicates that the data read is not new.
Dependencies
This output port appears only if you select the Magnetic Field Status parameter.
Data Types: double
Timestamp — Timestamp at which data is read
matrix | (n
)-by-1
Timestamp (in seconds) at which data is read from the sensor, returned as
n
-by-1 matrix, where n
is the
value specified as Samples per frame.
Dependencies
This output port appears only if you select the Timestamp parameter.
Data Types: double
Parameters
I2C module — I2C communication module
0
(default) | scalar
Specify the I2C module on the Arduino® hardware to communicate with sensor peripherals. For more information on the Arduino pin mapping and modules that hardware boards support, see Pin Mapping for Arduino Timer Independent Blocks.
Acceleration (m/s2) — Set output port for reading acceleration
on
(default) | off
Select this parameter to set Acceleration as one of the output ports.
Magnetic Field (µT) — Set output port for reading magnetic field
on
(default) | off
Select this parameter to set Magnetic Field as one of the output ports.
Temperature (℃) — Set output port for reading temperature
on
(default) | off
Select this parameter to set Temperature as one of the output ports.
Acceleration Status — Set output port for obtaining acceleration status
off
(default) | on
Select this parameter to set Acceleration Status as one of the output ports.
Magnetic Field Status — Set output port for obtaining magnetic field status
off
(default) | on
Select this parameter to set Magnetic Field Status as one of the output ports.
Timestamp — Set output port for obtaining timestamp
off
(default) | on
Select this parameter to set Timestamp as one of the output ports.
Samples per frame — Number of samples that the block outputs
1
(default) | positive integer
Specify the number of samples that the block outputs.
The value that you specify here is also used to compute the output sample time:
Output sample time = Samples per frame
*
Sample time
.
Sample time — Time interval to read data
-1
(default) | positive integer
Specify how often this block reads the data from the LSM303 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. The output sample time is the product of
Samples per frame
and Sample
time
that you specify.
Accelerometer range — Full scale for measuring linear acceleration
±2g
(default) | ±4g
| ±8g
Select the full scale for measuring linear acceleration (the range of acceleration that the sensor needs to measure).
Accelerometer output data rate — Rate at which accelerometer data is sampled
10 Hz
(default) | 50 Hz
| 100 Hz
| 200 Hz
| 400 Hz
| 800 Hz
Select the output data rate at which accelerometer data is sampled, which also determines the bandwidth.
Magnetometer range — Full scale for measuring magnetic field
±16 gauss
(default)
Select the full scale for measuring linear acceleration (the range of acceleration that the sensor needs to measure).
Magnetometer output data rate — Rate at which magnetometer data is sampled
0.625 Hz
(default) | 1.25 Hz
| 2.5 Hz
| 5 Hz
| 10 Hz
| 20 Hz
| 40 Hz
| 80 Hz
Select the output data rate at which magnetometer data is sampled.
Version History
Introduced in R2021a
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)