I have this basic circuit but it's doing my head in with the actual prototype:
[![enter image description here][1]][1]


  [1]: https://i.sstatic.net/mLhhc.png

When LINK is open (not connected to the optocoupler), Encoder output works OK - it goes 0V and 5V. Also while LINK is open and if I put optocoupler cathode to ground, optocoupler output is triggered.

But when LINK is connected, output (LINK voltage) just swings between 3.1V and 5V.

3.1V is too high for a LOW logic so optocoupler output isn't triggered. I thought it was a component issue but it's same result for other prototype.

Simulation with LTSpice shows circuit should work. But not in my actual prototype.

Encoder: https://www.grayhill.com/documents/62AG-VG-Datasheet

Opto-isolator: http://isocom.com/wp-content/uploads/2017/09/DD93211-IS2801-4-240317.pdf

Ideas please?

Thank you!