# using a multiplexer for a high dynamic range current sensing

I am working on a project in which I am supposed to do current measurements for a sensor node.

the range of the current varies from 0-30 mA the sensor node has two modes: 1. active mode (maximum value is 30 mA as stated from the datasheets ) 2. sleep mode (maximum value of current during sleep mode is 35 uA )

to be able to detect up to 1 uA in this system, I need an ADC of a dynamic range of 30mA / 1 uA = 30,000:1 while my ADC is only 10 bits ADC which will only provide 1000:1 dynamic range or to be more accurate, 1024:1 dynamic range

I decided to take two different sets of readings, one during the active mode, and another one during the sleep mode. this way I will have a better accuracy for the sleep mode ( measuring current in micro-Amps). a multiplexer will choose between the two modes as follow

during the active mode, my shunt resistor is going to be small, lets say 1 ohm, that means 1 mA, is equivalent to 1 mV, this 1 mV will go through a differential amplifier with 200 V/V gain to be 200 mV, for my maximum 30 mA , voltage will be 30 mV when amplified it will be 6V.

during the sleep mode, I am using a larger resistor 250 ohm so that 1 uA will produce 250 uV which is .25 mV, and this 0.25 will then go to the 200 V/V gain to produce 50 mV which is measurable using my 10 bit ADC.

my question is, is this really a better way of describing the system? and will it work to get current measurements for this sensor node that is a part of a Wireless sensor network ? and what kind of multiplexers needs to be used? is there such a thing as switching speed ?

• Consider putting 1R and 250R in series and putting shorting 'switch' across 250R. This could be a low Rdson FET. The FET on resistance does NOT affect the high-I error. The off resistance affects Lo-I error but will be extremely high. | You could use two FETS as a mux at the point you show. Their Rdson will also not affect current measurement accuracy. Commented Nov 15, 2015 at 12:23
• How will the off resistance affects Low-I error? Is the off resistance very high? @Russell McMahon Commented Feb 9, 2016 at 14:49
• MOSFET off resistance is "immense". To make <= about 1 bit error with a 10 bit ADC it would need to be 2^10 = 1024 x as high as the 250R or about 250 kOhm. So if MOSFET off resistance is > 2.5 MOhm it will have ~= < 0.1 bit error on a 10 bit A2D. The not marvellous 2N7002 MOSFET has an off Idss of 1 uA max at 60V at 25C. It can't be relied on tpo be linear with voltage, but that's 60 megohm at 60V so probably >> 2.5 MOhm at 5V or so. SO an off MOSFET should have minimal resistance load on a 250 R resistor. Commented Feb 10, 2016 at 11:19
• thanks. so in my words, the MOSFET off resistance is supposed to be very small comparing to the 250 R resistor? and what about the not marvellous MOSFET you mentioned, as do you suggest using it or not? I kinda got lost here @RussellMcMahon Commented Feb 10, 2016 at 15:05
• Off resistance is meant to be very LARGE compared to 250 R. Even the 2N7002 MOSFET qualifies but it's Rdson is large and Id is small - both OK here but there are many vastly superior MOSFETs for not vastly more cost. Search eg Digikeys MOSFETS for examples. Commented Feb 10, 2016 at 15:19

You are going to need a make-before-break solution for the switch from active to sleep to not be disturbed. There's analogue switches and muxes with that ability specified, but they could be complicated to find straight away.

If you do not find something suitable, you can use two analogue switches and make sure your MCU sets one on before it turns the other off.

However, with 250 Ohms, at 30mA it will get -2.5V from a 5V supply, which works mathematically, but obviously not realistically, so it will turn off, basically. You need to be aware of this, so you need to pre-empt the waking up with your measurement device, or you will lose continuity, which usually invalidates measurements of this type.

You also need to be aware of the amount of noise that exists in the world and the amount of effort you will need to get a clear signal out of anything in the single mV range or below. It can be done, it doesn't even have to be hard in terms of component count, but it needs serious attention and awareness of offset voltages and currents and current loops and ground planes, etc.

If you want to seriously get this amount of dynamic range, I would say you'd be better off finding a current-amplification or current-sensing chip with seriously well designed innards, that allows you to use a single resistor with extremely low offset voltage and gives a mirrored output current. You can then measure that mirrored current across two different resistors, with little or no risk of problems caused by your analogue switches and their internal resistance.

