Hello I'm a newbie and want to hear some advice
What I want to implement is using a mpu6050 sensor to detect someone kicked when riding the kickboard. I've recorded the acceleration using MATLAB when the user kicked on the kickboard but the question is how to set the kick threshold using this data. Cause what I want to do is similar like if( integration value > threshold) then the kick motion happened from the user. Do I have to integrate the acceleration period using the graph and use it as a threshold value? If so could someone can give an idea of how to approach to do the integration? Or how to set the threshold value in this case?
I'm not sure how you are using a kickboard. Or what your kickboard is. For me a Kickboard is used to teach children to swim but I suspect you are doing something different.
About your threshold:
In you integrate the readings coming in it would be representative of the amount of energy received.
For instance, if someone kicked the board with a value of "10" (made up numbers) but for 1/10th of a second it would be different that if someone kicked the board with a value of "8" but kept that up for a full second, the second one would have kicked with more energy than the first.
But the first kicked the board harder.
With a little more info I could give you a better recommendation.
Hello, sir thank you for the reply. For me, the kickboard is the wheeled scooter. What I want is with the Accelerometer, do the actual motion several times to get optimal acceleration data to set it as a threshold. So if someone does the kick on the scooter, and if the acceleration value is higher than the threshold value(obtained in some way) the program noticed some did the kick motion.
I mean get Yourself an idea for what the curve looks like and then decide for a suitable trigger level. That trigger level You hard code in the real sketch.
Thank you for the reply. So what you mean is doing the experiments several times and finding the best curves which would represent the threshold. Thanks
Sample as fast as possible, print the values. Decide for the value when the kick is considered to have started and a kick is in progress. Use that value in Your real code.
The integral of the acceleration is velocity, which would be very susceptible to noise and bias from the sensor. If you really need velocity you might be able to measure more directly and accurately with other means. The derivative of accelleration is "jerk", Jerk (physics) - Wikipedia which might be more interesting for your purpose.
One way to set a threshold is to use a moving average, or multiple moving averages. Technical financial analysis of stocks compares 5 day averages with 30 day averages to get an adaptive threshold. If the averages are far apart, (larger than a "deadband" then something unusual might be happening.
I'm partial to an exponentially weighted moving average because they are easy to calculate and adjust.
const float alpha_fast = 0.2; // EWMA constant for fast tracking
const float alpha_slow = 0.01; // EWMA constant for slow tracking
const float acc_deadband = 0.1 // a 0.1g difference from 'average' is normal
double ewma_acc_fast, ewma_acc_slow;
double new_acc_reading;
...
new_acc_reading = read_acceleration;
ewma_fast = alpha_fast * new_acc_reading + (1-alpha_fast) * ewma_fast;
ewma_slow = alpha_slow * new_acc_reading + (1-alpha_slow) * ewma_slow;
if (ewma_fast - ewma_slow > acc_deadband) {
// unusual positive accelleration
...
}
get optimal acceleration data to set it as a threshold.
What do you mean by "optimal"?
Getting back to my earlier post....
So a rider Kicks (pushes forward with their foot). They could "stab" it quickly but not for a long stroke. Someone else could not push as hard but does push for a long stroke.
Hello, thank you for the idea. With your ewma codes, the alpha values and the deadband value should be decided depending on the values from the sensor outputs right?