Zener diode clamp not working for fast spikes? - Page 1
Forum section: electronics / beginners

author: icecats
author_rank: Contributor
timestamp: March 23, 2024, 02:37:02 pm
content: Hi!I am working on a project for a farmer friend to measure the voltage of his electric fence for a monitoring device. My plan is to use a voltage divider to drop the electric fence pulses to a safe level to read with an STM32 ADC. Electric fence pulses are generally 5-10 kV, 1 Hz or less, and duration < 500 μs.My voltage divider has R1 = 20 MΩ and R2 = 2 kΩ to form a division ratio of 10,000; theR1 resistorsare rated for high voltage.Currently I am connecting the voltage divider directly to a fence energizer with some high voltage capacitors to simulate a real fence.After scoping the output of the voltage divider, I noticed that the pulse exceeded 3.3v which is the upper limit of what I want to put into the analog pin configured with the ADC. Therefore, I added a3.3v Zener diodeand 100 ohm resistor to clamp the spikes.The Zener successfully limits the pulseexceptfor a series of high speed spikes which it does not seem to affect. I zoomed in on these and they appear to be about 100-500 ns long. I couldn't find anything in the datasheet or online about high speed limitations of Zener diodes.Any thoughts?

author: Ian.M
author_rank: Super Contributor
timestamp: March 23, 2024, 02:54:44 pm
content: Lets see a photo of your PCB and probing setup. I'd bet you have unwanted inductive coupling, possibly via the probe ground lead.

author: bdunham7
author_rank: Super Contributor
timestamp: March 23, 2024, 03:14:38 pm
content: That's interesting that the spikes all show up at the zero crossing point. It may be an issue with the probing or wiring setup, but also consider the soft 'knee' and high dynamic resistance of a small 3.3V zener. The zener does appear to be limiting those spikes, just not to 3.3V which indicates the peak current may be too high (over 10mA or so). I would try increasing R3 to see if the spikes recede. I think you'll still get an adequate signal with R3 = 1k.

author: icecats
author_rank: Contributor
timestamp: March 23, 2024, 03:31:52 pm
content: Quote from: Ian.M on March 23, 2024, 02:54:44 pmHere is a photo of the setup.Quote from: bdunham7 on March 23, 2024, 03:14:38 pmI tried a 680 Ω and then a 6.8 kΩ resistor and could not see any difference in the signals.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: March 23, 2024, 03:57:59 pm
content: I suspect you are seeing a real speed limitation on the zener. I would try something simple, making your voltage divider a low pass filter by adding a few pF capacitance across R2. I believe you could put up to 50 pF without materially affecting the desired pulse, but as always results rule.

author: Ian.M
author_rank: Super Contributor
timestamp: March 23, 2024, 04:09:52 pm
content: Lots of loop area, coiled croc clip leads and a solderless breadboard! I'd bet most of the spikes are due to near-field EMI picked up by the probe ground lead, which has too much self-inductance.Low voltage (true) Zeners should be plenty fast, with the main limitation being junction capacitance that in a shunt clamping configuration would attenuate short spikes, not enhance them. Avalanche breakdown may be a bit slower but the die dimensions are nowhere near large enough (by several orders of magnitude) to account for the observed spike widthAssuming your probe came with a BNC adapter, solder the Zener direct to the back of a chassis mount BNC socket, keeping its leads as short as possible. Solder one end of the 2K resistor to the ground of the BNC socket, and whatever resistor you choose between the other end of the 2K resistor and the Zener cathode, again keeping leads as short as possible, and try to minimise the loop area between the Zener and the resistors. Solder the HV resistors, but the lead length shouldn't be critical for them so you can keep them long enough to reuse. Twist the white ground croc-clip lead and the red HV croc-clip lead lightly together to minimise the loop area and keep the ground lead really close to the resistors on the way to clipping it onto the BNC socket, with no significant loops. You may need to sleeve the HV resistors so they cant flash over to the ground lead.If you don't have a BNC adapter for your probe, remove the probe's hook tip and wind a couple of turns of tinned solid copper wire round something a bit smaller than the probe's ground ring to form a spring to grip the ground. Solder it with very short legs at the edge of a piece of copper clad PCB, and build the circuit on the PCB, Manhattan style. The connection to the probe tip should be by a DuPont female contact or similar with only just enough lead length to get up to the probe axis.Lastly, keep the fence energiser and its battery well away from the scope!

