juan manuel garofalo wrote... >Does it make sense to build an ADC using a PWM output, low pass filtered= and >a comparator from a 16f627? >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 ? This should be workable, though you're right about it not being very fast. =20 As for the "gotchas", keep in mind that the comparator's input common-mode range goes up only to Vdd-1.5V; also, you'll need a filter that reduces the worst-case PWM output ripple by at least 60 db to get full 10-bit resolution. You probably would be best with a filter response which has no time-domain overshoot, i.e. a Bessel response. As a matter of strategy, how about arranging the software to implement a "tracking" converter? You'd have an interrupt on each PWM cycle; in this interrupt, you'd query the comparator to determine whether the current PWM output is too high or too low, then increment or decrement the PWM accordingly. This arrangement would not be good at following fast input changes; but it would be superior for slowly-changing inputs since it continually keeps itself within a count or two of the current input value. Just an idea... Dave -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body