On Mon, Feb 04, 2002 at 08:08:01PM -0300, juan manuel garofalo wrote: > Hi there: > > > Does it make sense to build an ADC using a PWM output, low pass filtered and > a comparator from a 16f627 ? Absolutely. It'll be slow, grainy, and somewhat uncalibrated. > > My idea is to conect the voltage i want to measure to one input of the > comparator and the pic's PWM output to the other input. Then i sweep the > duty cycle from 0 to the point at wich the comparator changes. My guess is > that it's not a very fast ADC, but that's not a concern. Is this a workable > solution or are there any gotchas i should be aware of ? You have the major gotcha: You'll have to sweep slowly and allow the filter time to settle between steps. You may also want to consider an opamp sample and hold for your input voltage so that it won't change during your sweep. Here's a pdf with some tutorial slides: http://www.eecg.toronto.edu/~kphang/ece1352f/chap08a_slides.pdHere's a pdf with some tutorial slides: http://www.eecg.toronto.edu/~kphang/ece1352f/chap08a_slides.pdff If you can spare a timer you could program an interrupt to step the PWM and check the comparitor, essentially automating the operation. BAJ -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body