High speed Mosfet switch: need help - Page 1
Forum section: electronics / projects

author: girishji
author_rank: Contributor
timestamp: October 03, 2022, 10:11:54 am
content: I am trying to design a switch that can turn on/off a 5V supply (500 mA load) using a 3v3 GPIO pin of a mcu. It should switch within a microsecond or so. The switch will be turned off/on at 10kHz (every 100 us).I tried BSS138 N channel enhanced Mosfet, connected the Gate directly to GPIO pin (without gate resistor), connected Source to ground (low side switch) and Drain to 5V pin. It takes 35 us to switch. Too long. I am not sure what is causing delay. The gate capacitor should charge up quickly given the specs. Maybe it needs a complicated driver circuit.Is there a better solution?

author: Marian_elf
author_rank: Contributor
timestamp: October 03, 2022, 10:20:03 am
content: Are you sure that GPIO pin has a fast enough transition?Meaning without any load on it, does it has a fast enough rise time?How about with some resistive or capacitive load on it?Does the rise time change?A basic schematic of what you are testing could help.I am asking this because that mosfet seams very fast ( much faster that needed ), and it should work.

author: redkitedesign
author_rank: Regular Contributor
timestamp: October 03, 2022, 11:01:26 am
content: With 3.3V Vgs, and 500mA Id you are in, or close by the linear region of this FET (where it turns into a voltage (Vgs) controlled current(Id) source).Look at figure 1 in the OnSemi datasheet.You could try to see what happens with a 50mA load, or look for a newer FET with better characteristics.

author: Marian_elf
author_rank: Contributor
timestamp: October 03, 2022, 12:39:50 pm
content: I think what it is needed is a mosfet with a bigger case, 500mA from a sot23 seams a bit too much if you ask me.But anyway this one does have 0,22A stated as absolute maximum continuous current, that indeed makes it ill suited for this task.Here is a selection from Digikey:https://www.digikey.ro/en/products/filter/transistors-fets-mosfets-single/278?s=N4IgjCBcoGwJxVAYygMwIYBsDOBTANCAPZQDaIALAAxwDMdIAuoQA4AuUIAymwE4CWAOwDmIAL6EArAHYqiECkgYcBYmRC1psigmYh2nHgJHjCMKjHmLleQiUjlNADjiumrDpG58hoiSHMnKzQsWzUHEAAmaUi4SSDCaOkKSMtErQowNKjpJwoXEHS4KmkEIulJSMKopxhI2OrIp1KqOUS4erzGuhSIdrgsto1W2izq2ip6lOqwMDgtKsJMyRhpaopJFdp1zckyyidaLqWYWkkKdfg3KRoqSXW4U8WQSSowSL6XprGpb4SX17xS6ZWbVTYWZ4yCj0MEdI6wyIwqQDRGw94XMw0D7VOrSWjbMzRWgYgJE%2B6ELLSGBgbZ6AxeIy%2BUzgOAFaAKEIqOzqOSMfxzBjs6yhVT2cibJx7MHxcwPN77amZNZmMApZUBVVwEmKx44sCvT40xHHcC0Y3k02ImF0zzeYx%2BRIWIJCzlhMVRKgAAgAao1Ij7GhQA4lJMGamGJhHaBGg77CGcIzAI04w9RU6G4y8vZnNgGbZwAKqCfhsADyqAAsrh0NgAK68XDiMRiIA

author: Benta
author_rank: Super Contributor
timestamp: October 03, 2022, 07:22:57 pm
content: I wonder how a 360 mA device is supposed to switch 500 mA. Lots of open questions here, should probably be moved to "Beginners".

author: Marian_elf
author_rank: Contributor
timestamp: October 04, 2022, 02:58:06 am
content: Quote from: Mechatrommer on October 03, 2022, 07:12:38 pmThat wasn't clear to me either, that's why i've asked for a basic schematic of what was done...