author: bdunham7
author_rank: Super Contributor
timestamp: March 23, 2024, 05:40:22 pm
content: Quote from: Ian.M on March 23, 2024, 04:09:52 pmI don't have any 3.3V zeners to test, but I'm pretty sure you're right that the junction capacitance and lead inductance dominate any HF response. IOW, the zener action itself is faster than the parasitics unless you are very careful. Of course zener capacitance is highly variable, but in this case as he's increased R3 with no effect and you would expect there to be some change.I do wonder though if it isn't just a common mode issue. The battery powered scope may not have a CMRR as high as one would hope and this whole circuit is just floating on the bench. I'm still intrigued by the spikes arising at the zero crossings, but perhaps all of that is generated within the fencing unit.

author: Berni
author_rank: Super Contributor
timestamp: March 23, 2024, 05:56:54 pm
content: Yep what you are seeing is perfectly normal when you are working on fast high voltage transients with wires just strung around all over the place.Because of all the stray inductance around the circuit things are actually most likely ringing that much, the voltage across the zenner is probably being clamped just fine, but what your oscilloscope measures is at the BNC connector. Between the BNC connector and your diode there is a probe, that probe has a sizable loop formed by the black ground clip, so you are measuring the voltage inside that loop as well. This is the reason why the gate drive wires for large power MOSFETs/IGBTs are twisted together, the loop area of a untwisted wire in such a noisy high power electronics environment alone could pick up enough voltage to not only make the transistor mishebave, but it could pick up so much voltage that it kills the gate.To be fair this is a pretty difficult measurement to make when you are looking at small voltages in a noisy environment like that. First thing to do would be to use the tiny spring ground to reduce loop area, if there is still noise, then perhaps help reduce the common mode noise some by connecting the ground of your circuit to a metal ground plane under the setup.

author: icecats
author_rank: Contributor
timestamp: March 23, 2024, 06:20:26 pm
content: Quote from: Berni on March 23, 2024, 05:56:54 pmI'm planning to try what members Ian.M and Berni are suggesting but I do worry about managing these spikes when this is implemented in real life on a real fence. Would you expect these spikes todamage the STM32? I could easily filter them out in code if they don't pose a threat to the micro.Quote from: CatalinaWOW on March 23, 2024, 03:57:59 pmThanks for the suggestion. I tried making the filter with various caps up to 50 pF across R2. This did not seem to have any effect on the spikes. I suspect that the issue is what the other commenters are mentioning.

author: Berni
author_rank: Super Contributor
timestamp: March 23, 2024, 08:15:56 pm
content: Well if your diode is going to be protecting your STM32 then the aim is to minimize the loop area of the connection between the STM32 and the zenner. That way the voltage on the MCUs pin most closely matches the voltage across the diode.Also series resistors make protection diodes much more effective. So always a good idea to have a series resistor between the clamping diode and outside world to protect the diode, and another resistor between the clamping diode and actual protected device to limit any fault currents that have managed to slip past the clamping diode (since the diode might clamp at a much higher voltage than 3.3V if you send a very large current trough it)Also with your kind of voltages, something to watch for is using resistors physically large enough so that they don't arc over. Also for electronics being in the vicinity of an electric fence, it is likely a good idea to put a metal shielding can around the PCB, both due to capacitive noise pickup, and to prevent arcing from the fence into any sensitive parts.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 23, 2024, 08:31:05 pm
content: I'm guessing the charger uses a resonant switching circuit, hence the noise burst near zero crossings.High frequency noise "doesn't like to stay in wires". What you're seeing is the voltage drop across the probe ground lead and other ground connections, which are just loose wires. It's common mode noise, not actually seen across the zener.Zeners are essentially instantaneous, at least ps scale response; the propagation of voltage and current along their body and lead length utterly dominates. Practically speaking, they're usable down to some ns, at which point the junction capacitance tends to dominate.3.3V zeners are a poor choice for clamping anyway, as the knee is very soft. A pair of clamp diodes, to 0/3.3V supply, is more effective for analog purposes.Tim

