I tried every AD oscillator / Sample time possible, and it made no difference.
Even with the A/D input tied directly to ground, it was getting crazy readings between 0 and 20.
After I tried it with a 12F675 (without the CCP) and got the same results,
I finally figured out that I had removed the big cap on the power lines on this protoboard.
Probably needed it for something else. Doh!
After putting a 100uf cap across the power supply, everything calmed down again.
It's still not perfect, but I think that has alot to do with the breadboard.
So then to really stabilize things I added an averaging routine, and I think that's about as close as we're going to get.
First make sure you have enough capacitance on your power lines (I think mister_e already suggested that).
Then add this to the bottom of the program
Code:
' -=-=-=-=-=-= Average Analog values -=-=-=-=-=-=-=-=-=-=
Avg VAR WORD
AvgCount CON 16
spread CON 20
Average: ' Smooth data
IF ABS (pote - Avg) > spread then
Avg = pote
else
Avg = (Avg*(AvgCount-1)+pote)/AvgCount
pote = Avg
endif
Return
And also, just after the ADCIN statement, add thisHTH,
Bookmarks