Maker Pro
Maker Pro

Oscillating PIC Comparator

R

Robert Monsen

Jan 1, 1970
0
I am using a PIC12F675, which contains an onboard comparator. The comparator
has the option of using an onboard vref (which is just a voltage divider of
Vcc!) or an input pin. Also, it has the option of exporting the output of
the comparator to an output pin.

I spent several hours last night trying to figure out why the thing has not
been working properly for me (I'm using it as a trigger, and it would
sporadically fire without input,) and it turns out that when the output is
not configured to connect to a pin (e.g., its only readable by the CPU,) and
the only input is the V- input (the V+ input uses the Vref,) the thing is
oscillating! When I configure the output to come out to a pin, and bypass
the output to the V- input using a 0.1uF cap, it works quite well.

Anybody else having problems like this with the onboard comparator? Is it a
known POS? (Jim Thompson mentioned he was going to clean up some of the
analog work on the PIC line. Perhaps this is one of those things?)

FYI, I'm feeding the V- input with a GP2D12 IR proximity detector, and
running the chip at Vcc=5V. I turned off the pull-ups for the V- input.

Regards,
Bob Monsen
 
J

John Fields

Jan 1, 1970
0
I am using a PIC12F675, which contains an onboard comparator. The comparator
has the option of using an onboard vref (which is just a voltage divider of
Vcc!) or an input pin. Also, it has the option of exporting the output of
the comparator to an output pin.

I spent several hours last night trying to figure out why the thing has not
been working properly for me (I'm using it as a trigger, and it would
sporadically fire without input,) and it turns out that when the output is
not configured to connect to a pin (e.g., its only readable by the CPU,) and
the only input is the V- input (the V+ input uses the Vref,) the thing is
oscillating! When I configure the output to come out to a pin, and bypass
the output to the V- input using a 0.1uF cap, it works quite well.

Anybody else having problems like this with the onboard comparator? Is it a
known POS? (Jim Thompson mentioned he was going to clean up some of the
analog work on the PIC line. Perhaps this is one of those things?)

FYI, I'm feeding the V- input with a GP2D12 IR proximity detector, and
running the chip at Vcc=5V. I turned off the pull-ups for the V- input.
---
If the output of the PIR is ever open-collector or floating, for any
reason, then with no pullup or pulldown the comparator's V- input will
also be floating during the time the PIR's output is floating and it
will be in an unstable state and could oscillate.

Connecting the comparator's output to V- through a cap is not a real
solution because once the charge leaks off the V- input you're right
back where you started with a floating high impedance input.
 
S

Spehro Pefhany

Jan 1, 1970
0
I am using a PIC12F675, which contains an onboard comparator. The comparator
has the option of using an onboard vref (which is just a voltage divider of
Vcc!) or an input pin. Also, it has the option of exporting the output of
the comparator to an output pin.

I spent several hours last night trying to figure out why the thing has not
been working properly for me (I'm using it as a trigger, and it would
sporadically fire without input,) and it turns out that when the output is
not configured to connect to a pin (e.g., its only readable by the CPU,) and
the only input is the V- input (the V+ input uses the Vref,) the thing is
oscillating! When I configure the output to come out to a pin, and bypass
the output to the V- input using a 0.1uF cap, it works quite well.

Anybody else having problems like this with the onboard comparator? Is it a
known POS? (Jim Thompson mentioned he was going to clean up some of the
analog work on the PIC line. Perhaps this is one of those things?)

FYI, I'm feeding the V- input with a GP2D12 IR proximity detector, and
running the chip at Vcc=5V. I turned off the pull-ups for the V- input.

Regards,
Bob Monsen

Have you put an oscilloscope on the output of the GP2D12? It makes
measurements every 5msec, there might be some noise in the output.

Also, don't put a capacitor directly on Vo, you must use a series
resistor otherwise you could be causing it to oscillate.

Best regards,
Spehro Pefhany
 
R

Robert Monsen

Jan 1, 1970
0
John Fields said:
---
If the output of the PIR is ever open-collector or floating, for any
reason, then with no pullup or pulldown the comparator's V- input will
also be floating during the time the PIR's output is floating and it
will be in an unstable state and could oscillate.


Thanks, I'll take a look at the PIR and see if it ever floats.
Connecting the comparator's output to V- through a cap is not a real
solution because once the charge leaks off the V- input you're right
back where you started with a floating high impedance input.

Hmm, I was afraid of that. It seems stable now, with the cap, but I'm
worried about long term stability.

