1
\$\begingroup\$

I am using an accelerometer ADXL206 and a microcontroller PIC16F917 to determine the relative linear motion of a device that functions according to this motion.

I can read data from the accelerometer:

  • It gives an output of 2.5 @ no Motion
  • It gives an output of 2.5 + 0.312 Volts per 1g Right
  • It gives an output of 2.5 + 0.312 Volts per 1g Left

I have a device with 2 LEDs to determine direction of motion. It should work like this:

  • start of the program: LEDs off
  • right motion: red LED on and stays so. Blue LED off. even when the device stops motion
  • left motion: blue LED ON and stays on. Red LED off. even when the device stops motion

The real results I get is when the device moves, it blinks the LED only during motion then they are OFF during no motion.

I cannot get the direction from the Accelerometer and stay in a stable state.

Is the problem in reading the values from the accelerometer or in the algorithm?

\$\endgroup\$
  • 2
    \$\begingroup\$ Insufficient information. You need to describe the problem properly. \$\endgroup\$ – Leon Heller Apr 17 '13 at 12:04
  • \$\begingroup\$ I need to use the accelerometer as a motion detection and direction detection switch. Then have stable state of my device. For example, Motion from stability to right lights up red LED and stays ON , And motion from stability to Left Turns ON a Blue LED and Turns the RED LED OFF \$\endgroup\$ – Swiftmind Apr 17 '13 at 12:35
  • \$\begingroup\$ Where's your source code? \$\endgroup\$ – Dave Tweed Apr 17 '13 at 12:39
  • \$\begingroup\$ Please provide source code and schematics. \$\endgroup\$ – Renan Apr 17 '13 at 13:49
  • \$\begingroup\$ The current description of the desired behaviour of the device should be trivial to implement: simply stop reading from the accelerometer once one of the two LEDs was turned on. However, I suspect that's not really what you want, but rather that you then want to detect motion in the opposite direction. For that Anindo's answer provides reasons why this is non-trivial with an accelerometer. \$\endgroup\$ – fm_andreas Apr 17 '13 at 18:06
6
\$\begingroup\$

The device containing the accelerometer is experiencing a force (of x G) momentarily, against the direction of acceleration, when the motion starts. Then it will experience 0 Gees as acceleration stops, i.e. once the target speed has been achieved.

Similarly, when bringing the device to a standstill from constant velocity, it will experience a momentary force opposing the deceleration, then zero force again once it comes to a standstill.

That is what your experiment reports - the LEDs flash when the acceleration is experienced, once in each direction. In other words, the behavior is as designed.

For keeping an indication on as long as motion continues, an accelerometer is not the ideal device. It is not a motion detector, it is an acceleration detector, as the name implies.

While some simple software trickery (integrating the acceleration over time) could be used to track when acceleration is felt in one direction or the other, such a mechanism would fail if the deceleration (or acceleration) force is very low compared to the sensitivity and sense signal noise floor, such as if one were to accelerate the device very sloooooowly, but bring it to a halt rapidly, or vice versa.

\$\endgroup\$
  • \$\begingroup\$ Thank you. I need indication is ON even when the device stops motion. It 's meant to sense the burst of motion. Not the motion itself. \$\endgroup\$ – Swiftmind Apr 17 '13 at 14:32
  • \$\begingroup\$ @PhilFrost Yes, you're right... Edited it to make sense now. Thanks. :-) \$\endgroup\$ – Anindo Ghosh Apr 17 '13 at 17:05
  • \$\begingroup\$ @Swiftmind I'm not sure I understand your comment, it seems to be contradicting itself: If you want the LED on even when the motion stops, just plug in an LED in series with a resistor, no other electronics required. If you want to sense the burst of motion (which presumably means acceleration in your terminology), then the moment that acceleration stops i.e. there is no more acceleration (change of velocity), the indication will stop, which is what you say is happening. \$\endgroup\$ – Anindo Ghosh Apr 17 '13 at 17:08
1
\$\begingroup\$

An accelerometer doesn't measure motion: it measures change in motion. Or more accurately, it measures the derivative of velocity. So, when your accelerometer begins to move in a direction, you can detect that. But once you are moving, and you are no longer accelerating, to the accelerometer, it might as well be sitting on your desk. The only thing you will be measuring is noise and the constant acceleration of gravity.

An analogy would be this: if you can't see, and you can't hear wind and road noise, and the windows are up so you can't feel wind, how would you know you are in a moving car or a parked car?

Put another way, imagine a ball balanced on the top of your object. The accelerometer measures how the ball will move relative to the object as the object changes velocity.

You can not do what you describe with a practical accelerometer. When your object begins to move to the left, the accelerometer registers a force in one direction. When your object later stops moving, the accelerometer registers a force in the other direction. The problem is this: that force in the other direction is indistinguishable from the force you'd measure when your object begins to move to the right.

You are measuring the change in velocity. The change in velocity is the same in both these cases:

  • moving left -> not moving
  • not moving -> moving right

You can not distinguish them with an accelerometer. If you want to measure "moving left" and "moving right", that's velocity, not acceleration. You need a device that measures velocity. In theory, you can integrate acceleration to get velocity1, but practical details like noise and offset will cause your calculation of velocity to drift from the actual value.

1: an example of a system that does this is an inertial navigation system. These systems employ very careful engineering and expensive systems to reduce, but not eliminate drift.

\$\endgroup\$
  • \$\begingroup\$ Thank you. I just want to detect the start and direction of motion. \$\endgroup\$ – Swiftmind Apr 17 '13 at 12:31
  • \$\begingroup\$ @Swiftmind perhaps you should edit your question to be more clear. \$\endgroup\$ – Phil Frost Apr 17 '13 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.