# Why is this MOSFET showing this behaviour?

I have solar charge controller PCB in which I am using MOSFET IRF9540. I am using ATmega328P as microcontroller to read the voltages of battery and solar and to enable/disable the charging process. Below is the schematic:

Now in the above schematic, I am giving solar voltage at X1 connector. R1 and R2 are used as a voltage divider and its output is going to an analog pin of the microcontroller. CHARGEPIN is a GPIO of the microcontroller. So when this GPIO is high, it turns on the transistor, which then turn on the MOSFET and solar is then connected to the battery to start the charging process. When the GPIO is low, solar and battery are disconnected. I am also using a serial port to monitor the voltages.

Now what's happening is when I have not connected the solar pins and only connected the battery pins. At that time, charging is off (because we do not have a solar voltage), so CHARGEPIN is low thus, the MOSFET will be OFF. So solar and battery should be disconnected. But somehow battery voltage is going to solar voltage because when I read the voltage at the MBR2045 diode, it shows the battery voltage, which should not show because the MOSFET is OFF. Why is the MOSFET acting like this?

• Do measurements of the voltages of all terminals of the FET, then you will see why it does what it does. – PlasmaHH Feb 9 '17 at 12:41
• @PlasmaHH At drain, it is 12.32 and at gate and source it is 11.7. Can you explain more. Thanks – S Andrew Feb 9 '17 at 12:43
• Hm, I just saw you are using a PMOS... Anyways, have you considered the effect of the body diode? – PlasmaHH Feb 9 '17 at 12:47
• Look up "body diode". – WhatRoughBeast Feb 9 '17 at 12:47

MOSFETs have an internal diode that conducts in the reverse direction thus you see battery voltage on the diode node: -

Note the diode above. There is usually a diode junction from both source and drain to the substrate in both P and N channel MOSFETs. Here's the P channel MOSFET: -

What usually happens is that the manufacturer connects the "body" terminal to the source terminal so that one of the diodes can never be forward biased and this leaves the other diode able to be forward biased only when drain rises higher than source (P channel MOSFET).

• This is why I insist that when appropriate, MOSFET symbols get drawn with the body diode present! It's an immediate reminder / clue into behavior of your circuit. – Krunal Desai Feb 9 '17 at 18:59

The P-channel power MOSFET has a body diode that points from drain to source.

The diode is actually the PN junction between the drain contact and the substrate. The substrate needs to be held at a higher voltage than all of the other terminals in order to keep those PN junctions from conducting. In a MOS IC the P-channel substrate is normally connected directly to Vdd. However, in nearly all discrete MOSFETs, the substrate is not brought out as a separate terminal; instead, it is bonded directly to the source terminal, which is expected to be the most positive terminal of the device.

If you want bidirectional isolation, you'll have to use two MOSFETs in a back-to-back arrangement. Driving the gates can be tricky; things are simplified somewhat if you connect the sources together — then the gates share a common reference and can also be connected together.