5
\$\begingroup\$

I'm working on a microcontroller-based device, and I need it to detect an input voltage (distinguish between zero and non-zero). When it's not zero, it can be anything between 10 V DC and 14.6V with some added noise of various frequencies. When it is zero, it will either be at GND or floating, I'm not sure yet.

Can I use a 5V Zener diode to stabilize this voltage and connect to the 5V-tolerant MCU's input? The current consumed will be however much the MCU requires, I expect it to be in the range of 1-3 mA (but I should probably see if I can find input current in the MCU's datasheet, which I couldn't so far but I'm sure it's there).

\$\endgroup\$
  • \$\begingroup\$ It will probably work. You would want a resistor in series with the Zener to limit the current. You need to make sure everything works at min and max voltage and min and max current. And check the power dissipated in the resistor to make sure it is reasonable. Might be easier to use a 5V LDO. \$\endgroup\$ – mkeith Dec 1 '15 at 15:44
  • 1
    \$\begingroup\$ ... and when it's zero, what is the range of voltages? \$\endgroup\$ – Andy aka Dec 1 '15 at 15:50
  • 4
    \$\begingroup\$ No, this is not an application for an IC voltage regulator. It is a signal application, not a power one. It would be good however to select a zener a bit below the MCU supply voltage, and one should realize that most of the current will go through the diode not the MCU. You calculate the current from the voltage drop above the zener and the resistor. Make sure it is sufficient for the zener to behave as such. \$\endgroup\$ – Chris Stratton Dec 1 '15 at 16:54
  • 2
    \$\begingroup\$ There is a point that needs clarification. Are you powering the MCU from this 5V rail? Or is the 5V just going to a logic input pin on the MCU? If it is only going to a logic input, then the current will be much less than 1 mA. Also, is there a case where the 10-14.6V may be present when the MCU power is not present? This could create a problem for the MCU. In general, if you could tell us a little more about what you are doing and why, I think an easy solution can be proposed. \$\endgroup\$ – mkeith Dec 1 '15 at 18:08
  • 1
    \$\begingroup\$ A 78L05 would work with no extra components- just connect it directly to the input. If the signal could (ever, even momentarily) be present when the micro is not powered, add a resistor such as 10K in series. There is no reason to use an LDO and it would be counterproductive since an LDO typically requires an output capacitor for stability and that would slow the response. \$\endgroup\$ – Spehro Pefhany Dec 1 '15 at 18:42
3
\$\begingroup\$

I think the best thing would be to use NMOS with gate connected to 14V. The drain would be connected to 3.3V (the same one powering the IO for your microproceessor), and the source to your IO pin.

schematic

simulate this circuit – Schematic created using CircuitLab

With the Zener circuit, if the 14V is present when your micro power is not present, current will flow into the microprocessor by way of the clamp diode internal to your microprocessor IO pin. Even if the current is limited, this could cause a partial or complete power-on of your microprocessor. Best to avoid this situation.

This circuit will only turn on when VIN_14V is well above 3.3V. But when it is on, all it does is connect the 3.3V VCC to the IO pin. So if 3.3V is not present, then there is no harm, and no current will flow into the IO pin.

You might want to add a series resistor on the gate to prevent ringing.

The 100k resistor (R1) is just to make sure the node does not float high after 14V goes away. 1M may be enough if you want to reduce sleep current.

Note: I am assuming that there is enough load on VIN_14V that it will quickly decay to below VCC_3.3V. But if not, you might want to add a resistor from VIN_14V to GND to provide a path for decay.