author: srb1954
author_rank: Super Contributor
timestamp: March 23, 2024, 08:40:32 pm
content: Quote from: icecats on March 23, 2024, 06:20:26 pmYou will need more than 50pF across R2 to compensate the voltage divider to see the correct waveform shape.This is like the need to compensate a x10 probe on your scope where a variable capacitor, usually in the compensation box attached to the scope, is adjusted to maintain an even response across all frequencies. Since you have the equivalent of a x10000 probe the capacitor across R2 needs to be 10000 times the stray capacitance across the two 10MΩ resistors, probably about 0.5pF - 1pF although this will depend on physical circuit layout. You will therefore need between 5nF and 10nF across R2 and this can be adjusted as you would for a scope probe by feeding a square wave into the divider and adjusting the compensation capacitance for the fastest rise time without overshoot.This compensation problem would not cause the spurious spikes you are seeing which, as other posters have pointed out, is most likely due to excessive inductance and coupling in the long leads of your circuit lash-up.

author: TimFox
author_rank: Super Contributor
timestamp: March 23, 2024, 09:00:56 pm
content: Adding to Berni's comments above:To protect the STM32, put the Zener diode directly at the input pins of the STM32.The series resistors ahead of the Zener exist in order to limit the current into the Zener during the transient, so you want the connections between the output of the resistors and the Zener to be as short as possible.Otherwise, the requirements for minimum loop area, non-dangling of wires in an uncontrolled fashion, etc. are relevant to the accuracy of the measurement, but the Zener and series resistor are to protect the STM32.

author: icecats
author_rank: Contributor
timestamp: March 23, 2024, 09:40:54 pm
content: Quote from: Ian.M on March 23, 2024, 04:09:52 pmHere is my rendition of this. R2, diode current limiting resistor, and the zener diode are as short as possible on the probe tip. I did not twist the + and - from the charger together because I am afraid they will arc. Plus, I think long dangly wires for this part of the circuit are realistic of a fence wire and charger grounding (right?).The new signal appears to be 1/2 the original one I captured (variability in the energizer or something with my new circuit construction?) and I am still seeing high voltage spikes.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: March 23, 2024, 09:52:13 pm
content: Quote from: icecats on March 23, 2024, 09:40:54 pmHalving the noise is a step in the right direction. Generic Zener diodes are usually not built for speed (I'm not sure datasheets even specify this) But TVS diodes are built for speed, (and are zener diode's otherwise (although bipolar TVS diodes are also common).

author: Ian.M
author_rank: Super Contributor
timestamp: March 23, 2024, 09:59:34 pm
content: The spikes seem to be smaller, so that may be progress. Twist the 12V supply leads to the fence energiser together to minimise their loop area.If you don't dare twist the high voltage lead with the ground lead, as you should be trying to minimise the loop area, get rid of the clip leads and try soldering the HV resistor direct to the energiser, with a cut to length ground lead next to the resistors and no more than a couple of centimetres away from them.Also, srb1954's suggestion is worth a try, so add a 4.7nF capacitor directly across the 2K resistor.

author: Manul
author_rank: Super Contributor
timestamp: March 23, 2024, 10:42:37 pm
content: Disconnect the positive lead entirely, what do you capture? It must be common mode noise going through the coax shield, totally expected result. It's not on the zenner. Such common mode noise is hard to avoid. You may try winding the mains cord of you energizer a few turns through the ferrite ring. Do same with scope power cord.Zenner is not the best choice. Better small, low capacitance schottky diodes. Or maybe even nothing at all. Realistically there is not much to clamp here. Top leg of divider is 20MOhms. So the only thing to clamp is parasitic capacitance of that resistor. 0.2pF? 0.5pF maximum? Charge and discharge of such small capacitance should not be a problem even for integrated ESD diodes of your STM32. The rise and fall times of that thing can't be stellar high, so the impedance of your divider even with parasitic capacitance included will be quite high. If the rise time is 1us, we are talking 2-4mA of peak current into the ESD diodes. Not much at all. Best is two small signal diodes to the rails if you want to stay extra protected.

author: jonpaul
author_rank: Super Contributor
timestamp: March 23, 2024, 11:04:30 pm
content: bad probng technique.See Tek Circuit concepts book "oscillope Probe circuits "https://w140.com/tekwiki/images/6/62/062-1146-00.pdf"probe measurements"https://w140.com/tekwiki/images/1/19/062-1120-00.pdfread and learn!Jon

author: icecats
author_rank: Contributor
timestamp: March 24, 2024, 12:23:19 am
content: Quote from: Ian.M on March 23, 2024, 09:59:34 pmI eliminated all of the looped alligator clips and sure enough the high voltage spikes disappeared. Thanks for the guidance!This is great progress and I'm pleased to have eliminated that issue. But... I suspect that I will face this issue again once I switch to a full fence which is by definition a really long dangly wire. From a processing point of view, the spikes are not a problem; they can be easily filtered in code. My only concern is if they will damage the microcontroller. Maybe it isn't something to worry about?Quote from: Manul on March 23, 2024, 10:42:37 pm

author: icecats
author_rank: Contributor
timestamp: March 24, 2024, 06:55:42 pm
content: I foundthis well-documentedelectric fence voltage monitor circuit. Theschematicshows that a voltage divider is used with what I think is a negative feedback and a positive feedback op-amp arrangement? I assume this is to pick up both positive and negative signals? I think the gain is 1 so do you think the purpose of the op-amps in this circuit is to buffer/protect the microcontroller ADC input?

author: antenna
author_rank: Frequent Contributor
timestamp: March 24, 2024, 07:05:47 pm
content: Sounds like a complicated solution to a simple problem imo. Why not use neons like most fence testers? Those things are about $5 US, delivered, so why build it?I used to use a blade of fresh green grass as a limiter. If it can 'get your attention' through a 1 foot long blade of fresh grass held between your fingers, its working. If you barely feel anything, start walking down the line listening for where the short is.

author: twospoons
author_rank: Frequent Contributor
timestamp: March 25, 2024, 04:27:49 am
content: Quote from: antenna on March 24, 2024, 07:05:47 pmBecause sometimes farmers want to know if a distant fence is powered without having to walk a mile to find out. Cows can tell when a fence goes dead.To the OP: I'd suggest using a longer string of HV resistors, preferably potted, and a solid TVS to clamp the input to the micro. Electric fencing is a lightning magnet. I've seen the inside of many a fence energiser completely obliterated by a lightening strike - as in components are nothing more than charred lumps and all the PCB copper has been evaporated and deposited on the inside of the casing. Its really quite impressive.Also any arcing on the fence will create a lot of HF noise that you might want to filter out.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 25, 2024, 04:58:31 am
content: Even more simply, I'd use an electric field probe and look for nearby AC. The detector frequency response doesn't need to be very specific at all, continuous and infrequent interference can be excluded statistically, and the signal of interest is more or less periodic.A suitable input circuit would be a capacitance plate near the fence (doesn't have to be touching it, you're picking up the EMI and bounce that the scope was reading directly), a half-wave voltage doubler circuit using small-signal schottky e.g. BAS70, and an RC filter to remove RF, obtaining a simple envelope of detected RF. A clamp diode (to VDD) should probably be added, and then it's safe to go right into the ADC input. A conversion every so often, clustered near where the next pulse is anticipated, would suffice, minimizing current consumption; solar panels can furnish idle power, and some means of transmitting the status to a central collection site would be needed (probably not wired, but RF transmitters may greatly increase power consumption).The general insight applied here is that, sense dividers don't need to be resistors, and often are worse when you do -- or at least harder to clean up. A capacitor divider works perfectly fine for AC, as long as the load resistance (here, the detector) is large enough not to mind (i.e., resistance sets the LF cutoff).Note that this doesn't need to be done very close by, at all; indeed we could opt for an RF receiver, perhaps tuned to a resonant frequency of the fence system -- this would have to be probed, but could provide some gain, and rejection of interference, in the process. Such an RF amp or chain might be built with BJTs, maybe a JFET at the front end; current draw of fractional mA is reasonable, I think, while getting a noise floor not far above atmospheric noise (and not requiring much of an antenna). It might even suffice to listen for blips on an AM radio, no custom hardware required. A directional loop might be able to provide specificity, in case there are multiple fence chargers around the property.Tim

author: antenna
author_rank: Frequent Contributor
timestamp: March 25, 2024, 05:34:52 am
content: Quote from: twospoons on March 25, 2024, 04:27:49 amGood point. I am from an area where farms are relatively small.What about using a neon bulb as the zener then? Come off the HV fencer lead with a HV resistor followed by a neon bulb to ground, then use a 1N4007 to sample the 60-90v spikes that appear across the neon to charge a low value smoothing capacitor. After that, another high Ω resistor feeds a zener which protects your digital circuitry. Could have several neons in parallel in case one fails.Edit: if the neon is fed by a voltage divider, you can set the threshold voltage.

author: Berni
author_rank: Super Contributor
timestamp: March 25, 2024, 06:45:31 am
content: Yep adding capacitors to the resistive divider would help improve the response for fast spikes, depends on how fast you actually need to be. I assume the goal is to actually measure how big the pulse is so that you can also detect the electric fence arcing over somewhere.For large overload input protection a MOV is a good choice as it triggers reasonably precisely, acts very fast and can absorb a very large amount of fault energy. So it could make for a good first defense wall of protection.For protecting the MCU input you do still want a protection diode, they are fast and precise even if they can't handle huge overloads. Also you don't want to use regular zenners for this. The low voltage ones have a very soft knee, so they will conduct early and mess up your linearity and conduct late when a large current is flowing, they also can't handle a lot of overload. You want to use a TVS diode for protection as those are specifically designed to be protection diodes (it is in the name Transient Voltage Suppressor) so they are designed to load down the signal as little as possible in normal mode then once they go into overload they clamp down as much as they can (some even latch and act sort of like a diac) while being designed to survive large brief peak overloads.

author: SeanB
author_rank: Super Contributor
timestamp: March 25, 2024, 10:52:36 am
content: Most fence energisers use a LED in the sense circuit, with a long path to the photodiode used to sample the power. The IR LED will provide a light pulse, and the photodiode can be used with an integrator, probably leaky, to provide an idea of the power level, as the fence energiser uses this to provide a rough power level, and also to detect touch as it damps the pulse energy down a lot.

author: twospoons
author_rank: Frequent Contributor
timestamp: March 25, 2024, 10:49:46 pm
content: First line of defense should be a lighting diverter on the fence itself. This consists of a choke between energiser and fence (just a big stretched out steel spring), a spark gap of about 20mm made from some fat bolts, and a number of earth rods.Second line of defense would be a GDT. I'd choose this over a MOV as MOV's degrade every time they get hit (and they can explode if hit too hard). Either GDT or MOV needs some impedance to work against, so your divider (be it resistive or capacitive or both) needs to be able to handle a substantial overvoltage - I'd rate it for at least 50kV in this case.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 25, 2024, 11:15:40 pm
content: Quote from: twospoons on March 25, 2024, 10:49:46 pmMOV degradation is a popular misconception; in fact, they do not wear below a threshold.But MOVs and GDTs are wildly overkill here. For direct electrical measurement, large-value resistors are the best protection and filtering (as RC filters). The resulting energy at the circuit level is trivially handled by clamp diodes. You may need to use high-voltage resistors to stand off direct or induced lightning surge, and an air spark gap would do just fine. The use of a spark gap implies a two-stage (or more) protection system, i.e. series resistor (expected to arc over or otherwise fail during lightning), spark gap, another series resistor (can't arc over before spark gap does), then clamp diode/TVS. And probably one more resistor to the MCU/acq/detector/etc. system.Or maybe you mean to protect the energizer, but considering its output is already many kV, I don't see what good a typical MOV or GDT would do there, that wouldn't immediately defeat its whole purpose. You'd need one of those MOV stacks from the power company, and the clamping voltage is still many times nominal operating voltage.Tim

author: twospoons
author_rank: Frequent Contributor
timestamp: March 26, 2024, 12:22:27 am
content: I personally wouldn't bother with the MOV or GDT either, just that MOVs were mentioned further up the thread. Diverter on the fence + HV divider + TVS or similar should be enough.I've also witnessed first hand some weird behavior around HV resistors and fence energisers - notably they are just fine when directly connected, but sometimes will blow their guts out when connected via a small arc gap to the resistor lead wire. Something about the arc must set up a resonance or something that creates an internal overvoltage in the resistor. Next thing your 25kV (expensive) resistor has a hole in the side even though the energiser only has a peak output of 8kV. I never did find an explanation, but the effect was quite repeatable with any kind of film resistor. Wirewound ones didn't appear to have the same issue.Also a note to the OP: don't underestimate how far a high voltage will track across a surface. I've seen 25kV travel 20cm across a sheet of mylar, instead of punching through. This is another reason to use a string of resistors - you can greatly increase the total creepage distance.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 26, 2024, 01:39:35 am
content: Not familiar with that effect myself, but not to say it can't happen. Sparks in air can have extremely short risetimes; sparking to the resistor lead basically sets up that lead as a crude transmission line element, resonance of which is some 1GHz, ballpark. That, and perhaps the resistor element and its ceramic body makes something of a waveguide structure, and combined with the extreme peak power (say 10kV in fractional ns), you could very well end up with the effect of microwaving a CD, except it's the thin metal film of the resistor.Put another way: the voltage along the resistor element does not distribute evenly and instantaneously, and the high-frequency voltage limit can be much lower than you would otherwise expect. This is why oscilloscope probes are rated as such, for example.You would want to use pulse-rated, wirewound, or perhaps thick-film, types for this. Or good old carbon compTim

author: Berni
author_rank: Super Contributor
timestamp: March 26, 2024, 06:31:15 am
content: The MOV shouldn't ever really see any activation in any sort of normal operation. It would just be there in the case of lightning or similar that could arc over the high value divider resistor. You can never know what to expect. Sure a direct lightning strike into the input would turn the MOV and all the rest of the electronics (and possibly enclosure) into plasma and charcoal. But most strikes would happen just near by and the long fence wire might pick up a huge voltage spike from that. Having an extra layer of protection rater for handling large energies would help you survive that. Hopefully the high voltage divider resistor survived the arc over and can continue working.If you want to also help protect the HV resistor you could add a spark gap directly to the input. This is quite common in telecom equipment where the PCB has exposed metal close together right at the input so that huge overloads would arc over in that spot and possibly save the protection circuitry down the line. But since your project is going to live outside you can't use a PCB pad as a free sparkgap since condensation is going to screw it up.It all depends on how robust you want to make it. It would work just fine even with 0 protection, just direct divider into MCU pin (there is some weak ESD protection inside the pin after all). And if you are lucky it might take years before it sees a transient big enough to blow up the MCU. But protection circuitry is so cheap that it is worth the time it saves you in having to fix blown electronics later.