It also wouldn't hurt to take an average. Since 60 Hz has a period of 16.66 milliseconds, and an A/D conversion takes about 30uSecs, you could average 16 samples (a full cycle) something like this:
This should do a pretty good job of smoothing the result.Code:ADCAvg = 0 ; Clear the variable For X = 1 to 16 ADCIN,x, ADCresult ADCAvg = ADCAvg + ADCresult Pauseus 1000 Next X ADCAvg = ADCAvg >> 4 ; divide by 16
Bookmarks