How can I design an isolated, wide-range digital logic input compatible with AC and DC voltages from (say) 5V-300V?
A circuit that I have used in the past is a simple BJT. This will detect positive DC voltages, or AC voltages as a series of pulses.







simulate this circuit &ndash; Schematic created using CircuitLab

Note that Q1 and D1 together keep the base voltage to within &plusmn;0.7 V, even if the input swings to -300 V for any reason.

R1 sets the collector current at saturation. This, combined with the minimum current gain of Q1, determines the minimum base current. Minimum base current and minimum input voltage determines R2.

Note that R2 must be able to withstand the full input voltage. Use multiple resistors if necessary.

C1 is optional. It provides a low-pass filter that helps mitigate switch bounce as well as ESD. 10 nF gives a time constant of 10 ms, but you can vary this as needed for the application.