cancel
Showing results for 
Search instead for 
Did you mean: 

Tilt angle on a bicycle using ISM330BX

JosepNiche
Associate

I'm using an IMU ISM330BX on my electric bicycle, and I want to detect while I'm cycling, if I'm ascending or descending a climb, and then calculate which is the angle in degrees or percentage of the slope. For this I'm using Sensor Fusion Function SFLP, which combines accelerometer and gyroscope data, and using the Gravity Vector to calculate the Pitch.

When I'm static, not moving the bicycle forward or backward, just lift the front wheel while the rear wheel touches the ground, simulating pedaling uphill. The results are quite good and I can calculate the pitch and transform to degrees.

The problem rise when I'm pedalling, then exists acceleration and decelerations, in this situation I can not distinguish if there is a slope (positive or negative) because these accelerations forces are masking the pitch. I tested different filter options trying to acquire the best results, but It doesn't matter which filter option I choose that always I found the same problem.

I attached a picture called Pitch.png, where I'm just pedalling on a flat surface accelerating and then braking. As you can see Pitch measurement is really affected by accelerations forces.

Do you know how I can process pitch data in order to eliminate these accelerations forces and only measure pitch due tilt angle? or which configuration on the IMU I need to change to have better results?

The current configuration I have is this, values are decimal.

Captura de pantalla 2025-11-19 163025.png

Thanks in advance

2 REPLIES 2
Federica Bossi
ST Employee

Hi @JosepNiche ,

You could implement a complementary filter or Kalman Filter that model vehicle dynamics to separate gravity from dynamic accelerations.

Otherwise, you could fuse gyroscope data for angle integration: integrate gyroscope angular velocity to estimate pitch, then fuse with accelerometer data to reduce drift and improve stability.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi @Federica Bossi 

Thanks for your reply. I'm a little confuse, I thought SFLP algorithm is doing some kind of Complementary or Kalman filter, but seems is not doing it. Do you have more information regarding SFLP algorithm, just to understand better which is the advantages of used it instead of using the raw data from accel and gyro.

Regarding the solution proposed, I will start trying the Complementary filter. Just to be align, I must used the output raw  separately from accelerometer and gyroscope, not the SFLP output.

The equation is as follows,

JosepNiche_1-1764323791769.png

Where:

α (alpha): The weighting factor (or trust factor) that determines the contribution of each sensor. From 0 to 1.

g: the raw gyroscope data in radians per second

f_fil_rate : filter update rate

a: is the rotation angle calculated from the accelerometer data

JosepNiche_4-1764324345686.png 

Also I suppose that I still can use the configuration that I'm applying (current config is the picture on the previous message) regarding register CTRL 6, 7, 8, 9  and disable SFLP.

Regarding register configuration I'm not sure if the configuration I'm using is the better configuration or not, I'm not completely sure to understand the real contribution or affect of each configurable parameter. I've tested several combination of register configuration and I'm using the one which give me better results . Also do you have more information or explanation about the contribution of each configurable parameter?

Thanks for the support.