Electronic – Problems while using accelerometer as a motion switch

accelerometermotion

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?

Best Answer

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.