I'm not sure if this is an EE question or a StackExchange question due to the programming involved, but anyway here goes:
I just built a tilt sensor for my tractor's front loader. I wanted something easy to read in bright daylight, wireless, magnetic attachment, and reasonably accurate to indicate the tilt and level of my front loader so I can use it to level some ground easily.
I used my own custom-built wireless MCU as the controller, interfacing via I2C with a GY-521 accelerometer/gyroscope module.
The display is just a servo motor connected to an indicator hand and a laser-printed dial face, and 5 LEDs also.
Here's a video of the device working: https://www.youtube.com/watch?v=xWT8AyE1JLU (sorry about the noise, I was trying to show how jitter doesn't seem to affect it as bad!)
In testing, it worked great. But as soon as I snapped the sensor to my tractor's bucket, the vibration from the engine caused the accelerometer readings to go crazy. The needle basically jumps from one end to the other, making the readings useless.
So first I tried to average the output. (I am sampling at approx 5-10 samples per sec) That still yielded shaky results.
So I implemented a low-pass filter, using a coefficient of 0.1 for new readings. As you can see in the video, this helped to eliminate the jitter, but now the readings are too laggy. Turning the device from one end of its range to the other, it takes several seconds for the needle to catch up to the input. This also makes it unusable, as it needs to be more realtime. And as you can see, it takes a long time to get back to zero.
Does anyone have suggestions/ideas on how to reduce jitter from the engine vibrations and bumps/thumps experienced by the bucket, while yielding a fairly fast and accurate output?
Note that my MCU won't be able to handle lots of math for each sample, so don't know if that eliminates FFT or not - it's only a basic 8051 running at 16MHz.
Here are the links for spec sheet/register map for the Accel/Gyro: https://www.cubby.com/pli/Spec+Sheet.pdf/_506bd71d53d3454282f06fa698666f04 https://www.cubby.com/pli/Register+Map.pdf/_17685da9808c42099c5ebdc1058c63b3
Any info appreciated!