In essence, this approach is a single-slope integrator. Because the comparator (the PIC port input, which ought to be a schmitt trigger input, for maximum noise rejection) always trips on a positive-going ramp, there is potential for some jitter due to noise. Capacitors also suffer from various non-linearities which can affect the reading. More sophisticated A/D approaches use dual-slope integration. In this approach, the capacitor is first charged until the port reads a logic 1. It is then full-charged to the supply voltage and then discharged until the comparator reads 0. The two times are averaged. > ---------- > From: DREITEK[SMTP:DREITEK@AOL.COM] > Reply To: pic microcontroller discussion list > Sent: Thursday, January 08, 1998 8:14 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: Best way to read a POT without the A/D? > > In a message dated 98-01-07 11:48:01 EST, you write: > > << > What is the best way to read a POT without using an A/D converter? I > need > to generate values between 0 and 128 from the reading. It also needs > to be > repeatable i.e. when the POT is not moved, the same number is > generated. > The time limit for reading is not too critical, maybe 250 msec or > less. > Idealy it should not need "calibration" so that multiple units would > behave > the same. > > What I am currently doing is the method shown at: > http://www.geocities.com/SiliconValley/2499/answers.html#PIC00065 > and measuring the charge time. The times seem to vary quite a bit > when the > pot is in the same position. > > Is there a better way to get more stable readings? > > BTW I am using a 16C84 for the project. If I can't get it to work > right, > I'll switch to the 16C71 and use the A/D converter. > > Thanks for any help > > Norm >> > > Hello Norm, > I haven't looked at the URL you mentioned but I have used this method > quite a > bit and it works very well. You need to select good quality caps to > prevent > drift. Use a mylar cap. Also experiment with the cap values. I used > a 16 > bit counter instead of the usuall 8. This steadies things up a bit. > Then you > only use the MSB of the counter for your value. All of the drift will > show up > in the LSB which you ignore. > I use this method when I need simple numeric input. End users > understand > knobs. I made a bottled water pump for refridgerator ice makers. The > timer > on the pump was set with a simple knob. It works great. > > Dave Duley >