Need help reviewing my design for a voltage protection and regulator - Page 1
Forum section: electronics / beginners

author: Alexitoo00
author_rank: Newbie
timestamp: February 04, 2025, 07:32:30 pm
content: Hello Forum, I'm Alex and this is my first post.I was designing a voltage regulator for a project I am doing, however, because of the specifics of the requirements, I am not entirely sure if what I've done so far is correct or if there is a better way to do it.The goal of my system is to take a signal in the range from 0 to 9, 12 or 24V, and map it to a voltage between 0-5V to be inputted into an ESP32 device. Because the source I am using may not be very stable and also the different input voltages (although connected in different sockets) that I don't want to mess up, I want to include some sort of feedback that tells me if everything is okay or if there is a problem so I don't blow everything up.In summary, I need to map the input value to a range between 0-5V and clamp any voltage above that. In my design, if the voltage exceeds the threshold, it will turn on the LED. The MOSFET plus the forward voltage of the LED makes it activate when the output is at around 5.4V aprox onI am using the attached circuit on a simulator so far, but one of these days I will go buy the components to mount it on a protoboard before commiting to make a PCB board. In the photo there is also the simulated voltage in normal condition on the system. You can see three batteries with switches in order to simulate the different inputs. From left to right, 24V, 12V and 9V.I want to know if I am going well with this. I don't want to alter too much the input signal so it is the most exact and linear possible. The system must draw almost no power when the value is below 5V and then clamp every voltage above that.Thank you so much for your help.Greetings,Alex

author: ahsrabrifat
author_rank: Regular Contributor
timestamp: February 05, 2025, 10:21:25 am
content: For overvoltage indication, you can add an LM393 comparator with 5V reference. The comparator output will drive an LED.

author: Alexitoo00
author_rank: Newbie
timestamp: February 05, 2025, 01:00:42 pm
content: Hello, thank you very much for your input. I thought about using one of those, but because the plan is to move away to another system that does not have a 5V reference, I would like to not rely on that and cover as much as possible logic within this circuit itself without additional voltage sources. Do you think there is a way to use an op-amp to compare the voltage without a outside source? Also I saw that regulators draw quite some power and that may disturb the mapping from input to output voltages

author: Zero999
author_rank: Super Contributor
timestamp: February 05, 2025, 10:24:05 pm
content: Please clearly mark the output on that circuit.It will draw just under 1mA from the 24V PSU, which I'd say is considerable.Why not simply use a 300k and 75k potential divider? That will scale 0 to 25V to 0 to 5V. You can then program the MCU to turn on an LED when the voltage exceeds 24V plus a small margin. Higher voltages than 25V will be clamped by the MCU's internal ESD protection diodes.

author: Alexitoo00
author_rank: Newbie
timestamp: February 12, 2025, 12:32:50 am
content: I'm sorry it is not clear, I thought it was obvious that the voltmeter on the right was the output of the circuit. As you can see in the image, with the 9V connected to the input, the output is effectively 5.079V.What will draw under 1mA, my circuit or theLM393 that is proposing ahsrabrifat?As I stated on the first message, I want to be able to map inputs from the scales of 0-9, 0-12 and 0-24 on the input to 0-5V on the output, so using 300k and 75k potential divider to map 0-25 to 0-5V is, as you can understand, not part of the requirements of this project. Also (and again), I don't want to depend on internal protection of the MCU.To clarify, on the subject of the post states that Ineed help reviewing my design for a voltage protection and regulator, so I think, understandably, that my doubts are more related to the fact that I am using a bunch of components to guarantee that protection and also include an LED feedback (self-contained on the system) to notify when the input exceeds the design parameters.Thank you either way for your input, but next time I would appreciate it if you could read the post before answering the question

author: xvr
author_rank: Frequent Contributor
timestamp: February 12, 2025, 12:47:55 pm
content: Clump voltage of your circuit defined by zener voltage and BE voltage drop of BJT. This is not very convenient way to adjust voltageIf you need precise clump voltage setup you can replace both transistors and zener by TV431 (and pair of resistors)

