DIY BLDC ESC problem is causing MOSFETS and motor to get very hot very fast, HELP
Hey everyone this is my first time reaching out to the community for help to see if someone can show me what I'm not seeing on this. Basically I am trying to make my own ESC for a BLDC and before anyone says the commercial solution is cheaper and easier, I know. I'm doing it to try learn some more in-depth programming/power electronic as well as to make a customisable version that's all my own work for if i want to use it for something else down the road, so lets get into the issue.
The problem is although I'm using a 20khz Pwm signal at a variable duty on the high side HBridge generated by direct timer control on the atmega328p (Arduino NANO), to try "chop"/control the current (also to control speed when using Zero-Cross detection) as well as keeping the lowside HBridge fully grounded on any given step, the MOSFETs (N-channel irf1405s 55V and 160A rated) are getting really really hot very fast and so is the motor like over 150 degrees Celsius hot even after only running for 30 - 120 seconds. The actual motor spins just fine however, I can even change the speed using an arduino delay timed step change (although I do have the hardware and did have the software for BEMF step changing too I disabled it to try simplify things while attempting to solve the heating issue as its my main priority).
I've attached my code and schematic if anyone can see something on this that I can't it would be much appreciated because I'm outta ideas I've tried adding lots of different changes to the hard and software with no luck.
I built a version using P Chanels on the high side and a BJT to switch them whilst PWMing the low side, it had a similar heating problem although abit slower. 552
I built a version using a BJT to feed the PWM coming from the Arduino OUTPUT to both HIN and LIN on the ir2101, since LIN is inverted I was hoping to connect the bridge to ground whenever it wasn't being pulsed in an attempt to give the collapsing magnetic field of the BLDC coil somewhere to flow but even though the scope showed the output was pulsing correctly when I connected the motor this didn't work either, at the end of it all I went back to the attached schematic and code but I still can't seem to stop the MOSFETs and motor from getting really hot because of what I assume is excessive current draw (possibly from an EMF building up in the coils and trying to ground through the FETS body when the HBridge goes to floating??).
and if I increase the duty to 60-70%+ the MOSFETs also just straight up explode even with some long dead time coded in using delay functions. I'm using a 12V 6.5Ah lead acid battery for testing as its close to the power supply I would use the ESC with normally and an amount of power something like this should handle no problems when working properly.
So to conclude if anyone with experience in power electronics or who has any ideas on how to fix my heating issue is reading this please help. Any equations I may need to consider more carefully, or advanced things a fairly beginner engineer like me might have missed would be much appreciated since at this point ive killed more Fets than id like to have. Thank you, <PERSON>. 552