checking my logic on n-channel as a power switch

I need to double check my logic on this.

I'm using a 2n7000 n-channel as a switch (to deny power to a bluetooth device to power it down).

If I connect the source to ground, and an Arduino output through a 2k resistor to gate, and then connect the drain to a whatever, that whatever should be able to pass current to ground (thus live, or turn on, light up, etc.) when given a LOW from the Arduino, and should be isolated from ground (so no current flow) when the gate is driven with a HIGH.

Am I correct here?

thanks,

hawk

you should switch power using P Channel / High side ... there are issues with low side switching with power.

I started with high-side switching. In fact, I started with running it off an output pin (it's well within capacity).

The problem is that it picks up enough parasitically through it's RX that it stays power at times.

It's not the power budget, but that EN isn't enabled on most of these cheap bluetooth devices, and killing power is the only way to drop the connection!

Eventually, I'll have these switched over to nerf, but I need to build another pi first (I can talk to blue from my phone).

Yes, I have apparently lost my pi to someone cleaning house ::slight_smile:

(the pi is to be a base station monitoring the various garden stuff. This particular arduino lives in the garage as a sprinkler and irrigation controller).

dochawk:
I need to double check my logic on this.

I'm using a 2n7000 n-channel as a switch (to deny power to a bluetooth device to power it down).

If I connect the source to ground, and an Arduino output through a 2k resistor to gate, and then connect the drain to a whatever, that whatever should be able to pass current to ground (thus live, or turn on, light up, etc.) when given a LOW from the Arduino, and should be isolated from ground (so no current flow) when the gate is driven with a HIGH.

Am I correct here?

thanks,

hawk

I think you have it backwards.

Are you connecting the whatever's ground pin to the drain? If so, then the whatever will turn on when the Arduino GPIO pin goes high. The N-channel will turn on when the gate is higher than the source.

Alternatively, you could use a P-channel in the line to the whatever's Vcc pin. In that case the Arduino's GPIO pin would be brought low to turn the mosfet ON. The source would be connected to the power supply, and the drain would be connected to the whatever's Vcc pin.

eeks!

I hadn't considered that I had the output pin backwards.

Let's see if I have this straight, then.

An N-channel with its gate floating or lower than the source allows no conventional current flow from drain to source.

An N-channel with gate voltage > source allows conventional current drain from drain to source.

An N-channel always allows conventional current from source to drain.

(and flipped for P-channel).

I successfully used the arduino output directly, but had too many drops. Then I got it working with the mosfet, and had to spend a month away on other projects.

I suppose that a 100uf cap across would solve the fluctuations as much as powering through a mosfet, but I still need to get my he'd swapped around mosfets.

(for this particular part, Vcc doesn't seem to be an option; it powers itself parasitically through it's RX pin [hmm, but maybe if I force that to float, too; I don't recall whether or not I tried that])

Hmm, and is there any reason that I couldn't use the n-Channel between Vcc and the power pin of my device?

And, finally, I had thought that n-channel was generally preferred to p-channel for power switching. Was I wrong?

And, finally, I had thought that n-channel was generally preferred to p-channel for power switching. Was I wrong?

You are wrong to think in terms of what is preferred; that kind of thinking is fine for pizza toppings, what matters here is what will do the job you want to do. If you switch ground then you end up with your device connected to power but not ground, that's probably OK for a motor or light that has no other connections, but for anything that has connections to other things then you have to consider the consequences of those connections being connect to the supply voltage. If they are outputs driving the inputs on other devices then they will take those inputs high, is that acceptable? What are the consequences of doing so? If they are inputs, perhaps with a button to ground for example, then what happens when that input is taken low? It may well be that taking the input low provides an alternative ground and thus parasitic powering to the device you thought was switched off. Switching the supply rather than ground generally makes dealing with these kinds of issues easier, but it is not about preference, it is about what makes the circuit design behave in the way you desire.

Always use high side switching for active modules. Pololu has a good selection.

This one would be a good choice for your application. It can be controlled by the built in switch, an external switch, or a microprocessor output pin.

dochawk:
An N-channel with its gate floating or lower than the source allows no conventional current flow from drain to source.

A floating gate can couple signal and turn on the MOSFET. You should have a resistor between gate and source to prevent that.

An N-channel with gate voltage > source allows conventional current drain from drain to source.

Not quite. The threshold voltage that allows the 2N7000 to start conducting is 0.8-3.0V.

An N-channel always allows conventional current from source to drain.

Conventional current would be from drain to source.

Hmm, and is there any reason that I couldn't use the n-Channel between Vcc and the power pin of my device?

Driving a load high side with an N channel MOSFET is problematic because the gate voltage would need to be several volts above the load voltage.

And, finally, I had thought that n-channel was generally preferred to p-channel for power switching. Was I wrong?

This is wrong. N channel devices are used for switching low side and P channel devices are used for switching high side. You should have no difficulty finding power devices of either polarity.

You can switch ground or power. The only advantage to switching power high side is that no voltage is present on the load unless MOSFET is turned on (aside from a small leakage current). With low side switching, voltage is present at the load, but only leakage current flows unless the MOSFET is turned on.

Also be mindful that when you use a MOSFET as a switch, you need to drive the gate hard enough that it operates in a low RDS(on) region. The curves in the datasheet show characteristics for a "typical" device. Most of the devices you buy will be in that category, but it's possible to get some at the spec extremes and conservative circuit design would consider that.

A mosfet gate should never be allowed to float. A floating gate may pick up ambient electronic noise that will cause the state of the mosfet to be essentially undefined, which is not what you want. That's why mosfet gates almost always have a pullup resistor (P-channel), or pulldown resistor (N-channel) so they are off by default. Bipolar transistors are more forgiving in this regard because they are current-based devices, and require material current to flow through the base to turn them on, so stray rf is unlikely to cause a problem.

And not to further confuse you, but while it is the gate-source differential voltage that determines whether the mosfet conducts, if it IS turned on, it can conduct pretty much equally well in either direction through the drain and source. But mosfets also have body diodes across drain and source, so it does matter how you orient them when using them as a switch. It doesn't do any good to turn off the mosfet if the body diode still lets current through.

Hmm, and is there any reason that I couldn't use the n-Channel between Vcc and the power pin of my device?

You would have to apply voltage to the gate that is higher than Vcc to turn on an N-channel mosfet. Similarly, using a P-channel to switch the ground line would require a gate voltage below ground. So unless you are a glutton for punishment, you would typically use a P-channel to switch the high side, or an N-channel to switch the low side. As others have said, it's usually best to switch the high side.

And, finally, I had thought that n-channel was generally preferred to p-channel for power switching.

N-channel mosfets are theoretically more "perfect" transistors than P-channels. They usually have lower ON resistance, and can handle more current. But the differences are not very large, so really it's pretty much a question of what suits your circuit best.

Thanks to all. I now hv a small bit of what I knew bout this decades ago, when I actually understood the fields themselves and could do the raw math . . .

A couple of notes:

  1. I had to switch from high side to low side switching due to the device powering itself parasitically. And as a practical matter, I have a bag of these n-channels sitting around. I switched from the raw pin to the mosfet simply because from time to time, it would apparently lose enough power to reset the device. I probably could have solved this with a capacitor . . . (if I killed power in one line of code, and restarted in the next, it wouldn't even shut off, but a was delay caused it to shut). I might also have solved the parasitic drain by stopping AltSoftSerial and turning TX to an input until it was turned on again.

  2. while I have coming projects in which I would like to save the power of the device always on, kn this case, it was a matter of being the only way to break the connection once established.

  3. in playing around with jumpers, it seems that if I let the gate to the 2n7000 float, and applied vcc and ground to the 2k resistor, it would stay on for several seconds. On power floating, it was somewhere between on and off (a light flicker from the led on the BT device).

  4. there's no chevy draw; all of the pins connect to the arduino.

And one last thing to check on:

dl324:
me:>An N-channel always allows conventional current from source to drain.
Conventional current would be from drain to source.

But that's when on, correct? I mean that when off, the diode still allows current in that direction.

Thanks to all

hawk, now with a somewhat fuller brain

dochawk:
But that's when on, correct? I mean that when off, the diode still allows current in that direction.

The body diode is reverse biased for normal operation.