You could use a compare and keep algorithm *probably*,
PSEUDO CODE.
value = 0;
while(1);
latest = inPin.read();
if (latest > value) {
value = latest;
}
}
You could put the test on a ticker, so that the largest value is always kept in the background.
Questions to consider, are things like..
What's your timescale ?
Do you need to zero it, do you need the value of each peak, or just between 2 times, or just ever ?
Watch out for random spikes, you'll need to find the "Good ADC practice" page.
(set unused pins low etc etc). You might want to do some software filtering,
cheers,
Dave.
Hey guys,
I want to know how I can get (in the MBED) the maximum value that I can see in the oscillator.
My signal is similar to the following image.
I did a loop using the while(1) and saved 20 values in an array. But with this technique most of the times I can't get the maximum value, which is what I'm looking for.
How I can do that?
Regards