MCU controlled voltage divider input – is this correct? - Page 1
Forum section: electronics / projects

author: Mr.B
author_rank: Unknown
timestamp: November 30, 2014, 07:22:42 pm
content: Hi all,I am wanting to measure voltage using an ADC and also wanting decade range control.The circuit below is intended to be able to facilitate the following:FET1 and FET2 on: 200vdc input yields 2vdc to the ADC.FET1 off and FET2 on: 20vdc input yields 2vdc to the ADC.Both FETs off: 2vdc input yields 2vdc to the ADC.Maximum input voltage in the actual application will not exceed 120vdc.Is this design correct or even sane?Thanks in advance for your advice.

author: timb
author_rank: Super Contributor
timestamp: November 30, 2014, 07:59:30 pm
content: Add another Zener facing GND for reverse polarity protection and, at the very least, add a precision Op-Amp set to unity gain at the input to the ADC. (You could also use a PGA instead so you can boost sub-2V signals up.)Sent from my Tablet

author: Yansi
author_rank: Super Contributor
timestamp: November 30, 2014, 08:20:49 pm
content: That zener diode there is a f-word design failure. Have you ever considered the reverse current through the diode and its voltage and temperature dependencies?You cannot simply use a zener diode for clamping in high impedance circuit like this. It instantly kills the linearity and accuracy.The only proper method is to use low leakage clamping diode PAIR between supply rails, OR to use a reverse biased BE junction of a smallsignal NPN transistor. (It will open around 6-7 volts and also has almost negligible reverse current. Around 2 volts we might talk about <nA.)

author: Mr.B
author_rank: Unknown
timestamp: November 30, 2014, 08:22:16 pm
content: Thanks timb,I don't quite follow "Add another Zener facing GND for reverse polarity protection".Do you mean in series with the existing Zener?I had inadvertently omitted the fact that I will be using a Texas Instruments OPA4188AID for unity gain before the ADC.I don't have much need to boost sub 2v signals. The ADC is 12bit and will provide more than enough accuracy for the application.Thanks,

author: Mr.B
author_rank: Unknown
timestamp: November 30, 2014, 08:36:54 pm
content: Thanks for your advice Yansi,I was planning to use the ON Semiconductor MMSZ4680T1G as it has a maximum reverse leakage current of 4uA.I will do some more research on the BE junction method as I don't quite understand the configuration.The other issue may be that the ADC has a max input of VDD, which will be 5vdc.

author: Yansi
author_rank: Super Contributor
timestamp: November 30, 2014, 08:41:24 pm
content: 4 microamp current at 1kiloohm impedance circuit makes 4mV change. That equals error of almost 0,2%. As MCP3204 is 12bit A/D converter, you get a nonlinear temperature dependent error of 8 LSBs. Man... that sucks like a bitch. It is also common design fail.BE junction protection is only applicable IF the ADC input can withstand voltage of about 7V. MCP3204 inputs can tolerate only voltage levels up to Vdd+0,6. It clearly tells you, that the input is CMOS with protection diodes. If you try to pass there more voltage that Vdd+0,6 through some resistance, it will clamp the voltage by its internal protection diodes. But the diodes are the last protection, you should make better protection before the ADC input. So obviously you cannot use BE protection. Usually by taking a doublediode package (like SOT23) with tw small signal diodes connected in SERIES (not common cathode) to make external clamp. Two diodes in series between Vdd and ground will mostly compensate for their leakage, because both diodes in the same package will have almost same leakages and V/T dependent characteristics.Note: The BE protection is pretty simple, take a NPN like BC547C. Connect BASE to the ground, EMITTER to the voltage to be clamped and leave colletor floating. If you have access to some better test and measuring equipment, you can proof yourself the leakages by measuring reverse VA characteristics of the fucking zener diode and then tha reverse biased BE junction. The difference shoud be obvious.Some time ago, I made a coarse measurement, just for simple comparison to be sure theory is the same as practice. Also note that the Y axis is logarithmic.

author: Mr.B
author_rank: Unknown
timestamp: November 30, 2014, 08:52:18 pm
content: Quote from: Yansi on November 30, 2014, 08:41:24 pmYeah, got that...As I said, I will research the BE junction method further.Thanks,

author: Yansi
author_rank: Super Contributor
timestamp: November 30, 2014, 08:55:03 pm
content: I just updated my message, more info added.

author: Mr.B
author_rank: Unknown
timestamp: November 30, 2014, 09:26:59 pm
content: Like this?

author: Yansi
author_rank: Super Contributor
timestamp: November 30, 2014, 09:44:18 pm
content: If the ADC is powered by 5 volts, than yes.C2 shoud be enough when only about single nanofarad to speedup ADC's sampling capacitor chargeup.I think it would also be nice to split the wire between diodes and C2 and insert there small value resistance, maybe few hundreds ohms. This because now you have physicaly two diodes in parellel - one is D1 and second matching diode is inside the ADC. But the internal is/might be weak and you want most of the error curent to flow through the diodes you added externally. But it might do without that resistor aswell.The doublediode doesn't have to be in SOT23 package, but usually it is hard to find suitable double diode in such package as TO92 (through hole). But it is easier to find some in surface mount, like SOT23 package. It might also work well with two separate matched diodes like 1N4148, but a doublediode device will have almost perfect match.

