Introduction: How to Use an Optocoupler to Pass Signals Between Controllers at Different Voltages

This tutorial makes use of the 4N25 optocoupler chip to allow for communication between controlling devices operating at different voltages. In my examples, I use the Raspberry Pi, which uses 3.3V DC signals, and a PLC (Programmable Logic Controller) operating at higher voltages (often 24V DC). Without this level of isolation, the lower voltage signals will not trigger input on the PLC, and the high voltage signals coming from the PLC will break circuitry in the Raspberry Pi.

Step 1: Gather Materials

For this project, you will need:

-Devices for communication (Raspberry Pi, Arduino, PLC, etc.) and their associated power sources

-Prototyping breadboard

-A variety of resistors (we used 2x56 Ohm and 2x1K Ohm)

-A 4N25 optocoupler, or similar chip

Step 2: Understand 4N25 Pinout

The 4N25 optocoupler datasheet shows the pinout, and the short version is this: the signal you pass through the left-side circuit (pins 1 and 2) will power an LED. This LED will emit photons that interact with the transistor connecting pins 4 and 5, allowing current to flow between the pins (from 5 to 4).

Step 3: Choose an Appropriate Resistor

The 4N25 LED, according to the datasheet, typically drops 1.3 V, and can handle a maximum current of 60 mA.

Using Ohm's Law, choose a resistor value to place between your signal source and pin 2. The voltage drop across this resistor will equal the voltage of your source signal minus the 1.3 V of the LED, and you can set the current equal to 40 mA (or any value you like, as long as it is under 60 mA).

One additional consideration is the power through the resistor. Most conventional resistors are rated for 1/4 Watt, so be careful that your power (voltage times current through resistor) does not exceed .25-- otherwise, your resistor will get very hot, and may potentially fail.

Step 4: Build the Circuit

To build the circuit, you'll want your signal source to lead to the resistor, resistor to pin 1, then pin 2 to signal ground.

On the other side of the chip, you'll want your receiving source to lead to pin 5, then receiving circuit connected to pin 4. This circuit should eventually connect to ground; the chip acts as a switch between pins 5 and 4.

Step 5: Test Your Circuit

You should now be able to pass an electrically isolated signal from the left side of the chip to the circuit on the right side.

Some final considerations: there is a collector current limitation with the optocoupler, in general, not allowing more than 50 mA to flow. If your receiving circuit requires more current/power, you may want to consider a different solution. I use this circuit to pass signals between my PLC and Raspberry Pi, but cannot use it to power components of my project (like solenoids).

Comments

About This Instructable

1,430views

19favorites

License:

More by rossgreer:How to Use an Optocoupler to Pass Signals Between Controllers at Different Voltages
Add instructable to: