Author Topic: Protecting ADC Input with Diode Clamp?  (Read 23630 times)

0 Members and 2 Guests are viewing this topic.

Offline timbTopic starter

  • Super Contributor
  • ***
  • Posts: 2536
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
Protecting ADC Input with Diode Clamp?
« on: November 29, 2013, 05:58:00 am »
Just wanted to run something by you guys real quick!

I got an Epic Re:load v2 (Variable DC Load) from Arachnid Labs awhile back and am just getting around to putting it together and into a case. I picked up a bunch of Tinkerkit LCD's for $10 in September during a Radio Shack clearance and thought one would make a perfect display for the Re:load. The neat thing about these LCDs is that they have a fully programmable ATmega32U onboard, which allows you to load up "Serial/I2C" firmware so you can use them as generic serial LCD backpacks with an MCU or you can use it as a standalone Arduino Leonardo (albeit with limited I/O). I'll be using it to display the voltage, current, power and temperature (DS18B20 glued to the FET + MCU sensor).

Anyway, the Re:load has an onboard OPAMP that outputs 0.1V per amp for current monitoring, so I'll be hooking that to one of the analog inputs. I also want to monitor the input voltage so I'm just going to use a simple voltage divider (0-30V to 0-5V). I want to protect the ADC from over voltage in case something shorts out or I turn the voltage divider potentiometer the wrong way, stuff like that.

So I was thinking about it and came up with the idea of hooking a Shottsky diode from the 5V rail to the output from the voltage divider. The theory being that once the output starts moving past the 5V rail's voltage the diode will start absorbing excess current and keep the output at 5V + Diode Drop. I did some research on Google and after looking at some app notes and datasheets it seems feasible.

I ran some simulations in iCircuit and it seems to work perfectly! The following images are 3.7V, 30V, 60V with the diode on and off.

So, will this work? I also imagine if I put another diode (in the opposite direction) from the rail to ground it should protect against negative voltages/reverse polarity as well, right?






Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 

Offline drtaylor

  • Regular Contributor
  • *
  • Posts: 120
  • Country: us
Re: Protecting ADC Input with Diode Clamp?
« Reply #1 on: November 29, 2013, 06:45:31 am »
With the impedances you show here, a schottky diode is a terrible choice due to very high leakage. A low leakage diode will be a better choice. It will still protect the ADC input as it will be lower Vf than the on board diodes in the ADC. Your simulation should include the leakage of the diode.
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: Protecting ADC Input with Diode Clamp?
« Reply #2 on: November 29, 2013, 06:46:45 am »
Yes, diodes as you've drawn them will work just fine for overvoltage protection.

Be aware that they will cause a slight reverse leakage current, this leakage current will create a voltage drop that affects the ADC accuracy. How much leakage you can tolerate depends on your application and your ADC resolution.

Schottky diodes are the  worst, with reverse leakage currents often > 1uA
regular PN junction diodes are better, and can be found with leakage currents in the 10's of nA
Zeners are worse than Schottkys for reverse leakage.

You can also use a diode connected BJT such as a 3904 for even lower reverse leakage current if you need it.

You also need to be careful dumping overvoltage into a supply rail, as this can easily lift your rail up and blow up chips on the supply rail.  For short lived overvoltage events it's (usually!) not a problem, but for longer lived over voltage events you need to protect against this.  You need to make sure your regulator can sink current, or the total load on the supply line is greater than the over-voltage current.  You can help by putting a 1k resistor in series with the output from the load's 0.1V/Amp signal, then the diodes, then another 100 ohm to the ADC




