Need help with getting acceleration without gravity using mpu9250 on a swing

I'm having big troubles finding the speed of a childrens swing seat independent from its tilt. I believe this is called aceleration without gravity / acceleration in world frame / linear acceleration.

I installed an arduino, nodemcu with mpu9250 imu on a swing seat and light it up with movement using fastled library and ws2812b leds.

The swing seat is tilted towards the end of its swing which means some acceleration is on the mpu, and this is exactly when I want the swing to be dark. So when its swinging it lights up and at the end of its swing, it should be dark.

The final current version of it is here:

There is some info on getting this acceleration value on

however these information definetely exceeds my capacity. Is anyone familiar with any library or any methods which I can use to get the speed of this simple swing?

Sounds like you need to open up the old kinematics textbook and write your own, I haven't heard of a library for this personally, nice project

1 Like

thank you, thats exactly what im trying to avoid. :slight_smile: Its rather odd that there are no easy ways to get this measurement yet.

The reason that you are having trouble finding "easy ways to get this measurement" (remove the acceleration due to gravity) is that in actual practice, this is not possible with consumer grade IMUs.

To do so, you need to know the 3D orientation of the IMU very accurately. This page discusses and illustrates the problem: https://web.archive.org/web/20180112063505/http://www.chrobotics.com/library/accel-position-velocity

1 Like

If it's just for visual effects, why do you need that specific measurement? Can't you just graph the three raw acceleration values and find some useful patterns to trigger your effects? If you have a laptop you can live-graph the data with Serial Plotter.

1 Like

yes I use serial plotter. The raw acceleration values dont seem to help because of the 3 different states of the swing:
#1: not swinging initially, the seat doesnt move. acceleration value is zero so the leds are dark.
#2: the swing is moving and swinging so the leds get brighter with the swing of the seat
#3: the swing moves to one end and stops for a brief moment. This is the trouble point. This is when the swing should slowly go all the way dark. however because the seat is tilted the swing registers acceleration on the axis and does not go completely dark.

This might have some work around through measuring x axis for the swing movement and then the y axis for the tilt . This seems like a simple problem regarding measuring values on certain axises but i couldn't figure out.

from what i see the errors for each angle degree tilt cause in acceleration readings seems to be a linear value. I'm still hoping to offset these errors with simple arithmetic functions for just the use on a swing.

Except that the acceleration value is not 0. It is 1G downward because of gravity. Are you using only one axis? What happens if you graph all three?

Consider using an IMU with a gyroscope. At state #1, all three axis with read 0 (zero). At state #2, at least 1 gyro's will read non-zero. At state #3, all three gyro axis should be zero.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.