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

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ก.ย. 2024
  • 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...
    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.aliexp...
    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 TH-cam library.

ความคิดเห็น • 84

  • @leynardvillagracia6036
    @leynardvillagracia6036 2 หลายเดือนก่อน +2

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

  • @marcov9581
    @marcov9581 2 ปีที่แล้ว +11

    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 ปีที่แล้ว

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

    • @michalaugustyniak6449
      @michalaugustyniak6449 ปีที่แล้ว

      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 ?

  • @denizsogutlu2070
    @denizsogutlu2070 8 หลายเดือนก่อน

    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 4 หลายเดือนก่อน

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

  • @gregg2597able
    @gregg2597able 4 หลายเดือนก่อน

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

  • @shabbee
    @shabbee 2 ปีที่แล้ว +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.

  • @GameAndJokes
    @GameAndJokes 20 วันที่ผ่านมา

    Well done video, Appreciate the efforts, you earned a sub, just please dont use music in your videos or atleast keep it very low

  • @dogeeatsveggies
    @dogeeatsveggies 3 ปีที่แล้ว

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

  • @caffeinatedinsanity2324
    @caffeinatedinsanity2324 4 ปีที่แล้ว +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  4 ปีที่แล้ว

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

    • @elliot1784
      @elliot1784 4 ปีที่แล้ว +1

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

    • @elliot1784
      @elliot1784 4 ปีที่แล้ว +1

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

    • @hardcoregaming4118
      @hardcoregaming4118 2 ปีที่แล้ว

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

    • @salahuddintarar6539
      @salahuddintarar6539 10 หลายเดือนก่อน

      @@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 )?

  • @ljmeng
    @ljmeng 3 ปีที่แล้ว +1

    I like it. It gives all details.

  • @juntendo6104
    @juntendo6104 3 ปีที่แล้ว

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

  • @brunoperezmedellin7000
    @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?

  • @happycrayon7621
    @happycrayon7621 4 ปีที่แล้ว

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

    • @IndrekL
      @IndrekL  4 ปีที่แล้ว +1

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

  • @bakulplastik
    @bakulplastik 2 วันที่ผ่านมา

    sir , I connected 5v Arduino to source in minutes 3, the Arduino emitted smoke

  • @41_ahwaszargar73
    @41_ahwaszargar73 3 ปีที่แล้ว

    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 2 ปีที่แล้ว

      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

  • @Learnelectronics738
    @Learnelectronics738 4 ปีที่แล้ว +1

    Hello brother Ilike your video thank you very much

  • @cuf_
    @cuf_ 2 ปีที่แล้ว

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

  • @Creative_Electronics
    @Creative_Electronics 4 ปีที่แล้ว +3

    Good Explaining!! ;)

    • @IndrekL
      @IndrekL  4 ปีที่แล้ว +1

      Thanks!

  • @HS-hz4fx
    @HS-hz4fx 4 หลายเดือนก่อน

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

  • @JacobStevenson
    @JacobStevenson ปีที่แล้ว +1

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

    • @muflah
      @muflah ปีที่แล้ว

      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.

  • @muhammadbilal2000
    @muhammadbilal2000 2 ปีที่แล้ว

    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 ปีที่แล้ว

      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.

  • @yassindahmen203
    @yassindahmen203 3 ปีที่แล้ว

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

    • @IndrekL
      @IndrekL  3 ปีที่แล้ว +1

      Hey! I used a 1N4007

  • @gholiamirza7102
    @gholiamirza7102 4 ปีที่แล้ว +1

    Nice discribed. Thank you.

    • @IndrekL
      @IndrekL  4 ปีที่แล้ว

      Thank you for the feedback!

  • @fredd8881
    @fredd8881 3 ปีที่แล้ว +1

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

    • @IndrekL
      @IndrekL  3 ปีที่แล้ว

      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.

  • @charleyandsarah
    @charleyandsarah 4 ปีที่แล้ว

    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  4 ปีที่แล้ว

      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 4 ปีที่แล้ว

      @@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

  • @bigmac9712
    @bigmac9712 10 หลายเดือนก่อน

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

  • @awaazmatroko5972
    @awaazmatroko5972 ปีที่แล้ว

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

  • @melkerper
    @melkerper 4 ปีที่แล้ว

    Good video!

    • @IndrekL
      @IndrekL  4 ปีที่แล้ว

      Thanks!

  • @ozkantuzemen
    @ozkantuzemen 3 ปีที่แล้ว

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

  • @shivamdeshpande1959
    @shivamdeshpande1959 4 ปีที่แล้ว

    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  4 ปีที่แล้ว +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 4 ปีที่แล้ว

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

  • @StefanoZamprogno
    @StefanoZamprogno 4 ปีที่แล้ว

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

    • @IndrekL
      @IndrekL  4 ปีที่แล้ว +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.

  • @netrapatil2169
    @netrapatil2169 4 ปีที่แล้ว

    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  4 ปีที่แล้ว

      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.

  • @sunilkumar-ls2yb
    @sunilkumar-ls2yb 4 ปีที่แล้ว

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

    • @IndrekL
      @IndrekL  4 ปีที่แล้ว +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 4 ปีที่แล้ว

      @@IndrekL thanks broo..
      It was really helpfull

    • @biasedbit
      @biasedbit 3 ปีที่แล้ว

      @@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!

  • @orides5976
    @orides5976 ปีที่แล้ว

    Are there any driver chip for P Mosfet?

  • @CURIOSIDADEOUCRIATIVIDADE
    @CURIOSIDADEOUCRIATIVIDADE 3 ปีที่แล้ว

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

  • @phuonganh6445
    @phuonganh6445 8 หลายเดือนก่อน

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

  • @exessd7051
    @exessd7051 ปีที่แล้ว

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

  • @faizmajeed409
    @faizmajeed409 3 ปีที่แล้ว

    You use 12volt battery and how many amperes?

    • @IndrekL
      @IndrekL  3 ปีที่แล้ว

      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 3 ปีที่แล้ว

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

    • @IndrekL
      @IndrekL  3 ปีที่แล้ว

      @@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 3 ปีที่แล้ว

      Okay bro thanks👍

  • @make6689
    @make6689 4 ปีที่แล้ว

    How much current does the motor consume?

    • @IndrekL
      @IndrekL  4 ปีที่แล้ว +1

      Hey! I don't remember exactly. It might have been somewhere around 1A

    • @BegginersGuidetoCode
      @BegginersGuidetoCode 3 ปีที่แล้ว

      12V @ 0.1A

  • @matteogamer2606
    @matteogamer2606 2 ปีที่แล้ว

    the diode

  • @gaurabpokharel6373
    @gaurabpokharel6373 2 ปีที่แล้ว

    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  2 ปีที่แล้ว +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.

  • @ConspiracytardHunter420
    @ConspiracytardHunter420 4 ปีที่แล้ว

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

  • @traptown7507
    @traptown7507 4 ปีที่แล้ว +1

    Indrek

  • @jonathanvanbuskirk5326
    @jonathanvanbuskirk5326 4 ปีที่แล้ว

    This is sending 5v to a 12v motor

    • @IndrekL
      @IndrekL  4 ปีที่แล้ว +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-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!

  • @tattoome_eu
    @tattoome_eu 2 ปีที่แล้ว

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