Furthermore (there's always something else) the diodes add capacitance and together with the 1k current limiting resistor form a low-pass filter.  Now you have rolled off your circuit's BW response, which may be OK in your case here today, but in the general case for ADC applications that need higher bandwidth it may not be OK and I just mention it to be complete.

There are protection diodes in sot-23 from Vishay, Maxim and others that offer low leakage and low capacitance for just this purpose.

One more thing I forgot to add... if your over-voltage event will be long lived and the VCC rail cannot take the current (i.e. your regulator cannot sink current) then you can also create a clamping rail with a shunt regulator on it to take the over-voltage instead of sending it into your Vcc rail.

« Last Edit: November 29, 2013, 06:51:47 am by codeboy2k »
 

Offline timbTopic starter

  • Super Contributor
  • ***
  • Posts: 2536
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
Re: Protecting ADC Input with Diode Clamp?
« Reply #3 on: November 29, 2013, 07:23:50 am »
Thanks, that's good information!

I should have made this clearer, but it's not the current to voltage output I'm worried about, this is for the second ADC input will be reading voltage directly from the eLoad's supply terminals. Like the examples above show, it will be going through a 5k/1k voltage divider (the 5k resistor will be a 10k pot for trimming) to convert the 0-30V input down to 0-5V. Since it's already going through a resistor, do I still need the 1k before the diode?

I was thinking I could deal with the voltage drop in software if I know the resistances on the way to the ADC and characteristics of the diode, right? It's a 12-bit ADC, but unless I multiplex the input over several voltage ranges, it's not going to be super accurate.

I mainly want it so I can monitor and characterize batteries and stuff, so I'd like tenth of a volt resolution, but if it's off by a few mV it's not a huge deal (battery discharge graphs are more about the curve, not the exact voltage).
Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 

Offline mjrandle

  • Contributor
  • Posts: 27
Re: Protecting ADC Input with Diode Clamp?
« Reply #4 on: November 29, 2013, 10:15:36 am »
I've used BAV199 double diodes to protect analogue inputs in the configuration suggested by codeboy2k, but with a higher vale downstream resistor sized to suit current limit of internal clamping diodes in analogue input (e.g. 1-2 mA).


Regards,

Mike
 

Offline timbTopic starter

  • Super Contributor
  • ***
  • Posts: 2536
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
Re: Protecting ADC Input with Diode Clamp?
« Reply #5 on: November 29, 2013, 11:11:17 am »
Thanks! I'll take a look at those. I just did some simulations on an NPN BJT with the base and collector (anode) connected to the eLoad and the emitter (cathode) hooked to the 5V rail, it seemed to work very well, so I think I'll hop into the lab and test that first!

Noted about the Shottky. When normally all you ever worry about is voltage drop, you get used to basically all diodes being Shottky types. My simulator only has regular and Zener Diodes to choose from, so I just labeled it as Shottky out by force of habit. As for showing the leakage, it's saying 0.010pA (yes, picoamps) of leakage, which I know can't be right. This isn't a SPICE simulator and has a limited range of components to choose from. It was hand written by a pretty damn smart dude (he also wrote a great calculator/text editor called Calca) and has been around for years now. It's available on iPad + OS X and, even though it's rather basic, it's fantastic for testing out ideas quickly before breadboarding. I like how it visually shows the path of current flowing and colors everything green or red based on the voltage (relative to the originating supply voltage). It's called iCircuit and while it's not perfect, I do recommend checking it out; it's only a couple of dollars on the App Store.

Anyway, I digress...
Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Protecting ADC Input with Diode Clamp?
« Reply #6 on: November 29, 2013, 12:18:28 pm »
Quote
came up with the idea of hooking a Shottsky diode from the 5V rail to the output from the voltage divider.

Not sure why you configured it that particular way - it doesn't work.

Most mcus (all?) have clamp diodes on their input pins (check the datasheets to be 100% sure). All you need is to put a serial resistor there to help limit the current.

You can use external diodes, mostly in cases where input impedance is important (for speed reasons for example). In those cases you put two serial resistors + two external diodes - regular silicon diodes like 1n4148s work well.
================================
https://dannyelectronics.wordpress.com/
 

Offline timbTopic starter

  • Super Contributor
  • ***
  • Posts: 2536
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
Re: Protecting ADC Input with Diode Clamp?
« Reply #7 on: November 29, 2013, 01:24:16 pm »
Quote
came up with the idea of hooking a Shottsky diode from the 5V rail to the output from the voltage divider.

Not sure why you configured it that particular way - it doesn't work.


Uh, what exactly doesn't work about it? Because I just tested it on a breadboard about an 30 minutes and it worked perfectly. It worked in my simulations as well (see the last image in my original post). Also see the image in codeboy2k's post and Fig. 2 on the second page of this PDF from TI.

I know some ADCs and MCUs have protection diodes built-in, but they're rather small and can easily burn out. That's why I want external protection, so I could use large power diodes or at the very least something I could easily replace if it burnt out (versus having to replace the entire MCU). This ADC will be hooked to an electronic load and exposed to high voltages or large amounts of current.
Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Protecting ADC Input with Diode Clamp?
« Reply #8 on: November 29, 2013, 03:20:59 pm »
What will happen when your pot is at its left most position and a voltage > 5v (+Vfwd) is applied?
================================
https://dannyelectronics.wordpress.com/
 

Offline timbTopic starter

  • Super Contributor
  • ***
  • Posts: 2536
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
Re: Protecting ADC Input with Diode Clamp?
« Reply #9 on: November 29, 2013, 07:51:12 pm »
What will happen when your pot is at its left most position and a voltage > 5v (+Vfwd) is applied?

The diode will clamp it? That's the idea: I don't want more than 5V going to the ADC. That pot would normally just be a 5K resistor, the only reason I've got a pot there is so I can tweak the resistance to get exactly "1023" on the ADC at 30V in. If I do something dumb like turn it left instead of right or the input goes past 30V, I want the ADC protected from voltage >5V!

I have a dedicated 5V rail coming from the USB port (which powers the MCU), the cathode of the diode will be connected to that; the anode will go between the voltage divider output and ADC input.
Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Protecting ADC Input with Diode Clamp?
« Reply #10 on: November 29, 2013, 09:05:11 pm »
Quote
The diode will clamp it?

Yes, until it is burned up.
================================
https://dannyelectronics.wordpress.com/
 

Offline timbTopic starter

  • Super Contributor
  • ***
  • Posts: 2536
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
Re: Protecting ADC Input with Diode Clamp?
« Reply #11 on: November 29, 2013, 09:11:22 pm »
How will it burn up if there's a current limiting resistor before it? In my testing this morning I showed around 2mA current flowing through the diode at 10V (60V before the voltage divider)...
Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 27680
  • Country: nl
    • NCT Developments
Re: Protecting ADC Input with Diode Clamp?
« Reply #12 on: November 29, 2013, 09:28:49 pm »
I strongly recommend against clamping to a power supply rail. You'll couple noise from the supply into the signal and when push comes to shove the supply rail can be pushed up wrecking the circuit. Using a low leakage zener diode to as a shunt is a better alternative.

I mostly use a low value series resistor from the input to the zener diode and a higher value resistor between the zener and the ADC. The ADC input also has ESD clamping zeners.

edit: typos
« Last Edit: November 30, 2013, 07:51:10 pm by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline timbTopic starter

  • Super Contributor
  • ***
  • Posts: 2536
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
Re: Protecting ADC Input with Diode Clamp?
« Reply #13 on: November 30, 2013, 10:52:20 am »
So I took codeboy2k's suggestion on using a a diode-connected transistor and seems to work very nicely, at least with my lab power supply. I ended up having a small box full of 2N3904s (as everyone should) and it lets the input go from 0 to 5 just fine, but once it hits the ceiling it holds it at (a maximum) of 5.7V. I tested this at the upper limits of my main power supply (60V) and I couldn't see any issues.

I might rig up another transistor to pull a logic line low on the MCU at around 5.3V, to signal an out of range condition.

Anyway, here's a few pictures of my testing!



Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 

Offline fcb

  • Super Contributor
  • ***
  • Posts: 2129
  • Country: gb
  • Test instrument designer/G1YWC
    • Electron Plus
Re: Protecting ADC Input with Diode Clamp?
« Reply #14 on: November 30, 2013, 12:48:45 pm »
I strongly recommend against clamping to a power supply rail. You'll couple noise from the supply into the signal and when push comes to shove the supply rail can be pushed up wrecking the circuit. Using a low leakage zener diode to as a shunt is a better alternative.

I mostly use low value a series resistor from the input to the zener diode and a higher value resistor between the zener and the ADC. The ADC input also has ESD clamping zeners.

I use the highest input impedance that my circuit can stand, nearly always clamp to a supply rail and do some basic maths on what is likely to hit it and protect it accordingly.  If it's ESD your bothered about, there are clearly defined tests, and you can calculate the effect of the thwack.

https://electron.plus Power Analysers, VI Signature Testers, Voltage References, Picoammeters, Curve Tracers.
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: Protecting ADC Input with Diode Clamp?
« Reply #15 on: December 01, 2013, 09:37:42 am »
I strongly recommend against clamping to a power supply rail. You'll couple noise from the supply into the signal and when push comes to shove the supply rail can be pushed up wrecking the circuit. Using a low leakage zener diode to as a shunt is a better alternative.

I mostly use a low value series resistor from the input to the zener diode and a higher value resistor between the zener and the ADC. The ADC input also has ESD clamping zeners.

edit: typos

This is a valid point, and should be part of the design process.. i.e. decide if the ripple noise on the power rail when bleeding through the reverse leakage current of the diode is tolerable or not (i.e. how many LSB's is it going to be at the ADC input??).  The designer needs to do the math here.

As I said in my first post, a clean and separate shunt regulated clamping rail can be used here. Since there is no load on the rail it won't see much ripple, and is only there to dump current into.

What will happen when your pot is at its left most position and a voltage > 5v (+Vfwd) is applied?

A separate, shunt regulated clamping rail will also take care of dannyf's concern about the long-lived over-voltage event. I said that too :)

If you do use a clamping rail (for any one of the numerous reasons posted here) then you also have to make sure that you can't dump so much current into the rail that you blow the shunt to pieces. 

It boils down to stated numbers, i.e. planned protection against specific events up to a limit. Perhaps using some defined specs for ESD and other events as fcb has said.
 

Offline timbTopic starter

  • Super Contributor
  • ***
  • Posts: 2536
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
Re: Protecting ADC Input with Diode Clamp?
« Reply #16 on: December 01, 2013, 09:35:32 pm »
Yeah, very good advice. I measured the ripple of my test circuit connected to the actual 5V rail from the Tinkerkit LCD (connected to a current limited 5V source, just in case) and it was acceptable for this use. I tested the circuit up to 60V (as high as my triple output supply would go) and the 3904 + uC 5V rail has no problems holding the voltage for 15 minutes, so I think, in this case at least, I'm good.

For applications with higher currents or if I needed precise readings from the ADC, I'd use a shunt regulated rail for sure. I actually did try out the suggestion of using one for this project last night with a TL431 I had handy and it worked great! Just to keep in simple I'm going to go with the 5V rail for now.
Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf