Use Mosfet as switch and control it by teensy

Status
Not open for further replies.

Gripporillat

Well-known member
Hi everybody!

I'm trying to figure out how to use a mosfet as switch and control it by a teensy. Is it gonna work like this?

Mosfet.jpg

If so, what resistor should I use as R1?

Thanks in advance!
Robert
 
It's not gonna work like this, since there is no common reference potential. Stand by, I'll get my iPad and draw a working schematic for you...
 
Here it is :
fullsizeoutput_20d9.jpg
R1 serves as a bypass resistor for the gate-source capacitance of the MOSFET and would by around 10kOhm when using a common N-MOSFET like the BS170 as long as the switching frequency wouldn't go up in the RF range which would require smaller values. R2 has to eat up the difference of the battery voltage and the LED's forward voltage (typically 2V) when the LED forward current (typically 20mA) flows. Here (14.4 - 2)V / 0.02A. Next standard value would be 680 Ohm.
 
Thank you very much! Just for my better understanding: if the teensy would be driven by a USB hub, which is driven by a DC DC buck converter which is driven by the same 14.4V battery that drives that Led - would my circuit work?
 
Why making it so complicated ? No USB hub is needed for that. You can use a 14.4V to 5V converter and power the Teensy directly via its Vin pin with these 5V.
 
So, you might go with the USB hub. The latter will have to power the Teensy and probably other devices present on the hub, so count 500mA per USB device connected for the current which the buck converter should be able to provide.
 
Yes, because my circuit would work and yours not... :)

You might still try to build yours for pedagogic fun, just to see that in the best case it just would not work and in the worst case (drain-gate capacitance charge current in the mosfet) it could kill your Teensy. I don’t know where you studied electronics, but that’s pretty obvious.
 
:D I'm very new to this stuff. Thank you very much for your help. And since it's the only teensy I have at the moment I will have to renounce this pedagogic fun ;)
 
I would advise against building that circuit.

Most discrete mosfet transistors have some sort of gate protection circuit built in. Depending on how the other connections are made, though the hub and its power supply, you could possibly end up with a conduction path from the 14.4V power, through that protection circuit, right to the 3.3V only pin on your Teensy.

Theremingenieur's circuit is good. :)
 
On the battery, there are 2 common cases for 14.4V.

If you have 4 lithium ion cells in series, then this warning doesn't apply.

But if your 14.4V is from the electrical system of a car or truck, where it's 12V with only the battery and 14.4V when the engine is running, then you should plan for the high voltage spikes which most cars alternators produce when the battery is disconnected. You can find plenty of info about this online. Many people have learned of these harsh automotive realities the hard way.
 
Thank you for this warning Paul, I will keep it in mind for whenever I will build a automotive project. In this case its 4 lithiom ion cells.
 
Here it is :
View attachment 15952
R1 serves as a bypass resistor for the gate-source capacitance of the MOSFET and would by around 10kOhm when using a common N-MOSFET like the BS170 as long as the switching frequency wouldn't go up in the RF range which would require smaller values. R2 has to eat up the difference of the battery voltage and the LED's forward voltage (typically 2V) when the LED forward current (typically 20mA) flows. Here (14.4 - 2)V / 0.02A. Next standard value would be 680 Ohm.

Hello Theremingenieur.

1. Regarding the bypass resistor. would the teensy output being pulled low not acheive the same thing?

2. I don't think I've seen a series resistor going too the gate but I always wonder what limits the current on the teensy output to charge the gate capacitance?

I only have basic understanding of electronics and the couple of times I've required to used a mosfet basically as a switch I've used a driver because I wasn't sure.


1.PNG
 
Hello Theremingenieur.

1. Regarding the bypass resistor. would the teensy output being pulled low not acheive the same thing?
Yes, as long as the Teensy is powered. With the Teensy off and the pin in hi-Z state, the Mosfet needs a defined state though, to protect the metal oxide gate isolation layer.

2. I don't think I've seen a series resistor going too the gate but I always wonder what limits the current on the teensy output to charge the gate capacitance?
A series resistor as a current limiter or even an additional more powerful driver stage can be needed for power mosfets with higher gate capacitance. Here, since we are only switching one single 20mA LED, a small signal mosfet like a BS170 is sufficient. Its gate capacitance is small enough to not harm the Teensy's internal GPIO drivers which can source or sink 10mA.

I only have basic understanding of electronics and the couple of times I've required to used a mosfet basically as a switch I've used a driver because I wasn't sure.
If you aren't sure, using a driver or buffer is never wrong. But aren't you curious to fully understand the way of each single electron before you take the soldering iron in hands? I don't know how things are taught nowadays in schools and universities, but when I was young, people had to successfully finish their first year of theoretical semiconductor physics before they were allowed to experiment with CMOS stuff...
 
Thanks for quick reply.
That's cleared that up.

I regret dropping out of uni (around 15 years ago), but I blame age of empires II more than the universities course structure.
 
Since I realised that I feel way safer with a high side switch and want to avoid ground loops, I decided to replace the nmos with a pmos and use an optocoupler. Is there anything wrong with this circuit?

Optocoupler.jpg
 

This is a rather strange way to draw a schematic. While it may be technically correct, when using schematics to communicate with other humans, you really should follow the long established conventions.

Schematics are arranged so the more positive voltages are towards to top and most negative at the bottom.

Usually signal or data flow (or causal effects) are arranged left to right, where inputs are on the left side and outputs are on the right.
 
This is a rather strange way to draw a schematic. While it may be technically correct, when using schematics to communicate with other humans, you really should follow the long established conventions.

Schematics are arranged so the more positive voltages are towards to top and most negative at the bottom.

Usually signal or data flow (or causal effects) are arranged left to right, where inputs are on the left side and outputs are on the right.

Yes, I'm sorry for that. I couldn't find a pmos symbol in Kicad where the source pin is the top pin so I tried to arrange the rest in a still somehow understandable way. I seem to have failed.
 
Of course you're right. Obviously I knew about the rotating function but somehow I didn't think about the possibility of mirroring objects. So this is hopefully better readable:

Optocoupler.jpg
 
Status
Not open for further replies.
Back
Top