While building a stepper motor driver board, I ran into the problem that my motors would draw so much power away from the microcontroller I was using to switch them that the microcontroller would shut down. When I did get it to work, spikes in the power supply were large enough to destroy my expensive microcontroller. I realized that I needed to isolate my control circuits from the high power supply that they were switching to protect the controller and to ensure proper power distribution. Optocouplers seemed perfect, but I decided it would be more fun to make them myself instead of buying them in integrated circuits. This is also way cheaper, since my local Radioshack has ridiculous prices per chip. Before we build one, however, let's go over what an optocoupler actually is.
An optocoupler is basically a light and a light sensor used to communicate between two circuits. This is desirable in situations where you need complete isolation from a load and very fast communication. A simple transistor will give you that fast switching speed without the isolation. Relays give you the isolation you need, but don't have a switching speed anywhere near fast enough to handle the pulses used to drive a stepper motor. Optocouplers are the solution, since they provide total isolation and have a very fast switching speed. My homemade ones will handle about 300 hertz, but fancy ones used in industry can be switched at kilohertz. In my version, the light is an LED, the sensor is a photoresistor, and a MOSFET transistor switches the actual current through the load.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Parts Required
1 LED- Super-bright ones work the best. I used a green one.
1 Photoresistor- These are cheap little components that conduct electricity in the presence of light.
1 NPN transistor- I used a 3904 from Mouser. Almost any brand will do.
1 N- channel MOSFET transistor- I used one labeled IRFZ44N that I got in bulk on eBay.
2 resistors, with values 10,000 Ohms and 100 Ohms, respectively. If your microcontroller supplies more than 5 volts, you should substitute a 470 Ohm resistor for the 100 ohm one.
1 ordinary diode
Electrical tape or a small enclosure that light will not penetrate
Step 2: Circuit Diagram
This circuit uses a microcontroller I/O pin to control a high power load such as a motor, without risking damage to the sensitive circuits of the microcontroller. Here's how it works: The microcontroller switches on the LED. This causes the resistance of the photoresistor to drop enough for current flowing across it from high power to turn on Q1. Q1 then allows current to flow to the gate of Q2, which is a high power MOSFET transistor. This provides the load with a connection to ground, so the load is switched on. If your load is a motor or any form of electromagnet, don't forget the free-wheeling diode. This is connected across the load to prevent the magnetic field from destroying things when it is switched on and off quickly. The 10,000 Ohm resistor is there to make sure that when Q2 is switched off, it reads a logic zero. Without this feature, some transistors won't stop conducting electricity when they are switched off. Note that although I marked the high power as 5 volts, it can be as high as your transistor will allow without breaking down. I am using this circuit to switch motors off of a high current, 5 volt computer power supply. I would also like to add that though I designed this circuit myself, I did not invent the optocoupler, and there are probably plenty of similar solutions out there.
Step 3: Put the LED and Photoresistor Together
For the optocoupler to work, the LED and photoresistor must be very close to each other. They also must be sealed in complete darkness. This ensures that when the LED is off, no light will hit the photoresistor, and when the LED is on, as much light as possible will hit the photoresistor. I did this by putting their faces together and binding them with black electrical tape. Make sure that the wires of the components do not short together. A daub of glue on the ends could help with this, but I didn't include it and mine work fine.
Step 4: Finished Circuit
Here are two optocouplers wire up side by side on a breadboard. This is the circuit from the previous page. The big orange wire is the high power positive line, and the black one to it's right is the ground. The wires to the load are on the left. Thanks for viewing!