PWM to drive Power MOSFET - Is my circuit viable?

You have replaced your 40V-device with a 30V-device. That is you have low margin to your power supply of 24V. I would like to encourage you to look for a higher voltage rated MOSFET (40V should be fine)
With respect to R1 of 180R: It would allow a current of almost 28mA in the very beginning of switching. I would design for max 20mA as per data sheet of ATmega328p.

30 volt MOSFET.... Good observation. Any zener added, the zener value needs to be added as the demand on the transistor capabiliy.

Thank You. My pleasure. That's why being here.

Using a larger voltage margin when selecting a MOSFET is very helpful advice. I wasn't sure whether to leave more like 10-20% headroom or 80%, but on your recommendation, I will look for one rated 40V or higher.

Checking the current across the Arduino pins (and using a resistor to limit it) never would have crossed my mind before talking to you and Railroader, so I've also gone and checked that to make sure everything is safe. I didn't even realize that there was a datasheet for the Arduino and its components. I went and found the reference document for the ATMega328P, and it lists the maximum current per pin (page 308) as 40mA. Therefore, I might keep R1 at 180 Ohms.

That’s absolute maximum !

Read the side bar where it says:

True, but a 180 Ohm resistor would let 28mA through at 5V, which seems well under the 40mA maximum. Am I missing something?

  • Actually, you will probably be just fine using the 180Ω.
1 Like

Thank you to everybody who contributed to the discussion. I've taken all of your feedback to heart and come up with a final circuit.

Here is a summary of everything I learned and put into practice:

  • Instead of making a really complicated circuit assuming parts will fail, just make a simple circuit out of parts that won't fail. I removed the optocoupler and extra diodes, and just selected a logic-level MOSFET. Thanks, Railroader!
  • Add a small current-limiting resistor to the output pin of the Arduino to make sure that you aren't drawing above the absolute maximum 40mA current from the output pin in order to charge the MOSFET gate. I've seen recommendations between 100 and 330 Ohms on different forum posts, but 180 Ohms seems to work out nicely mathematically and it was what Railroader recommended, so that's what I'm using. Also thanks to dsebastian for explaining the issue and pointing me to the ATMega328P datasheet.
  • Add 80 to 100% overhead to the voltage rating on the MOSFET, meaning a minimum 40-50V rating for a 24V power supply. I also checked the Safe Operating Area (SOA) of the MOSFET datasheet to make sure that it could dissipate enough power to drive the electromagnet at 100% duty cycle. Thanks again to dsebastian and Paul_B
  • Confirmed that a Schottky diode was indeed valuable as a freewheeling diode across the magnet and that it needn't be rated for more than the input voltage and magnet current (with appropriate overhead - I went with 100%). Thanks to Paul_B for the excellent explanation.
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.