Shock Detection

Hi All, I'm trying to use an accelerometer(LIS3LV02DQ) to detect shocks. Currently it is configured to use I2C interface, +/- 6g 40Hz sampling rate. I'm integrating every 60 samples' absolute value, to work out the energy. I then reset the energy value to zero after 60 samples and start over. If the calculated energy is greater then x, I trigger a shock alert.

Is that a correct way of detection shocks? Is my sampling rate too low? Are there any algorithm out there I can use?

Thank you for any help you may offer.

Regards,

Zhao

Reply to
Zhao
Loading thread data ...

You may want to mount the accelerometer on rubber feet or use some other mechanical arrangement to remove the high-frequency components from the shock. This would help to spread the shock out over a longer time for more reliable detection of a sharp (short duration shock).

40 Hz seems reasonable, but I'm not a mechanical engineer. It depends a lot on the total environment the accelerometer is in. For example, if the accelerometer is already on a PCB that might flex ...

The only observation I'd make about your algorithm is that you might want to go to a rolling window rather than one you reset. You don't need to sum the

60 samples every time--just add in the new sample and subtract out the oldest one, i.e.

int queue[60]; int index; int window_sum;

...

void stuff_new_accel(int new_accel) { int old_index = index;

index++; if (index >= 60) index = 0; queue[index] = new_accel;

sum += new_accel; sum -= (queue[old_index]); }

The Lizard

Reply to
Jujitsu Lizard

Define "shock"? What kind of shocks are you looking to detect? Does your algorithm need to reject vibrations?

I suggest you start by capturing a large number of events - real "shock" events and other random events that you think your device will see in real life - and looking at the waveforms. Run some test algorithms over these captured data sets and tweak your catch/reject rates. Then move over to real hardware.

Reply to
larwe

Thank you Jujitsu and Larwe, very helpful hint. To determine what a shock is, I'll do a series of test and recored energy level and fine tunning the alarm threshold. May be I should make the size of the sample buffer a variable to adjust shock period.

Reply to
Zhao

e

I had a similar sort of application - which I will not discuss in detail, sorry - and what I did was to make a logger pod out of a Logomatic datalogger and 512MB SD card. I am using an analog accelerometer. I put the "logger box" into a jiffy box and installed it in various representative situations to gather background noise and decide on my algorithm and sense criteria. I sampled at

500Hz on all three axes (note that I had an RC filter with a 303Hz

-3dB point).

Reply to
larwe

shock

the

Furthermore, to work out the shock, I need to work out the vector of energy? sqr(x^2+y^2+z^2) ?

Reply to
Zhao

That simply gives you the magnitude of the force vector. I would not suggest reducing it to this scalar immediately because you're hiding important data. To find a shock, one approach is to look at the first derivative of the input signal. I'd suggest that you try sampling into a circular buffer, take the first derivative of the x,y and z curves, combine them to get a magnitude using the Pythagorean formula you quote above, then look for local maxima.

That's not presented to you as a solution, merely as something you can try to help visualize the problem. I don't remember exactly how to use the ST accelerometers in digital mode - I use AD and Kionix parts mainly - but you might need to do some digital filtering to get a good result. Experiment, experiment.

Reply to
larwe

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.