michael brown wrote: > Can anyone recommend better values for the charging resistor and cap. > I'm probably wasting allot of power using a 4.7K resistor, aren't I? About 1 mA, which may or may not be a lot in your application overall. All you should theoretically need is to be an order of magnitude or so larger than the comparator input's leakage current, which is on the order of 500 nA. 470K and 0.01 uF should be fine. However, the data sheet says "A maximum source impedance of 10k is recommended for the analog sources." They don't say why. (I don't think the comparator is muxed like the ADC.) If true, then you have to use 10K and 0.47 uF. You're also putting 0.5 mA through your 10K pot. 50K should work just as well, but this puts the source impedance (12.5K max.) a little outside the spec. > > +5V |------------- > > | V | 16F628 > > |____/\/\/\/\___ | __________________ > > | > > | |___RA2__| Comp + Comp - |___RA1___ > > > > 10K V | | | > > Gnd __RA3__| Charge Pin | | > > > > | |_________________| | > > | > > | _________________| > > | > > |____/\/\/\/\____|___|(______ > > > > 4.7K 1uF V > > Gnd Assuming high impedances are OK, there's a different way to address the problem with the common-mode input range of the comparator. Instead of connecting the RC filter to the comparator (-) input, connect it to the (+) input and put a resistor between the pot wiper and the (+) input, like this: o +5V 16F628 | +--------- \ 10K | / 470K RA2| \<---/\/\/\---+------------| comp + / | 470K RA3| \ +--/\/\/\----| charge | | | V === 0.02uF | | | V +--------- Connect the (-) input to a fixed internal or external reference of 0.5*Vcc. Modify the firmware so that it inverts the state of the comparator output bit when it copies it to the charge pin. The circuit now operates so that the average voltage on the charge pin is the complement of the voltage on the pot wiper, and both inputs to the comparator are held at 0.5*Vcc. -- Dave Tweed -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body