Microcontroller Power Button: Manual On and Automatic Off

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ม.ค. 2017
  • It turns out that 'Likes' and 'Shares' actually help the channel so, if you want to, please click the thumbs up or share the video.
    I don't have a Patreon or a donate thingy, I get by fine. That said, if you are mega rich and fancy donating something I would find useful then feel free to check out my Amazon wishlist (No pressure) - www.amazon.co.uk/registry/wish...
    If you want to get in contact Twitter is probably the best way @mrdavidjwatts
    www.davidjwatts.com
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @shvideo1
    @shvideo1 2 ปีที่แล้ว +3

    Great video! Thank you for the demo and the schematic. the pull-down resistor for the MOSFET can be much larger 10 K - 1 M. You can also use the internal (built-in) LED as indicator instead of tying up pin # 12 and using 2 more components.

  • @HariWiguna
    @HariWiguna 7 ปีที่แล้ว +3

    That's a very useful circuit David! Thanks for sharing!

  • @mdwahidmunir2124
    @mdwahidmunir2124 5 ปีที่แล้ว

    I have seen many TH-cam videos, perhaps this is the best and easiest, love your work bro ,keep it up!

  • @azyfloof
    @azyfloof 7 ปีที่แล้ว

    Nice idea! Gonna have to implement this if I ever make something battery powered I want to have soft on-off switches :D

  • @voltlog
    @voltlog 7 ปีที่แล้ว +2

    Neat circuit!

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

    Most LDOs now have EN/SHUTDOWN pin, so its ON/OFF state may be arranged similar way without dropping additional MOSFET into a circuit.

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

    Thanks. Interestingly I found (and designed myself) only high side switch with P-MOSFET. It's fine, cause I used it to shutdown SD card reader and it's voltage regulator once. Kind of problem is that if switch is designed to disconnect Arduino from battery to prevent deep discharge and damage of rechargeable batteries, not every MOSFET works. Some may still allow few microamps to flow - either because Vgs(th) is specified for 1mA, or because they conduct a bit all the time and there's some sweat spot - if voltage is close to Vgs they conduct, if voltage is double vgs, they conduct too and when voltage is close to maximum rating (e.g. 60V), there should be current no higher than 1mA. But for similar design I used 1M as a mosfet pullup (here pulldown) and 100k for base of bipolar transistor.

  • @darkphotons101
    @darkphotons101 7 ปีที่แล้ว +5

    The problem with this circuit is short button presses, the micro needs time to boot.
    Why not add a cap and resistor to artificially prolong the on state after the button press ?

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

    You could meassure what the current consumption is when you put the uC to sleep mode and then make a wakeup call via interrupt pin. And compare both metvods. But I'm guessing your solution is more efficient.

  • @bwack
    @bwack 7 ปีที่แล้ว

    Cool stuff. If you replace the mosfet with a 2n700x (logic level nmos) (edit: oops, bs170 is similar to 2n7000), you can hook its gate to pin 13 via a resistor. The circuit will be the same as before just without the pnp. Why ? because when the avr powers on, the GPIO is in High-Z. The first thing the software needs to do is to turn on the gpio driver for pin13, bring it high. I think. Watched the whole video before responding.

  • @roberteliassen5020
    @roberteliassen5020 7 ปีที่แล้ว +2

    Thanks! Great video. At 11:50 you ask if this draws any current (when not turned on I assume). I could not measure any current on my multimeter, which can measure currents down to 10 uA. In theory, the only current is the leakage of the PNP transistor through the pull-down resistor on the gate. In practice, the battery will die of age (self discharge) :-)

    • @DavidWatts
      @DavidWatts  7 ปีที่แล้ว +2

      Thanks Robert, my meter has trouble measuring accurate uA currents due to the burden voltage so I have to go with 'in theory' for most things. Thanks for checking it out, I really appreciate it.

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

    Question: can you not just wire pin 13 directly to the MOSFET gate via a current limiting resistor and pull the pin HIGH to power off the MOSFET? Why use a transistor there?
    Thanks

  • @jogomez1988a
    @jogomez1988a 7 ปีที่แล้ว

    I guess the MOSFET gate current is little high. I recommend a resistor between BJT emisor and Gate terminal of mosfet.,

  • @stephenstewart1653
    @stephenstewart1653 3 หลายเดือนก่อน

    What happens when the button is held closed indefinetly? Like using it for a mailbox door sensor, and the door is left open? Thanks

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

    Could this be modified to work with 3 switches then tell which switch was pressed to start the power?

  • @mojtabavahdatparast5132
    @mojtabavahdatparast5132 5 ปีที่แล้ว

    Okay . Is very Good Circuit.

  • @MDFRESCUER
    @MDFRESCUER 7 ปีที่แล้ว

    Nice.

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

    Really a detail but you need to show the emitter of the transistor on your schematic. By the way, I'd be interested in a solution to automatically turn on that switch every hour for a battery-powered remote sensor application. Thanks for the video!

  • @roberteliassen5020
    @roberteliassen5020 7 ปีที่แล้ว +2

    I'm not sure I understand... At 5:57 you explain: "The nano, when it boots up, will put pin 13 high". Wouldn't that turn OFF the PNP transistor? Assuming the emitter is on BAT+ (you didn't draw the arrow, but it makes sense), the base should be at least 0.7V more negative than the emitter in order to turn the transistor on. Anyway, thanks for all the great videos. You have inspired me to brush the dust of some 30 years old knowledge... And I might be wrong when it comes to the PNP transistor. It's been a long time... :)

    • @DavidWatts
      @DavidWatts  7 ปีที่แล้ว +5

      Sorry, you are right, it seems I mis-spoke when I said High, I meant low.

    • @JairoGustavo
      @JairoGustavo 6 ปีที่แล้ว

      thanks man, i was thinking the same!

  • @squalazzo
    @squalazzo 7 ปีที่แล้ว

    i usually connect limiting resistors to the anode side of leds, is it the same putting them on the cathode? thanks :)

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

      +squalazzo yeah it is exactly the same.

  • @jamesdamewood4997
    @jamesdamewood4997 7 ปีที่แล้ว

    There could be a problem of NANO being held to the "On" state through one of the I/O pins being sinked to BATT-. Might need to separate your peripheral I/O GND from BATT-.

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

      You are absolutely right, they all need to go through the mosfet/nano ground. Or as I wired it in the end the LED needs to go to power with the micro providing the ground path.

  •  7 ปีที่แล้ว

    You can swap the functions of pin 12 and 13 to save a resistor and a led by using the built-in led. ;)

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

      Not quite as visual in the video though :)

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

    Why are you using a transistor to drive the mosfet gate and not just the uC pin itself? Is it just because it's not logic level?

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

      +Mark Higgins honestly I cannot remember why, there must have been a reason. I will post a video update with an answer or simplification of the circuit ;-)

    • @Davedarko
      @Davedarko 7 ปีที่แล้ว

      Mark Higgins if its a 9v batterie you would probably kill the arduino by feeding 9v to its pin once you press the button, I think.

    • @AdamWelchUK
      @AdamWelchUK 7 ปีที่แล้ว

      Mark Higgins I was thinking the same. As long as you're not pushing more than 5v across the switch the transistor isn't required.

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

      If the 9V is a problem, a resistor in series and the protection diodes in the micro should keep the levels safe.. Right ?

    • @akarshagarwal4516
      @akarshagarwal4516 7 ปีที่แล้ว

      I too think that connecting the pin 13 directly to the gate of the MOSFET would able to do the trick

  •  5 ปีที่แล้ว

    Hi david, the 2N7002 work for this circuit?

    • @DavidWatts
      @DavidWatts  5 ปีที่แล้ว

      It will but you will stuggle to get 300ma through it with 3 AAA batteries on the gate of the mosfet. I would pick something with a lower on resistance.

    •  5 ปีที่แล้ว

      David Watts Which mosfet do you recommend? please

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

      The IRLML2502 or something of a similar spec would be good.

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

    where is the Code to this?

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

    Why is it 11 degrees? That is not very comfortable!

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

    I cannot get it to work

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

    I couldn't get the circuit to work. The only difference from yours is that I used an Arduino Uno. The MOSFET will power the UNO when the switch is held and then off when released. When I add the transistor and attach it to pin 13 via a 1K resistor, the Arduino remains on after the switch is released. So all working well. However, when I set pin 13 low, digitalWrite(pwrPin, LOW), the Arduino continues to operate. I tried different pins both analog and digital but still no joy. For some reason the transistor will not switch off (open the gate on the MOSFET) once it is powered. The only way I could get this to work is by resetting the Arduino board (I used the watchdog function). But that's not really the way to do it...but I can't find any other way??

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

      I am having the exact same problem. I can turn off the BJT with a push button but not by taking the base down using a digital low from the UNO. Don’t understand why?!

    • @ryleebrownfox
      @ryleebrownfox 5 หลายเดือนก่อน

      just my opinion. some transistor becomes live when the gate is above 0.7V. the reason why you can't turn it off could be that pin 13 sourced out 0.7V when set to low.

  • @Davedarko
    @Davedarko 7 ปีที่แล้ว +5

    Please measure the current :)

  • @Gauravkumar-fe1cv
    @Gauravkumar-fe1cv 5 ปีที่แล้ว +1

    I want to increase time to 4 hours. I want to use it to switch off my cooler after 4 hours of running

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

      im a bit late but did you implement a timer to keep track of any last input/activity?

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

      Just keep HIGH the pin connected to base of transistor (eg. Pin 13) for 4 hours. You need to program the Nano to do this.

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

    Please send circuit and code please