> -----Original Message----- > From: David VanHorn [SMTP:dvanhorn@CEDAR.NET] > Sent: Thursday, April 26, 2001 12:08 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC]: Pin impedance > > I've hit an Funky problem. > > For many reasons, I'm discharging a 0.1uF cap through a selectable > resistance, using a pic output to discharge it, and a pic input to sense > when it's done. > > I first discharge the cap through a known resistance to get a nominal time > value. > Then I discharge through the variable resistance, and I had expected that > 4.7k would take roughly 5x as long to discharge as a 1k > would. Unfortunately, this is not the case. > > Discharging through various multiples of 1k, here's the timing values I > get: > > Test run: > Capsense value (nominal "1") 07Bh > Set Time Delta > 0 00A All shorted > 1 079 6F Note that the delta is roughly the same as the > nominal value, > as you'd expect. > 2 0E2 69 > 3 12D 48 However, as R increases, the delta shrinks rather > a lot. > 4 187 5A > 5 1B7 30 > 6 1EA 33 > 7 214 2A > 8 241 2D > 9 25C 1B > A 27A 1E > B 292 18 > C 2AD 1B > D 2C2 15 > E 2CE 0C (anomaly?) > F 2E3 15 All open > > I expected to be able to divide the time by the nominal value, and get > 0-15 > out of it, but obviously that's not working very well. > > The charge routine runs through the fixed resistor, and charges FAR longer > than required, before each discharge, in order to get up into the very > flat part of the charge curve, so that the measurements would be > repeatable. > > Is this showing me something unusual about PIC output pin impedances, or > ??? > Can't answer this one directly, but I spent about a week trying to get this method to work accurately for a thermistor measurement (although I was charging the cap, and linearity over the supply range was the problem I had). Gave up in disgust in the end. As Bob says, the Schmitt trigger input on RA4 is a little unpredicatble. Using a comparator to sense the discharge point gives a huge leap in accuracy. Looking at your figures, the delta seems to stabilise around 15-1B range as the resistance increases. The lower value resistanaces obviously dump a higher peak current through the port, I'm wondering if this upsets the switching point of your sense pin somehow? Are you ensuring the cap is fully charged before starting your discharge cycle? A possible fix might be to introduce a fixed resistance in series with your variable one which would move the results down towards the more linear region. Obviously the PIC would have to take into account the offset. Regards Mike -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu