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:
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:
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:
- 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.
- 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.
- 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)
- 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.