author: Alexitoo00
author_rank: Newbie
timestamp: February 12, 2025, 02:52:16 pm
content: I see what you mean with the TL431. The only problem with that chip is that in order to regulate the output, the input must be less than my reference voltage. Is there a way to vary the reference voltage for having a correct map of the input voltage? For example, in my design, if I input 12V in the 12V input pin, the output is 5V and when I input 6V, the output is 2.5V, and when I input 3V, the output is effectively 1.25V.Let's say I design the TL431 to output 5V. If I input then 12V, the output is 5V, good. But if I input 6V, the output is still 5V, bad. And if I input anything less than the reference, let's say, 3V, the output is almost 3V, bad again. That system does not solve my objective of effectively map the input to output voltages in proportion.I like however the LM431 as a sort of security system in case the output value exceeds a determinate threshold, that can be an interesting option, and even use it to activate the LED for feedback when that happens. I will think about it.Do you have any suggestion as to use the TL431 to correctly map my different input voltages? If I had only a 12V input, that could be done like that, but with several different inputs, I don't know how can it be done using just that chip.Thank you for your answer

author: xvr
author_rank: Frequent Contributor
timestamp: February 12, 2025, 03:06:38 pm
content: QuoteI suggest use TL431 for clamping circuit. It will clamp all voltage over 5V to 5V, and will not change anything below this limit.For mapping input ranges to 0-5V range yoi can still use voltage dividers (as in original cuircuit)

author: Zero999
author_rank: Super Contributor
timestamp: February 12, 2025, 03:50:21 pm
content: Quote from: Alexitoo00 on February 12, 2025, 12:32:50 amI read your post several times and you asked if there is a better way to do it, hence my suggestion.The 12k + 3k + 4k + 6k5 divider will result in a current drain of nearly 1mA from a 24V supply.What is the grey circle with 0.747V across it? What's the part number/breakdown voltage of the zener diode?What if one or more switch is on? Will current flowing from one power supply to another one cause any issues?Your requirements seem to be unusual. Why do you need to scale three different voltages to 0 to 5V?How do you know for sure your 24V supply will be exactly 24V and not 24.2V, your 9V supply won't be 9.4V etc.?Scaling to 0 to 25V to 0 to 5V, will enable you to read 9V, 12V and 24V, without using different resistor chains. It's always a good idea to scale your analogue input to cover a sightly wider range of voltages, than you would for normal operation. It has the added bonus of allowing your microcontroller to drive an indicator to show the input voltage is too high, rather than having to rely on additional components. Never assume that the supply voltages will be exactly equal to the voltages specified. Even if the power supply is regulated, there will be some deviation.If you must have separate inputs for 9V 12V and 24V, then I advise scaling from slightly higher voltages 9.5V, 12.5V, 25V to 5V, so you have some headroom. Heck, I generally design for a maximum input of +25% over the nominal, so 30V, for a system which is going to monitor a 24V supply. 25V is the absolute minimum.If the internal ESD protection diodes on your MCU aren't good enough to provide adequate protection, then add a Schottky diode from the analogue input to +V and a 5.6V zener across the supply pins, to clamp the supply voltage.Here's an example. It has much higher value resistors to reduce the current drain in the input. A capacitor is added to the output to add some filtering and provide a reservoir for the sample and hold capacitor inside the ADC. The BAT54 Schottky diode will clamp the input voltage to within 200mV of VDD. The 5.6V zener will then limit VDD to 5.6V, if too much current flows into VDD. If required, more resistors can be added to the potential divider (R1 & R2) for different voltages.I've simulated it. The Y-axis on the plot is the output voltage and the X-axis, the input voltage. Even when the input voltage is 30V, the output is 5.13V, which shouldn't cause any damage to the MCU.

author: Alexitoo00
author_rank: Newbie
timestamp: February 12, 2025, 06:15:32 pm
content: How is it possible that you have read my posts several times and still weren't able to retain anything?I am not using an MCU, I am using a variable aperture valve among other analog devices, but that is not even relevant to the requirements of the circuit. I am using an ESP32 to check the output as it simulates better the behavior with the final elements than an open circuit.I will quickly answer your questions quoting the previous posts that clearly you haven't read.Quote from: Zero999 on February 12, 2025, 03:50:21 pmIt is an LED, as stated in the first post. The design is made using falstad.com, that's why it is shown like that.The zener diode I am using has a breakdown voltage of 5.1VQuote from: Zero999 on February 12, 2025, 03:50:21 pmQuote from: Alexitoo00 on February 04, 2025, 07:32:30 pmEmphasis on thesimulate. I still haven't decided if make them screw connections, a selector, or what.Quote from: Zero999 on February 12, 2025, 03:50:21 pmQuote from: Alexitoo00 on February 04, 2025, 07:32:30 pmQuote from: Zero999 on February 12, 2025, 03:50:21 pmI am not reading, I am using an analog signal, no ADC, no MCU.Quote from: Zero999 on February 12, 2025, 03:50:21 pmQuote from: Alexitoo00][quote author=Alexitoo00 on February 04, 2025, 07:32:30 pmNo microcontroller, I want the indicator self contained in the circuitQuote from: Zero999 on February 12, 2025, 03:50:21 pmQuote from: Alexitoo00 on February 05, 2025, 01:00:42 pmQuote from: Zero999 on February 12, 2025, 03:50:21 pmThat may actually be the only piece of advice slightly useful, but unfortunately, I don't have any +V signal, as I will not be using any MCU. Again, I want the system to be as self-contained as possible, with no external inputs.As it seems that you are having some trouble understanding the purpose, I am attaching the response of the simulated circuit. As you can appreciate, the relation between the input (in green) and the output (in red), in a graph with 1V/div, the relation is linear until it reaches the mark of 5.4V on the output. From that point on, the output stays constant (constantish).Given the fact that almost all of your nonsense was answered almost in its totality with quotes of the previous messages, that leads me to think that you did not read anything, or that you don't know how to comprehend or retain information. That's sad, I really think that you have the knowledge to actually provide very good advice, but you decide to be a moron instead.I would suggest that before answering anything else you try to think if you actually have something to add to the topic. Because if not, I think answering only wastes your time, my time, and confuses other people that are actually trying to help.Thank you very much

author: Zero999
author_rank: Super Contributor
timestamp: February 12, 2025, 06:35:42 pm
content: Quote from: Alexitoo00 on February 12, 2025, 06:15:32 pmWhere did you say that in your original post? Please provide a quote.QuoteWhere did you say that in your original post? Please provide a quote.Quote1) You will get better responses, if you provided that information i.e. no microcontroller from the start.2) How much did you pay for this advice? Note people give up their time for free to help. You're now coming across as ungrateful.3) You don't need 5V. Just skip the Schottky diode in my schematic (replace it with a short) and remove V1.

author: Alexitoo00
author_rank: Newbie
timestamp: February 12, 2025, 07:02:56 pm
content: Quote from: Zero999 on February 12, 2025, 06:35:42 pmHere it is your quoteQuote from: Alexitoo00 on February 05, 2025, 01:00:42 pmQuote from: Zero999 on February 12, 2025, 06:35:42 pm1) I got good responses from other people. They read the problem and provide advice acording to the requirements of the project.2) In time? You would be surprised... I just told you that if you don't know how to help, just don't say anything, your contributions can be condensed in suggesting a Schottky diode.3) Talking of which, a short to what? To ground? To the input that will vary and we don't want to alter? Can you clarify?Thank you for your input

