This is a follow up-question for this question where I had troubles with a latch occuring at start-up. While solving the earlier issue I found another one which I had not been able to anticipate since this is the first time I'm playing with a P-channel MOSFET.
Have a look at this schematic, where I have stripped away everything that's not relevant to the actual problem:
The circuit is a part of a voltage monitor. Nominal input is Vcc = 5V, and if the voltage goes higher than 5.5V (feel free to read the above mentioned question for further details) the outgoing supply line (Vcc_OUT) is cut-off to prevent damage.
The opamp is configured as a comparator. It's unfortunately not rail-to-rail, so "high" is ~4.5V, "low" ~0.5V.
When the opamp output is "low", it means that the voltage tripping has not occured. The PNP (Q2) is therefore saturated and pulls the Gate to ground, making the MOSFET go wide open and Vcc_OUT is around Vcc. This is expected, and also works as expected.
When the opamp output is "high", it means that the voltage tripping has occured. The PNP is cut-off, and Gate is tied to Vcc effectively closing the MOSFET and cutting off the supply to Vcc_OUT. This also works as expected.
Background info about Vcc
Vcc comes from a linear regulated power supply. A 9V-transformer is rectified, fed and filtered into a 7805. Their design are beyond my reach. Sometimes error can occur and the Vcc gets raised slightly, and that's where my voltage monitor comes in.
Absolute worst case disaster scenario would be if the rectifier diodes and the 7805 all gets shorted, meaning Vcc will be 9VAC (RMS), around 13VAC. This will instantaneously kill everything.
The opamp controls the MOSFET as I expect, but when I played around earlier with my lab supply I increased Vcc to the level of the worst case scenario described above; 13V. At this voltage, the MOSFET conducted (or whatever the word, it was not "cut-off")! It should definately not conduct at this Vcc-level! My test-LED that's connected to Drain was very, very lit.
I turned my lab supply back to 5V, and the LED went dark. Increased to 6V, still dark. 7V, still dark. 8V: a tiny, tiny light can be seen in the LED. Increasing to about 10.5V made the Drain / Vcc_OUT have ~5V, and increasing to the disaster level 13V, Vcc_OUT was around 7V.
As stated earlier, this is my first try with a MOSFET so I'm unable to pin-point the error. My only hypothesis is that because Vcc is floating, and GND is not, the Vgs level is somehow affected at Vcc > 8V, making the MOSFET conduct (which it shouldn't).
Using this setup, is there any way to keep the MOSFET cut-off at all times whenever opamp is "high", no matter what level Vcc has?