On Sunday 02 February 2003 09:22 pm, you wrote: > At 02:04 PM 2/3/2003 +1100, you wrote: > >I did post an answer yesterday, the problem is NOT the > >comparator, it's the fact that you are doing successive > >approximation using a PIC OUTPUT pin! The output pin > >is not capable of going rail to rail, there is a sat > >voltage loss of 0.3v to 0.8v or so depending on current > >and which PIC and which type of output, TTL or ST. > > I don't know his circuit, but the outputs of a PIC should swing to > within a few millivolts of either rail if not loaded- and there's no > such thing as a ST output. I believe that Roman is misunderstanding my problem. I'm not having=20 trouble with the output voltage of the PIC, that's working as expected. =20 At the bottom of this message is an ascii-art schematic, use a fixed=20 width font to view. I have RA3 (output) connected thru a 4.7K resistor to a 1uF cap. One=20 comparator input is connected to the junction of the resistor and the=20 cap, to monitor the DC charge present. There is no further load on=20 that part of the circuit. =20 RA3 is used to charge/discharge the cap based upon feedback from the=20 comparator. RA3 has no trouble pushing the cap voltage to very near 5=20 volts, nor does it have any problem lowering the cap voltage to almost=20 zero. IOW, I'm not having any trouble getting rail to rail voltages=20 out of the pic pin for charging the cap thru the resistor. The other comparator input is connected to a pot wiper. When the pot=20 wiper's voltage is below 300mV, the comparator seems to percieve that=20 as being less than the other input which is almost 0V. This causes my=20 program to stop charging the cap completely, by not turning on RA3 at=20 all, even though the comparator output should be a 1. It's as if the=20 comparator can't handle the inputs being driven near the rail voltages. =20 If the pot wiper is above about 4.5 volts, the opposite problem occurs. =20 The cap voltage suddenly increases to 5V as my program (which simply=20 copies the comparator output to RA3 starts writing nothing but ones to=20 the pin, apparently never seeing the fact that RA2 is now < RA1. The=20 datasheet does say that I should keep the input below 3.5V (Vdd -=20 1.5V), but it also says that I should be able to go to the lower rail. If I were using a revision A chip, would it be marked with an actual=20 letter 'A'? The chip I'm using is not so marked. Here is some ugly ascii art of the schematic. Obviously it has been=20 simplified for my convenience, but it shows all the components of the=20 feedback loop.=20 +5V |------------- | V | 16F628 |____/\/\/\/\___ | __________________ | |___RA2__| Comp + Comp - |___RA1___ 10K V | | | Gnd __RA3__| Charge Pin | | | | | | | |_________________| | | | | _________________| | | |____/\/\/\/\____|___|(______ | 4.7K 1uF V Gnd Thanks for any advice you may have. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.