Thank you all for the helpful tips. I see what my problem is now. From the LTSpice, the power to the Mofset will peak to 7w! Yes, that must be why I managed to blow 5 of them and a few long nights of soldering de-soldering.
As to why I need this much capacitance, it is a longer story. I hope to make a semi auto gokart using the 40v battery and adding the ultrasound sensors to detect obstacles (
https://www.instructables.com/Hacking-Automotive-Ultrasonic-Sensors/). The ultrasound sensors are from an old GM car (ebay). The code and the rest of the circuit work as expected, meaning the Ardunio can command the ultrasound sensors to send out ultrasound and detect distance to obstacles. However, when the BLDC motors are turned on (or the BLDC controller is turned on), the ultrasound sensors didn’t return the electronic signal as expected (I verified this using the oscilloscope.) Tried as I may, I still couldn’t get it to work. I do see a lot of voltage noise from the 40v battery input to the buck convert when the motor control turns on. So I am trying to add a lot of filters, even including the common mode choke, to try to stabilize the 5v and another 9v feeding to the ultrasound sensor. Still no luck so far.
The Brosche ultrasound sensors are supposed to be automotive grade and capable of resisting electrical noises although the exact communication protocol is proprietary. I have also thought about whether the BLDC motor itself generates a lot of ultrasound noise confusing the Brosche sensor. That was not the case however. When they don’t share ground, meaning powering the Arduino and the Brosche sensors using a separate battery from the motors, the ultrasound sensors works fine even when the motors are running.
I don’t have any electrical engineering background other than from websites. If you have tips for me to try, I will definitely appreciate it. Thank you again!