Go Down

Topic: P-Channel mosfet controlling car 12v light (Read 65194 times) previous topic - next topic

kajmaya

I would like to control a 12v light in a car. (grounded on one side) will this circuit work?



Thanks


Grumpy_Mike

Swap over the source and drain an it will.

jwatte

#2
Nov 02, 2012, 06:30 pm Last Edit: Nov 02, 2012, 06:34 pm by jwatte Reason: 1
You can see the diode pointing forwards on the P-channel, so yeah, swap that around.
Also, I think the 10 kOhm pull-up is a bit weak. It will make the P-channel switch slowly, and if it's weak and/or the load is heavy, it might overheat.
Also, the transistor and base current limiting resistor are not needed. A 500 Ohm or 1 kOhm resistor from the Arduino to the gate of the MOSFET is all you need if you're using an N-channel that switches on the bottom -- that will be a lot more efficient. If you still need a P-channel, then use a 500 Ohm or 1 kOhm resistor into the gate of a small-signal N-channel MOSFET (like the BS170) and a 1-2 kOhm pull-up, instead of the BJT NPN you're using.

So, what I would do, assuming the grounding of the lamp is not interruptible or reversible to power (so, must use P-channel):
500 Ohm resistor from Arduino to gate of BS170. BS170 source to ground, BS170 drain to P-channel gate and 2 kOhm pull-up to 12V. P-channel source to 12V. P-channel drain to light.

MarkT

The way car bulbs are wired is one side to the grounded chassis, so that only one wire needs to be run to the light,
so high-side switching is mandatory - that circuit (with source and drain swapped) is OK unless you want to PWM the light, where the
weak-pullup will start to be an issue (by causing slow switching).

You do need to ensure the p-channel device has a low enough on-resistance for the load in question. Aim for no more than 0.25V across the device when on (IR), and less than 0.5W dissipation (I^2 R) if poss - otherwise a heatsink becomes needed.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

kajmaya

So if I use an N-channel the circuit would look like this?


majenko

No, again it is backwards - look at the diode inside the FET.

Also, N-Channel is better for low-side switching.  I would stick to the P-Channel and keep the NPN.

One addition I would recommend is a 10K? pull-down resistor between the base of the NPN and ground.  This will force the NPN to be OFF when the input is floating, which it will be before you to a pinMode(xx,OUTPUT); on the relevant IO pin.

MarkT


So if I use an N-channel the circuit would look like this?




No - the simple rule is drain always connects to load, n-channel switches on low-side, p-channel on high-side (for a positive supply rail).
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Grumpy_Mike

Quote
Also, the transistor and base current limiting resistor are not needed. A 500 Ohm or 1 kOhm resistor from the Arduino to the gate of the MOSFET is all you need if you're using an N-channel that switches on the bottom

Yes but he is not he is using a P channel FET so that transistor IS needed to ensure the FET can turn off.
What was it about
Quote
Swap over the source and drain

That is puzzling you? You still have not done it.

dhenry

Quote
the simple rule is drain always connects to load


Simple rules are generally wrong. There are cases where you may want to switch a load on source/emitter.

Grumpy_Mike

#9
Nov 02, 2012, 08:23 pm Last Edit: Nov 02, 2012, 08:25 pm by Grumpy_Mike Reason: 1
Quote
There are cases where you may want to switch a load on source/emitter.

And do we know why we generally do not oh dear Henry?

I'll give you a clue, we are switching a 12V load with a 5V signal. Ring any bells? Light any lights?

kajmaya


Quote
Also, the transistor and base current limiting resistor are not needed. A 500 Ohm or 1 kOhm resistor from the Arduino to the gate of the MOSFET is all you need if you're using an N-channel that switches on the bottom

Yes but he is not he is using a P channel FET so that transistor IS needed to ensure the FET can turn off.
What was it about
Quote
Swap over the source and drain

That is puzzling you? You still have not done it.


Oh, yea (S=source) oops. i'm not thinking. So is this correct for an N-channel MOSFET?
I changed the resistor as well.
(I omitted the Diodes inside the fet for faster drawing on my side)


dhenry

There needs to be a pull-up or your mosfet will never turn off the lamp.

Take one of your earlier schematic and just swap out drain and source.

kajmaya


There needs to be a pull-up or your mosfet will never turn off the lamp.

Take one of your earlier schematic and just swap out drain and source.


I thought with an "N" you didn't need the pull-up. But the "P" you do. I changed to the "N" MOSFET because of "jwatte" suggestion and did the switch at the bottom. Otherwise I will swap the "D" and "S" and go with my original post the "P-channel MOSFET". Im starting to get a bit confused.

I would rather go the "N" route as I have very little board space.

What do you think?

runaway_pancake

Here's what a few have tried to get you to do, note the difference in the FET's Source and Drain


Quote
I would rather go the "N" route as I have very little board space.

You will have to place that between the lamp and Ground (chassis).  How will you do that?
"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

kajmaya


Here's what a few have tried to get you to do, note the difference in the FET's Source and Drain


Quote
I would rather go the "N" route as I have very little board space.

You will have to place that between the lamp and Ground (chassis).  How will you do that?


Yes I understand

Thanks

Go Up