Main Content

BMI160 IMU Sensor

Measure linear acceleration, angular rate, and temperature from BMI160 sensor

Since R2021b

Add-On Required: This feature requires the Simulink Support Package for Raspberry Pi Hardware add-on.

  • Raspberry Pi BMI160 IMU Sensor Block Icon

Libraries:
Simulink Support Package for Raspberry Pi Hardware / Sensors / IMU Sensors

Description

The BMI160 block outputs the values of linear acceleration and angular rate along x-, y- and z- axes as measured by the BMI160 sensor connected to Raspberry Pi® board. The block also outputs the temperature as read by the BMI160 sensor. If you connect the BMM150 as a secondary sensor to BMI160, the BMI160 block also outputs magnetic field along x-, y- and z- axes as measured by the BMM150 sensor.

The block supports Single tap, Double tap, High g detection, Any motion, Slow motion, Flat detection, and Data ready interrupts.

Interrupt source output is a 1-by-7 vector with elements corresponding to the source of single tap, double tap, high g detection, any motion, slow motion, flat detection, and data ready interrupts respectively. 1 indicates that it is the source, 0 indicates that it is not a source, and -1 indicates that the interrupt is not active.

Tap source output is a 1-by-4 vector, with the first three elements indicating whether the single tap / double tap occurred in X, Y and Z axis, and the fourth element indicating whether it is on positive or negative direction of the axis. High g source output is a 1-by-4 vector, with the first three elements indicating whether the High g interrupt occurred in X,Y and Z axis and the fourth element indicating whether it is on positive or negative direction of the axis. Any motion source output is a 1-by-4 vector which shows on which of the X,Y and Z axis did Any motion interrupt occur and whether it is on positive or negative direction of the axis. First byte denotes whether the event occurred on X axis, second byte denotes whether the event occurred on Y axis, third byte denotes whether the event occurred on Z axis and fourth byte denotes the direction. For direction byte 0 denotes negative side and 1 denotes positive and for other bytes 1 denotes that axis is the source and 0 denotes that axis is not the source.

When interrupts are enabled use external interrupt block and develop respective function call subsystem.

Examples

Ports

Output

expand all

Linear acceleration (in m/s2) measured by BMI160 sensor connected to Raspberry Pi board, along the x-, y- and z- axes, specified as a row vector [x,y,z].

Dependencies

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

Data Types: double

Angular rate (in rad/s) measured by BMI160 sensor connected to Raspberry Pi board, along the x-, y- and z- axes, specified as a row vector [x,y,z].

Dependencies

This output port appears only if you select the Angular rate (rad/s) parameter.

Data Types: double

Magnetic field strength (in µT) measured by a BMM150 sensor that is connected as a secondary sensor to BMI160 sensor, along the x-, y- and z- axes, specified as a row vector [x,y,z].

Dependencies

This output port appears only if you select the Enable secondary magnetometer and Magnetic Field (µT) parameters.

Data Types: double

Temperature (in ℃) measured by BMI160 sensor connected to Raspberry Pi board.

Dependencies

This output port appears only if you select the Temperature (℃) parameter.

Data Types: double

Status of acceleration 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: int8

Status of angular rate 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 Angular Rate Status parameter.

Data Types: int8

Status of magnetic field 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: int8

Interrupt source is a 1-by-7 vector which represents Single tap, Double tap, High g detection, Any motion, Slow motion, Flat detection, and Data ready interrupts.

Status of interrupt source 1 indicates that the interrupt enabled and it is the source of the generated interrupt, 0 indicates that the interrupt is enabled and it is not the source of the generated interrupt, and -1 indicates that the interrupt is not enabled.

Dependencies

This output port appears only if you select one of these parameters.

  • Single tap

  • Double tap

  • High g detection

  • Any motion

  • Flat detection

  • Data ready

Data Types: double

Tap event source is a 1-by-4 vector which represents Single tap or Double tap interrupt. The first three elements indicates if the interrupt occurred in X, Y and Z axis, and the fourth element indicates if it is on positive or negative direction of the axis. For direction, byte 0 denotes negative side, 1 denotes positive side and for other bytes 1 denotes that axis is the source and 0 denotes that axis is not the source.

