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
ADC read, capture one result, if result varies between two.
Moderator: Benj
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- 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.
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.
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.
Thanks steve, Will give that a try.
Martin