0
\$\begingroup\$

I'm trying to find a good solution for protecting the GPIO pin of an ATmega32u4 in short circuit conditions. Normally I would just use a simple resistor but that isn't the best option for this use case.

What the circuit should do is generate a Wiegand signal for which one data line looks like this:

Wiegand signal

That is: the signal line is normally at 5V, but when sending a data bit the signal is pulled to ground for somewhere between 30-200μs after which the signal should be high again for at least 1ms. So not really a high speed signal.

The electronic circuit I currently have looks like this: enter image description here

The ATmega chip produces either 5 or 0 volts at the output of a GPIO pin, which is now current limited by R1. Then it goes into the harsh outside world with a cable of up to 100 meters in length. After which it enters an unknown circuit which should read the wiegand signal. Since wiegand isn't defined very well I'm seeing all kinds of different reading circuits. The most difficult one I encountered was a chip with a pullup resistor R3 = 495 ohm, R2 > 500 kohm and Vpullup = 3.23V. Since I'm using R1 = 270 ohm, this resulted in these values when trying to send the signal:

Signal High: 5 - (5-3.23)*270/(270+495) = 4.37V

Signal Low: 3.23*270/(270+495) = 1.14V

Of which the signal low was too high to trigger a low on the input side.

To get the best signal it would be great if I could remove R1, effectively setting R1 = 0 ohm in this circuit (+ the GPIO output resistance). However this would lead to a too large current draw from the GPIO pin under short circuit conditions, which are likely to happen due to wiring with screw plugs.

From the ATmega datasheet, the absolute maximum sink/source current on a GPIO pin is 40mA, let's say 35mA to be on the safe side. Furthermore from the "I/O pin Output Voltage vs Source Current at 5V" graph from the datasheet we can find that the GPIO output resistance is about 40 ohm. So I'm considering these options to limit the current:

  1. Keep using a simple resistor with the lowest possible value. I.e. 5V / 0.035A - 40 ohm = 103 ohm -> 110 ohm. This will get the low signal in the example circuit to 3.23*150/(150+495) = 0.75V. Still a bit too high for my liking.
  2. Use the smallest PPTC resettable fuse I can find: the Littelfuse zeptoSMDC0015F. With an initial resistance between 10 and 60 ohm and a hold current of 15mA. Although time to trip might be large and resistance increases if it's getting hot which might happen in a server room.
  3. Use a push pull digital isolator with short circuit protection like the MAX14930AASE+, which has ESD protection built in as added bonus but does cost much more than a resistor (€2,51 for 1)
  4. Use a bidirectional current sense amplifier like the INA2181A1IDGSR. With the added benefit that I can inform the user that the output is in a short circuit state, but with the downside that I need to continuously monitor the output of the ic at an analog input of the ATmega chip.

What do you think is the best option? Are there other options I missed? Or shouldn't I worry about short circuit conditions and just use a small resistor (e.g. 47 ohm) as said here?

--EDIT--

Based on your suggestions I'll probably be using a circuit like the one below. This also allows the B GPIO pin to be used as input such that the circuit can both be used for input and output wiegand signals.

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ A separate line driver chip is a good possibility. You can find one with current limit / short-circuit protection, and a speed that is appropriate for your application. Also look into ESD/transient protection and termination (on both ends). On the receiving end, AC termination may be an attractive option for the unidirectional case. \$\endgroup\$ – Pete W Feb 11 at 21:17
  • \$\begingroup\$ Are Wiegand interfaces 5V these days? The last time I saw them used, they were using 12V. Do you have to be compatible with the 12V interface? The MCU pin can't handle that directly. \$\endgroup\$ – Justme Feb 11 at 21:21
  • \$\begingroup\$ @Justme The 12V line is only to power the devices, 5V is the data line \$\endgroup\$ – Wout_bb Feb 11 at 21:34
1
\$\begingroup\$

Why don't you drive it from some power line able to support higher current. For example, from Vcc=5V directly via P-ch MOSFET, that you will open and close using GPIO. I suggest some 10k-100k (you can do some math and experiment, but any should work probably) pulldown on that line to make sure the line is at 0 when the MOSFET is not conducting (pulldown on drain side on my picture; load on my picture = your line's output). If you find MOSFET quick enough, and there is plenty of fast MOSFETs, you'll be fine. After all, your intervals aren't all that quick, I'd bet almost any logic level MOSFET that works with 5V would fit. Provided it's rated for the maximum current you expect, not that it's big anyway.

CORRECTION

Since the receiving end has built-in pullup resistor, the transistor's role would be to pull the line down at the right time. For that purpose you use N-channel or BJT instead. A quick google search revealed that BJT are faster switches than MOSFETs, but these days they're all quick, and certainly quick enough for your application, so it's up to you (but don't forget to look at the datasheet). This correction is sponsored by @Justme.

enter image description here

\$\endgroup\$
5
  • \$\begingroup\$ Ah nice idea! Although it's probably better to have a pullup resistor on the drain side, and GND on the source side to combat the pullup voltage from the receiver end. \$\endgroup\$ – Wout_bb Feb 11 at 21:50
  • \$\begingroup\$ It won't work that way. The MOSFET always conducts in another direction due to body diode (also present in the picture) \$\endgroup\$ – Ilya Feb 11 at 21:57
  • \$\begingroup\$ and the @Justme just proposed the same solution just with replacing MOSFET with BJT, the core idea is the same) \$\endgroup\$ – Ilya Feb 11 at 21:58
  • \$\begingroup\$ @Ilya I did not specifically say BJT, I simply said transistor. A NPN BJT or N-channel FET will do. The P-channel solution will not work as mentioned by OP, as Wiegand interface is pulled up by resistor and pulled down by a transistor. \$\endgroup\$ – Justme Feb 11 at 22:19
  • \$\begingroup\$ ok I looked at the original schematic again, you're right, there's a pullup on the receiving end, so the transistor should pull down. Then yes, an N-Channel or BJT, agree. \$\endgroup\$ – Ilya Feb 11 at 22:25
1
\$\begingroup\$

None of the above solutions you mentioned. Simply a transistor to pull the tens or hundreds of milliamperes low to ground, it can still be limited by series resistance but much lower in value than you must use with the MCU.

\$\endgroup\$
1
  • \$\begingroup\$ Ah yes, that might also be a good solution. Thanks! \$\endgroup\$ – Wout_bb Feb 11 at 21:51
1
\$\begingroup\$

You can do something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

(part numbers conceptual, not necessarily optimal).

The second circuit is rather more bulletproof, capable of handling large transients with current limited to a couple hundred mA, but more costly.

\$\endgroup\$

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.