author: dannyf
author_rank: Super Contributor
timestamp: November 30, 2014, 09:49:48 pm
content: QuoteWhether you need those two diodes will depend on the voltage you think may be present before the 100K resistor.The adc pin will likely have a couple clamp diodes. They are typically good up to 2ma. That means that it is ok to rely on those until the input gets to 2ma * 100k = 200v.If you do expect more than 200v, you want to put in those two diodes, so that they clamp the input, rather than the clamp diodes in the adc. To do that, you need to insert a serial resistor between the two diodes and the C2. 1Kohm would be sufficient. That resistor ensures that the external diodes kick in before the internal ones.

author: timb
author_rank: Super Contributor
timestamp: November 30, 2014, 09:58:34 pm
content: If absolute precision isn't key, a Zener pair would work fine as the leakage can be calibrated in software. However, if you can afford the matched pair of signal diodes, it will offer better precision.Sent from my Tablet

author: Mr.B
author_rank: Unknown
timestamp: November 30, 2014, 10:25:09 pm
content: Many thanks to all for all your help.@YansiYes, the ADC is powered from the 5 volt rail.No problems inserting a couple of hundred ohms between C2 and the diodes. (dannyf is suggesting 1Kohms...)I will find a suitable SOT23 device. All components in the design are SMD.@dannyfThe application should not see more than 120vdc, however I guess it is better to be safe than sorry considering the cost of the ADC and the pain to replace it.@timbI will use a matched pair of signal diodes. The cost of that is not too much of a consideration.

author: dannyf
author_rank: Super Contributor
timestamp: November 30, 2014, 10:45:13 pm
content: Those two external diodes offer NO additional protection over and above what the internal clamp diodes do, unless they kick in before the internal clamp diodes - the two sets of diodes are parallel to each other.The internal diodes typically kick in at around 0.3v. So using a 1n4148 there does absolutely nothing for you.

author: Yansi
author_rank: Super Contributor
timestamp: November 30, 2014, 11:23:38 pm
content: As was said, resistor between them !Or just forget that completely.

author: Mr.B
author_rank: Unknown
timestamp: December 01, 2014, 12:29:57 am
content: The MCP3204 datasheet says the maximum input voltage is VDD + 0.6v.Minimum is -0.6vThis would indicate that the internal clamping diodes are 0.6v.If I was to use an external Schottky pair, namely BAT240A, the datasheet specifies Vforward as 0.325v @ 100vThis would be "mission accomplished" yes?Datasheets below.

author: timb
author_rank: Super Contributor
timestamp: December 01, 2014, 12:45:17 am
content: NM, won't work with your setup. Ignore!

author: Yansi
author_rank: Super Contributor
timestamp: December 01, 2014, 12:52:13 am
content: Mr.B:That Vdd+0,6V does not say anything about where the internal clamp begins conducting some (serious) current. 0,6V is absolute maximum voltage across the clamp, at unspecified current which might damage the device, if over 0,6V + over Vdd (or 0,6V less than gnd).I wouldn't recommend schottky clamp, because schottky diodes are notorious for bigger leakage than Si diodes. (But I am not sure about this when using small signal schottky).So that is the reason, why to use external Si clamping and the separation resistance beteen ext and int clamping diodes. If the internal ones starts to open at 0,3V (as dannyf said), the external Si will fully open at around 0,7 (heavy current clamping). This is 0,4V difference voltage and if you want to let only (randomly selected number) 2mA to pass through int clamp, the required series separation resistor will be around 200 ohms. (or more). The resistance calculation is only very informative, but I think will be enough accurate to make the stuff bombproof.timb, what is NM and what will not work? Did I miss something?

author: Mr.B
author_rank: Unknown
timestamp: December 01, 2014, 01:07:03 am
content: Thanks Yansi,I will go back to the BAS31.Leakage @ 100nAThe Schottky was 1uA

author: dannyf
author_rank: Super Contributor
timestamp: December 01, 2014, 01:11:19 am
content: QuoteBAT54S is often used - it has two diodes in serial so easy to work into the circuit. Designed primarily for clamping.

author: Yansi
author_rank: Super Contributor
timestamp: December 01, 2014, 01:20:10 am
content: maybe just one another thing we overlooked - the mosfets. I've tried to look for thir leakage, and didn't see taht in the datasheet. Well.. these wweren't obviously meant for signal switching.The leakage will never be (close to) zero, but you must at least know the range where it could exist (if nanoamps or microamps, ...), calculate the worst case effect on your circuit and then decide if the device is usable.

author: c4757p
author_rank: Super Contributor
timestamp: December 01, 2014, 01:22:11 am
content: Somewhat offtopic: do you truly need such accurate resistors? The signal is going to a microcontroller - acomputer, you can do math in it, and adjust the value to the correct level. You just need them reasonably accurate to avoid going outside the ADC range (or too far inside).

author: Mr.B
author_rank: Unknown
timestamp: December 01, 2014, 01:43:54 am
content: @dannyfThey have a peak reverse voltage of 30v. (very good Vforward charastics though).If the input voltage suddenly swings to 100v my MCU is going to take a little bit of time to react and switch in the voltage divider resistors.Will this not fry the diode between signal and GND?@YansiI had designed in the Si2366DS simply because I have half a reel in stock.I will track down a more suitable FET.Thanks.@c4757pYou are right. The tolerance is probably overkill.I will probably just use 1% as they are quite a bit cheaper than 0.05%