author: Zero999
author_rank: Super Contributor
timestamp: February 12, 2025, 07:52:27 pm
content: Quote from: Alexitoo00 on February 12, 2025, 07:02:56 pmStill you made no mention of not using an MCU, or anything else.QuoteFor over-voltage protection, all you need is a zener diode on the output of your potential divider, but that won't give you an indicator. The solution is to put the zener diode in series with the base of a BJT.The problem with this simple solution is the output voltage develops a non-linear relationship with the input, just about the time it limits. There ways to overcome this, but at the expense of complexity.Note that I had to reduce the resistor values to give more drive to the BJT. Change them to scale from 24V, 12V, 9V or whatever.Again, the X-axis is the input voltage. The green plot is the output voltage and the red is the LED current.

author: Alexitoo00
author_rank: Newbie
timestamp: February 13, 2025, 08:40:19 pm
content: Thank you, that graph is very useful. The concept is great although it consumes much more than mine for some reason and the power dissipation is very poor.In my design at 40V overload, it consumes 1.7mA and the maximum power consumption is one resistor with 37mW.In your circuit, with just 28V overload (just 4 volts over the rating voltage), it consumes 7.6mA and the maximum power consumption is the 4k resistor with 188.4mW, dangerously close to the limit.Just for the record, at 40V overload, the consumption and max power in a single element is 10.7mA and 363.5mW (way over 1/4W typical resistors).I chose overload voltages so the LED is active as well as regulation as that is the only way of testing for protection.And I know I can always use bigger resistors or with higher power rating, but that is not the point.You are making pass through one resistor almost all of the voltage of the input source, as that is not a voltage divider, but just two branches from the source.

author: Zero999
author_rank: Super Contributor
timestamp: February 13, 2025, 10:06:39 pm
content: You didn't say power consumption needs to be low during over voltage, or what the maximum input voltage will be.What do you mean by dangerously close to the limit? What limit?Try to post as much information as possible right from the beginning.My circuit only draws 640µA, with no over voltage, which is less than your circuit, under the same conditions.At least my circuit will work. Your circuit won't. The MOSFET hardly turns on and the voltage across your LED is only 0.747V, so it won't turn on, at least 1.8V is require to make a high efficiency red LED light. This should be obvious: look the voltages at both sides of that 200R resistor are the same, so the voltage across it is zero therefore no current flows through it. I would have told your that, right at the start of the thread, if you'd use the correct LED symbol, or put a note next to it saying LED.There are ways to reduce the power consumption, even under overload conditions. Use a high efficiency LED, a current source, rather than a resistor or perhaps even go for switched mode regulator, but ultimately you still need to drive an LED and the power must come from somewhere.

author: Alexitoo00
author_rank: Newbie
timestamp: February 14, 2025, 12:13:51 am
content: My friend, I cannot continue texting with you. You still haven't read the posts.Quote from: Zero999 on February 13, 2025, 10:06:39 pmQuote from: Alexitoo00 on February 04, 2025, 07:32:30 pmQuote from: Zero999 on February 13, 2025, 10:06:39 pmQuote from: Alexitoo00 on February 13, 2025, 08:40:19 pmQuote from: Zero999 on February 13, 2025, 10:06:39 pmThat is exactly why I added more information as requested. Perhaps if you read the posts you would understand it.Quote from: Zero999 on February 13, 2025, 10:06:39 pmThat is actually true, mine draws 1mA at normal operation, but when the LED turns on, yours jumps quite more than mine.Quote from: Zero999 on February 13, 2025, 10:06:39 pmOut of nothing hahaha. I have it working on a protoboard right now.Quote from: Zero999 on February 13, 2025, 10:06:39 pmMy friend, the LED must not turn on under normal operation. The MOSFET is in a configuration such that when the gate is pulled low, it permits the flow of current to the LED. In that case, and only in that case, the voltages on both sides of the resistor are different, current flows through it, and that helps dissipate the overvoltage. Under normal conditions, the power consumption of that resistor is null. I think that should be obvious. I am not super proficient in electronics, but I believe that is Electronics I in engineering.By your beloved quotes:Quote from: Alexitoo00 on February 04, 2025, 07:32:30 pmSounds quite like the definition of a security system, which is precisely the topic. Because the LED doesn't turn on, it indicates that the system works correctly.I would appreciate it if you don't add anything else to the post without reading the messages. I am starting to get a bit tired of this, you refuse to read the messages, you say nonsense continuously, talk about obvious things without understanding the functioning of a MOSFET. I don't know if it is lack of knowledge or if you are just trolling. On top of that, I have checked other answers from you in other posts and it seems that you also didn't read those other people requirements before answering. I am beginning to think that you are answering just because you want to have a bigger number on your profile (please don't ask me to quote other posts, I have enough with this one already).I have no right to judge how you live your life, but I would appreciate it if you only talked if you have something to add to the conversation. Thank you.

