The threshold Voltage of IRF3205 is between 2V-4V and the Raspberry Pi gives signal of 3.3v that will be fine
No. Gate threshold is where the MOSFET barely starts conducting. So if it varies between 2-4V and you are applying 3.3V you are at best barely turning it on and at worst you aren't turning it on at all. You use at least the Vgs listed to get the rated RDson in the datasheet. You should be applying a Vgs of at least 10V.
Ignore Vgsth when using MOSFETs as a switch.
You also need a gate driver which does three things:
- Supplies more current than your GPIO
- Supplies more voltage than your GPIO if the MOSFET gate source requires it
- Allows your low-voltage, low-current GPIO to control the two above.
Your GPIO can't sink or source enough current to charge/discharge the gate-source capacitance fast enough so what is happening is that your MOSFET is spending too long in the inefficient transition region between conducting and blocking where it acts as a moderate value resistor. When blocking, there is lots of voltage across the MOSFET but no current so no heat. When conducting there is lots of current through the MOSFET but little voltage across it so little heat. During the transition region there is moderate/lots of current through the MOSFET and moderate/lots of voltage across the MOSFET so LOTS of heat.
If you just switch the MOSFET on and off occasionally, you can get away with direct drive from GPIO (if the MOSFET is logic level, yours is not) since time spent in the transition region is very small fraction of the overall operating time and there is plenty of time to cool down. But when you're PWMing you're switching thousands of times per second you are entering the transition region just as often.
You can buy gate driver ICs or you can make your own from discrete transistors in push-pull or totem-pole configurations
- if you choose to use MOSFETs in the level shifter they need to be logic level or else you will obviously run into the same problem you are trying to solve
- as drawn below, the PMOS must have |Vgs max| > 10 or 15V since that is what it will be when its gate is pulled LO by the GPIO. Otherwise zeners and resistors to clamp the PMOS Vgs to tolerable levels need to be added.
- You want these MOSFETs to be small so they have low gate-source capacitance and can respond quickly to the weak GPIO.
CORRECTION FOR SCHEMATIC ABOVE: 1MOhm resistor on gate driver input should be pull-up, not pull-down. Website has glitched out and I can no longer edit the schematic.
In the level-shifter, a current source or active pull-up (made of transistors) will be faster than a pull-up resistor since no RC time constant which will in turn switch your gate driver MOSFETs more quickly (if you are using MOSFETs in the gate driver stage).
The 5 Ohm resistors are there to limit shoot-through since both gate driver transistors are being driven by the same control signal so there is no guarantee they won't both be moderately conducting as one turns off and the other turns on.
Depending on the details of the transistor you are using and how the drive for them exactly turns out, you might be able to remove the 5 Ohm resistors and just tolerate the shoot-through current if it is small and fast enough.
Another way to deal with shoot-through (when using MOSFETs in the gate driver at least) is to use diodes to route the gate current paths through different components during gate-source capacitance charge and discharge so that the turn off time is faster than the turn on time. This doesn't work with BJTs whose control depends more on base-emitter currents than base-emitter voltage. By the way, this approach works for power MOSFETs in half-bridges and H-bridges as well where you can't use any other shoot-through handling methods mentioned in this answer which rely on throttling power (makes too much heat for high powered circuits). My opinion is you should just use independently controlled gate signals in that case, but for gate drivers no one wants that extra complexity.
simulate this circuit – Schematic created using CircuitLab
You can also swap the positions of the NMOS/NPN and PMOS/PNP of the gate driver stage for a configuration with no shoot-through. This makes them act as source/emitter followers, more like amplifiers with a controlled crossover rather than switches. This then allows you to remove the 5 Ohm resistors which are only there to limit shoot-through currents which prevents them from limiting the current charging/discharging your power MOSFET gate-source capacitance. But the price you pay for this is that they won't reach the rail voltage as closely, but without those resistors they will traverse the middle region more quickly.
simulate this circuit