Protecting a GPIO pin on OneWire bus? - Page 1
Forum section: electronics / projects

author: jwhitmore
author_rank: Regular Contributor
timestamp: October 06, 2017, 09:26:59 am
content: There's another thread on protecting an LM317 from voltage spikes, but because the 3v3 GPIO pin I'm trying to protect is on a OneWire Bus I'm concerned that any attempt to protect the pin will have a detrimental effect on communications. I'm working on a DS2502  using the circuit in Figure 8(a)  to switch between the normal comms voltage level (3v3) and the programming pulse voltage (12v).I did have a previous thread on here about the circuit, as I was blowing the FETs when soldering them. Turned out the tip of my soldering iron wasn't earthed. I can't find that thread now but it was during that discussion that somebody pointed out that the FET circuit would produce voltage spikes and I should protect the uC's GPIO pin with a Zenner diode.So I've been testing things out on a bread board and using a 3v3 Zenner diode, which has reduced the voltage spike caused in switching to the 12v programming spike, but whilst reduced there is still a noticeable spike. I'll attach two traces from the scope.So now that the Zenner has reduced the spike, but not totally eliminated it, I jumped to the idea of putting a bypass capacitor from the GPIO pin to ground, to further reduce the spike. My problem with this is that I could test it out on the bread board, find a Cap that suitably reduces the spike but would that have a detrimental effect on the fairly strict timings of the OneWire Protocol? I'm sure the ultimate, belt and braces, protection would be opto-isolation, but that would be one direction and the pin is Open Drain R/W.Being an embedded SW engineer I know the basics of electronic components but it's the detailed stuff that I'm sure I'll miss. An RC circuit has a raise/discharge time but I can't see anything in the datasheet  which suggests a limit. I've had a look around and found information  but I'm afraid I got lost in that. Is there a simple rule of thumb when selecting a value for bypass cap on a, possibly high frequency, signal line?Thanks for any advicehttps://datasheets.maximintegrated.com/en/ds/DS2502.pdfhttps://www.micron.com/~/media/documents/products/technical-note/tn0006.pdf

author: Ian.M
author_rank: Super Contributor
timestamp: October 06, 2017, 10:32:42 am
content: Your previous topic:https://www.eevblog.com/forum/beginners/simple-fet-circuit-for-onewire-protocol-doesn%27t-work-as-expected/. Next time look in 'Show posts...' in your 'Profile Info' for topics you have created.I didn't suggest a Zener clamp because Zeners typically have too much junction capacitance for clamping fast signals - e.g a BZ79C3V3 has about 200pF. You'll have to do the maths to see if 200pF is tolerable.The datasheet (1) you linked indicates that the maximum permissible capacitance on the 1-wire bus for the DS2502 is 800pF. Too great a capacitance would result in invalid logic levels at the data bit read sampling point.Without a current schematic with the points you are probing above indicated, your scope traces are worthless to us - we can see there is a difference, but not if its significant.

author: David Hess
author_rank: Super Contributor
timestamp: October 06, 2017, 07:24:19 pm
content: Like all open collector/drain buses, the 1-Wire bus relies on a pull-up current either from a resistor or current source. Usually a resistor is used and this combined with the shunt capacitance produces the typical exponential RC charging curve with a limited slew rate. A current source provides slightly better performance with a constant slew rate. (1) Logic inputs usually have minimum slew rate requirements and this limits the amount of capacitance.The capacitance of a zener diode can be isolated by placing a reversed diode in series with it and driving a current through the zener diode to keep it charged. A bipolar transistor with its base held 1 Vbe below the clamping voltage also makes a good low voltage clamp. The zener diode could be combined with the bipolar transistor to provide a higher current low capacitance shunt.Why not use the configuration shown in figure 8-B? It only requires 1 extra I/O pin to control the 12 volt source.(1) I have designed a couple of discrete RS-232 drivers that worked like this. The current combined with the output capacitance including the cable capacitance determines the slew rate and near ideal performance with a minimum of EMI and overshoot is attainable. Some oscilloscope calibrators work this way also. I might do something like this for a no expense spared 1-wire implementation.

author: wraper
author_rank: Unknown
timestamp: October 06, 2017, 07:52:03 pm
content: Quote from: Ian.M on October 06, 2017, 10:32:42 amWhy bother with zener diodes when there are a lot of specialized ESD protection devices / TVS diodes / ESD varistors? Not only many of them provide much lower capacitance but also provide much better protection.

author: Siwastaja
author_rank: Super Contributor
timestamp: October 07, 2017, 09:13:11 am
content: With onewire, the speed is typically very slow. In this case, the edges can and should be slowed down too, by the same ratio. Hence, high-speed digital rules of thumb of capacitance do not apply - even a few hundred pF is most likely not only just fine, but actually preferred. Use some series R termination to form a properly damped RC filter. The RC also decreases coupled noise.A 47 ohm series resistor and a zener might provide both edge rate control RC filter, and clamping all in minimal BOM.I sometimes add 1nF ceramic caps right next to low-speed (meaning some kHz) digital input pins and they have fixed many EMI issues in difficult environments - where, quite frankly, a proper differential signaling such as RS422 would have really been the right thing to do, but didn't fit the budget and/or footprint.Onewire uses a pullup, so do the calculation of the RC time constant to verify that the capacitance you add is indeed ok. You can also verify with a 'scope.

author: jwhitmore
author_rank: Regular Contributor
timestamp: October 08, 2017, 06:30:24 pm
content: Thank you for pointing out "My Posts" link, I saw the "My Messages" link at the top of my profile but could not see past that upper menu.On the TVS diodes I'm not too familiar with them and have never found any for low voltage protection like 3v3. Now I'm probably wrong but from what I've seen they're specifically for High Voltage ESD protection. Like I say I'm probably wrong, still learning.Thanks for pointing out the 800pF limit from that datasheet I'd not spotted that limit. I'll play around with the breadboard.Lastly using the RS422 driver hadn't occurred to me. You're probably right that it would have been an easier option but doing it wrong might mean I learn a bit more. But learning is like throwing "stuff" at a wall and only some of it'll stick to the wall. Thank you all for your advice and help.

author: jmarkwolf
author_rank: Regular Contributor
timestamp: October 09, 2017, 11:36:47 am
content: I've seen the Maxim DS9502P part recommended for protecting the 1-wire bus without affecting communication.

author: jwhitmore
author_rank: Regular Contributor
timestamp: October 11, 2017, 11:27:45 am
content: That Maxim DS9502P looks great but it seems to be for 5V logic, the uC I'm using is only a 3v3 so I'm not sure it'll work. I'll have a look at the datasheet and see. Thanks for the suggestion.