Floating inputs and Vref on a voltage subtractor (PWM to Gate converter)
simulate this circuit &ndash; Schematic created using CircuitLab

Figure 1. An opto-isolator solves the problem of floating inputs to the OP's comparitor. (a) Series connection. (b) Parallel connection.

Consider the circuit of Figure 1 as a possible solution. Using the opto effectively solves the floating input issue. Just check the response time of your chosen opto to make sure it switches quickly enough for your application.

(a) Opto-isolators use infra-red LEDs with a typical Vf (forward voltage drop) of 1.2 V. It may be necessary to reduce the value of R1 accordingly.

(b) If the voltage headroom is inadequate to drive the series configuration of Figure 1a then 1b may provide a solution. R5 limits the current and provides the additional voltage drop between the visible LED (1.8 to 2.0 V) and the infra-red of the opto-isolator (1.2 V). Again R3's value would need to be reduced to cope with the approximately doubled current.







simulate this circuit

Figure 2c. As per Ressull's comment below a parallel connection simplifies the solution even further.