Dave Tweed wrote: > > michael brown wrote: > > I saw someone make reference to doing your > > own AD conversion using PWM. I'm curious about this. Could someone > > describe how to do it, or point me to some kind of example of this. > It really isn't too hard. You connect your pot between Vcc and Gnd, with > the wiper going to the "+" input of an analog comparator (internal or > external to the PIC). You connect a digital output pin to the "-" input of > the comparator with an RC low-pass filter (R from output to input, C from > the "-" input to ground). The RC time constant of this filter should be on > the order of 10 to 100 ms. > Theory: This is actually a very simple delta-sigma ADC. The comparator > provides the delta, the timer interrupt provides the sampling, and the RC > filter provides the sigma (integration). The dual-counter setup in the > firmware forms a low-pass filter that converts the one-bit data stream from > the comparator into a multibit digital value that is analogous to the > voltage at the output of the RC filter. Or you could just ground the cap via the PIC pin, reset the timer and release the pin. When it triggers the comparator you stop the timer and have the count. :o) -Roman -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu