# Wide voltage range input regulation (24V - 3.3V)

TL; DR: I need a circuit capable of handling input voltages from 24V to 3.3V (with a 10mA/5mA maximum current) and delivering 3.3V to the microcontroller (ESP32) input.

Recently, I've been working with the EPS32 microcontroller. And this project in specific requires signals from different sources, with different maximum output voltages: 5V, 24V and 3.3V. The frequency wouldn't be more than 100KHz.

My signal sources can provide up to 10mA, but a 5mA limit would be more confortable for me to work with. Galvanic isolation isn't a requirement, but it would be interesting!

I searched on the web for circuits to implement in the project, but almost every one that I could find, could only handle a single specific voltage. The majority of the designs I found were based on the classical optocoupler circuit, with a current limiting resistor, calculated for a certain voltage.

In fact, I found an Electronics Stackexchange question that was almost exactly what I needed (How is this 5-24V input circuit working?), but I don't have access to any JFETs in my local store, also, I couldn't find any MOSFET to effectively replace this JFET.

I was thinking if OPAMPs could do this job, but I am not sure if this is a good practice.

Any help will be very appreciated!

PS.: Sorry if my question doesn't express my current effort in the project, as it doesn't contain any circuit/design attempt made by me, but I am really lost with this part of my project! So I couldn't figure out any decent circuit.

• You haven't expressly stated it: are you just looking for a circuit to drive an opto-isolator LED from a high of 3.3 to 24 V and a low of 0 V with an LED current of 5 mA when on? Feb 9, 2018 at 19:02
• @Transistor props to you for divining what OP wanted to do from this post... My interpretation was that he had a (digital) input that could be anywhere from 0V/3.3V to 0V/24V and needed to interface to a digital uC pin (0V/3.3V). In which case I'd either use a comparator or just an N-Ch MOSFET with a ~1.5V VGS_ON and > 24V VGS_max, configured as an inverter. Feb 9, 2018 at 22:45
• You are right Selvek! The problem is that I couldn't find a mosfet with a VGS > 24V, almost every mosfet that I know have a max VGS of 20V. If you could recommend a mosfet with such specifications I would appreciate! Feb 10, 2018 at 0:17

My interpretation of your question is:

• You want to drive an opto-isolator LED from a digital on/off signal.
• High level is 3.3 to 24 V and a low of 0 V.
• LED current of 5 mA when on.

simulate this circuit – Schematic created using CircuitLab

Figure 1. A constant current sink.

Opto-couplers use infrared LEDs with a forward voltage of 1.4 V approx. This leaves a couple of volts to work with for our current limiter.

• R2 biases Q2 on.
• Current flows through D1, Q2 and R1.
• When the current reaches 5 mA the voltage at the base of Q1 will reach 0.6 V and it will begin to turn on. This will steal the base current from Q2 preventing further rise in D1 current.

Figure 2. A quick run of the CircuitLab DC sweep indicates that this should work as required.

• In fact, 5mA / 10mA is the maximum current source/sink capability of my signal sources. Even though, your answer is great! Many thanks! I will adapt that current source to my needs! Feb 9, 2018 at 19:37
• It's a constant-current sink. The current is sourced from your sensor. Thanks for accepting my answer but you should wait a day or two to give the whole of humanity a chance to answer. You can unaccept for now, if you wish. Feb 9, 2018 at 19:40
• Just to kill my curiosity, could an OP AMP (rail to rail), with a 3.3V saturation and unitary gain be used? Or would it be a bad practice? Feb 9, 2018 at 19:41
• It could but you'd need to protect the inputs. A comparitor would be a better choice. Feb 9, 2018 at 19:41
• Thank you again! I will wait some days for other answers, as you pointed out :) Feb 9, 2018 at 19:43