Thanks again,
Bob Monsen
 
R

Robert Monsen

Jan 1, 1970
0
Spehro Pefhany said:
Have you put an oscilloscope on the output of the GP2D12? It makes
measurements every 5msec, there might be some noise in the output.

I'll take a look. That would cause it to trigger, and if the glitch is fast
enough, the cap might be supressing it. The inputs are pretty high impedance
(around 5M, I believe.)
Also, don't put a capacitor directly on Vo, you must use a series
resistor otherwise you could be causing it to oscillate.

I put the cap between the output and the V- when I guessed it might be
oscillating, and it seemed to get more stable. If there is noise, perhaps I
can put the cap between V- and GND, and that'll clean it up enough to use.

Thanks for your time
Robert Monsen
Best regards,
Spehro Pefhany
http://www.speff.com
 
S

Spehro Pefhany

Jan 1, 1970
0
I put the cap between the output and the V- when I guessed it might be
oscillating, and it seemed to get more stable. If there is noise, perhaps I
can put the cap between V- and GND, and that'll clean it up enough to use.

With a series resistor from the module of maybe 1K. The capacitor on
the comparator output could also cause problems.

Best regards,
Spehro Pefhany
 
R

Robert Monsen

Jan 1, 1970
0
Problem solved. Thanks.

The issue may have been glitches from the GP2D12 module. Anchoring it to
ground using a 0.1uF cap solves the stability problems.

Regards,
Bob Monsen
 
J

John Popelish

Jan 1, 1970
0
Robert said:
I am using a PIC12F675, which contains an onboard comparator. The comparator
has the option of using an onboard vref (which is just a voltage divider of
Vcc!) or an input pin. Also, it has the option of exporting the output of
the comparator to an output pin.

I spent several hours last night trying to figure out why the thing has not
been working properly for me (I'm using it as a trigger, and it would
sporadically fire without input,) and it turns out that when the output is
not configured to connect to a pin (e.g., its only readable by the CPU,) and
the only input is the V- input (the V+ input uses the Vref,) the thing is
oscillating! When I configure the output to come out to a pin, and bypass
the output to the V- input using a 0.1uF cap, it works quite well.

Before blaming the chip, I would give it all the help I could. The
PIC needs to be bypassed very close to the chip, to keep it from
making too much noise on its internal supply buss. I would also make
an input RC filter for the V- pin that had a series resistor and a
pair of capacitors, one ot the zero volt pin of the chip, and one to
the +5 pin, with the capacitors proportioned ot make a capacitive
divider that matched the ratio of the internal V+ divider.
For example, if the V+ divider is set to 3/4 (a 1:3 ratio of
resistors) of the 5 volt supply, then you might use a .027 or .033 uf
cap to the +5 pin and a .01 uf cap to the zero volt pin (1:3 ratio of
impedance). A 10 K series resistor might be okay, depending on the
speed of response you need.
 
R

Robert Monsen

Jan 1, 1970
0
John Popelish said:
Before blaming the chip, I would give it all the help I could. The
PIC needs to be bypassed very close to the chip, to keep it from
making too much noise on its internal supply buss. I would also make
an input RC filter for the V- pin that had a series resistor and a
pair of capacitors, one ot the zero volt pin of the chip, and one to
the +5 pin, with the capacitors proportioned ot make a capacitive
divider that matched the ratio of the internal V+ divider.
For example, if the V+ divider is set to 3/4 (a 1:3 ratio of
resistors) of the 5 volt supply, then you might use a .027 or .033 uf
cap to the +5 pin and a .01 uf cap to the zero volt pin (1:3 ratio of
impedance). A 10 K series resistor might be okay, depending on the
speed of response you need.

Thanks for the good advice. It does sound like I was premature in blaming
the chip; turns out that a simple bypass cap to ground on the V- solved the
problem. However, I'm still not sure if it was oscillation, or simply noise
from the sensor as was suggested elsewhere.

It was triggering when I rolled my chair around on its plastic rug
protector, three or four feet away from the circuit. The GP2D120 I was
testing with may have been glitching on very slight changes, or it may
simply have been some kind of static buildup causing problems. I've had lots
of problems lately with static discharge.

If I start seeing false triggering again, I'll try the capacitive divider
with a 10k series resistor. The input changes should be very slow, so there
isn't any reason for fast response. The power supply is already bypassed
with a 1uF cap right at the chip.

Thanks again
Bob Monsen
 
Top