High side P-Channel MOSFET with GPIO Pin with default on - Page 1
Forum section: electronics / projects

author: Bletru
author_rank: Newbie
timestamp: July 19, 2024, 08:23:31 pm
content: Hi everybodyI want to drive a 12V load with an GPIO pin (0V or 3.3V) of a micro-controller.It has to be the high side as I do not have access to the GND of the load.Instead of a transistor or and N-Channel MOSFET I wanted to use an optocoppler to drive the gate of the P-Channel MOSFET.The default state should be ON, i.e. taking the gate to GND which will be done by R12.If I want to turn OFF the load, the pin of the micro-controller will go to HIGH (3.3V) which shouldmake the optocoppler connect 4 to 3 and pull-up the gate to VCC (12V). R13 and R11 are here for current limitation.As you can imagine (otherwise I would not make this post), it does not work and I am sure that I am another victimof this "negative voltage" theory of the P-Channel MOSFETs.If anybody could take a look and see what's wrong with this circuit.Thanks in advance

author: moffy
author_rank: Super Contributor
timestamp: July 19, 2024, 09:20:49 pm
content: Just a few comments and questions.1. You say it doesn't work but not how it isn't working.2. You use an optocoupler, which is used for isolation, then show both grounds connected together?3. What you show should work if wired correctly.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: July 19, 2024, 10:03:33 pm
content: Quote from: Bletru on July 19, 2024, 08:23:31 pmAs wired, you are not taking the MOSFET gate to 0V.You do notneedan opto coupler here, you can get the same results with a single SMD package resistor Biased transistor pair NPN+PNP, giving Hi = OFF

author: moffy
author_rank: Super Contributor
timestamp: July 19, 2024, 10:06:53 pm
content: Quote from: PCB.Wiz on July 19, 2024, 10:03:33 pmTrue, my bad.

author: Benta
author_rank: Super Contributor
timestamp: July 19, 2024, 10:40:53 pm
content: Unless high speed switching is involved, this is a typical task for a photovoltaic optocoupler.The Vishay VO1263 is one of the best on the market, but look around.P- or N-channel MOSFET (doesn't matter), the VO1263 and two resistors will do the job.Doesn't get much simpler.

author: Bletru
author_rank: Newbie
timestamp: July 20, 2024, 08:13:43 am
content: Some more details:I have tested the circuit by putting 0V and 3.3V directly to the GPIO pin input of the circuit. It behaves as expected.But if I put my M5Atom (ESP32) with a pin configured as digital output and switching state every 2 seconds, I getonly 1.1V at the R11 input and I do not see any change between high and low state.If have mesured 2mA the current consumption of the optocoppler and its resistance. This should be no problemto be driven by the output pin of a ESP32!!??

author: Bletru
author_rank: Newbie
timestamp: July 20, 2024, 08:20:17 am
content: Quote from: Benta on July 19, 2024, 10:40:53 pmCould you please explain the difference between the VO1263 and the PC817?I do not see any evidence why one should be better than the other.

author: Bletru
author_rank: Newbie
timestamp: July 20, 2024, 08:21:14 am
content: Quote from: PCB.Wiz on July 19, 2024, 10:03:33 pmIf the optocoppler is open, the R12 will take the gate to ground. But perhaps is that the thing that I do not understand with P-Channel MOSFETs??

author: moffy
author_rank: Super Contributor
timestamp: July 20, 2024, 08:30:44 am
content: Quote from: Bletru on July 20, 2024, 08:13:43 amPerhaps you are overloading the pin, some pins have quite low drive currents, and for some you can even configure the drive current level.

author: Bletru
author_rank: Newbie
timestamp: July 20, 2024, 08:59:21 am
content: Here a more complete configuration of the circuit including the step-down converter LM2596 for converting the 12V to 3.3V for the M5 Atom.It seems that the M5 Atom is even not running eventhough the output of the converter is showing 3.3V and when shortcircuiting 3.3V with the R11 the circuit works.I am sure that I mess something up with the fact that the 12V is the "ground" and the GND is "-12V". In this point of view, the 3.3V becomes -8.7V and with its ground at -12V ...Perhaps I should only invert the 3.3V and the GND pin of the M5 Atom?

author: Smokey
author_rank: Super Contributor
timestamp: July 20, 2024, 09:08:45 am
content: https://www.digikey.com/en/products/filter/power-distribution-switches-load-drivers/726Off the shelf.

author: BennoG
author_rank: Frequent Contributor
timestamp: July 20, 2024, 09:45:51 am
content: below is your fixed schema this should work.Benno

author: Avelino Sampaio
author_rank: Frequent Contributor
timestamp: July 20, 2024, 09:49:55 am
content: For a collector current of 100µA you do not need a current of If=10mA. For a CTR of 100% a current If=1mA would be sufficient. Test with R11=1k ( If=2mA).

author: Benta
author_rank: Super Contributor
timestamp: July 20, 2024, 10:08:10 am
content: Quote from: Bletru on July 20, 2024, 08:20:17 amThe VO1263 is a PHOTOVOLTAIC coupler (think solar panels). It generates a voltage/current for the MOSFET gate.The PC817 is just a switch.

author: Bletru
author_rank: Newbie
timestamp: July 20, 2024, 10:09:50 am
content: All clear, "problem solved", everything is working perfect now.I always tested against the GND rail on the PCB .... and the GND pin of the M5 Atom had a cold soldering joint.Sorry everybody, and thanks anyway to everybody who contributed to try to solve the problem.NB: if anybody has a good idea of a good soldering mask tool for self-made CNC PCBs...

author: Peabody
author_rank: Super Contributor
timestamp: July 20, 2024, 02:22:38 pm
content: So are you clear now on P-channel mosfets?

author: Bletru
author_rank: Newbie
timestamp: July 20, 2024, 03:48:46 pm
content: Quote from: PCB.Wiz on July 19, 2024, 10:03:33 pmConcerning the transistor: Yes and No, because mixing up 12V at the collector and 3.3V at the gate needs rather a particular NPN transistor in order to get a usable voltage at the output.That's why have prefered an optocoppler which has more or less an ON-or-OFF behavior...

author: PCB.Wiz
author_rank: Super Contributor
timestamp: July 20, 2024, 08:16:37 pm
content: Quote from: Bletru on July 20, 2024, 03:48:46 pmIt’s not a single transistor, it’s a PAIR.one biased NPN drives a biased PNP.A single small SMD part.