Skip to main content
antonius
Associate III
November 8, 2018
Question

Peak value on ADC ?

  • November 8, 2018
  • 6 replies
  • 1375 views

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

    This topic has been closed for replies.

    6 replies

    AvaTar
    Senior III
    November 8, 2018

    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
    antoniusAuthor
    Associate III
    November 8, 2018

    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
    Senior III
    November 8, 2018

    > 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
    antoniusAuthor
    Associate III
    November 8, 2018

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

    Find maximum in loop ?

    LMI2
    Senior III
    November 8, 2018

    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.

    antonius
    antoniusAuthor
    Associate III
    November 8, 2018

    My thinking :

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

    ADCResult[i];

    ADCMax=ADCResult[i];

    if ADCMax<ADCResult[i]

    ADCMax=ADCResult[i];

    Do you reckon ?