Dear friends
Recently I came across an AVR application note about an intelligent charger
design based on their controller line.
There was a so called STABLE ADC READING FUNCTION
(not explained in detail ) which was used for getting valid ADC readings.
The following is copy-paste from there.
.................................................. ..................
void stable_ADC(void)
The stable_ADC function is used when measuring battery
voltage or temperature. It makes sure the ADC values are
stable inside a defined area. This is important for an accurate
measurement. The function loops until it gets three
ADC values where the highest is no more than one step
higher than the lowest.
.............................................
There was a pseudo c flowchart but I was not able to follow it through.
stable_ADC
|----------------- V[0] > V[1]+1 No ----------------------------- > return
| Yes
| V[5] = V[4]
| V[4] = V[3]
| V[3] = V[2]
| Start ADC
| ADC done? No ------>-continue conversion
| Yes
| V[2] = ADC
| V[1] = highest value of V[2] to V[5]
| V[0] = lowest value of V[2] to V[5]
| |
| |
-----------------------
I wonder if someone can help in implementing this for picbasic as I would like to
use it in order to improve ADC readings on a PIC12F675 .
At the moment I am adding 64 consecutive values in order to approximate a 16
bit result and by floating point math to end up to my final reading which is not
very stable.
Bill
Bookmarks