Dependencies

This output port appears only if you select the Interrupt source parameter.

Data Types: int8

High g event source is a 1-by-4 vector which represents High g interrupt. The first three elements indicates if the interrupt occurred in X, Y and Z axis, and the fourth element indicates if it is on positive or negative direction of the axis. For direction, byte 0 denotes negative side, 1 denotes positive side and for other bytes 1 denotes that axis is the source and 0 denotes that axis is not the source.

Dependencies

This output port appears only if you select the Interrupt source parameter.

Data Types: int8

Any motion event source is a 1-by-4 vector which represents Any motion interrupt. The first three elements indicates if the interrupt occurred in X, Y and Z axis, and the fourth element indicates if it is on positive or negative direction of the axis. For direction, byte 0 denotes negative side, 1 denotes positive side and for other bytes 1 denotes that axis is the source and 0 denotes that axis is not the source.

Dependencies

This output port appears only if you select the Interrupt source parameter.

Data Types: int8

Parameters

expand all

The I2C module to be used for communication to the BMI160 sensor.

The I2C address used by BMI160 sensor communicating with the Raspberry Pi board.

If this option is selected, the block can read magnetometer data from a BMM150 sensor that is connected as a secondary sensor to BMI160.

The I2C address used by BMM150 sensor connected as a secondary sensor to BMI160 sensor.

Dependencies

This parameter appears only if you select the Enable secondary magnetometer parameter.

Select outputs

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

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

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

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

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

Select this parameter to set Angular Rate Status as one of the output ports.

Select this parameter to set Magnetic Field Status as one of the output ports.

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

Select this parameter to set Tap event source as one of the output ports.

Select this parameter to set High g event source as one of the output ports.

Select this parameter to set Any motion event source as one of the output ports.

Accelerometer Settings

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

Select the output data rate at which accelerometer data is sampled, which also determines the bandwidth.

Select this option to enable the low-pass filter for the acceleration values read from BMI160 sensor.

Select the filter mode for low pass filter for accelerometer values. The 3dB Cutoff frequency of the accelerometer depends on the value of this parameter and the ODR that you selected using the Accelerometer output data rate parameter.

Gyroscope settings

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

Select the output data rate at which gyroscope data is sampled, which also determines the bandwidth.

Select this option to enable the low-pass filter for the angular rate values read from BMI160 sensor.

Select the filter mode for low pass filter for gyroscope values. The 3dB Cutoff frequency of the gyroscope depends on the value of this parameter and the ODR that you selected using the Gyroscope output data rate parameter.

Magnetometer settings

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

Generate interrupts on

Note

Selecting one of these parameters (Single tap, Double tap, High g detection, Any motion, Slow motion, Flat detection, Data ready) overrides the availability of other status values at the output. The selection of parameters for other status outputs (Acceleration status, Angular rate status, and Magnetic field status) is disabled.

If this option is selected, an interrupt is generated on pin INT1 or INT2 of the sensor when single tap is triggered and following conditions are valid.

  • The tap occurs during the Shock Time threshold.

  • No tap occurs during the Quiet Time threshold.

Select the quiet time threshold for generating single tap or double tap interrupt. The tap must not occur during the specified quiet time threshold for generating single tap or double tap interrupt.

Dependencies

This parameter appears only if you select the Single tap parameter or Double tap parameter.

Select the shock time threshold for single tap or double tap interrupt. The tap must occur during the specified shock time threshold for generating single tap or double tap interrupt.

Dependencies

This parameter appears only if you select Single tap parameter or Double tap parameter.

Specify the amplitude threshold value ranging from 0.03125g - 1.96875g for detecting a single tap or double tap. When the value crosses the specified amplitude threshold value, a tap occurs. Amplitude threshold has minimum and maximum range which depends on the accelerometer range.

Dependencies

This parameter appears only if you select the Single tap parameter or Double tap parameter.

Select the pin on which the single tap interrupt, which can be used by the Raspberry Pi board, gets generated on the sensor.

Dependencies