One such chip, which at a very quick first glance (I'm out of time, basically), looks promising but needs a good scrutinizing of the datasheet would be:

I'm going to design with the FAN4010 datasheet, because I think it looks slightly better at this time:

simulate this circuit – Schematic created using CircuitLab

You want the voltage across the sense pins to be maximised as much as possible, because that makes it much more noise immune. As you can see I used 10 Ohm, which means 0.3V drop at 30mA already, which may be too much for you, but 10Ohm is still relatively low, we'll look at a possible fix for that later.

With 10Ohm, the sense voltage will be 10uV for 1uA of drain, which means exactly 1uA of output current. Well, not exactly, because the amplifier has 5nA input current, which it adds to the Load current (but that's 0.5%) and an offset output current of 2uA. Funny thing is, that for small signals (<10uA) you can subtract a known offset current from the measurement and still get within a 5% accuracy. So you have the device measure the offset leakage through the high value resistor, with the load turned off (more on that later) and then subtract that voltage from every measurement across that larger resistor.

1uA through the 10kOhm resistor would become 10mV, again with such low currents you do need special attention to the design to keep out noise, but 10mV is easier to guide through amplification than 0.25mV already. And you could possibly use 50kOhm, or 100kOhm, depending on the ranges you want to measure and whether you also add a 1x/100x selectable gain amplifier later.

If you get 30mA into your load, you would get 0.3V of sense voltage, which is 3mA output current. That would cause a huge voltage across the 10kOhm, but the amplifier will just "clip" high, while the load still gets its 30mA with no problems: One risk fixed. Then you can switch to the 100Ohm resistor, which suddenly gets you back to 0.3V (or 10mV per mA), which is again easy enough to work with given a little attention.

If you would use the Diodes Inc chip, you will have a higher possible offset current, but also a higher internal gain, so adjust for that accordingly. The reason I chose the FAN4010, is that it allows upto 2.5V across the sense resistor (versus 0.8V), but it does have a lower maximum input voltage (6V versus 40V), so it's all a trade-off.

Let's say your device works on 3.3V, and you want the best noise performance, then you should, with the FAN, try to get at least 1V across the sense resistor at your peak current (this allows some margin before the chip breaks as well). This is of course pretty hard, because then your device will only get 2.3V, right? Not necessarily, but solving that completely will take a lot of maths and writing and my time is running out for today, so I will show you a solution and tell you what, how and why to look out for:

simulate this circuit

The 33 Ohm will give you about 1V at 30mA, while allowing up to 70mA before any rules from the FAN datasheet get broken, at 3.3V out.

R4 and R5 are the feedback system for the adjustable regulator and they get the feedback voltage from the point where your load is connected. C6 is a small capacitor to make the regulator react not too snappily to changes in the load current, or you may get weird oscillations. Its requirement may depend on the regulator you finally choose (probably not an LM317).

The feedback resistors need to be very large, because else you will be adding too much leakage current to be able to offset that out. Of course a total of around 1MOhm would be great, as it approaches the offset of the current sense chip. But you need to find a regulator that supports such big resistors. I currently doubt whether the LM317 pictured would be good with 100kOhm resistors, but due to my limited time I have no time to look it up. What you're looking for is a very small Adjust-pin leakage current, or a very stable one, that you can calculate in.

Because the adjustable regulator gets it's feedback from the output of the current sensor, it will try to regulate the input voltage, such that the load always sees about 3.2V. Of course some capacitances are needed to keep it from flip-flopping around all the time at small load changes. The values I chose are estimations, and you may be able to leave out the 100nF at the load output if you tweak the feedback capacitor a bit. If you do put that in, you will automatically be slightly averaging the current measurements (smoothing them a little over time). That may be desirable, or it may not be, that's up to you.

In that schematic I also added the load switch that your MCU can control to start with the load turned off, then you wait a little while for all capacitors to get fully stable, then you do one measurement to measure all the nearly static offsets in the low-current measurement system. (Caused by the FAN chip and the feedback resistors). You can even use that measurement to see if all is right, as you know the current drain your feedback resistors should cause and what the limit of the offset of the FAN is.

That load switch may be a P-Mosfet directly controlled by a 3.3V I/O pin, or buffered with an appropriate N-Mosfet from any voltage level.

I added a loading resistor to the voltage regulator (R6), in case you find a type that needs a minimum of 1mA of load, then that resistor (before the current measurement) will make sure the load is always above 1mA.

### One Small note:

If your device runs at 5V, and you use the later trick, you need to decrease to something like 20Ohm sense resistor, or such, or switch to the Diodes Inc chip, since 1V across the sense resistor will get you to the 6V maximum input voltage for the FAN chip, so a small error, some heating or an unforeseen peak can force the regulator to make a voltage that can damage the FAN.

• first of all thank you for the long reply, I bet that took a lot of time. when I checked the FAN4010, its stated that the Vsense is supposed to be 10mV-200mV(page 7). when my current is 1 uA, and by using a 10 ohm resistor, my Vsense would be just 10 uV which is in turn not included in Vsense range. and my Iout would not be 1uA, it would be 0.1 uA not 1, I bet you just had no time and you miscalculated things. my second q is, in short, is adding the Lm317 to regulate the current and to get rid of the noise ? or what is exactly the its function? I spent smtime trying to figure @Asmyldof Commented Nov 15, 2015 at 16:58
• @SabirMoglad Those are exactly the details I didn't really have time to work out, just quickly looked at the transfer ratios and Vin limits and worked from memory. There are chips like this one (may be a bit more pricey) that can do it, or else you may have to build its insides yourself with a very good op-amp. The LM317 (will have to replace with a better choice, probably) is made to regulate the load voltage, by adjusting the Vin as the load current changes. It creates a constant output voltage just before the switch, where its feedback is connected. Commented Nov 15, 2015 at 19:30