author: girishji
author_rank: Contributor
timestamp: October 05, 2022, 07:55:21 am
content: Sorry for late reply as I have to leave town for a few days. Fee corrections:1) the load I put was drawing 5ma and not 500ma before D of mosfet (low side switch). My design requires up to 500ma but I was experimenting with small load and BSS 138 only because I happen to have this mosfet in my possession.2) The schematic I used is like this except Rg is 0 :https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSQhm7DAXk7D8jhWPxXrkD_bS1DY3rRFS614A&usqp=CAUWhen I get back I will experiment with Rg value that draws 20ma from GPIO pin (max allowed by blackpill).I am only measuring switch-on time here. I wait for 2ms for it to switch off before measuring again, hoping it is enough time for gate capacitor to discharge before switching on again.Q: Is anyone convinced that ‘enhanced logic level N mosfet’ can switch in nanoseconds as they advertise without driver circuit? I assume ‘logic level’ to mean 3v3 or 5v at the gate.From datasheets, these mosfets need considerable charge to be provided to the gate capacitor for them to switch on fully. They need a jolt at the gate to make them switch on in nanoseconds. No GPIO pin can provide this. If they happen to have low charge requirements at the G they will have higher resistance across DS, which means you need high voltage (say 10v) at G to drive these without major power loss. I want to avoid a complicated driver circuit or IC if I can avoid. Am I missing anything?

author: redkitedesign
author_rank: Regular Contributor
timestamp: October 05, 2022, 09:28:32 am
content: The total gate charge for this FET is about 2nC. Assuming you have 20mA drive strength, that yields (2nC/20mA) = 0.2us/V. Thus the gate should be at 3.3V in about half a us.If yours take 35us, there is something else going on. Too much gate resistance so you don't make the 20mA I would guess.

author: Marian_elf
author_rank: Contributor
timestamp: October 05, 2022, 09:41:55 am
content: That is why i suggested those tests on the GPIO pin it's self, you need to confirm it's fast enough both without any load on it, and with the mosfet's gate connected to it, thus you need to see if the mosfet it's self is the problem, or the drive is. Single shot capture on the rising edge, look at the transition time between the ground level and Vcc, see if it is much smaller then needed or for some reason it isn't. If let say without anything connected to that pin, the rising time is fast enough ( should be so ) but with the gate connected the rising time becomes much larger, than you do need a driver ( you can test this with any mosfet you decide to use, just to be sure ).There are SOT23 drivers that would do the job perfectly, very fast, logic level compatible inputs, and very low component count.More so, you can power them from a higher voltage ( let say 5V ), and still have a 3,3V control but more drive voltage to the gate, and less losses ( conduction and switching ).You can even improvise a 2 transistor totem poll but i would choose a sot23 driver anytime i would need one.

author: girishji
author_rank: Contributor
timestamp: October 06, 2022, 07:48:53 am
content: @reddkitedesign I think your calculation is dubious. Equation is exponential, not linear. There is a dV/dt in there. Besides gate resistance itself is a function of Vgs.

author: girishji
author_rank: Contributor
timestamp: October 06, 2022, 07:57:10 am
content: @Marian_elf it is futile to test GPIO pins (without load) for sharp edge of pulse, except for defects. I tested on couple of ST32f4 boards and same behavior. It appears 3v3 is not sufficient to rapidly charge the gate capacitor. I haven’t seen examples on internet of anyone achieving nanosecond switch on with 3v3 at the gate.Maybe a driver circuit is the answer.