This parameter appears only if you select the Single tap parameter.

If this option is selected, an interrupt is generated on pin INT1 or INT2 of the sensor when double tap is triggered and following conditions are valid.

  • The first tap occurs during the Shock Time threshold.

  • No tap occurs during the Quiet Time threshold.

  • The second tap occurs during the Duration Time threshold.

Select the duration time threshold for double tap interrupt. The second tap must occur during the specified duration time threshold for generating double tap interrupt.

Dependencies

This parameter appears only if you select Double tap parameter.

Select the pin on which the double tap interrupt, which can be used by the Raspberry Pi board, gets generated on the sensor.

Dependencies

This parameter appears only if you select the Double tap parameter.

If this option is selected, an interrupt is generated on pin INT1 or INT2 of the sensor when high g interrupt is detected.

Specify the time threshold value ranging from 2.5 ms to 640 ms for high g interrupt. The high g detection must occur during the specified time threshold for generating high g interrupt.

Dependencies

This parameter appears only if you select High g detection parameter.

Specify the amplitude threshold value ranging from 0.00391g - 1.99546g for detecting a high g interrupt. When the value crosses the specified amplitude threshold value, high g interrupt is detected. Amplitude threshold has minimum and maximum range which depends on the accelerometer range.

Dependencies

This parameter appears only if you select the High g detection parameter.

Select the pin on which the high g interrupt, which can be used by the Raspberry Pi board, gets generated on the sensor.

Dependencies

This parameter appears only if you select the High g detection parameter.

If this option is selected, an interrupt is generated on pin INT1 or INT2 of the sensor when any motion interrupt is detected.

Select the time threshold value for any motion interrupt. The any motion detection must occur during the specified time threshold.

Dependencies

This parameter appears only if you select Any motion parameter.

Specify the amplitude threshold value ranging from 0.00195g - 0.999g for detecting any motion interrupt. When the value crosses the specified amplitude threshold value, any motion interrupt is detected. Amplitude threshold has minimum and maximum range which depends on the accelerometer range.

Dependencies

This parameter appears only if you select Any motion parameter.

Select the pin on which the any motion interrupt, which can be used by the Raspberry Pi board, gets generated on the sensor.

Dependencies

This parameter appears only if you select the Any motion parameter.

If this option is selected, an interrupt is generated on pin INT1 or INT2 of the sensor when slow motion interrupt is detected.

Select the time threshold value for slow motion interrupt. The slow motion detection must occur during the specified time threshold.

Dependencies

This parameter appears only if you select Slow motion parameter.

Specify the amplitude threshold value ranging from 0.00195g - 0.999g for detecting slow motion interrupt. When the value crosses the specified amplitude threshold value, slow motion interrupt is detected.

Dependencies

This parameter appears only if you select Slow motion parameter.

Select the pin on which the slow motion interrupt, which can be used by the Raspberry Pi board, gets generated on the sensor.

Dependencies

This parameter appears only if you select the Slow motion parameter.

If this option is selected, an interrupt is generated on pin INT1 or INT2 of the sensor when flat detection interrupt is detected.

Specify the amplitude threshold value ranging from 0.7° - 44.8° for detecting flat detection interrupt. When the value crosses the specified amplitude threshold value, flat detection interrupt is detected.

Dependencies

This parameter appears only if you select Flat detection parameter.

Select the time threshold value for flat detection interrupt. The flat detection interrupt must occur during the specified time threshold.

Dependencies

This parameter appears only if you select Flat detection parameter.

Select the pin on which the flat detection interrupt, which can be used by the Raspberry Pi board, gets generated on the sensor.

Dependencies

This parameter appears only if you select the Flat detection parameter.

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

Select the pin on which the data ready interrupt, which can be used by the Raspberry Pi board, gets generated on the sensor.

Dependencies

This parameter appears only if you select the Enable data ready interrupt parameter.

Specify the output data type for the values read from BMI160 sensor. The default data type for Raspberry Pi board is single. Use this parameter to change the values to double, if required.

Specify how often this block reads the data from the BMI160 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.

Version History

Introduced in R2021b