How can I design an isolated, wide-range digital logic input compatible with AC and DC voltages from (say) 5V-300V?

There are some excellent suggestions on how to create a wide-voltage range digital logic input on this question.

The question is very similar to my needs. I'd like to be able to detect the presence of a voltage (either AC or DC of either polarity, from, say, 5V-300V or thereabouts) and have the input go to a digital input pin of a microcontroller. I particularly like the second solution that suggests current-limiting resistor -> zener diode clamping... but...

In my understanding, an input that can take such high voltages should really be isolated (by a transformer / optoisolator) from a normal low-voltage circuit. How could I create an isolated input like this? Is the limited current and voltage of an input circuit like this enough to drive the input of an optoisolator?

And furthermore, how can I cope with DC voltages of either polarity and AC voltages on that input? I assume that I can put a bridge rectifier straight after the input, but that will cause a decent voltage drop before anything else has happened. Then I know there will be a capacitor in there somewhere to smooth out the input for AC, but I don't understand where it should go, how big it should be and how it will affect switch-on and switch-off times when it's just a plain DC voltage input?

Bonus points if the solution can go down to 3V (or even lower) instead of just 5V. Further bonus points for use of only cheap, standard 'jellybean' parts.

• You need to describe the thresholds you want for this digital output. What voltage +/- describes 0/1 for a +/-5V input versus what voltage +/- describes 0/1 for 300V input. What variation of threshold can be tolerated over a temperature range? If the thresholds' will vary then there is no passive detector possible and you'd have to resort to a self ranging detector. Apr 18, 2018 at 18:14
• To keep it simple, I'd be happy to keep the threshold the same across all voltage ranges (somewhere between 2V and 4V would be ideal, the lower the better). I'd prefer the threshold didn't vary too much with temperature. But varying within that range (2V-4V) would be OK. Out of interest, how would you build a self-ranging detector? Apr 18, 2018 at 18:28

Your specifications lack detail, but let's assume the following:

1. A single threshold voltage, the same for both positive and negative voltages.
For example, if the threshold is 4V, then anything between +/- 4V input will give a zero, and anything more than +/- 4V would be a one on the digital output.

2. Vin can be +/- 4V to +/- 300V minimum

3. Input is isolated with no ground reference

4. No input power supply needed

You could try a circuit like this:

simulate this circuit – Schematic created using CircuitLab

I've used a very similar circuit to provide zero crossing detection on mains voltages. The input threshold should be a little under 4 V with this opto.

The CPC3982 is a depletion mode FET that works as a constant current source for the opto once the input voltage is high enough. R1 should be selected to give the low current opto 500 uA. This limits the power dissipation in the FET to around 150 mW at 300 V input. When the voltage input is low (under 5 V) the FET will be turned on. At about 2-3 V the opto current will be low enough to register a zero on the digital ouptut, though this will depend on the value of R1. You can increase the low voltage threshold by reducing R2.

• You might want to explain what's so special about the CPC3982... Apr 19, 2018 at 4:27
• There is nothing special about it ...it's a high voltage N-Channel depletion mode FET which you can see from the datasheet. There are a bunch of high voltage depletion mode FETs available, I just happen to like IXYS and have used them before. Now if you'd asked instead how it works. Apr 19, 2018 at 4:43
• This is great! Thanks. It took me a little while to read up and understand how the depletion-mode MOSFET works, but this is a perfect solution as far as I can see! Apr 21, 2018 at 20:18

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 – Schematic created using CircuitLab

Note that Q1 and D1 together keep the base voltage to within ±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.

• I might be being stupid, but I don't think this circuit isolates the input voltage from the microcontroller. Also, I'm pretty sure it doesn't accept DC input of either polarity (just positive). Apr 18, 2018 at 16:37
• Do you understand that the BE junction of Q1 and D1 together form a bipolar voltage clamp? Apr 18, 2018 at 16:41
• Regarding negative inputs -- it's easy to extend the concept to include them, too. But let me ask you this: for what voltages should the circuit produce no output? Apr 18, 2018 at 16:42
• Do I understand the voltage clamp? Sure, it's very similar to the circuit that I posted in the link in the question - and then referenced in the question. Apr 18, 2018 at 16:44
• Regarding negative inputs: I'd like the circuit to produce no output for +/- 0V-2V. Apr 18, 2018 at 16:45