Optocoupler input problem

Hello.

I'm using optocoupler ct817 and 4n25 to amplify and control 2 relays for my project. Here's the schematic I've drawn (look at first picture).

But, I'm confused with the input in one of the optocouplers. It states that minus voltage when I pin the input to the arduino. And it's based one the schematic I drew first.

What should I do to have the positive input in Optocoupler? Thanks for Your attention.

This is the code for controlling the relay

int pin1 = 10;
int pin2 = 11;
int pin3 = 12;
int pin4 = 13;

void setup() {
//start set pin
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
}

void loop() {
digitalWrite(pin3, LOW);
digitalWrite(pin2, HIGH);
digitalWrite(pin1, LOW);
digitalWrite(pin4, HIGH);
}

You've posted no images and code that does nothing but setting pins 2 and 4 high and 1 and 3 low over and over again.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

Hello. Thanks to note me a picture. This is the schematic I had drawn.

The code is just testing the circuit that works properly. And to test it, I also change the cable to other pins.

Doc1.pdf (157 KB)

Hi,
Thanks for the diagram, however it does not show
What pins you are using.
What the relays are.
What is your power supply.
Are you using current limit resistors for the input of the optocouplers?
You only need one output to control one opto, not two outputs.
OP diagram.

Tom..... :slight_smile:

I'm using 12VDC relay and I'm not using any resistor to electrify the relay. The power supply is 12 VDC and it's out of Arduino board. The pin is 10 and 11 in Arduino Mega (but I'm testing it at Arduino Uno).

Very few optocouplers can pass enough current to drive a relay. You said in the first post "4N25" which sounds like a transistor. More detail on that part of the schematic is required. Is it a module you've purchased? Can you show a link to the product detail or datasheet?

Hi,
Can you post a proper circuit diagram, showing ALL wiring and part numbers and pin numbers.
Post you circuit in jpg or png format please.

What is the part number and spec/data of your relay?
Do you have any resistors in your circuit?

Can you post a picture of your project, so we can see your component layout?

Thanks.. Tom.. :slight_smile:

Hello, Tom. This is the complete schematic I've drawn. I didn't use any component to trigger the relay instead of optocoupler.

This is the schematic I aimed that connected to the relay which can change the direction of the electricity. I use Relay to control the trigger and change of resistor value in CD4047 that can varies the frequency. I connect the relay to Arduino Mega (now UNO) for changing the voltage (HIGH and LOW). The change is managed by using temperature sensor to command the Relay and CD4047 that can adjust the resistance which affect the frequency

MorganS:
Very few optocouplers can pass enough current to drive a relay.

If you let us know the part numbers of both the relay and the opto, we would have some chance of checking this for you. Why don't you try reading the datasheets yourself and asking any questions that you have from the data sheet. (Refer to the page numbers and link to the actual document you're reading.)

The use of optocouplers is to isolate the input from the output. By using the same power supply with common gnd and +V there is no isolation so no point in using these. If you don't require isolation use a MOSFET or Transistor. If you require isolation supply a separate PS for the output side of the coupler

Hi,
OPs "diagrams"



PLEASE a complete circuit diagram, a picture of a hand drawn circuit in jpg, png?

  • How have to go these two circuits together?
  • How fast do you want to switch the relays? ?
  • What is the part number and spec/data of your relay?
  • Do you have any resistors in your circuit?
  • Can you post a picture of your project, so we can see your component layout?

You only need one pin to control an optocoupler.
Tom.. :slight_smile:

MorganS:
Very few optocouplers can pass enough current to drive a relay. You said in the first post "4N25" which sounds like a transistor. More detail on that part of the schematic is required. Is it a module you've purchased? Can you show a link to the product detail or datasheet?

Even the most cursory search shows 4N25 is one of the most commonly used opto couplers. The 4N immediately tells you it has 5 terminals and is silicon based.