MacGyvered Optoisolator Is A Great Introduction

DIY Optoisolator

Sometimes the best way to learn about a technology is to just build something yourself. That’s what [Dan] did with his DIY optoisolator. The purpose of an optoisolator is to allow two electrical systems to communicate with each other without being electrically connected. Many times this is done to prevent noise from one circuit from bleeding over into another.

[Dan] built his incredibly simple optoisolator using just a toilet paper tube, some aluminum foil, an LED, and a photo cell. The electrical components are mounted inside of the tube and the ends of the tube are sealed with foil. That’s all there is to it. To test the circuit, he configured an Arduino to send PWM signals to the LED inside the tube at various pulse widths. He then measured the resistance on the other side and graphed the resulting data. The result is a curve that shows the LED affects the sensor pretty drastically at first, but then gets less and less effective as the frequency of the signal increases.

[Dan] then had some more fun with his project by testing it on a simple temperature controller circuit. An Arduino reads a temperature sensor and if the temperature rises above a certain value, it turns on a fan to cool the sensor off again. [Dan] first graphed the sensor data with no fan hooked up. He only used ambient air to cool things down. The resulting graph is a pretty smooth curve. Next he hooked the fan up and tried again. This time the graph went all kinds of crazy. Every time the fan turned on, it created a bunch of electrical noise that prevented the Arduino from getting an accurate analog reading of the temperature sensor.

The third test was to remove the motor circuit and move it to its own bread board. The only thing connecting the Arduino circuit to the fan was a wire for the PWM signal and also a common ground. This smoothed out the graph but it was still a bit… lumpy. The final test was to isolate the fan circuit from the temperature sensor and see if it helped the situation. [Dan] hooked up his optoisolator and tried again. This time the graph was nice and smooth, just like the original graph.

While this technology is certainly not new or exciting, it’s always great to see someone learning by doing. What’s more is [Dan] has made all of his schematics and code readily available so others can try the same experiment and learn it for themselves.

17 thoughts on “MacGyvered Optoisolator Is A Great Introduction

    1. “Why not use a black heat-shrink tube? ”

      Yah, I was thinking the same thing. I know I have read about people heatshinking an LED to a phototransistor before. Maybe the angle of the LED is too wide and he needs the aluminum foil to reflect light from the sides back at his sensor. Heat shrink tubing would just absorb the light from the sides of the LED.

      Or maybe I’m just reaching here…

      1. Actually it’s more simple than that. I didn’t have any black heat shrink tube large enough to stuff an LED into. Also, heat shrink tube would not have looked nearly as cool :)

      2. Reaching. The amount of light captured in a cone depends in distance from subject. If you butt up the photosensor against the LED you’ll capture nearly all of it. Plus if reflection was critical the two pieces of alu foil wouldn’t be so far apart, as closely coupling them would also improve the amount of reflected light.

    2. Fender was using heat shrink optocouplers back in the 20th century, original tube amp vibrato circuit used a neon tube, a little slow but fine for tremelo circuit! Look up fender optocoupler in your favorite search engine for more info.

  1. Nice idea, for those having to abide by RoHS you can make an infrared version of this using the sensor from an old digibox etc, some old VCRs have eight of these throughout the chassis for the tape and position sensing.

    protip: you can also use this to replace annoying “4 pin” clipping preventers in old amplifiers, I had to make one from yellow LEDs and CdS before as the part was over £22 for one unit *!*

  2. I like the pc817 4 pin optoisolator, but sometimes an LED/CdS version is better. I use heatshrink tubing. I used a similar setup to this to make a quick and dirty DAC. I used a tube with several LEDs mounted on the inside with a CdS cell in the end. By sending digital signals to the LEDs and running a voltage through the CdS you get a variable voltage. This is very raw but it works well for CMOS noise circuits.

  3. One of the things going on with that response curve is the relatively slow response time for CDS cells. Using PWM is not exactly the same as using a variable voltage across the LED.

    The photo-resistor probably has a response time of around 30-50 ms, and the decay time is usually a bit longer. The Arduino PWM period is 2ms as I recall so a little bit of pulse-width will behave like a lot more light.

    It would be interesting to see the response curve if he used a low pass RC circuit on the LED to make it a true variable DC voltage.

    1. That’s why they’re really good for homemade audio compressors: the timing is just right to give that punch to the sound. Some very well known guitarists from the 70s and 80s built their fame around that sound.

  4. this sort of thing was done in older answering machines and electronic phones where a plastic tube was used.

    though you can get the same part from junk power supplies (dumpster rummaging anyone)?

  5. Note that these days an optoisolator typically refers to a LED and phototransistor pair. Substitute the phototransistor for a CDS photocell, and you might call it a resistive optoisolator, or other names. The one I’ve heard used most often is Vactrol, which was a trademark once used by a now defunct manufacturer, but is now used more generically (like how some people call all facial tissues Kleenex). I don’t think anyone manufactures them anymore, though NOS Vactrols can still be purchased. Or just make your own. I have found a LED and photocell linked in a plastic tube as [ejonesss] described in some old audio gear. But have never seen one in a power supply, AFAIK they use phototransistor-based optoisolators only.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.