Imagine an optocoupler's output as a device which is willing to pass through a light-dependent amount of current whenever the collector voltage is higher than the emitter voltage (in practice, the amount of current is a complicated function of the amount of light and the amount by which the collector voltage exceeds the emitter voltage). With no light, it will pass 10 microamps, and its current-passing capacity will "peg" at 100mA. If the current limit of the opto is I, the voltage at the collector will be 12V-IR or zero volts, whichever is less.
If the resistor were e.g. 1 meg, the amount of volt dropped by the resistor would be a minimum of 10 volts, meaning the collector voltage would never get above 2 volts. Cutting that resistor to 500K would reduce its minimum voltage drop to 5 volts, allowing the collector up to 7. Cutting it to 100K would reduce the voltage drop to 1 volt, allowing the collector up to 11 volts. The smaller the resistor, the higher the voltage when the opto is "off", approaching but not quite reaching a limit of the full 12 volts.
On the flip side, when the opto is on, the voltage drop across the resistor will be 100mA times the resistance or 12 volts, whichever is lower. If the resistor value is 120 ohms or less, the 12 volt supply will me the limiting factor. If the resistor were e.g. 100 ohms, the resistor voltage would be limited to 10 volts, meaning the collector voltage would only get down to 2 volts. Note that if the resistor is large enough, further improvements won't affect the voltage, but if it's too small, the output voltage will be quite sensitive to resistance.
The data sheet says: -
The VCC supply to each optoisolator must be bypassed by a 0.1μF
capacitor or larger. This can be either a ceramic or solid tantalum
capacitor with good high frequency characteristic and should be
connected as close as possible to the package VCC and GND pins of each
device.
Is this the problem? Here's a picture showing the 100nF cap from the data sheet: -
For information the data sheet also says: -
Enable Input – No pull up resistor required as the device has an
internal pull up resistor.
Best Answer
The entire point of the a optocoupler is to allow electrical separation of a circuit. It's literally a led, a little tube, and a phototransistor. You could make one yourself. You don't have to share a common ground, but you can if you want.
As for a short on the phototransistor size, for most circuits, especially low voltage low current ones you have nothing to worry about. Unless you connect a high voltage high current line that way exceeds the optocoupler's absolute maximum specs, enough that they cause the optocoupler to melt/explode/catch on fire.