Switchable Voltage Divider - Page 1
Forum section: electronics / beginners

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 08, 2015, 06:14:13 pm
content: For my next project, I want to measure voltages up to ~60V with a 12bit ADC, but to get reasonable resolution also for lower voltage values, I'd like to implement some kind of switchable voltage divider.The µC I'm gonna use has built in voltage comparators with hysteresis and all, so the main challenge is to actually find a proper way to switch the divider.The following two ways seem to be most promising:1) Use separate ADC-channels in parallel, each with a specific voltage divider and switch on/off the patch from the divider to the ADC input.2) Use multiple resistors in parallel in the lower side of the voltage divider and use switches to ground to activate one or more resistors.Now for the 2nd approach I did some simulations with N-FET transistors (IRLML2502PBF) as lowside switches, but this doesn't seem feasible, as the leakage current of a few microampere influences the voltage divider too much for high resistance values.And obviously I want to use resistors in the MOhm range to not influence the measurement too much.I would suppose I could use analog switches, but I figure their resistance is temperature dependent.The only other alternative that comes to mind would be (reed) relais, but they are rather expensive and slow. More or less the same is true for miniature solid state relays.For the 1st approach, a P-FET could be used per range/channel. Problem is that at least for the low voltage ranges, even behind the voltage divider, the typical VDS of -20V for most small P-FETs is exceeded. There are -60V types, yet with higher RDSon. E.g. BSS83P: -60V, 2Ohm. With a divider in the MOhm range, I guess the 2Ohm should be ok.Drawback is the use of multiple ADC inputs, but this is most probably not a problem.After some thinking about it, I found the p-FET approach isn't working out either. For low input voltages, VGS is too low to switch through, for high voltages it gets too high even for the 60V types...This should be a common problem, but I didn't find really much information on standard solutions. I found only references to reed relays or analog switches, but without really talking about the drawbacks or naming an certain part. So any hint?

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 09, 2015, 07:46:21 pm
content: To continue my monologue, it seems that analog switches are still my best choice. Until I find something better, I tried a simulation with a 74HC4066.Looks kinda promising...

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 09, 2015, 08:00:40 pm
content: It look like you are building some kind of auto ranging. Why not have a look in some DMM's on how they tackle this problem?

author: bugs
author_rank: Contributor
timestamp: February 09, 2015, 08:18:19 pm
content: You could try to use a programmable gain amplifier like the PGA112/PGA113. They are not that expensive, but maybe it does not have the precision you want.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 09, 2015, 08:43:54 pm
content: Well, letting aside that the 74HC4066 is not really 3.3V compatible, I guess the above circuit should work, shouldn't it?I guess I can find a switch better suited for low voltage operation, e.g. TS3A4751 or MAX4751

author: cosmicray
author_rank: Frequent Contributor
timestamp: February 09, 2015, 08:56:16 pm
content: An I2C controlled potentiometer is effectively a remote controlled resistor ladder. You could use it to get a stepped voltage, albeit with only a small available current draw. Various devices offer steps of 64, 100, 128 and 256.The only restriction there is that the top of the resistor ladder has a maximum voltage close to Vdd.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 09, 2015, 09:33:33 pm
content: Interesting devices for sure, but I don't think I can use them for this purpose. Firstly, they seem to come only in the 10k to 100k range. I'd prefer the MOhm range to not change the current too much.Secondly, the idea is to protect the ADC from too high voltages for too long. With comparators I can switch the voltage divider fast enough to protect the ADC. With any ADC/software based approach, the time for switching ranges would dramatically increase which is not what I aim for.

