Introduction
Optocouplers, or optoisolators, are components that allow electrical signals to be transmitted between circuits while maintaining electrical isolation. The CNY17-2 is a popular optocoupler often used in a variety of applications, such as isolating signals in power electronics, signal processing, and remote switching systems.
In this project, we will build a remote switch using the CNY17-2 optocoupler. The switch will allow you to control the power to an electrical device (such as a lamp or a fan) using a low-voltage control signal. The benefit of this design is that it keeps the control circuit electrically isolated from the high-voltage side, making it safer and reducing the risk of damage to sensitive components.
This DIY project requires basic knowledge of electronics, including familiarity with resistors, diodes, and capacitors, as well as basic soldering skills. By the end of the project, you will have a remote-controlled switch that can control devices in a safe and isolated manner using the CNY17-2 optocoupler.
Materials and Tools
Components Needed:
· 1 x CNY17-2 Optocoupler
· 1 x NPN Transistor (e.g., 2N2222)
· 1 x Relay (with a 5V or 12V coil, depending on your application)
· 1 x Diode (1N4007 or similar for flyback protection)
· 1 x Resistor (220 ohms for the optocoupler LED side)
· 1 x Resistor (10k ohms for base of NPN transistor)
· 1 x Resistor (1k ohms for the optocoupler phototransistor side)
· Breadboard and Jumper wires
· External power supply for the controlled device (e.g., 120V AC or 12V DC depending on the device)
· Microcontroller (optional) or manual switch for the control signal
· Soldering iron and solder (if you decide to build a permanent version)
· Multimeter (for testing and verification)
· Optional: PCB for a more professional finished product
Circuit Diagram
The circuit design for this remote switch is relatively simple. The CNY17-2 optocoupler has an LED on the input side (for the control signal) and a phototransistor on the output side (for switching the relay). The relay allows you to control higher-voltage devices with a low-voltage control signal.
Here’s how the components will be connected:
Control Side (Input):
o The control signal (could be from a microcontroller or a manual switch) is applied to the LED side of the CNY17-2.
o A 220-ohm resistor limits the current to the LED side to ensure it does not burn out when powered by the control signal (5V typically).
o When the LED is on, it generates a light signal that triggers the phototransistor on the output side.
Relay Driver Circuit (Output):
o The phototransistor of the CNY17-2 is connected to the base of an NPN transistor (e.g., 2N2222). This transistor acts as a switch, allowing a higher current to flow to the relay coil.
o A 10k-ohm resistor limits the base current of the NPN transistor, ensuring safe operation.
o The emitter of the NPN transistor is connected to ground, and the collector is connected to the relay coil.
o The relay contacts can then control a higher-voltage circuit, such as turning on a lamp or a fan.
Flyback Diode Protection:
o When the relay coil is de-energized, it generates a voltage spike (flyback voltage) that could damage the transistor or other components. A flyback diode (e.g., 1N4007) is placed across the relay coil to absorb this voltage spike and protect the circuit.
Circuit Description
Step 1: Powering the Control Side
The first part of the circuit is the control input side, which is powered by a low-voltage DC supply (such as 5V from a microcontroller). The control signal will drive the LED inside the CNY17-2.
· The 220-ohm resistor limits the current through the LED to a safe value. A typical current for the CNY17-2 LED is around 10–20mA, so the resistor is sized appropriately for the voltage and current requirements of your control side.
· The LED is connected in series with the resistor, and the control signal (either a high or low state) will determine whether the LED is on or off.
Step 2: Switching the Relay
On the output side of the optocoupler, the phototransistor responds to the light from the LED. The phototransistor is configured to operate as a switch, allowing current to flow to the base of the NPN transistor.
· When the LED is turned on, it activates the phototransistor, which allows current to flow through the base of the NPN transistor. This turns on the NPN transistor, allowing current to flow through the relay coil, which in turn activates the relay.
· The 10k-ohm resistor between the phototransistor and the base of the NPN transistor ensures that the base current is limited and that the transistor does not turn on too hard, which could lead to damage or excessive heating.
Step 3: Controlling a Higher-Voltage Load
Once the relay is activated, it closes its normally open contacts. These contacts can be used to control an external device such as a lamp, fan, or any other appliance that requires higher voltage to operate.
· If you are using a 120V AC device, ensure that you handle the relay contacts with care, as high voltages can be dangerous.
· A flyback diode is essential when using relays because relays generate a high-voltage spike when the current is turned off (known as inductive kickback). The diode will absorb this spike and protect your transistor and other components.
Building the Circuit
Step 1: Assemble the Control Side
Start by connecting the LED side of the CNY17-2 to the breadboard. Attach one side of the LED to the positive rail (5V or 3.3V depending on your control voltage), and connect the other side through the 220-ohm resistor to the control input (this could be a microcontroller or manual switch). The ground pin of the control input should be connected to the negative rail of the breadboard.
Step 2: Assemble the Relay Driver Circuit
Now, build the relay driver circuit using the phototransistor of the CNY17-2 and the NPN transistor.
· Connect the phototransistor’s collector to the base of the NPN transistor through the 10k-ohm resistor. The emitter of the NPN transistor connects to the ground.
· The relay coil is connected between the collector of the NPN transistor and the positive voltage rail (typically 5V or 12V, depending on the relay).
· Connect the flyback diode across the relay coil, with the cathode (marked side) connected to the positive voltage rail and the anode to the transistor's collector.
Step 3: Testing and Troubleshooting
Before powering the circuit, double-check all your connections. Once you're confident everything is wired correctly, power the circuit and test the control signal.
· If you are using a microcontroller, you can use a simple digital output pin to send the control signal.
· When the control signal goes high, the LED inside the CNY17-2 should turn on, which will activate the phototransistor, causing the NPN transistor to switch on, which in turn activates the relay.
Test the relay by connecting it to a simple load like an LED or a small lamp. If the circuit is working correctly, you should be able to control the load by sending a control signal.
Conclusion
This DIY project demonstrates how to use the CNY17-2 optocoupler to build a remote switch capable of controlling high-voltage devices with a low-voltage control signal. The use of an optocoupler ensures electrical isolation between the control side and the high-voltage side, making the circuit safer and more reliable. With a few simple components, you can build a functional and practical switch for controlling various electrical devices.
Whether you are controlling a light, a fan, or other household appliances, this project introduces you to basic relay control and optocoupler isolation techniques that are widely used in industrial and consumer electronics.
Comments
participate in discussions
Please login ? to participate in the comments
New customer Start here.