0
\$\begingroup\$

I need to sense a logic low on the GPIO. The input will come from external resources (By end user) so I need to protect the circuit as well from high positive voltage. Generally the circuit will be used in places where I don't expect a voltage of more than 30 Volt. So from external input, it can be a ground (If user does it correct) or a max of 30 volt, in case user does a wrong wiring. Is this circuit going to be good enough?

schematic

simulate this circuit – Schematic created using CircuitLab

Please suggest if there is any mistake and if this can be simplified.

\$\endgroup\$
  • \$\begingroup\$ I don't see how your circuit can possibly work. Can you explain how it is supposed to work? What does V1 0V supply represent? \$\endgroup\$ – Vince Patron Sep 5 '17 at 16:09
  • \$\begingroup\$ Where is the "user input" in this diagram? \$\endgroup\$ – Ale..chenski Sep 5 '17 at 16:12
  • \$\begingroup\$ In your scenario, is a grounded input equivalent to an unconnected floating input? \$\endgroup\$ – brhans Sep 5 '17 at 17:29
  • \$\begingroup\$ V1 is the user input.. It can be anything between Ground or 0 to 30 V. I need to detect when it is grounded. I have updated the schematic, removed V1 and marked it as user input. \$\endgroup\$ – Rakesh Mehta Sep 5 '17 at 18:48
1
\$\begingroup\$

Why can't you just clamp the input and put a high resistance to keep the input current low, like this simple circuit?

schematic

simulate this circuit – Schematic created using CircuitLab

With 30V input, the resistor sees about 25V across it. 25V / 10k = 2.5 mA. Pretty small. Power dissipated would be 25^2 / 10k = 0.0625 Watts, quite small.

The GPIO input of most MCUs are CMOS so current is ideally 0. Realistically most datasheets will spec maybe 100 nA, so 10k would be low enough to certainly detect the logic state at the input.

The zener would also protect from user accidentally injecting negative voltage as well as ESD strikes.

\$\endgroup\$
  • \$\begingroup\$ I want to sense ground and not a positive volt on the input. Just need to protect the input so that even user apply +V instead of ground my GPIO is safe... So the intention is to detect when user is applying ground to the input.. A floating input means I'll detect LOGIC HIGH on the GPIO \$\endgroup\$ – Rakesh Mehta Sep 5 '17 at 18:52
  • \$\begingroup\$ Then add a weak pullup to this circuit. The point is that you don't need all that complexity in your circuit. \$\endgroup\$ – Vince Patron Sep 5 '17 at 18:55
  • \$\begingroup\$ When 30V applied, what will be the zener current? Also are zener diodes quite dependable? I have heard many times that practically it does not work exactly as per it's breakdown voltage. Just looking for suggestion.. \$\endgroup\$ – Rakesh Mehta Sep 5 '17 at 19:00
  • \$\begingroup\$ Sorry, discard my last message.. I looked incorrectly.. I treated left as input and right as output. :) So sorry... In floating input condition, if my GPIO is internally pulled up, it will detect logic high, right? \$\endgroup\$ – Rakesh Mehta Sep 5 '17 at 19:11
  • \$\begingroup\$ Yes, CMOS inputs float. Some MCUs have a setting for "weak pullup", in which case, an open input will pull up and indicate high. Make sure you understand external circuit driving this. If you use weak pull and there is a long wire connecting input, it could pick up AC line voltage and give you 50 Hz or 60 Hz signal. You might need to do some SW filtering or apply external stronger pullups. Zener diodes are absolutely reliable. The problems are almost always from engineers who don't understand them. \$\endgroup\$ – Vince Patron Sep 5 '17 at 19:15
1
\$\begingroup\$

The answer is to use a simple diode.

schematic

simulate this circuit – Schematic created using CircuitLab

Yes, it's that simple. If your input is grounded, the GPIO will detect a logic zero. If it is above ~1V, it will detect a logic high. The voltage you can apply externally depends on the reverse breakdown voltage of the diode.

\$\endgroup\$
  • \$\begingroup\$ Its difficult and quite costly to have a diode with reverse breakdown of 30V \$\endgroup\$ – Rakesh Mehta Sep 5 '17 at 19:04
  • \$\begingroup\$ Sorry, I am wrong there.. 40V reverse breakdown diodes are cheap indeed. Looking at the data sheets.. I am such a dumb :) \$\endgroup\$ – Rakesh Mehta Sep 5 '17 at 19:06
  • \$\begingroup\$ Just a question, when I am applying ground to the input, will it not be 0.7V at the GPIO? \$\endgroup\$ – Rakesh Mehta Sep 5 '17 at 19:09
  • \$\begingroup\$ Yeah, but as a rule of thumb the µC will detect anything less than half of Vdd as low. \$\endgroup\$ – Janka Sep 5 '17 at 21:04

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.