author: redkitedesign
author_rank: Regular Contributor
timestamp: October 06, 2022, 08:58:40 am
content: Quote from: girishji on October 06, 2022, 07:48:53 amMy calculation gives an order of magnitude. And look carefully: I calculate 2nC/20mA = 0.2us/V. Which is of course wrong, it should be 0.1us/V. You can just as easily do 20mA/2nC = 10MV/s. Which the dV/dt you were looking for.Gate resistance of the BSS138 is a few ohms. At 20mA, that would give maybe 0.1V voltage drop over the resistance. Not relevant compared to the 3.3V power supply, by the time it will materially affect the charge current the gate is already way over the threshold voltage and the FET is solidly conducting.The exponential formula can be ignored. Unless there is some material gate resistance, or your GPIO is not putting out 20mA. Did you configure the pin for maximum drive strength/fastest operation?Just to verify I'm not talking out of any orifice here I measured a board I've got laying around. It has a ATMEGA4809 CPU, so its 5V and not 3V3. And the FET is an 2N7002. It drives an red led with series resistor.Switching time is about 0.6 us. 2N7002 gate charge is about 1nC. Microchip doesn't spec GPIO pin drive impedance, but is specs 15mA for a part at 5V. So it is in the same magnitude as I calculated for your situation.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 06, 2022, 03:13:23 pm
content: That's a pretty weak fet, with Vgs=4.5V Rds is 3.5ohm, so at 3.3V Rds will be even higher.Find a better fet suitable for the job!There're specific fets meant to work well with logic voltage levels of 3-5V.You can also try a MOSFET driver, they're cheap and will switch waaaay faster.Use the higher gate voltage you can, 5v will switch faster than 3.3V and so on.There's little to no gain over 12V, that's a typical working Vgs, also you want to avoid getting too close to the absolute limit of 18-20V.Today I tested a TC4452 driver, switching a 1200V GW38IH130D IGBT which has a fairly large gate capacitance of ~3nF.Using 12V for VDD and adding a little overkill capacitor bank of 6x100nF ceramic caps at VDD pin to stand the heavy switching current spikes, it was able to toggle the gate at 1MHz without much effort with rising/falling times of 75/50ns, which I find crazy for a transistor of this size.Of course this frecuency is not practical, the transistor spends a lot of time in the edges causing power loses and heating, the actual frecuency will be about 25KHz.

author: girishji
author_rank: Contributor
timestamp: October 08, 2022, 08:51:18 am
content: Solved.I connected a resistor between Gate and GPIO pin and now it is switching within 1us both ways (on/off). Current to Gate is now capped at 20ma because of resistor.Connecting GPIO pin directly to gate was the problem. Maybe there was a spike in current that briefly shutoff GPIO pin.I still need to chose a better FET with higher drain current capability, but thanks everyone for various suggestions.

author: Terry Bites
author_rank: Super Contributor
timestamp: October 08, 2022, 09:05:57 am
content: I cant find wattage in any datasheet....

author: Marian_elf
author_rank: Contributor
timestamp: October 08, 2022, 10:27:17 am
content: Quote from: girishji on October 06, 2022, 07:57:10 amTesting is never futile, in fact you can never have too much testing, it's the only way to really understand a problem.Besides i said to test it both with and without capacitive load, it would have gave you a base line for comparison of how it can react when dealing with capacitive loads.Quote from: girishji on October 08, 2022, 08:51:18 amYou haven't done your research very well, theory says you should never drive a mosfet without a gate resistor ( even BJT's need base stopping resistors ). Plus, that GPIO pin maybe just does not do capacitive loads, for that you should check the datasheet of the device.Testing with the scope always tells you things you simply cannot find by guess work on the forum as it has been done thus far on this topic.Quote from: girishji on October 08, 2022, 08:51:18 amIn reply number 3 here i already posted a link with a wide selection of possible mosfets from digikey, any of that list should do the job just fine.Still, check each one's info and datasheet and choose whatever seams to be the best suited.

author: Marian_elf
author_rank: Contributor
timestamp: October 08, 2022, 10:31:41 am
content: Quote from: Terry Bites on October 08, 2022, 09:05:57 am

author: girishji
author_rank: Contributor
timestamp: October 08, 2022, 03:39:59 pm
content: Quote from: Marian_elf on October 08, 2022, 10:27:17 amI don't disagree, but I don't own an oscilloscope! The cheap ones from Aliexpress can barely do 100khz sampling. I believe you need an expensive one to do sub-microsecond measurements. I have been measuring time indirectly through a phototransistor. I am new to electronics. If I encounter another situation like this I will get a scope.