# Comparator LED Control Mystery

Hi there,

So I'm using the MCP6541R push-pull comparator to control two LEDs, one green and one red. The green LED is supposed to turn on whenever 5V is present (and it does that well), and the red LED is supposed to be on when 5V is NOT present... here's when the problem comes up. The red LED will be on for like 20s but then it magically switches back to green!!! Can anyone figure out what's going on here? To my understanding it's a very simple push-pull comparator that either goes HIGH or LOW when comparing V+ and V-. Why would it work as expected and then switch later when the inputs are constant?

I've attached the circuit for reference. 3.3V is from a voltage regulator and there's no problem with that. 5V can either be connected or not connected (in which case the 20k pulldown pulls it low so that the comparator input isn't floating).

Thanks!

The only thing I can see wrong is you're not supposed to connect 5V to the input when you have a 3.3V power supply.

Under absolute maximum ratings I see:
Analog Input (VIN) †† ...................... VSS - 1.0V to VDD + 1.0V

So you might have fried the comparator. And what does "not present" mean? Is it zero volts? Have you measured the voltage to make sure the input is being pulled-down?

I would suggest that you use a potential divider to reduce the voltage that you are measuring (5V) to one that is less than the supply voltage of the IC. Do the same with the reference voltage too.

Use equal value resistors, so that the comparison becomes:

is (5V/2) greater than (3.3V/2) ?

This gives the same result as your original: is 5V greater than 3.3V?

I've modified your schematic to show you what I mean.

Thanks for the replies, the 5V being too much for 3.3V supply makes sense. However, the part that's not working is when 5V isn't connected (so the IN- pin is only connected to GND via the pulldown). In that case both inputs are within the acceptable range. Could it just be that I fried it with 5V and that's causing instability even when the input voltages are OK?

5V to the input of an IC powered by 3.3V is definitely compromized. It might do anything really.

Its always wise to have some form of current limiting on inputs, otherwise you have a very fragile
setup (should, for instance, the supply fail and the input still see external voltage).

Hence the recommendation to use a divider chain on each input.

Besides, not all comparators are truly rail-to-rail (you may simply be seeing
phase inversion for instance). Unless an opamp or comparator is stated as free from
phase inversion in the datasheet, its typical that the output phase inverts on input