jay123035 wrote:just to clarify. if the 24v side of a optocoupler is closed/powered the 3v side will be closed too.
my voltage is DC.
Can be both ways, only depends of how you build the circuit, hence depends of yours electronics skills.
The optocoupler transistor needs to be polarized according what you are looking for, in most circuits you should note a resistor in series with the emitter or the collector, to limit the current flow trough the transistor to a safe level ensuring the proper operation of the device.
Please have a look at this other example:
http://www.8051projects.net/e107_files/ ... 4178_1.jpg
With the
Configuration 1 example, you can connect the RPi GPIO direct to the Q1 Emitter and the R2 junction, however there is some situations when the output can not be exactly detected by the GPIO input, that is when the GPIO is not sensing the proper voltage to lock in the "high" or the "low" state.
If the voltage falls (and remains) between the "high" and "low" voltage level thresholds, the GPIO can lead to unexpected behavior.
The way to overcome this situation is inserting a Schmitt trigger gate (can be an Inverter, or any other logic gate, according to your needs) between the phototransistor output and the GPIO.
References:
http://en.wikipedia.org/wiki/Schmitt_trigger
http://en.wikipedia.org/wiki/Optocouplers
http://www.nxp.com/documents/data_sheet/74HC_HCT14.pdf
http://www.datasheetcatalog.org/datashe ... 357_DS.pdf