# How to calculate an exaggerating variable based on accelerometer input.

I am building a scale RC model with active suspension that is trying to simulate weight and mimic a real car’s suspension behavior to avoid it moving like a toy as much as I can. So far I have it getting the acceleration data from a MPU6050 and leaning the car forward/backward and sideways.I want to take it to the next level and create a function that takes the acceleration of an axis as input and outputs a variable that lags in its ability to change direction or suddenly stop changing. See the graph in attachment for a better explanation. The red line is the input data and I want to be able to output the blue line. See how it takes longer to switch from increasing to decreasing and overshoots at the end where the input stops at 0, and then continues to oscillate until it attenuates.

This is exactly what a digital filter will do - you need to characterize the response of the system you want to emulate, either as an impulse response or equation. The latter can be converted to poles and zeroes.

If the response is non-linear you'll need to simulate more accurately as the linear approximation doesn't apply.

Thank you for pointing me in a direction. I did some reading up and even though I have some basic knowledge of filters from UNI I am still mostly lost. Would that be an IIR filter I need to use to create the attenuating wobble?

EDIT
I just tried a two pole IIR filter with a low dampening factor and it did exactly what I need (graph in attachment). I got it from here:
https://playground.arduino.cc/Code/Filters