Opto coupler wiring basic

I need to use an opto coupler to reduce 24V to 5V to directly pulse the AVR. This is the first time I'll be using an opto coupler.

As per what I know the OptoCoupler is a 6 pin package. Internally there is a LED on one side and a light detector of some sort on the other.

What pins stand for what. How do I mate the 24V to the opto and which pins should I receive the 5V from ?
What resistors should I use to control current?, series or parallel.

Please give me the resistor values, since I understand the only the basics of it.

http://evelta.com/index.php?route=product/search&filter_name=opto

Data:

I/P pulse from an encoder @ 24V
O/P pulse required for AVR @5V
Overall current required depends on the opto and AVR I guess (Technically a very low current).
Also here's a link to opto couplers which I have easy access to, can I use one from these ? :

HELP !

You need to tell us exactly what opto you are using in order to calculate the seriese resistor value.
I to the arduino connect the emitter to ground and the collector to the input pin and enable the internal pull up resistors.

Well here's a link to optos I have easy access to.

http://evelta.com/index.php?route=product/search&filter_name=opto

Please tell me which according to you is the best one.
The I/P from the sensor is 24V and the AVR I/P is 5V.

Help :frowning: !!

Well the cheapest one will need a 1K2 seriese resistor for 24V operation.

The only suitable one for your application in that list is the MCT2E, which is also the cheapest. Connect the output to the Arduino as Mike has suggested (pin 4 to Arduino ground, pin 5 to the Arduino digital input pin, and enable the pullup resistor on the input pin). Connect pin 2 to the negative side of your 24V input, and connect a resistor between pin 1 and the positive side of the 24V input. See pin diagram here http://www.ti.com/lit/ds/soes023/soes023.pdf. For the value of the resistor, anything between about 500 ohms and 10K should work. I would choose 2.2K or 4.7K.

Pull up resistor as in digitalWrite(pinNum,HIGH) when the pin is an INPUT ?. Currently instead of doing that I've been using a 10k resistor in series to ground and the pin, same thing ?

If that resistor went to 5v rather than GND yes

I'll be using falling as an interrupt then ?, I prefer using RISING, probably need a PNP photocoupler for that then ?

Why? Because "on" = high.
Why? Because "on" = high?
Lots of times, especially in industry, things are "tied high" and the active state is LOW.

Anyway, if you can't reconcile to that, with the attached drawing, when the opto-LED is on (conducting) then its output goes High. Don't use an internal pullup with it.

spcl.JPG

If you are designing the circuit, "on" is whatever you choose it to be.

dc42:
If you are designing the circuit, "on" is whatever you choose it to be.

I thought I posted that as a question.
So, I went back and edited that.

That's what I'm sayin'.
So, why not use fewer parts (one opto and no output resistor) and get on with "on" is low?

Anyway, I made allowance for the other way round by providing the circuit for it.

vikramnayak:
I'll be using falling as an interrupt then ?, I prefer using RISING, probably need a PNP photocoupler for that then ?

Why?
There is no advantage in either using rising or falling why do you prefer one over the other?
Good luck on finding a PNP opto isolator, I haven't seen one.

Is there any IC (Optocoupler) available to have 24vdc digital input convert to 5vdc signal for Aurduion Due board? Want to avoid more component on board.

Well, they don't convert as such....

You have a voltage into the input LED, and a pullup to 5V on the output. So the output is then either 5V normally or 0V when the LED is on.

You need resistor on the input to bring the input voltage down to Vf for the LED, to limit the current through the LED to whatever the maker says it must be.

This page shows the connection and links the datasheet of a 4N25, as an example.

Wouldn't a voltage divider work? - Scotty

scottyjr:
Wouldn't a voltage divider work? - Scotty

Yeah but he said he wanted opto-isolation...

Is there any IC (Optocoupler) available to have 24vdc digital input convert to 5vdc

Are you sure he wants to opto isolate?
He wants to "convert" 24 volts to 5.
Two resistor are better, can withstand higher voltagespikes.

Pelle

Pelleplutt:
Are you sure he wants to opto isolate?

Well I'm just going by this:

dvj215:
Is there any IC (Optocoupler) available to have 24vdc digital input convert to 5vdc

Thanks for reply. I have 24vdc signal from proxy & other sensors. To keep my aurduino board safe side wan to isolate this signal. Since arduino support 5v or 3.3v as input, want to convert this signal to his level with isolation.

scottyjr:
Wouldn't a voltage divider work? - Scotty

too simple. it would be "ON" as high as desired. not enough parts to make it interesting.