\$\endgroup\$
  • \$\begingroup\$ Very neat! Can I assume that the BSS138 FET is the one you can recommend for this circuit? Actually, will almost any MOSFET with induced channel work? Do I understand correctly that the MOSFET can be of any polarity (n-p-n or p-n-p)? I might have to select another device because the choice in the local shop is limited. \$\endgroup\$ – Violet Giraffe Dec 1 '15 at 20:30
  • 1
    \$\begingroup\$ I believe the BSS138 will work. Probably the limiting factor is going to be the gate/source breakdown voltage. A lot of smaller FET's have a 12 or even 8V limit on Vgs. The BSS138 is a very old FET that has been in production since before I was an engineer. Back when voltages were higher, and CMOS logic operated at 10V. \$\endgroup\$ – mkeith Dec 1 '15 at 20:36
  • \$\begingroup\$ Note that in MOSFET's polarity is designated using the terms "N-channel" and "P-channel." N-channel is analogous to NPN and P-channel is analogous to PNP. You want N-channel (sometimes also called NMOS). \$\endgroup\$ – mkeith Dec 1 '15 at 20:39
  • \$\begingroup\$ Right, I forgot the terminology, thanks for the correction. Why does the polarity matter in this application? \$\endgroup\$ – Violet Giraffe Dec 1 '15 at 20:44
  • \$\begingroup\$ PMOS turns on when gate voltage is lower than source. You need a transistor that turns on when the gate is higher than the source. One kind of brute force way to look at it is this: If the gate of a PMOS is connected to the highest voltage present on the board it will never turn on. \$\endgroup\$ – mkeith Dec 1 '15 at 20:49
4
\$\begingroup\$

I would personally use an 5V LDO regulator but as OP requested it is possible using a Zener diode, in my example I used a 1N751 5.1V Zener diode. As @mkeith said you will need to limit the current.

Max current is calculated as Power Dissipation/Voltage, in our case it is 500mW max/5V giving the maximum current as 100mA although the datasheet also states that the maximum current is 70mA so we will stick to that.

Rs = (Vs - Vz)/Il = (14.6v - 5.1v)/70mA = 135 Ohms E12 series makes that 150 Ohms

Assuming a 1K load Il = Vz/Rl = 5.1v/1k = 5.1mA

Max zener current Iz = Is - Il = 70mA - 5.1mA = 64.9mA

Circuit

R1 is Rs R2 is the Load

\$\endgroup\$
  • 3
    \$\begingroup\$ An MCU input pin will probably have a much higher than kiloohm DC impedance. The only time you will see substantial load should be at switching when charging the capacitance. You probably want a far, far larger source resistor. \$\endgroup\$ – Chris Stratton Dec 1 '15 at 18:48
  • \$\begingroup\$ even so a 1M RL will give a load of 5.1uA therefore still not risking breaching the max current of 70mA \$\endgroup\$ – ed-wright Dec 1 '15 at 18:54
  • 1
    \$\begingroup\$ The maximum is not the concern, but your quiescent current is several times what it needs to be. \$\endgroup\$ – Chris Stratton Dec 1 '15 at 21:33
3
\$\begingroup\$

Because you describe the MCU input as "5 volt tolerant", this suggests that the MCU is operating at a lower power supply voltage, probably 3.3 volts. In that case,

schematic

simulate this circuit – Schematic created using CircuitLab will work. When the source is 10 volts, the GPIO pin will be 3.3, and for larger voltages the diode will clamp the pin to no more than 4 volts, with a current drain of less than 1 mA. This assumes, of course, that your low source voltage is low enough to be reliably detected as a zero after being divided by 3.

\$\endgroup\$
  • \$\begingroup\$ Thank you. Yes, the MCU is 3.3V. 1N4148 is not a Zener diode, though, is it? Can you please explain how this circuit works? I'm terrible at electronics, actually, and all I can see is a 1:3 voltage divider and a mysterious plain diode. Also, I may not have access to the MCU's 3.3V supply, only to the 5V which powers the MCU's local 3.3V regulator. \$\endgroup\$ – Violet Giraffe Dec 1 '15 at 19:07
  • \$\begingroup\$ P. S. What software do you use for drawing the schematics, if I may ask? \$\endgroup\$ – Violet Giraffe Dec 1 '15 at 19:09
  • 2
    \$\begingroup\$ @VioletGiraffe The program is called CircuitLab, which is included as part of this site. To access it, while composing an answer or editing one, you can click on the little icon with the diode at the top -- a little hard to see, it's the furthest right in the group of five icons with the {} as the middle one. It's also available as a standalone product. \$\endgroup\$ – tcrosley Dec 1 '15 at 19:23
  • \$\begingroup\$ This is pretty good. Maybe use a Schottky, though, to make sure internal protection diodes do not conduct. Also, it does still dump a small amount of current into the 3.3V rail, which is not really desirable. \$\endgroup\$ – mkeith Dec 1 '15 at 20:30
  • 1
    \$\begingroup\$ @VioletGiraffe - It acts as a divide by 3 until the divided voltage is about 0.6 volts over 3.3. Then the diode turns on, and clamps the output at ~3.9 to 4.0. In effect, the source provides a little current to power the MCU, while the power supply doesn't have to work quite as hard. I specified 20k specifically to keep the current down. \$\endgroup\$ – WhatRoughBeast Dec 1 '15 at 20:40
