ADC read, capture one result, if result varies between two.

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

ADC read, capture one result, if result varies between two.

Post by medelec35 »

If reading ADC then dividing result by 5 and result is borderline. Does anyone know how can the highest figure be captured, e.g. if result keeps varying from 49-50 i.e. result =49,50,49,50,49,49,50,49 etc I just require the highest figure of 50. if result =49 just want 49 etc. I was thinking along lines of before adc read, store adc previous as temp, then read then compare. If temp is lower then keep adc, if temp is higher then new adc = temp. Not sure if that will work?
Thank you
Martin

User avatar
Steve
Matrix Staff
Posts: 3434
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: ADC read, capture one result, if result varies between two.

Post by Steve »

Would ignoring small changes in the input value work? E.g. read the first value (say 50) and store this in a holding variable. Then on each subsequent read of the voltage, see if the difference between the new and the holding voltage is more than 3. If it is not, ignore the reading. If it is a bigger difference, set the holding value to the new one (e.g. 46) and react accordingly.

You could continually update the holding value with the newly-read one. But this may not be a good idea because if the voltage is slowly rising or falling, then all the updates will be ignored.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: ADC read, capture one result, if result varies between two.

Post by medelec35 »

Thanks steve, Will give that a try.
Martin

Post Reply