#53 Protect your Arduino - use an Opto Isolator! And RGB sound-to-light demo

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.ย. 2024
  • New! https:/ralphbacon.blog
    Connecting your Arduino to other equipment to make it 'intelligent' is tempting but fraught with danger. I'll show you how to use an opto-isolator (aka opto-coupler) to reduce the chance of cross-equipment malfunction to a minimum.
    The two halves of the PC817-series isolators are totally isolated (yes, the clue is in the name) allowing you to drive a signal to your Arduino without your Arduino being exposed to external signal and voltage levels that may harm it.
    It's easy and cheap (see below where I bought this from) and should be considered an essential way of connecting Arduinos to 3rd party equipment!
    I also demonstrate the RGB (Red Green Blue) LED with my sound-to-light unit (microphone preamplifier) which looks fantastic. Even on camera where the colours always get washed out a bit it still looks great.
    Component sources:
    PC817
    www.banggood.co...
    but don't buy them individually, you can get 10 for £1 if you search eBay!
    RGB module (only buy it like this for experimentation, buy them loose to put into your projects)
    10-pack: www.banggood.co...
    You can get them individually too, either loose or on a module board.
    If you like this video please give it a thumbs up, share and if not already subscribed please do so :)
    And my channel is here:
    -----------------------------------------------------------------
    / ralphbacon
    ------------------------------------------------------------------
    How can I remember this? Memory tip: "See" Ralph Bacon, geddit?

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

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

    Every time I'm doing an Arduino project, I somehow end up back here because Ralph has made a video covering the EXACT thing I'm struggling with. Thank you for yet another helpful video

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

      Glad I could help!

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

    Hey Ralph, this has saved my bacon (no pun intended) we have just built a machine that relies on the isolation and this vid has done the trick. many thanks Rob

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

      You're most welcome, Rob, glad it helped!

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

    I had to watch this again not that I'm working on the PC817 again. You are a really valuable technical library to watch over and over.

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

      I hope it was helpful Danny!

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

    Thanks for the video. For others watching - 13:51 main part if you are looking for quick check if this can be hooked up to 12v and more.

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

      Excellent timecode, thanks!

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

    Thanks! I need to safely receive the pulse of my old-style doorbell. This is my first project using an optocoupler and your presentation and explanation were very helpful and easy to follow.
    Thanks again!

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

      I'm very glad it helped you Brian, thank you for posting!

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

    Ralph, thanks for keeping beginners in mind. Beginners are the ones that watch these great videos. The experienced ones that already know this make their own videos.
    Very helpful.

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

      You got that right, Danny, as this channel is for beginners, to get their projects off the ground. That said, I hope we never stop learning something, no matter how "experienced" we think we are! And it's always good to get "experienced" Arduinites' points of view on things as there may be better (or, at least, other) ways of doing things. But thanks for that supportive message, Danny, very much appreciated. Plenty more videos for you to watch!

    • @FirstLast-tx3yj
      @FirstLast-tx3yj ปีที่แล้ว

      @@RalphBacon i have 5 button switches connected to 5 automotive relays and 5 fuses
      A very simple 12v citcuit
      What I want is to remove the 5 button switches and connect an arduino inplace of all 5 switches
      And through a bluetooth module I will use my phone to switch any of the 5 outputs wirelessly
      The problem is that I do not want to channge the automotive relay to a relay board with optocouplers built in I want to leave the automotive relays and fuses as is
      So all I can think of is get optocoupler bourd and connect the arduino to 5 optocouplers then the optocouplers to original switch wires and voila!! Right??
      Please let me know if I am wrong in any way

  • @USA-GreedyMenOfNoIntegrity
    @USA-GreedyMenOfNoIntegrity 4 หลายเดือนก่อน

    PC817 used in many of my mini split heat pump communication circuits.

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

      Excellent!

  • @JoseGarcia-mm9kq
    @JoseGarcia-mm9kq 6 ปีที่แล้ว +1

    Excellent work Ralph! Your explanations are very clear ! I 've seen more than 10 videos and you cover all FAQs about optoacoplers and arduino and this is the best one.

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

      You are most welcome Jose Garcia, I'm glad you like the video. Nice to hear from you.

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

    Back in the late 80's, I learned the hard way that not all grounds are equal. :) I added my neighbor to my lan network and blew up 5 network interface cards. Turns out, our ground potentials had a 50 volt difference. That's when I learned about fiber optics. We both had good deep ground rods, so I thought nothing of it at the time. Took me a few hours to figure out what the problem was as it was not something I could conceive of before finding the problem. Never got bit by that problem again.....

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

      Too true! In the old days of the Wild West in the USA, they had to pour water around the ground rods for the single wire telegraph wires!

  • @TheTubejunky
    @TheTubejunky 8 ปีที่แล้ว

    You could use this to trigger a transistor to allow switching of higher voltage.
    I'm comfortable with these for use with lower voltage switching.
    Great depth of knowledge given in this video.
    Thanks for posting.

    • @RalphBacon
      @RalphBacon  8 ปีที่แล้ว

      +The Tubejunky
      Absolutely right about driving higher loads (eg a relay or motor) with a transistor (either directly or, more likely, via Arduino control). I didn't include it as it added another layer of 'complexity' that Arduinite noobs don't feel comfortable with but good job you mentioned it here so others can read that and it may trigger off some thoughts for how to repurpose my demo sketch into something useful to them.
      Thanks for posting and your words of encouragement :)

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

    Hi Ralph. A very good video that just may save destroying equipment (or worse) someone's life if they are a HW novice. I have successfully used the higher performing 4N35 to isolate Arduino I/Ps from electronics voltages on industrial control equipment (24v DC) and solid state relays to control 240vc/50Hz on the output.
    "Why solid state relays?". No contacts to burn and no back EMF precautions required. '-)

    • @RalphBacon
      @RalphBacon  6 ปีที่แล้ว +2

      Interesting that you mention an SSR, Brian, as I have recently received a couple with a view to doing a quick video update on them, viz-a-viz a true coil relay and even a MOSFET. Thanks for the reminder!

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

    Mr Bacon, your explanation is 4k clarity !!! thanks man :D

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

      I wish I could film in 4K! Or afford the camera to do it, ha ha! Thanks for posting.

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

    thanks a lot for showing diagram it made your tutorial more useful

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

      Good to know that, always useful to get feedback on what worked. Thanks for posting.

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

    I use home-made vectrols for this purpose because the polarity can be a problem, vectrols are bidirectional (current can flow in both directions) and don't need any additional components and care.

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

      Isn't that like using two optocouplers, back to back? Connect the LEDs up A-to-K and vice versa on the other end and voila! A homemade vactrol is yours for pennies? Much cheaper than what I've seen as a 'proper' vactrol.

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

      @@RalphBacon No, a Vactrol is a LED with a LDR (light-dependent resistor) so it is another puppy with different characteristics. With home-made I mean "made at home", made it myself with a LED and a LDR and dipped in black substance. I believe the name "Vectrol" is a commercial name and they are pretty expensive. When made yourself they are very inexpensive and very easy to use.

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

    Helpful vid! But, using a self-blinking christmas LED compromises the diagnostic function of that LED. You can't know if the LED is blinking, the power-supply for the LED, a bad mechanical switch, or the opto-isolator. Still, it's helpful to show that when current is broken on the input (in this case, due to a self-blinky LED), then the output current is also broken.
    Using an arduino purely as a power-supply for the big LED may be confusing to some. As a viewer, i keep thinking the arduino is being used as an arduino-- which it isn't. The potential for confusion is compounded, cuz in typical usage involving a 'duino and an opto', the 'duino would be on the control-input of the iso, not on the output.

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

      Well, it's only "self-blinking" when power is available, Johny, and it's slightly less boring than a standard red or green LED! After a while you get to recognise the pattern too.

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

    I'm not sure of the physics behind it, but LEDs seem to generally have very low reverse breakdown voltages. I deal with protecting those when necessary by connecting a diode across the LED, the other way around-- anode of the diode to cathode of the LED, and vice versa. A 1N4001 is overkill in that application, just about any small signal silicon diode will do the job, and since I have a couple of thousand (salvage! :-) 1N914s and 1N4148s, I use those.

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

      LEDs seem to have a reverse voltage max of 5v these days (just high enough that I don't kill them on Arduinos when I put them in backwards!). I've not seen a protection diode ever connected across them though, Roy. I'm just trying to think of an (Arduino-style) circuit where that would be necessary, given that the voltage would have to be reversed?

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

    Thank you very much for this video and your important explanations which are very helpful! Boris. 🇨🇭

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

      Glad it was helpful!

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

    In a mobile application where I want to use an Arduino to operate a 12v 20A relay, the optocoupler looks like a great option to isolate the two halves of the device. However, since the whole thing is being powered by the same electrical system (14.+ volts from the alternator) am I able to truly isolate the two sides? Thanks for all your help.

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

      In that case, you're not _totally_ isolated but it's still a lot better than running off the same local power supply. If nothing else you can add fuses to the Arduino side of things and reduce the voltage before it hits the Arduino thus reducing any possible interference too. You can get any number of buck converters that will reduce from 12v to 5v but do double check them - we don't want any zapped Arduinos!

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

    Excellent VIDEO thanks. Will be back!

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

      I look forward to welcoming you back!

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

    Congratulations from Brazil.

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

      Muito obrigado, Glaucio, tudo bem!

  • @Toro-Tor
    @Toro-Tor 4 ปีที่แล้ว

    Excellent explanation, thank you !
    QUESTION: I'm using an nano in a car with lots of different 12V inputs (obviously regulated down) to suitable). There are also a few BJT's etc involved and due to this the car-GND and the uno-GND need to be connected. The outputs are converted back to high-current 12V again. Fo rthe safety of the nano, I was planning to put opto-isolaters on the outputs (between nano and the the outgoing mosfets). Would that work as to isolate the nano - because they have common ground ?

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

      Yes that will work and is a good idea to prevent 12v ever touching an Arduino pin (goodbyte Arduino port, possibly the whole Arduino). It will work in exactly the same way as the Relay Optocoupler from video #18. Test it out with lower voltages first on your workbench!

    • @Toro-Tor
      @Toro-Tor 4 ปีที่แล้ว +1

      Thank you very much Ralph and thanks for your efforts.
      I'm sure I've watched #18 already, but will watch again.

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

    Hi, I don't understand how a 43k resistor can work on the collector side. That gives you only 0.1mA current at 5V, way below the datasheet min collector current 2.5mA. What am i missing?

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

      I don't think you'#re missing anything. I just happened to use a 47K resistor (as we were dealing with signal levels) and it worked just fine (despite what the datasheet might say, which I obviously didn't read well enough!)

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

    this is fantastic thank you. i was wondering, if i wanted to send control voltage signals to my arduino, would i need one of these? i'm hoping to send signals from -10v - 10v

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

      It depends on whether the voltage has any meaning other than on/off. Does -5v mean something different to +10v?

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

    Great Explanation: thank you very much. :)

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

      Glad you liked it, Taran72!

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

      @@RalphBacon , I'm glad I found your channel!! 😃😃😃😃

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

    Hi Ralph; Thanks a lot for this wonderful tutorials.I'm trying to connect my motion sensors from the old wired alarm to an arduino with an ethernet shield .Do you believe that this PC817 will work fine to protect Arduinio from the 12 v of the sensors? Rgds

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

      Yes, you can, just be sure to current the limit into this device from the 12v supply so that it is not overdriven. So, for example, 12v at 20mA would require a series resistor of 600 ohms (use a standard 680 ohm value, or thereabouts). The output from this device connected to the Arduino is then fully isolated from the 12v supply.

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

      @@RalphBacon Thank you so much

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

    Ralph, if you wanted a small kit / assortment of these could you recommend a few

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

      I'm not sure about a kit of these, I couldn't find any not even from our Asian warehouses. But I used the PC817 in this video and it worked fine. Depends on whether your want multiple isolators in the single chip. Do a search on RS Components or Mouser to narrow down what you want.

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

      Ralph S Bacon thanks Ralph

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

    great man nice job

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

      Glad you liked it, Ali!

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

    Thanks, very useful!))

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

      Glad you liked it Renat, plenty more to choose from too! Thanks for the feedback.

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

    No, i was just wondering if it had any hysteresis.
    Cheers

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

      No, Joe, it is not mentioned in the datasheet so I would expect a linear response.

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

    Hi Ralph, I think you forgot to mention that this is an analog device and i don't think there is any hysteresis..... right? I don't know:-)

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

      Hmm, all the circuits I've seen (on the datasheet, for example) seem to assume we're using TTL-level and style signals, but that doesn't preclude using it in an analogue fashion, of course. In which case, there should be no hysteresis of any kind otherwise that wouldn't work at all well. Did I say there was in the video?

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

    17:18 "Let's look at the equivalent circuit" 17:31 "there's the code" daMN, I DIDN'T KNOW DRAWING CIRCUITS REQUIRED PROGRAMMING; what's more, you didn't show the location of the pushbutton switch in your diagram, ethereally referring to it as "input", not only obfuscating the function of the built circuit as did the superfluous Arduino code, but by negligent exclusion of demarcation c. any secondary power source- you're also making the presence of any 'Opto Isolator' apparently EXTRANEOUS...
    And really that's just how simple it all is! Totally occult.

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

      Thanks for the critique, Ryan, I shall endeavour to be more accurate in future, thanks for posting.

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

    You no?

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

      Um, probably... not.