Author Topic: High side P-Channel MOSFET with GPIO Pin with default on  (Read 552 times)

0 Members and 2 Guests are viewing this topic.

Offline BletruTopic starter

  • Newbie
  • Posts: 7
  • Country: ch
High side P-Channel MOSFET with GPIO Pin with default on
« on: July 19, 2024, 08:23:31 pm »
Hi everybody
I 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 should
make 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 victim
of 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
 

Offline moffy

  • Super Contributor
  • ***
  • Posts: 1913
  • Country: au
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #1 on: July 19, 2024, 09:20:49 pm »
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.
 
The following users thanked this post: Bletru

Online PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1684
  • Country: au
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #2 on: July 19, 2024, 10:03:33 pm »
If anybody could take a look and see what's wrong with this circuit.

As wired, you are not taking the MOSFET gate to 0V.

You do not need an opto coupler here, you can get the same results with a single SMD package resistor Biased transistor pair NPN+PNP, giving Hi = OFF
 
The following users thanked this post: moffy

Offline moffy

  • Super Contributor
  • ***
  • Posts: 1913
  • Country: au
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #3 on: July 19, 2024, 10:06:53 pm »
If anybody could take a look and see what's wrong with this circuit.

As wired, you are not taking the MOSFET gate to 0V.

True, my bad.
« Last Edit: July 19, 2024, 11:14:38 pm by moffy »
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6031
  • Country: de
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #4 on: July 19, 2024, 10:40:53 pm »
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.

 

Offline BletruTopic starter

  • Newbie
  • Posts: 7
  • Country: ch
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #5 on: July 20, 2024, 08:13:43 am »
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 get
only 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 problem
to be driven by the output pin of a ESP32!!??

« Last Edit: July 20, 2024, 08:25:34 am by Bletru »
 

Offline BletruTopic starter

  • Newbie
  • Posts: 7
  • Country: ch
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #6 on: July 20, 2024, 08:20:17 am »
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.

Could 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.
 

Offline BletruTopic starter

  • Newbie
  • Posts: 7
  • Country: ch
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #7 on: July 20, 2024, 08:21:14 am »
If anybody could take a look and see what's wrong with this circuit.

As wired, you are not taking the MOSFET gate to 0V.

You do not need an opto coupler here, you can get the same results with a single SMD package resistor Biased transistor pair NPN+PNP, giving Hi = OFF

If 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??
 

Offline moffy

  • Super Contributor
  • ***
  • Posts: 1913
  • Country: au
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #8 on: July 20, 2024, 08:30:44 am »
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 get
only 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 problem
to be driven by the output pin of a ESP32!!??

Perhaps you are overloading the pin, some pins have quite low drive currents, and for some you can even configure the drive current level.
 

Offline BletruTopic starter

  • Newbie
  • Posts: 7
  • Country: ch
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #9 on: July 20, 2024, 08:59:21 am »
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?
 

Offline Smokey

  • Super Contributor
  • ***
  • Posts: 2702
  • Country: us
  • Not An Expert
 
The following users thanked this post: Bletru

Offline BennoG

  • Regular Contributor
  • *
  • Posts: 103
  • Country: nl
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #11 on: July 20, 2024, 09:45:51 am »
below is your fixed schema this should work.

2316859-0

Benno
« Last Edit: July 20, 2024, 09:47:25 am by BennoG »
 
The following users thanked this post: Bletru

Offline Avelino Sampaio

  • Frequent Contributor
  • **
  • Posts: 263
  • Country: br
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #12 on: July 20, 2024, 09:49:55 am »
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).
 
The following users thanked this post: Bletru

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6031
  • Country: de
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #13 on: July 20, 2024, 10:08:10 am »

Could 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.

The VO1263 is a PHOTOVOLTAIC coupler (think solar panels). It generates a voltage/current for the MOSFET gate.
The PC817 is just a switch.
 
The following users thanked this post: Bletru

Offline BletruTopic starter

  • Newbie
  • Posts: 7
  • Country: ch
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #14 on: July 20, 2024, 10:09:50 am »
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...
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2085
  • Country: us
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #15 on: July 20, 2024, 02:22:38 pm »
So are you clear now on P-channel mosfets?
 

Offline BletruTopic starter

  • Newbie
  • Posts: 7
  • Country: ch
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #16 on: July 20, 2024, 03:48:46 pm »
If anybody could take a look and see what's wrong with this circuit.

As wired, you are not taking the MOSFET gate to 0V.

You do not need an opto coupler here, you can get the same results with a single SMD package resistor Biased transistor pair NPN+PNP, giving Hi = OFF

Concerning 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...
 

Online PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1684
  • Country: au
Re: High side P-Channel MOSFET with GPIO Pin with default on
« Reply #17 on: July 20, 2024, 08:16:37 pm »
If anybody could take a look and see what's wrong with this circuit.

As wired, you are not taking the MOSFET gate to 0V.

You do not need an opto coupler here, you can get the same results with a single SMD package resistor Biased transistor pair NPN+PNP, giving Hi = OFF

Concerning 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...
It’s not a single transistor, it’s a PAIR.
one biased NPN drives a biased PNP.
A single small SMD part.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf