How to control a MOSFET with Arduino PWM

Поделиться
HTML-код
  • Опубликовано: 31 янв 2025

Комментарии •

  • @RexxSchneider
    @RexxSchneider 3 года назад +7

    This circuit is susceptible to the non-linear transfer characteristic of the MOSFET. Since the gate threshold (the voltage required before the MOSFET starts to turn on) varies from sample to sample, the circuit is not reproducible without finding the initial offset by trial and error. Secondly, the relationship between the gate voltage and the drain current is essentially quadratic, not linear, when the MOSFET has a drain voltage significantly greater than the gate threshold voltage, as is the case here. That means that the output current rises more quickly at higher currents for the same amount of button press. However, if you require a steady dc current output, this is the simplest way to do it.
    The alternative is to pass the pwm signal to the MOSFET without filtering, i.e. remove the 100μF capacitor, but leave the other resistors in place. Now the MOSFET will be either on or off at the same frequency as the signal from the Arduino and with the duty cycle of the pwm. That means the power dissipated in the MOSFET is near to zero and it can handle greater loads. The average drain current will now be directly proportional to the duty cycle of the pwm and will provide a linear relationship between button press and output current with no offset, regardless of the individual logic level MOSFET used.
    However, the current through the load will be in pulses at 1.95KHz and not every application will cope with that. Nevertheless for controlling lights or motors, etc. it will be satisfactory. Remember, though, to use a reverse-biased diode between drain and positive supply when driving inductive loads to suppress the back emf each time the MOSFET switches off.

    • @pbandjmaniac
      @pbandjmaniac 2 года назад

      I was wondering about being able to drive the MOSFET directly with the PWM signal. Thank you for this reply. I have an application where I'm going to be using a similar circuit to drive a heating element (digikey part number: 1568-1797-ND). I'll definitely remember the reverse bias diode since I will be driving an inductive load. I'm a little hazy on whether or not I need the resistors. I don't think I'll need to scale the Arduino's output level, but I thought there was a requirement on sourcing/controlling the current into the Gate. Thanks again for both the video and the reply!

    • @RexxSchneider
      @RexxSchneider 2 года назад +1

      @@pbandjmaniac The problem with driving power MOSFETs is that they have a significant gate capacitance and it will draw current briefly from the Arduino when the output changes. Since the Arduino can be damaged by currents of more than 40mA, it's a good idea to have a resistor between the Arduino and the MOSFET. The 1K resistor shown will certainly limit the maximum current to less than 5V/1K = 5mA, which is fine. Since the gate capacitance of the IRL540 is specified as typically 2.2nF, the combination of 1K and 2.2nF will form a low-pass filter with a roll-off at about 70KHz, which means that it will have no effect on the pwm signal at 2KHz. The 10K resistor is a safeguard to ensure the MOSFET is turned off if the Arduino is disconnected from it (they may be on separate power supplies with a common ground).
      Since the MOSFET is a "logic-level" type, it will have a gate threshold voltage somewhere between a logic 0 and a logic 1 (so usually around 0.5V to 2V), so there's no need to scale it as the high level output from the Arduino will be certain to turn it on fully. Hope that helps.

    • @pbandjmaniac
      @pbandjmaniac 2 года назад

      @@RexxSchneider Makes sense. It's been a while since I've had to design an analog circuit. its always good to refresh on the best practices. Thank you again for helping out. I guess this means not ALL youtube comments are evil and toxic :P

  • @thodorisbarbakos3982
    @thodorisbarbakos3982 2 года назад +2

    Nice and clear explanation!

  • @yuriselektro2236
    @yuriselektro2236 3 года назад

    Good information air. 👍

  • @tjunkieu2b
    @tjunkieu2b 10 месяцев назад +1

    filtering before mosfet, does it not defeat the purpose of operating fet a fast switch?
    this makes a variable resistor from the mosfet, not really a PWM

    • @drsimons
      @drsimons 7 месяцев назад

      Exactly my thoughts, unfortunately I came to this video because I don't know what I'm doing, but to me applying a DC voltage to a power transistor doesn't make sense. I thought they're only supposed to be operated in fully on/fully off for maximum efficiency.

  • @JackLe1127
    @JackLe1127 2 года назад +1

    Would it suffice to just use analogWrite to change the pwm duty cycle?

    • @simoncarter568
      @simoncarter568  2 года назад +1

      Yes you can use the default PWM values of 255 or 1024 steps, if you do that you won’t have super fine control but if you don’t need it then you can just use for example analogWrite(128) for 50% duty cycle. If you do that you won’t need the whole block of code at the start that sets up the compare registers etc.

  • @kamleshpanchal6485
    @kamleshpanchal6485 3 года назад

    really i enjoy your video and learn more , i need more about how to increase frequency from arduino . plz reply me .

    • @simoncarter568
      @simoncarter568  3 года назад

      Go to Arduino.cc and search on Pam, timers, frequency etc and you should find what you need.

    • @simoncarter568
      @simoncarter568  3 года назад

      PWM not Pam

  • @unlowyer
    @unlowyer 2 года назад

    hi simon, Im just trying to make a high current 3 phase esc. Im here to learn something from you. first I need to know how to drive mosfets with limited current output. Im using an arduino and its pwm current output is limited 40 ma. So I cant work directly with high current mosfets. so I tried to drive them with the help of small transistors. But my pwm is fading. Im stuck. would you please help me about it ?

    • @simoncarter568
      @simoncarter568  2 года назад

      Look up mosfet driver I.c, it’s on the Internet. ThIs is what you need to use for your situation. These chips are designed to work with low current microcontrollers and high current mosfets.

  • @abhayp9
    @abhayp9 2 года назад

    Nice Video, I am using ESP32 which works at 3.3v, I need to control Co2 Laser power which can be controlled using potentiometer powerd by 5v. Will this work for me where in I send PWM signal from ESP32 to the Gate and create variable resistance between Drain and Source (As this is control signal power draw would be small).

    • @simoncarter568
      @simoncarter568  2 года назад +2

      Not sure, this uses logic level FET, I.e 5v is a 1. Probably will still work, or you could supply a separate voltage to the FET gate via a voltage converter.

  • @Anton-sz6ef
    @Anton-sz6ef 4 года назад

    Hi, is this like a simple motor driver ?

    • @simoncarter568
      @simoncarter568  4 года назад

      Not exactly but you could use it for that. I’d suggest that you remove the RC filter circuit if it doesn’t work to your liking. That would make the circuit more like motor driver.

    • @Anton-sz6ef
      @Anton-sz6ef 4 года назад

      @@simoncarter568 ok, thank you. The motor is low power brushed dc, so I think it could work