cancel
Showing results for 
Search instead for 
Did you mean: 

Peak value on ADC ?

antonius
Senior

Dear Member,

I want to get a peak value from ADC,

How can I get it on the code ?

Loop and array ?

Any references ?

Kind regards,

A

6 REPLIES 6
AvaTar
Lead

Not sure what you mean.

The ADC has only one result register, ergo only one result. Maximal value is 2^12-1.

If you speak about values collected in an array or list, this amounts to a simple comparision in a loop.

antonius
Senior

Yes I speak about values collected in array or list,

I want to take maximum value to each of the cycle

I have 100Hz signal of voltage and I want to sampe 10 times and find the maximum value of them,

Any ideas or example ? thanks

AvaTar
Lead

> I have 100Hz signal of voltage and I want to sampe 10 times and find the maximum value of them,...

The 100Hz are irrelvant here.

Do you honestly have no idea of how to find the greatest value in a list/array of 10 ???

I would recommend a good C programming language tutorial. Such things are the bread-and-butter business of an embedded developer.

antonius
Senior

I'm thinking that looping ADC read and keep the result in one array variable then find maximum one,

Find maximum in loop ?

LMI2
Lead

There maybe some interference with ADC results so you better take several at a time and average. After that you just compare your current result to the maximum and keep bigger.

My thinking :

for i=0;i<=10;i++

ADCResult[i];

ADCMax=ADCResult[i];

if ADCMax<ADCResult[i]

ADCMax=ADCResult[i];

Do you reckon ?