Looking fo a sensor that can detect "movment changing direction"

Hi,
I need to put a sensor on the Arduino that can tell me when the direction of the movement has changed.
Not like gyro, I don’t want to find AXIS position, only physical movement.

lets say when I move my hand UP and DOWN → the arduino will tell me when I change the movement direction.

is there a sensor for this action?

I hope I was clear enough.

Thanks!
:slight_smile:

Untitled.gif

A change in the speed or direction of movement requires an acceleration therefore your first thought might be an accelerometer, of which there are many that and Arduino can read.

However, without knowing what it is you will actually use it for it's hard to guess whether it will be suitable because it would also detect, for example, a slowing of the movement in the existing direction (also an acceleration) so it may be important how clearly you need to distinguish a change in speed from a change in direction. Can you describe the project and what you require of it in any more detail?

An accelerometer won't do it because it will only tell you how quickly a velocity is changing. It won't tell you when a velocity reverses.

Motion has to be measured relative to something. You could use a distance sensor to measure the distance from a hand to a table or floor. When the distance goes from increasing to decreasing the motion as changed from away/up to toward/down.

Hi, Thanks for the response.

Distance sensor is too expensive I think (start with 18$) http://www.ebay.com/itm/New-Arduino-Sharp-GP2D12-Infrared-IR-Range-Sensor-Cable-/400264698920?pt=LH_DefaultDomain_0&hash=item5d31a29c28

Is there another way to notice movement direction? (like when a ball is bouncing, I want to know when it change the direction (up\down) )

Thanks again :)

Detecting the change from up to down is hard because the ball is in free-fall the whole way up and down.

Detecting the change from down to up is much easier because the ball makes a thump when it bounces.

Perhaps if you tell up what you are trying to do rather than how you think you need to do it we can come up with a workable solution.

The best way to envision what I'm looking to accomplish is think of a plumb bob hanging from a string. I need a way that I can sense if it is moved approx. 1/2" + in either direction, left, right, forward, back. The amount of movement (sensitivity) would be based on a threshold that I will set based on the values of 0-1023.

Any direction to solving this would be greatly appreciated.

HDRK: The best way to envision what I'm looking to accomplish is think of a plumb bob hanging from a string. I need a way that I can sense if it is moved approx. 1/2" + in either direction, left, right, forward, back. The amount of movement (sensitivity) would be based on a threshold that I will set based on the values of 0-1023.

Any direction to solving this would be greatly appreciated.

The plumb bob is easy compared to Guy P's problem. You can put a light on the bob and an LDR under it. As the bob moves the amount of light on the LDR is reduced. You can use a pair of capacitor plates, one attached to the bob and one below it. As the bob moves the capacitance will change. That can be used to change an oscillator frequency and the frequency used to detect displacement.

LDR seems to be a great idea :)

I'll try to sample the path for the first direction , and try to guess when the direction is changing (by compare it to the last samples)

Thanks!

johnwasser: An accelerometer won't do it because it will only tell you how quickly a velocity is changing. It won't tell you when a velocity reverses.

Motion has to be measured relative to something. You could use a distance sensor to measure the distance from a hand to a table or floor. When the distance goes from increasing to decreasing the motion as changed from away/up to toward/down.

I think you could be wrong there. To measure velocity you simply integrate acceleration and to measure displacement you integrate velocity. Therefore when there is a position change (second integration of acceleration) there is a change of both acceleration and velocity until the new position is attained.

jackrae:

johnwasser: An accelerometer won't do it because it will only tell you how quickly a velocity is changing. It won't tell you when a velocity reverses.

Motion has to be measured relative to something. You could use a distance sensor to measure the distance from a hand to a table or floor. When the distance goes from increasing to decreasing the motion as changed from away/up to toward/down.

I think you could be wrong there. To measure velocity you simply integrate acceleration and to measure displacement you integrate velocity. Therefore when there is a position change (second integration of acceleration) there is a change of both acceleration and velocity until the new position is attained.

Everything on or near the surface of the Earth is accelerating downward at 1G. If you integrate that over time then all of us would have a very high downward velocity. To 'subtract out' the gravity vector you need to know the orientation of the device relative to the gravity vector... while the device is under acceleration from unknown outside forces. If you get the gravity vector wrong that error gets integrated over time.

Physics is all very neat in thought experiments but in practice it gets messy fast!

Accelerometers are one of the simplest and most useful sensors used to measure vibration components of velocity and displacement without facing problems of the 1G force of gravity. In its most basic form the sensor comprises a magnetic mass suspended in a coil. If the device the accelerometer is attached to is experiencing forces due to an "external" or universal acceleration, say gravity or (for the sake of argument) the expansion of the universe, then the accelerometer sensor is experiencing a similar effect and hence there is no relative acceleration, velocity or displacement between the device and the sensor, so no compound error exists.

Either that or all those who build systems of acceleration, velocity and displacement measurement have got it all wrong.

Here is the output of an accelerometer moving up and down, as you can see it’s centered around 1g. I think it would be fairly easy to determine when it’s changing direction.

updown.jpg

John,

The LDR would be perfect but it won't work in my application because the sensor would have to be totally contained within the plumb bob. If I could use an accelerometer and set the initial values to zero on x,y, and z axis then based on a value I set on a threshold it would trigger the movement detected trigger.

wayneft:
Here is the output of an accelerometer moving up and down, as you can see it’s centered around 1g. I think it would be fairly easy to determine when it’s changing direction.

The graph does show when the ACCELERATION is changing direction (acceleration/deceleration), not when the motion (velocity) is changing direction. Suppose an ball is accelerated upward at 1G for 1 second. It will then be traveling 32 feet per second upward. Even if the acceleration stops and gravity takes over the ball will continue upward for another second.

Hello, I see this topic is old. However I am hoping someone may stumble on it and enlighten those of us trying to find a way to make something happen when there is a direction change. I have gyros, encoders, step motors and about every toy to go with Arduino. I have been learning a lot of coding which really doesn't interest me. I just want to make the project I started all of this for to work. I can make servo and step motors mimic the encoders and various sensors positions. However I only want to trigger an event when there is a change in motion. For instance when an encoder or distance sensor reads 21 22 23 24 23 22 21, when it falls from 24 to 23 I would instruct a stepper motor to go to a certain position. I would be reading from -90 to plus 90 at a frequency of 1 to 2 seconds.

Also, I would like to know if there are more precise affordable sensors out there than the stuff marketed with /for Arduinos.

ADNS 3080 Optical Flow Sensor. 12 bucks and it will tell you what direction the motion in front is going.

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.