author: Zero999
author_rank: Super Contributor
timestamp: February 14, 2025, 08:09:46 am
content: If you're happy with your circuit then why did you ask for advice?I've tried to help. This should have been clear by the fact I've posted detailed explanations and schematics. It appears as though you just want to waste time.

author: Terry Bites
author_rank: Super Contributor
timestamp: February 14, 2025, 10:14:33 am
content: Youve shown SPST switches. If thats the case then the circuit is prone to being incorrectly set tempting the magic smoke from it lair. Use a rotary switch.That would be a scaling circuit, not a "voltage regulator". Clamping is most eaily achieved with the ESP32 device its self. The ADC input pin has internal diodes that clamp the pin voltage at Vdd or Vss plus a diode drop. These diodes can handle a maximum current which is usually specified in the data sheet under "absolute maximum ratings". This is typically 5-10mA. So simply adding a series resistor will protect the internal diodes. This can be risky so a pair of external diodes can be used as back up. The seres resistor can be calculated as (Vin(max)-Vdd)/ I max. Ignoring Vf, with Vdd=5 and Vmax=24 thats 19/Imax. Its a good idea to keep Imax well under the limiting value, say half. So we get 19/(0.5*Imax) or ~ 7.6k. 10k would be a good choice. A 5cent fix. Dont use Schottkys here, they leak current into your high impedance divider.The voltage divider can act as the limiting resistor by ensuring that its input impedance is >10k. That'll also be handy as part of your RC antialiasing filter.A TL431 can be made into a low cost comparator. But it has limitations; a relatively low input impedance is needed to keep Iref effects to a minimum. That can load your input divider. The lack of sharp transition will cause the LED to glow dimly just below the threshold. A real comparator is a better choice. Use the ESP32 ADC reference to set the comparator trip point.Buffering the input divider output with a rail to rail (RRIO) low voltage opamp simplifies things with the added bonus that you can operate the buffer from Vdd and get the clamping action you need without any additional components. The opamp output can then not exceed Vdd. The input diode protection advice above is still needed for the opamp. You could forgo this on the grounds that a fried opamp is cheaper than a smoking ESP32. But why risk it.

author: Zero999
author_rank: Super Contributor
timestamp: February 14, 2025, 11:21:54 am
content: Quote from: Terry Bites on February 14, 2025, 10:14:33 amI hope you have your flame proof jacket on. The OP will have a go at you if they don't like your circuit, because you couldn't interpret their, unclear schematic and vague, overly verbose posts.The problem is, the OP doesn't have control over the ESP32, which is presumably built-into some other device and they can't rely on the internal protection diodes.The TL431 is a sensible enough choice, but there are lower power alternatives available and the lack of the sharp transition can be resolved by adding another transistor to provide positive feedback and therefore hysteresis.Here's an example of a such a circuit I designed awhile ago. It uses much lower value resistors, but works on a similar principle and can be reconfigured with a lower power '431 driving an LED, rather than a relay.TL431 Portable low voltage cut-off.asc

author: Terry Bites
author_rank: Super Contributor
timestamp: February 14, 2025, 01:45:12 pm
content: Touchet!

author: tooki
author_rank: Super Contributor
timestamp: February 14, 2025, 02:21:33 pm
content: Quote from: Alexitoo00 on February 04, 2025, 07:32:30 pmESP32 is a 3.3V device, and its ADC needs to be specially configured to support going even that high. You won’t be able to measure to 5V.