@taconite a couple of notes regarding your post:
The internal circuit of the input looks like this, with no connection to ground.
8811d975-4183-4a84-a65c-041d8c838c5c-image.png
Since the input is pulled down, you want to connect your opto coupler between the input and ground and use the inversion symbol "!" if needed. (You could still have an external pullup resistor if the internal 10K is too high for your purpose, if this an issue, you can ask here).
e8edb431-4447-4588-9b03-23c173a71eca-image.png
BTW, if you would use a duet 3 board, you may be able to drop the opto coupler all together since some of the input are can get higher voltages.