Let us try to solve this problem from a theoretic view point.
Let us assume that we have a particle that is moving “smoothly” on a straight line path, and its position at time t is given by s(t). In this case its velocity will be described by v(t)=s’(t) and its acceleration by a(t)=v’(t)=s’’(t).
We want to find t0’s such that the motion of the particle changes direction (that is why the assumption that the particle moves on a straight line path, otherwise it does not make sense to change direction). To change direction means that the position has reached a maximum or minimum value, that is why it has to change direction (cannot continue increasing or decreasing the position respectively). In terms of v(t) this is equivalent to have found t0 such that v(t0)=0.
We know that those t0’s such that v(t0)=0 are the critical points of s(t), and we know there are critical points that are not maximum nor minimum, in order to guarantee that we have found a critical point that is maximum or minimum we need to know that v(t) changes sign near by t0.
Now if we use an accelerometer then we have that v(t)=v0+integral from 0 to t of the acceleration function, where v0 is the value of the velocity of the particle at the beginning of the experiment at time t=0. We are trying to find t0 such that -v0=integral from 0 to t0 of the acceleration function.
If we can measure the initial velocity v0 then we can solve numerically the problem, as long as we know the sampling time of the accelerometer.
suppose we are sampling at certain frequency rate f, that means that we are sampling every 1/f seconds, we can then estimate v(t) as: v0+1/f* sum of the values obtained from the accelerometer until time t. Since we want t0 be such that v(t0)=0 then we are trying to find t0 such that sum of the values obtained by the accelerometer until time t0 = -v0*f.
But this is not enough since we need to guarantee that v(t) changes sign at t0, that is we need to know that the signs of v(t) right before and right after do not match.
A naive algorithm for this could be to
1.- setup a threshold to detect when v(t0)=0, say anything smaller that this threshold (in absolute value) is considered zero
2.- Measure v0, if you could start your experiment under the assumption that v0 = 0 then it is easier.
3.- Determine the sampling frequency of the accelerometer.
3.- Compute the cumulative sum of that values returned by the accelerometer
4.- If this value it is within +/- the threshold away from v0*f and the product of the previous cumulative sum and the next cumulative sum is negative then t0 has been found.
In order to be able to execute step 4, you wont be able to capture t0 but one sampling later, and you need to keep the cumulative sum for three samplings in a row.
I hope I am explaining my self.