author: Mr.B
author_rank: Unknown
timestamp: February 09, 2015, 09:40:54 pm
content: This is what I did on my Homebrew DC Load.Ranges are 2vdc, 20vdc, 200vdc (My load isn't rated to 200vdc, it was just a convenient range)

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 09, 2015, 10:45:17 pm
content: As I said, I experimented with N-FETs as lowside switches as well, but found that the drain leakage current made it necessary to use relatively low values for the voltage dividers.While the off state drain current of your FET seems to be lower than the one of mine, it seems you also chose 100k instead of 10M for the upper resistor to work around this.The problem with this is that a relatively high current is flowing into the voltage divider which kinda influences the measurement more than I would like.Besides, your approach seems to be SW controlled, so you need a low pass filter to not damage the ADC in case of voltage jumps. This is also something I try to avoid.

author: Mr.B
author_rank: Unknown
timestamp: February 09, 2015, 10:52:03 pm
content: Quote from: 0xdeadbeef on February 09, 2015, 10:45:17 pmYes, basically.And in my particular case I am not too concerned about the ~1mA @ 100vdc.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 09, 2015, 11:07:56 pm
content: As a side note: when I look at the datasheet, it doesn't really look like the Si2366DS fully switches through at 3.3V. Indeed the lowest Vgs value with a specified RDSon seems to be 4.5V.The 30mOhm seem somewhat optimistic as this is the typical value specified for 10V Vgs. Not that it would matter much, as RDSon is most probably still below 0.5Ohm, but to me this doesn't really look like an N-FET meant for 3.3V levels.

author: Mr.B
author_rank: Unknown
timestamp: February 09, 2015, 11:42:11 pm
content: I hope I don't have a fundamental design fault there...Still laying up the PCB.My datasheet says Gate-Source Threshold Voltage - 1.2 to 2.5Am I misreading the datasheet?(But you are right about the RDSon)Datasheet attached.

author: Psi
author_rank: Super Contributor
timestamp: February 10, 2015, 12:13:32 am
content: You can also control the ADC vref by feeding it from a DAC.This allows you to control the ADC full range value in code.It can be useful to get full resolution at say 5v but also be able to measure 25v at full resolution. You might use a 5/1 voltage divisor on the input so 5v input is 1v on adc and 25v input is 5v etc.First adc sample you do at 5v vref then reduce vref and resample.A disadvantage is the extra time you have to wait when changing ADC vref for it to stabilize before sampling again.If you really want to get fancy you can repeatedly scan the adc bit boundary and try to extract a few extra bits from the range. (Ive not actually tried but it might be fun)Also you could try a pwm DAC for vref control but it would need some pretty heavy filtering to be usable

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 10, 2015, 12:14:30 am
content: @Mr.BWell, the threshold voltage isnotthe point where the transistor is fully switched on but where it starts to conduct. Below saturation the FET behaves like a voltage controller resistor (linear region).If I understand the datasheet correctly, ~4-5V is needed to reach a full on state.So IMHO this is a 5V logic level FET, but not a 3.3V logic level FET.@PsiThis is for sure an interesting approach, but it also seems a bit over-complicated. Honestly I don't think the trouble is worth it if I can use simple analog switches.

author: Mr.B
author_rank: Unknown
timestamp: February 10, 2015, 12:47:23 am
content: Thanks for the heads up 0xdeadbeef.I am still laying up the PCB so I will try to find a more suitable FET.

author: Zero999
author_rank: Super Contributor
timestamp: February 10, 2015, 10:09:32 am
content: The leakage current will be more of a problem than the on resistance.Use high resistance values and a low leakage MOSFET which is rated to a much higher voltage than necessary.For example the BSS131 is rated to 240V and has a maximum leakage current of 10nA at the rated voltage and 25oC, at lower voltages it will be less. The on resistance is 14 Ohms but with high resistor values in the divider it won't be a problem.http://www.farnell.com/datasheets/1680766.pdf

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 10, 2015, 11:15:02 am
content: Problem is that the BSS131 also seems to be a 5V logic level type. So for 3.3V, it's not really fully on. Again, Rds_on is specified for 4.5V.

author: Zero999
author_rank: Super Contributor
timestamp: February 10, 2015, 11:44:41 am
content: Quote from: 0xdeadbeef on February 10, 2015, 11:15:02 amI doubt that would be a problem. Don't forget you're using this to switch just over 2uA so I really doubt the voltage drop would be a problem, even with a gate voltage of 3.3V.Look at graph #5 on the datasheet. Note how when IDis near zero VDSvaries very little between VGS= 2.3V and 10VGraph #8 shows RONwill be around 10Ohms when IDis near zero and VGSis 3.3V.

author: Dago
author_rank: Frequent Contributor
timestamp: February 10, 2015, 12:26:54 pm
content: Quote from: 0xdeadbeef on February 09, 2015, 09:33:33 pmNotice that ADCs usually require a fairly low source impedance (usually something like <10kohm) so you can't just feed them from some Mohm divider.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 10, 2015, 03:57:51 pm
content: Quote from: Dago on February 10, 2015, 12:26:54 pmWell, worst case I'd need another OP as voltage follower.

author: cosmicray
author_rank: Frequent Contributor
timestamp: February 10, 2015, 08:17:24 pm
content: Quote from: 0xdeadbeef on February 09, 2015, 11:07:56 pmTake a look at BSD840N, it runs at the lower levels you seek, but the voltage range may not be sufficient. One implementation of a level shifter uses that part to translate between as low as 1.5V to as high as 18V.

author: cosmicray
author_rank: Frequent Contributor
timestamp: February 10, 2015, 08:20:30 pm
content: Quote from: Dago on February 10, 2015, 12:26:54 pmThe MCP4017/18/19 series are all available in 5K, and some pieces in 2.1k.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 10, 2015, 10:54:16 pm
content: Quote from: cosmicray on February 10, 2015, 08:17:24 pmHm, worst case 400Ohm @2.5V and a maximum of 100µA leakage current. While this is a 3.3V logic level FET, it's worse in any other possible parameter.Quote from: cosmicray on February 10, 2015, 08:20:30 pmWell, much too low values. I want a voltage divider in the MOhm range. And the comment was about this MOhm divider being a too high resistance for an analog input. Which might be true but (as stated before) can be easily overcome by adding a voltage follower.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 16, 2015, 12:41:26 am
content: Ok, I found some time to rework my circuit a bit more.The main change is that I use XOR gates to only switch one of the resistors. So no more odd values due to parallel resistors. Furthermore I replaced the 6V->3.3V conversion with a simple division by two and changed the comparator thresholds instead.I also added voltage followers to make the divider (more or less) unloaded and to make the input to the ADC and comparators low ohmic.There are still four ranges:0-6.6V -> divide by 26.6V-13.2V -> divide by 413.2V-26.4V -> divide by 826.4V-52.8V -> divide by 16Notes:74HC4066 as analog switch is as dummy. I will most probably use a TS3A4751 instead.I plan to use 74VHC86M as XOR gates. Didn't find any working spice model though. The XOR gates used in the circuit are ideal/simplified ones with 5V output.Because of the fixed 5V output of the simplified XOR gates, I needed to use 5V as supply for the analog switches. In the real circuit, I'll most probably use 3.3V (even though I need 5V for the OPs).The comparators are also dummies. I plan to use internal comparators of a LPC1549 instead where I can set the threshold from 0/31 to 31/31 of a reference voltage. A 1/10 voltage divider is not the ideal choice, so this is also just for this test circuit.The XOR gate U10 is used only as inverter, simply because it's a 4 gate XOR and one gate is not used.

author: Zero999
author_rank: Super Contributor
timestamp: February 16, 2015, 08:56:59 am
content: Why are you using 3V? It will make life harder.Analogue switches don't work if the voltages are outside the supply rails.HCT logic is compatible with 3V so you could use that to interface with the MCU.Why are you so bothered about the on resistance?The potential divider now has a total resistance of 12M at the maximum input voltage of 52.8V so the current is just 4.3583uA.Even if the switch has a resistance of 400R, the voltage drop will be 1.743mV.The leakage current is a much more important parameter, 1nA will cause a voltage drop of 3mV across a 3M resistor.If the ADC is 12-bit, 1 count = 3/2^12= 3/4096 = 732.421875uVIn order for the switch to drop under 1 count, its on resistance should be < 168R and the leakage current < 244pA.Of course it may not need to be that good. It should be possible to calibrate the error out to some degree but it puts it into perspective.EDIT:I've just tested the old 2N7000 MOSFET. At room temperature the leakage current was difficult to measure, in the order of 500pA at a drain-source voltage of 51V. A higher voltage MOSFET such as the BSS131 will have an even lower leakage current.What about using a BJT? I tested the BC548 and could only just measure the leakage current (50pA) when the voltage was increased to over 50V: the maximum rating is only 30V, a transistor rated to >50V would be better.I didn't try to measure the transistor's saturation voltage at 5uA but it should be very low.I can't be 100% certain of my readings because I don't have an ammeter that sensitive. I measured the current by connecting a Fluke 175 multimeter set to mV in series with the transistor. The meter has an input impedance of roughly 10M so 1mV of voltage drop corresponds to a current of 100pA. The resolution is 0.1mV which is a current of 10pA.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 16, 2015, 11:51:15 am
content: Quote from: Hero999 on February 16, 2015, 08:56:59 amAs I said, I will use the comparators of a LPC1549 and this is a 3.3V device. So at least the analog switch has to be 3.3V compatible.Quote from: Hero999 on February 16, 2015, 08:56:59 amSure, so I don't do that. Or do I?Quote from: Hero999 on February 16, 2015, 08:56:59 amSure, I wrote that in my initial post I think. Problem is that are so many 74HCT4066 versions with different specs, I'd rather use the TS3A4751 anyway.Quote from: Hero999 on February 16, 2015, 08:56:59 amOnly if the error is noticeable of course. Besides, I care more about a reliable/predictable resistance over the voltage and temperature range.I could live with 60Ohm or so on resistance if they were stable. Then again, if I get 0.9Ohm for free, why would I use something higher instead?Quote from: Hero999 on February 16, 2015, 08:56:59 amAre you referring to the 1st schematic? In the new one, it's like 3.2MOhm in den 52.8V case and 16.5µA for the right divider.Quote from: Hero999 on February 16, 2015, 08:56:59 amYeah, but again: if I can get a TS3A4751 for about the same price and have an on resistance of 0.9Ohm, why would I use a 74HCT4066?Quote from: Hero999 on February 16, 2015, 08:56:59 amProblem is that most analog switches have typical leakage currents of 0.5nA to 1nA. There is not really that much I can do about it.Then again, I'm open to suggestions for better switches. I found one from AD, ADG712 as far as I recall, but it's much more expensive and has 0.5nAleakage current instead of 1nA. However, tests with the spice model from AD were catastrophic.Quote from: Hero999 on February 16, 2015, 08:56:59 amI'm too lazy/busy to look it up right now, but all the MOSFETs suggested up to now had somewhat gigantic maximum leakage currents compared to analog switches.Quote from: Hero999 on February 16, 2015, 08:56:59 amHonestly nothing I considered yet. Honestly I find it hard to believe that a plain vanilla BJT will have better parameters than a sophisticated analog switch.Besides, there are so many BJT types on the market that I imagine it will be hard to find one with specifically low leakage current.Problem is also that standard types are produced by so many vendors that it will be hard to make sure you really get the device fitting the data sheet(just like for the 74HCxxx gates).Quote from: Hero999 on February 16, 2015, 08:56:59 amWell, measuring in the pA range is tricky. Besides, measuring won't give the worst case values (high temperature and such).

author: Zero999
author_rank: Super Contributor
timestamp: February 16, 2015, 01:12:03 pm
content: Quote from: 0xdeadbeef on February 16, 2015, 11:51:15 amWhy? There are plenty of 5V comparators on the market.QuoteIf you switch ranges at the right time then yes.QuoteOh yes I see, you're right 3.3/200k = 16.5µA.QuoteThat's because the MOSFETs are specified under the worst case conditions to cover the manufacturer's back.For example, the BSS131 is a leakage current of 5µA but that's at a whopping 240V and 150oC. Reduce the temperature down to 25oC and if falls to 10nA. At 50V it'll go down even further, probably under 1nA. The leakage current doesn't scale linearly with voltage. It tends to be exponential, past a certain voltage.http://www.infineon.com/dgdl/Infineon-BSS131-DS-v02_06-en.pdf?fileId=db3a304330f68606013104bf65993eebChoose a MOSFET with as high a voltage rating as possible and as higher RONas you can stand and the leakage current should be low.QuoteWhy not? It makes sense that a BJT should have a lower leakage current than an analogue switch composed of MOSFETs.MOSFET has a diode in reverse parallel with the source and drain so you get the diode leakage plus that of the MOSFET. Analogue switches are made of MOSFETs which have diodes connected from each pin to either power supply rail.A BJT is much simpler than an analogue switch. When its operating in its cut-off region it looks like a reverse biased diode with an extremely low leakage current: much lower than any MOSFET.http://aries.ucsd.edu/NAJMABADI/CLASS/ECE65/06-W/NOTES/BJT1.pdfhttp://electronics.stackexchange.com/questions/13286/using-a-transistor-as-a-diode

author: cosmicray
author_rank: Frequent Contributor
timestamp: February 16, 2015, 03:02:09 pm
content: @0xdeadbeefHave you even considered using an electromechanical solution instead of solid state ? I'm speaking of small signal latching relays. Typical contact resistance is < 50 mOhm. Leakage current is not quoted because there probably isn't any. There is a brief settling time when the contacts close. If the voltage divider is intended to switch rapidly, then the electromechanical solution would not be appropriate. The units take up more board space, and may add BoM cost.

author: VintageTekFan
author_rank: Regular Contributor
timestamp: February 16, 2015, 03:10:26 pm
content: Quote from: cosmicray on February 16, 2015, 03:02:09 pmThat's (at least) what the Tektronix DM50x meters do.

author: Zero999
author_rank: Super Contributor
timestamp: February 16, 2015, 04:28:14 pm
content: You can't beat a mechanical relay for leakage and voltage drop but make sure it's a signal relay, designed for very low currents. Some high power relays won't produce a very good contact at low voltages and currents because a thin film of oxide can develop on the contacts and a reasonable voltage and current are required to break through itGold plated contacts are best and they're not expensive because the amount of gold used is tiny.The minimum current is often called the wetting current on data sheets.

author: JohnnyBerg
author_rank: Frequent Contributor
timestamp: February 16, 2015, 04:48:47 pm
content: Quote from: Hero999 on February 16, 2015, 04:28:14 pmIs there a relay you can recommend or have experience with?

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 16, 2015, 05:52:13 pm
content: Quote from: Hero999 on February 16, 2015, 01:12:03 pmLess parts, better use of existing resources, no need for creating the threshold voltages. To name a few things.Quote from: Hero999 on February 16, 2015, 08:56:59 amI see your point, but if a leakage current at e.g. 5V is not specified, there is nothing else to rely on than the defined worst case scenario. I can't afford to to large scale part testing under temperature stress to get statistically significant data. Relying on the measurement with a single part under room temperature conditions doesn't sound like what I'd call proper engineering.Quote from: Hero999 on February 16, 2015, 08:56:59 amI'll have to think about this. The simplicity sounds charming. Even though four discrete SOT-23 parts will probably take more room than a quad switch. I browsed through a few datasheets of standard BJT types looking for cut off and leakage currents. Nothing exciting up to now. Usually more in the µA range than in the nA range. I'm not sure whether it's worth to follow that road until someone comes up with a ultra low leakage BJT suggestion which is easily available.

author: jamesd168
author_rank: Contributor
timestamp: February 16, 2015, 07:05:05 pm
content: Quote from: 0xdeadbeef on February 16, 2015, 12:41:26 amI wonder how much does it cost for the BOM when you are done?

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 16, 2015, 07:37:59 pm
content: Quote from: jamesd168 on February 16, 2015, 07:05:05 pmMCP6004, TS3A4751 and 74VHC86MX together cost around 2€ if you buy them as single parts. Rest is resistors.Obviously other parts of the final project will be much more expensive as this is just the voltage measurement.E.g. the LPC1549 costs ~6€

author: Zero999
author_rank: Super Contributor
timestamp: February 16, 2015, 08:40:53 pm
content: Quote from: 0xdeadbeef on February 16, 2015, 05:52:13 pmDatasheets aren't the be and end all. I suspect most manufacturers even know the true leakage current of their parts because its difficult to measure. They probably just hook it up to a an ammeter with a resolution of 0.1uA and if it reads zero then it passes the rest, otherwise it fails and they have to investigate. Sometimes you just have to use your judgement.One striking thing is the cut-off current is specified as low as 100nA for the MPSA14 which is a Darlington transistor. This must mean the cut-off current for the small transistor, driving the larger transistor is in the nA range because it will be multiplied by the larger transistor's Hfe.http://www.onsemi.com/pub_link/Collateral/MPSA13-D.PDF

author: jamesd168
author_rank: Contributor
timestamp: February 16, 2015, 09:13:52 pm
content: Quote from: 0xdeadbeef on February 16, 2015, 07:37:59 pmgood to know, thanks for the info.

author: Zero999
author_rank: Super Contributor
timestamp: February 16, 2015, 09:38:10 pm
content: Quote from: JohnnyBerg on February 16, 2015, 04:48:47 pmReed relays are your best bet. They don't have a wetting current because the switch is sealed in a protective atmosphere, protecting it from oxidation.http://digital.ni.com/public.nsf/allkb/FE70EF537A6F2CB28625793700672CA3