Coming slightly late to this discussion; the problem appears to be getting a good low level, with an optoisolator output.
I've seen a circuit that gets around that, though I didn't realise at the time. It just adds a PNP transistor stage, acting as an inverter. The signal then needs inverting again, I guess, but you could probably just do that in software.
I have a schematic, as an image (saved a while ago - I've forgotten where from). I don't see any way to attach it here though.
I expect you can picture it anyway. The emitter of the PNP transistor is connected to Vcc, the collector connects through a resistor to ground. The base is fed via a resistor from the output side of the optoisolator.
If the output of the optoisolator is off, the base of the PNP transistor is at Vcc, so the transistor is off (output low, close to 0V thanks to the collector resistor connected to ground). If the optoisolator output is on, it only needs to drop by a little over 0.6V, to turn the PNP transistor on (output high, close to Vcc - 0.2V or so). So, even a dip of 1V for a zero, should be fine, depending on the base resistor value, and the gain of the transistor.
The diagram showed a PC817 optoisolator, with a 390 Ohm series resistor on the output side, and the same value resistor as the base resistor of the PNP transistor, shown as a BC640. The collector resistor is shown as 1k5 Ohms. Almost any small PNP transistor would do, I expect, and the resistor values aren't likely to be at all critical.