You could try Darrel's averaging include file.
http://sites.picbasic.net/index.php?...d=70&pageid=25
You could try Darrel's averaging include file.
http://sites.picbasic.net/index.php?...d=70&pageid=25
If your value goes to zero, there is something more wrong than a little noise. I have found some chips that don't work properly with ADCIN (18F2221 for example).
Try the following:
Result is, of course, a WORD varCode:Result = 0 Channel = 1 ; Whichever Channel = Channel << 3 ; offset the bits ADCON0 = %11000001 | Channel ; OR the channel into the reg. For X = 0 to 9 PAUSEUS 10 ADCON0.2 = 1 ; Start conversion PAUSEUS 2 ; Guarantee min time WHILE ADCON0.2:WEND ; Wait until done Result = Result + ADRES Next X Result = Result/10
Charles Linquist
Charles,
This sensor pulses hi to low. I suspect some of my sampling is reading on the low part of the cycle. Thats why I slowed way down the sampling time to 20ms.
ADC has worked well for me on this PIC.
I will look at your subr.
Thanks
James
I am getting better results using PULSIN since the sensor is pulsing as stated before.
I still need to condition the results, however.
James
You mean that you weren't concerned with the analog level of the signal at all? Only its duration?
Charles Linquist
Bookmarks