PDA

View Full Version : COMPARATORs as Comparator and Op Amp



flotulopex
- 9th April 2011, 18:06
Hi there,

I have a 40kHz sinwave, 70 millivolts (peak-to-peak) 200µs pulse signal I want to analyse in a PIC16F88; I'm making an ultrasonic range finder. I want to use one comparator as 'comparator' and the second one as an 'op amp'.

Firstly, I'm confused because of datasheets statements:
13.3.2 INTERNAL REFERENCE SIGNAL
... The internal reference signal is used when comparators are in mode CM<2:0> = 010

14.0 COMPARATOR VOLTAGE REFERENCE MODULE
The comparator voltage reference generator is a 16-tap resistor ladder network that provides a fixed voltage reference when the comparators are in mode ‘010’...These two statments made me think for hours that the voltage reference module would ONLY work in the comparator mode 010. I use the Two Independent Comparators CM2:CM0 = 100 and still can make the voltage reference work. So what's the exact meaning of these statements?

Anyway, I have set now CVRCON = %11100001 and get a reference voltage of 200mV. This is far too high for my incomming signal. I need to amplify the incomming signal.

I'm reading and re-reading the Tips'nTricks (see attachment) and still don't understand how I can use a comparator as an Op Amp :(

I know how to connect a conventional op amp but how do I do it "inside" the PIC? Any example?

Gusse
- 9th April 2011, 18:31
CM<2:0> = 010 -> 2 independent comparators (=op amps).
CM<2:0> = 100 -> 2 common reference comparators (=op amps).

AN0 and AN3 & AN1 and AN2 are input pins for op amps and C1OUT and C2OUT are respectively output pins (see FIGURE: COMPARATOR I/O OPERATING MODES).

Use those like conventional op amps.