Algorithm for analog pulse detection

Hey. I'm running an Uno R3 and have piezoelectric vibe/shock sensors feeding into the analog inputs. I'm trying to sense direct shocks. They are fairly repeatable and within a time envelope in width but sometimes have drop outs or ringing. I was wondering if there's a tried and true algorithm for detecting these pulses somewhere out there. I could hack something but I'd prefer something with some mathematical rigor. Filtering the pulses digitally or electronically is a possibility as well. Just looking for a good starting point so I don't have to bark up so many trees. Below are a few samples of time sequences of the kind of pulses we're looking at. They all follow this same basic pattern and can't occur closer than about 100ms. Assume values between pulses are zero or low level noise. I have a minimum detection threshold of 200. Happy to do analysis in Matlab.

time(ms) intensity

2620 0 2649 0 2676 0 2704 235 2735 0 2762 0 2791 843 2821 0 2849 801 2879 0 2907 0 2935 0

3356 0 3385 0 3412 0 3440 230 3471 307 3501 0 3529 0 3557 459 3588 0 3615 0 3644 0

4092 0 4121 0 4149 0 4177 337 4207 0 4235 269 4265 938 4295 0 4324 766 4354 206 4384 0 4412 0 4441 0

Perhaps something like this could help or give some ideas ... http://forum.arduino.cc/index.php?topic=299755.msg2106451#msg2106451

Looks like the sample rate is too low for your pulse width. Once you can reliably catch every pulse, you can then digitally filter.

Paulcet: Looks like the sample rate is too low for your pulse width. Once you can reliably catch every pulse, you can then digitally filter.

Is there a way to adjust the sample rate on the analog inputs?

The analogRead() normally takes about 120 microsecond to make a sample.

Can you tell anything about the pulses? how much are there per second? How long are these?

for faster sampling there are old threads like - http://forum.arduino.cc/index.php?topic=6549.0 -

google "arduino analogread increase sampling rate" google "arduino analogread decrease bit depth "

It also appears that the signal has incorrect offset (looks like the falling signal gets clamped at 0). Do you have a link or datasheet for your piezoelectric vibe/shock sensor? Also, how is it interfaced to your analog input?

dlloyd: It also appears that the signal has incorrect offset (looks like the falling signal gets clamped at 0). Do you have a link or datasheet for your piezoelectric vibe/shock sensor? Also, how is it interfaced to your analog input?

I've analyzed the data coming off the sensor and set a noise threshold, below which anything gets set to zero. It makes sense for this application.

I can't get pulses faster than about 100 ms apart. Can't get more than a few dropouts. I've written a routine that seems to be doing a pretty good job just using brute force. Sort of wanted something more elegant.

From the data, it looks like your loop iteration speed is 20-30ms. If your code was doing nothing else but reading, should be able to get up to about 250 readings in this amount of time.

Can you allocate a time slot to take multiple readings and fill an array, then analyze the data later in your code? Can you post your full code?

MotorcycleWriter: I've analyzed the data coming off the sensor and set a noise threshold, below which anything gets set to zero. It makes sense for this application.

I can't get pulses faster than about 100 ms apart. Can't get more than a few dropouts. I've written a routine that seems to be doing a pretty good job just using brute force. Sort of wanted something more elegant.

Yes, they are 100ms APART. But how LONG are they?

You might look into using a comparator and driving the output of the comparator into an interrupt, yes you will need to build a small circuit using an op amp.

Can you post your code as only the output of the sketch gives too little clues.