# How to simulate an accelerometer in code

I want to write a simulation of an accelerometer (with a fixed X and Y axis in this case but with respect to a world coordinate frame) on a stick, rotating in a circle around a fixed point. From that I want to figure out the tangential acceleration along the arc. I know the velocity omega but I do not know the length of the stick.

My problem is that I don't quite understand how to simulate the accelerometer, especially dealing with the rotations. Between time steps t1 and t2 the stick rotates by an angle theta and from that I can calculate the new position and rotation of the accelerometer point (one point is enough to calculate the accelerations from my understanding).

What values do I take now to calculate the acceleration in X and Y at each timestep and thereafter get the tangential acceleration?

Thanks for the help!

• You know this problem can be solved analytically, right? In any case, to compute the acceleration you require three consecutive data points: $\vec{a}(t)=[\vec{x}(t+\Delta t)+\vec{x}(t-\Delta t)-2\vec{x}(t)]/\Delta t^2+\mathcal{O}(\Delta t^2)$ Apr 14, 2016 at 14:56
• accelerometers - physically there are many ways to transduce acceleration into a signal. In general , most if not all accelerometers measure in a single axis so multiple sensors are needed for multi-axis measurement. None are perfect, so they do have cross axis coupling. To resolve axial forces into the body frame in 2D or 3D use Euler or quaternion transformations. Apr 14, 2016 at 16:08
• Thanks lemon I will try out the formula, but I am not sure what the last term means: O(Δt^2), what's the O? How do I then split up the acceleration to get the tangential acceleration or is this already the tangential acceleration? Apr 14, 2016 at 16:13
• Re I know the velocity omega but I do not know the length of the stick. Then you are out of luck. Apr 14, 2016 at 17:24

\begin{aligned} a_{tangential} & = \dot{\omega} \ell \\ a_{centripetal} & = \omega^2 \ell -g \end{aligned}
\begin{aligned} a_X & = \dot{\omega} \ell \cos\theta -\ell \omega^2 \sin \theta \\ a_Y & = \omega^2 \ell \cos\theta+\ell \dot{\omega} \sin\theta -g \end{aligned}