2
\$\begingroup\$

Opto-isolator! This has the optional advantage of completely isolating your noisy signal from your micro and the transistor output can turn hard on and hard off.

If you ever over-voltage it you only lose the opto-isolator.

schematic

simulate this circuit – Schematic created using CircuitLab

Bear in mind that with this circuit the input pin will pull low when the LED turns on. If that's a problem then put the transistor on the high side and R2 pulling low to ground.

\$\endgroup\$
  • \$\begingroup\$ I'd thought of this, but how do you deal with the fact that the LED has a pretty narrow range of acceptable input current? \$\endgroup\$ – Violet Giraffe Dec 1 '15 at 21:03
  • \$\begingroup\$ @VioletGiraffe -- consider something like a current regulator diode or a depletion N-fet constant current source \$\endgroup\$ – ThreePhaseEel Dec 1 '15 at 23:37
  • 1
    \$\begingroup\$ @VioletGiraffe: You should be able to get one that will work over at least a 2:1 ratio and choose an R1 value that will give it 5 to 10 mA. Browse the data sheets. \$\endgroup\$ – Transistor Dec 1 '15 at 23:43
0
\$\begingroup\$

As long as you obey the datasheet of zener, this would be possible. But you should consider the mcu's high level and low level voltages. For example some 5v mcus accept voltages over 3.8v as high and below 0.8v as low. Between these are fuzzy zones. Which mcu can act unstable. Maybe you can add an additional logic-level-gate n-channel fet and use a lower voltage zener according to Vgs. Feed resistor-zener output to gate and connect drain to mcu with a pullup resistor.

\$\endgroup\$
0
\$\begingroup\$

Why not just use a voltage divider? If you're expecting a value between 10V and 14.6V but want to scale this down, add a 10K resistor and a 4.7K resistor in series.

14.6V+   ---- [10K] --- [4.7K] --- GND
                     |
                    MCU

The noise issues can be dealt with by placing a capacitor across the 4K7 resistor.A zener can also be connected across the 4K7 resistor to protect the MCU input from overvoltages.

\$\endgroup\$
  • 1
    \$\begingroup\$ I would definitely go that way if the input was more stable, but as it is, I'm concerned with the divider's output not fitting the MCU's logical '1' zone. \$\endgroup\$ – Violet Giraffe Dec 1 '15 at 19:03
  • \$\begingroup\$ It will. An MCU's logical 1 zone is anything that isn't a zero value. If you leave the input floating, noise will interfere and you'll get a bunch of random 1's and 0's. The resistor network pulls it down to ground so that it stays 0 unless a signal comes through. \$\endgroup\$ – Aydin Dec 1 '15 at 20:33
  • 1
    \$\begingroup\$ It's true for any logical circuitry, from ancient TTL to modern CMOS! I'm genuinely surprised someone wouldn't know it. \$\endgroup\$ – Violet Giraffe Dec 1 '15 at 20:56
  • 1
    \$\begingroup\$ From my STM32 MCU's datasheet: Low level input voltage, MAX: 0.475 VDD - 0.2; High level input voltage, MIN: 0.5 VDD + 0.2. Anything in between is undefined. Logical circuitry couldn't operate reliable if it wasn't for this gap. How do you imagine interference being picked by trace leads, turning 0V into non-0, and thus - logical 0 to logical 1? \$\endgroup\$ – Violet Giraffe Dec 1 '15 at 20:57
  • 1
    \$\begingroup\$ @AydinAdn anything that's not zero is a 1? What about 0.00000000000000000000001 volts caused by induction from the user's neural impulses? \$\endgroup\$ – user253751 Dec 1 '15 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.