P-Channel MOSFET as a Switch. Turn ON a 12V Motor with Arduino. (Step-By-Step Guide)

Sdílet
Vložit
  • čas přidán 2. 02. 2020
  • This is a tutorial about using a P-Channel Enchantment Type MOSFET as a switch to turn ON and OFF a 12V Motor.
    UPDATE:
    You should also add a 100-ohm resistor between the Arduino pin and the Gate terminal of the MOSFET. The MOSFET has a small capacitance that starts to charge/discharge when you switch the Arduino pin. This creates a short current spike that can be bad for the Arduino pin. Especially if you plan to do high-frequency switching.
    Diagrams and code:
    circuitjournal.com/how-to-use...
    I am using an IRF9540N, but you can use some other logic level P-Channel Enchantment Type MOSFET.
    Buy from AliExpress.com:
    IRF9540N: s.click.aliexpress.com/e/_d8J...
    Disclosure: Bear in mind that some of the links in this post are affiliate links and if you go through them to make a purchase I will earn a commission. Keep in mind that I link these companies and their products because of their quality and not because of the commission I receive from your purchases. The decision is yours, and whether or not you decide to buy something is completely up to you.
    Music from CZcams library.
  • Věda a technologie

Komentáře • 83

  • @leynardvillagracia6036
    @leynardvillagracia6036 Před 19 dny +1

    AFTER 4 YEARS OF UPLOADING THIS YOU ARE STILL HELPING!!

  • @gregg2597able
    @gregg2597able Před 2 měsíci

    very good, your the first that I can understand what is going on with these p and n mosfet's
    👍

  • @denizsogutlu2070
    @denizsogutlu2070 Před 6 měsíci

    Thanks Indrek for an amazing explanation.
    You helped me to solve my 48hrs challenge with correct Mosfet wiring!
    It's very difficult to simplify and explain stuff like this, really appreciate it!

  • @greggpierce4077
    @greggpierce4077 Před 2 měsíci

    I added 1 component to the circuit and could do away with the Arduino, exactly what I was looking to do!
    Thanks again Indrek

  • @marcov9581
    @marcov9581 Před 2 lety +10

    Connecting the Arduino 5V to the 12V supply really threw me off at first. But I realize you are basically using that as the Reference instead of letting Ground be the common reference point. This way when the arduino output is Low (0V from the Arduino perspective) it is -5V on the Gate with respect to the Source. When Arduino output is HIGH (5V from Arduino perspective) then the Mosfet sees 0V at the gate with respect to the Source. You went over this at ~55 seconds on the Video, but seeing 5V connected to 12V throws me off until I remember voltage would be relative and depend on the common reference point which doesn't Have to be 0V/Ground. We're so used to connecting Grounds to make everything relative to 0V Ground, it seems backwards to leave grounds disconnected for circuits to act relative to the High Side instead.

    • @alejandroperez5368
      @alejandroperez5368 Před rokem

      Yes, it's a ground-shaking moment for us noobs. Thanks for commenting

    • @michalaugustyniak6449
      @michalaugustyniak6449 Před rokem

      How to solve it if you have a common ground ? Add another diode between Arduino 5v and the S to block current from the battery ?

  • @juntendo6104
    @juntendo6104 Před 3 lety

    thanks so much! very simple to understand and solved my problem

  • @ljmeng
    @ljmeng Před 3 lety +1

    I like it. It gives all details.

  • @dogeeatsveggies
    @dogeeatsveggies Před 3 lety

    its basically the same with the N-channel, but works differently. thank you!

  • @caffeinatedinsanity2324
    @caffeinatedinsanity2324 Před 4 lety +1

    That's a good video. Also thanks for the warning part :)
    I recently saw that you can avoid that power supply problem by controlling the P channel mosfet with another transistor (like an NPN or an N channel mosfet). That way you have two isolated circuits

    • @IndrekL
      @IndrekL  Před 4 lety

      Hey! Thank you for the feedback!
      Yes, with another mosfet/transistor it is possible to fix ground connection problem.

    • @elliot1784
      @elliot1784 Před 3 lety +1

      @@IndrekLAny good resource for this 2 mosfet approach?, thanks. great video!

    • @elliot1784
      @elliot1784 Před 3 lety +1

      Could you provide where you saw this, hoping to implement the 2 mosfet method.
      thanks!

    • @hardcoregaming4118
      @hardcoregaming4118 Před 2 lety

      @@IndrekL bro you deserve a 100millions years of electronics and our world thankyou I'm from India

    • @salahuddintarar6539
      @salahuddintarar6539 Před 8 měsíci

      @@IndrekL AS the same Inductive load (Motor) You used in case of N -channel MOSFET ,then why you did not use flyback diode in that case (N-Channel MOSFET )?

  • @shabbee
    @shabbee Před rokem +3

    If you connect the 12v to the arduino VIN pin, my understanding is that the regulator will provide 5v to the Atmel device. At that point you should be OK to connect the grounds?? This is a question rather than advice. I would also recommend using a NPN transistor to to drive the MOSFET gate, with the collector biased at 12v via 10k resistor, the emitter connected to ground, and the base going to the arduino via a 10k resistor.

  • @Learnelectronics738
    @Learnelectronics738 Před 3 lety +1

    Hello brother Ilike your video thank you very much

  • @brunoperezmedellin7000

    Your video is really comprehensive and helped me getting started with MOSFET driving, however i have a doubt about Arduino and it's ground, in case i needed to add sensors or anything that needs a ground with the configuration shown on the video would burn the Arduino? Even if the Arduino was powered with a different source to the motor?

  • @melkerper
    @melkerper Před 4 lety

    Good video!

  • @Creative_Electronics
    @Creative_Electronics Před 4 lety +3

    Good Explaining!! ;)

  • @gholiamirza7102
    @gholiamirza7102 Před 4 lety +1

    Nice discribed. Thank you.

    • @IndrekL
      @IndrekL  Před 4 lety

      Thank you for the feedback!

  • @charleyandsarah
    @charleyandsarah Před 3 lety

    Good info, thanks, I had only seen people talk about the n channel. Any way to isolate the GND for a single power source? I need to power an arduino off a 12v truck, was planning to use a 5v stepdown converter to power arduino, but I need to PWM the 12v signal to control some hydraulic valves

    • @IndrekL
      @IndrekL  Před 3 lety

      But why can't you use an N channel MOSFET on the ground side of the 12V load? It would make things so much easier.
      As far as I know all the step down converters expect to share the Ground. So if you step it down to 5V it will be relative to the negative output of the battery.

    • @charleyandsarah
      @charleyandsarah Před 3 lety

      @@IndrekL I'm controlling hydraulic valves with onboard electronic actuators. They call for a fixed GND and 12V supply with a variable voltage signal wire to control direction and amplitude, with 6V being neutral, and over 6v is one direction, under 6v is the opposite direction. I have potentiometers setup to work it fine, but I want to use an arduino so I can make a wireless control

  • @yassindahmen203
    @yassindahmen203 Před 3 lety

    thank you everything is well explained. However i have a question about the fly back diode what are its specifications ?

    • @IndrekL
      @IndrekL  Před 3 lety +1

      Hey! I used a 1N4007

  • @happycrayon7621
    @happycrayon7621 Před 4 lety

    How come you have so low subscriber. Gonna stay to climb up the ladder to millions.

    • @IndrekL
      @IndrekL  Před 4 lety +1

      Thanks! The sub count is ramping up slowly. I have to work on my delivery (improving my accent and thing like that).

  • @cuf_
    @cuf_ Před 2 lety

    Thank you so much helped me out man!
    Btw you sound like an estonian. Am i right? Im from est.

  • @ozkantuzemen
    @ozkantuzemen Před 3 lety

    Hi, if I want to use depletion type mosfet for this project, which component you suggest?

  • @awaazmatroko5972
    @awaazmatroko5972 Před 11 měsíci

    Hi, nice video, Q: is there MOSFET as a switch, when gate has 0v it switches on, need for 12v ups router

  • @bigmac9712
    @bigmac9712 Před 9 měsíci

    If my motor runs with 5v then I can use the same power supply for the arduino and the mosfet/motor right?

  • @41_ahwaszargar73
    @41_ahwaszargar73 Před 3 lety

    The video is misleading when you say connecting 12 V to a 5v from arduino should actually send 7 v inside the arduino leading to frying of arduino .Also Tysm for the information of potentially frying up of arduino and I really loved the fact you used the concept of Vgs Rather than saying give Vg negative using a npn transistor

    • @muhammedfatihsaruhan7532
      @muhammedfatihsaruhan7532 Před 2 lety

      it is not actually . i thought the same at first. but arduino ground is not connected to the ground of power supply . he uses separate power supply for arduino

  • @shivamdeshpande1959
    @shivamdeshpande1959 Před 4 lety

    Thanks for the very nice video and clear cut explanation.
    I am looking for the P channel (D-S) MOSFET for one of my project and its part number is Si2309CDS by Vishay Siliconix. I am not getting exactly what the D-S MOSFET is and how it is different from a normal P channel MOSFET. Can you please help me with this

    • @IndrekL
      @IndrekL  Před 4 lety +1

      Hey! I am guessing that the "D-S" is referring to Drain and Source. As in "the current is flowing through the Drain and the Source". I tried to google it but didn't find any significance of that marking.

    • @shivamdeshpande1959
      @shivamdeshpande1959 Před 4 lety

      Okay thank you 👍
      And thanks for the video, it was really helpful

  • @muhammadbilal2000
    @muhammadbilal2000 Před 2 lety

    Thanks for the simple video. I am still thinking that when the gate is given 0 volt then how Vgs is -5 volt?

    • @alejandroperez5368
      @alejandroperez5368 Před rokem

      Because you have a +5V cable coming from the Arduino to the transistor's source pin. You apply voltages with two cables, not just one. And it's -5V with respect to the Arduino's ground signal, not the motor power supply.

  • @StefanoZamprogno
    @StefanoZamprogno Před 3 lety

    Great video thanks! does it work also for 3.3v signal from eg ESP8266 ?

    • @IndrekL
      @IndrekL  Před 3 lety +1

      It denepnds on the MOSFET. If you find a logic level MOSFET that fully switches ON below 3.3V then you can. The one I am using switches fully ON at around 4V (according to the datasheet). So you could not use exactly the same one I was using. If it is not fully switched on, then the MOSFET will get hot.

  • @JacobStevenson
    @JacobStevenson Před rokem +1

    Could you use a photocoupler (opto-isolator) like PC817 to drive the MOSFET and eliminate the problem with sharing grounds?

    • @muflah
      @muflah Před rokem

      I generally suggest not only using an optocoupler but using a power transistor as well. May cost a bit more but I've not found these low rated transistors to be very reliable with motors.

  • @fredd8881
    @fredd8881 Před 3 lety +1

    Can we use analogWrite 0-255 ? In P channel mosfet . I thought that use negative to work in gate

    • @IndrekL
      @IndrekL  Před 3 lety

      Yes, the P-channel Mosfet is controlled with negative voltage on the Gate relative to the Source. That's why it is connected to the 5V instead of GND. If it is connected like that, you can use analogWrite with it.

  • @HS-hz4fx
    @HS-hz4fx Před 2 měsíci

    lets say te power supply for motor is 60 volts, would this circut still works ?

  • @orides5976
    @orides5976 Před rokem

    Are there any driver chip for P Mosfet?

  • @netrapatil2169
    @netrapatil2169 Před 4 lety

    brother..I want to use a push button to switch a motor ON and off..With mosfet..Can i connect gate to a switch and pther to source with resistor

    • @IndrekL
      @IndrekL  Před 4 lety

      Hey! Yes you can replace the Arduino with a simple switch. How high voltage does the motor need? If you need to turn on a 60V motor, but the maximum gate-source voltage for the MOSFET is 20V then you should use a separate lower voltage source to turn the MOSFET on. If the Motor is 12V then you probably can just connect the switch to the power supply.

  • @FreddieMare
    @FreddieMare Před rokem

    How to use MOSFET as a normaly close Switch?

  • @CURIOSIDADEOUCRIATIVIDADE

    what is the model of the channel p mosfet used in the video?

  • @sunilkumar-ls2yb
    @sunilkumar-ls2yb Před 4 lety

    Bro can you explain
    Why you connected 12 volt to power arduino 5v pin pin

    • @IndrekL
      @IndrekL  Před 4 lety +3

      Because a P-Channel MOSFET is a "high side switch" and must be connected to the VCC side of the circuit. To achieve this I need to pull Arduino 5V and the positive side of the 12V power source to the same level (note that the grounds are NOT connected).
      An N-Channel MOSFET is actually a bit simpler. Then you connect the grounds and it is easier to understand.

    • @sunilkumar-ls2yb
      @sunilkumar-ls2yb Před 4 lety

      @@IndrekL thanks broo..
      It was really helpfull

    • @biasedbit
      @biasedbit Před 3 lety

      @@IndrekL thank you for the great tutorial! I've applied this to my project and it worked out great! 🙌 But I confess I'm still a bit confused by this step -- joining the 12V and 5V. I'm very new to this type of thing, would you mind helping me understand what's going on here (is the 12V side pushing current to the 5V side, are the voltages adding up/being subtracted?) and what you call this kind of merging of two different voltages without a common ground? Thank you!

  • @faizmajeed409
    @faizmajeed409 Před 3 lety

    You use 12volt battery and how many amperes?

    • @IndrekL
      @IndrekL  Před 3 lety

      Hey! I didn't use a battery. I used a power source that is plugged into the wall. I don't remember exactly, it was probably somewhere between 0.5 and 1 amper.

    • @faizmajeed409
      @faizmajeed409 Před 3 lety

      How many volt that the mosfet need to on the gate?

    • @IndrekL
      @IndrekL  Před 3 lety

      @@faizmajeed409 The Vgs(th) = -4V. According to the datasheet, the optimal for ON position is -10V, but it didn't get hot at all with Vgs = -5V and sub 1A load.

    • @faizmajeed409
      @faizmajeed409 Před 3 lety

      Okay bro thanks👍

  • @make6689
    @make6689 Před 4 lety

    How much current does the motor consume?

  • @phuonganh6445
    @phuonganh6445 Před 6 měsíci

    dùng nguồn khác cũng như không

  • @exessd7051
    @exessd7051 Před rokem

    12V into arduino 5v output ??? what the hell !

  • @matteogamer2606
    @matteogamer2606 Před 2 lety

    the diode

  • @gaurabpokharel6373
    @gaurabpokharel6373 Před 2 lety

    There is no negetaive 5 v in Arduino , its 0 v that turns on mosfet , because you are turning on and off it worked

    • @IndrekL
      @IndrekL  Před 2 lety +1

      The voltage is always relative. If you use the Arduino's 5V as 0V from the perspective of the MOSFET then Arduino's GND is -5V.

  • @traptown7507
    @traptown7507 Před 4 lety +1

    Indrek

  • @ConspiracytardHunter420

    my adafruit esp32 feather died, i guess i did something wrong, rip im broke, so much for this robotics bs, back to reddit

  • @jonathanvanbuskirk5326

    This is sending 5v to a 12v motor

    • @IndrekL
      @IndrekL  Před 4 lety +1

      No, it is not. The only place to get 5V out of this circuit is between the Arduino 5V pin and Arduino GND. But Arduino GND is not even connected to the motor.

  • @Nobody-hs9cl
    @Nobody-hs9cl Před rokem

    "P-Channel MOSFET as a Switch. Turn ON a 12V Motor with Arduino. (Step-By-Step Guide)" ???
    Regrettably you DO NOT explain how to turn on a 12 V motor with Arfuino and a P-Channel Mosfet in this Video. Rather, you are just warning that this will damage the Arduino. Pitiable!

  • @tattoome229
    @tattoome229 Před 2 lety

    hi Indrek what's your email or FB I have a few question ?