switching between current shunts, Multiplexer? - Page 1
Forum section: electronics / beginners

author: super7800
author_rank: Regular Contributor
timestamp: March 02, 2021, 10:14:38 pm
content: I'm trying to design a precision current monitoring device, and i already have one designed and mostly working based on a 0.01R shunt, an op amp and a PGA going into a 24 bit adc (did'nt even get close 24 effective bits first time). i'm ready to order the components for a version 2, to hopefully fix a lot of the issues with the first version. however with this version i want to implement more current ranges, specifically uA and nA, so i figure i would need 3 shunts. maybe two if i gave up on the nA range.so basically I want to go from "shunt > opamp > PGA > ADC" to "shunt1,2,3 > switch > opamp > PGA > ADC"what would be the best way to accomplish the differential "switch" function? reed relays would be too slow and are rather expensive, so would a multiplexer be ok passing signals of such small voltages through it? is there a better solution i'm overlooking? i've never worked with multiplexers and analog signals before, only used them for digital.i figure that i would need a low on resistance and low capacitance on the multiplexer?pictured is a very rough diagram of what i was thinking.

author: Kleinstein
author_rank: Super Contributor
timestamp: March 02, 2021, 10:29:10 pm
content: It is normal that one would not get the full 24 bit resolution. This is more like a numerial upper limit. The noise from the ADC is usually high and the reference also adds to this when not measuring zero.For the lowest current range one could think about usising a transimpedance amplifier, so that the votlage at the resistor is larger that the burden seen externally. Otherwise the thermal noise of the 10 K resistor can limit the resolution.One may have to consider larger shunt values to really get highest resolution.For switching CMOS multiplexer chips may be a solution there are some with relatiely low resitance and low voltage. For the highest currents one can use discrete MOSFETs. It is still not an easy balance between the on resistance and leakage.

author: super7800
author_rank: Regular Contributor
timestamp: March 03, 2021, 12:33:06 pm
content: to elaborate on the goal of the project, it is to measure the current of microcontroller (or other) battery powered projects, thus has to have the lowest possible burden voltage on the shunts, which Is why i chose the values I did (might not use a 10K though, I don't think I need to measure nA that accurately)my rough calculations tell me that for a shunt like the 10R, V=i*r 1uA*10R=10uV per 1uA, and my concern was whether a mux could pass that signal (differentially) accurately.if i do go with a mux, should i go withshunt1,2,3 > x10-Op-Amp1,2,3 > "switch" (i.e. mux) > PGA > ADCso that the signal is at least x10 higher and allowing for specific op amps to be chosen per shunt for initial amplification, but requiring 2 more op-amps? or go withshunt1,2,3 > "switch" > op-amp > PGA > ADC?also yeah on my first version I screwed up with the layout and a few other things with my voltage reference, hence why I got such poor results. also i'll look into using a transimpedance amplifier, thanks.

author: Kleinstein
author_rank: Super Contributor
timestamp: March 03, 2021, 12:54:03 pm
content: For measuring the supply current to a µC or similar with high resolution one could use a configuration similar to a SMU. So integrate the current measurement as part of a voltage regulator. The votage regulator can compensate for the drop on the shunt, and this way a larger resisance can be used. In some respect this is similar to a TIA, but including the voltage regualtion.There are usually capacitors at the µC circuit, and as a digital circuit a µC can operate with a bit of ripple in the supply.

author: Terry Bites
author_rank: Super Contributor
timestamp: March 03, 2021, 12:59:04 pm
content: See Dave's µCurrent and blog about voltage burden.What's wrong with a good quality mechanical switch? How fast do you really have to switch between ranges?A MUX will pass a differential signal with good fidelity if the signals are of a reasonable amplitude. However, switching very small signals doesn't work well.As you reduce analog switch Ron the leakage currents go up which may well cause unexpected problems at low currents. Ideally no current flows into your X10 stage.I think you are setting yourself up for a headache with this design. Better to dump the analog mux, keep your sense lines clean and switch the shunts in or out with switches or relays.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: March 03, 2021, 01:11:56 pm
content: Complaining that reed relays are "rather expensive" is not a valid argument if you want to build a "Precision instrument". Accuracy & quality costs money.Some of the ADC converters have built in PGA's and MUX, some also have a built in voltage reference.Even such a chinese IC as the HX711 has two inputs (although not with the same capabilities).ADS1118 has two input channels PGA upto 128x and a voltage reference.Those are just two examples. You have to find an IC that fits your needs.The MUX-es that are built into the ADC's have been matched to the ADC, or at least the errors they cause are a part of the spec of the ADC. If you look at the datasheet of the ADS1118 for example then there are no specs at all for the voltage reference itself. Those are specced as part of the ADC accuracy itself.When using an external mux, it is indeed "better" to use one with a low on resistance, but you have to consider the whole signal path. For low bandwidht applications it is common to put a capacitor right at the input of the ADC. The ADC usually has a very high input impedance (Giga Ohms) but there is a sample capacitor that gets connected during, well, samplingand that capacitor has to be charged. If it gets charged though your MUX resistor, there is a voltage drop (charging time may be too short to fully charge it). A buffer capacitor at the ADC input can deliver a current peak during sampling Even without loosing too much charge, and then recharge during the time the ADC is doing it's AD thing.Another thing you should be aware of is that the sampling capacitor is usually shared between all the channels. If you measure channels with much different voltages, then the sampling capacitor has to be charged and discharged between those voltages each time. If you however only measure one channel, then the charge on the sampling capacitor does not change much at all.A fun and useful experiment to do yourself is put any microcontroller with and ADC (and MUX, but they all have that with their ADC) on a breadboard, and put a 100nF film capacitor on one of the ADC inputs. Charge the capacitor with some intermediate voltage from a potentiometer, and then remove the pot and watch how the ADC value starts changing.Then add a second channel and connect that directly to the potentiometer, and sample them both.You will probably see that the ADC channel that only has a capacitor as input will drift towards the same voltage as the potentiometer, because it gets charged or discharged a bit on each ADC cycle.

author: super7800
author_rank: Regular Contributor
timestamp: March 03, 2021, 01:44:33 pm
content: @Terry Bites the issue with a mechanical switch is speed, (i.e. a mcu etc wakes up, does work, sleeps again, so goes from uA to mA to uA quickly). honestly a mechanical switch (relay) might work, since i'm using a pga i could manually (relay) switch between shunts 10R and 0.01R, deciding whether I want accurate uA or accurate mA, but still getting "usable" values for both by increasing/ decreasing gain.@Doctorandus_P i should clarify that i was not necessarily saying that they where too expensive, but that they where too slow, although if I go with the design I just described above I would use some. I did initially take a look at that type of ADC as you described, but was not "impressed" with their accuracy, although I will take a look again at what is offered with those again, as you are right they would greatly simplify my circuit, and would solve the issue of a mux. also thanks for mentioning the capacitor, I will look more into that.

author: Renate
author_rank: Super Contributor
timestamp: March 03, 2021, 02:35:42 pm
content: I have a power supply with the shunt resistorabovebelow the pass transistor and above the voltage feedback feeding an TI INA226 high side current measurement.It works fine.I see what you're trying to do, but define "precision". Do you really need N bits?A µC might draw an Amp booting and microamps when sleeping.Do you really need precision or only 2 sig digs and an exponent?Radical idea: Use a Schottky diode as a shunt (bestbeforebetween the pass transistor and the voltage feedback).Yes, it will need calibration and temperature compensation but will give an enormous range.I think that I will try that myself.Still, my current INA226 doesn't have the PGA like the INA219.Maybe a dual diode so that you can use that for temperature compensation?With a constant current through one the voltage difference between the two diodes is the log of the current ratios (somewhat) independent of temperature.

author: super7800
author_rank: Regular Contributor
timestamp: March 03, 2021, 07:55:46 pm
content: @renate thanks for the idea, but i am looking to make a (attempt at a) "precision" instrument.so i think an idea might be to use something like @Doctorandus_P's idea of Muxing the signal at the adc. if i was to mux it in the adc i think i would use LTC2442, but i might use an external mux aswell combined with the ltc2410.pictured below is an rough design I came up with to meet this criteria. its not a very "cost effective" solution though, not like that matters though for a (attempt at a) "precision" instrument. i'm not sure yet if I want to go with the ltc2410 and external mux or ltc2442 that has built in 2 channel differential. does anyone have any other suggestions for how my initial problem could be solved, or have suggestions for different components/ other issues with the below design? ill admit i'm abit new to the world of precision analog.EDIT: changed schematic photo to better one

author: Renate
author_rank: Super Contributor
timestamp: March 03, 2021, 10:13:33 pm
content: So now you're down to two shunts?Why don't you skip the relays.Just put a Schottky across the 10 k (not like the logarithmic mode that I suggested).That will let the voltage across the "sensitive" shunt max out.Since 0.3 V burden won't kill you at all (when you integrate this with the power supply).That's better than having your DUT do a µP reset because you didn't switch ranges quickly enough.

author: pwlps
author_rank: Frequent Contributor
timestamp: March 07, 2021, 12:53:19 pm
content: I don't quite understand why you say the reed relays would be too slow. For example the CRR series (https://standexelectronics.com/products/crr-series-reed-relay/) has a switching time of 0.6ms. This is not that far from the maximum conversion rate of 3.5kHz of your LTC2442 at its lowest resolution, at higher resolution the conversion rate will be limiting the speed more than the switching delays.

author: super7800
author_rank: Regular Contributor
timestamp: March 10, 2021, 01:15:07 am
content: @pwlps Hm interesting idea. you are correct the switching time wouldn't really matter in this case i suppose. doing the rough calculations, you are right, i guess i just got it stuck in my head that it would be an issue at some point. I'll definitely keep that in mind for future designs, but i do "like" the design i have now, since the additional amplification circuit comes out to a cost of about the same as two coto relays (maybe slightly less), BUT cost would not be a concern if I felt like it would enhance the design, I think that my design below is best for this application, unless someone sees a better way of doing it?@Renate interesting idea, but i don't want to use that. i'm hoping to create something "precise", i know with this prototype i probably wont manage that, but perhaps version 3 will have all the issues ironed out. my "excuse" for attempting this project for a second time is i need a project for my advanced digital systems class for my ee degree, so this project will have a tft lcd gui etc, and i want to put that effort towards something "useful". i don't think that what you mentioned would be an issue according to my design, as the resistors are "shorted" out, not switched between, and I'm only using a 10R resistor and a 0.01R resistor. also 0.3v burden on 1.2v rail would be an issue in some systems I believe.attached are two images, one of my "final" analog section, and one of my "final" pcb layout of the analog section. (minus the inner two layers, gnd and gnd+power). if anyone wants full schematic id post that too.

author: Renate
author_rank: Super Contributor
timestamp: March 10, 2021, 11:29:10 am
content: Quote from: super7800 on March 10, 2021, 01:15:07 amIf you want precision, you want zero burden voltage.The only way to do that with shunts is to integrate the shunt into the power supply.Any standalone shunt will introduce a variable drop to the load.

author: super7800
author_rank: Regular Contributor
timestamp: March 10, 2021, 09:33:32 pm
content: good point but with my choice of shunts, 0.01 and 10R, the expected burdens are approximately 10uV/mA and 10uV/uA, so it will still definitely play a role in true "precision", I think that it would be negligible for most applications, i.e. 1.2v system at 1 amp would drop roughly 0.01 volts.

author: wizard69
author_rank: Super Contributor
timestamp: March 11, 2021, 01:03:41 am
content: You have some interesting reply's here and frankly I'm in the camp of reed relays designed for the purpose.However, why deal with all of this switching nonsense at all!! Take advantage of one suggestion above and monitor through the power supply. For the lower currents make use of a shunt as you proposed but monitor it continuously. With a bit of engineering you should be able to come up with a reasonable range on the shunt. When the buffering circuits go into saturation you rely upon the power supply monitor. As the current comes down you should begin to see valid readings for the secondary shunt. Give yourself a bit of overlap in the ranges and you will never need to switch. The analog side becomes more complex but your software should be simpler as you basically read both channels every sample time. It is likely you could warp all of this into your power supply.

author: larsdenmark
author_rank: Regular Contributor
timestamp: March 11, 2021, 07:45:40 am
content: If you design a SMPS (or a DC-DC converter) can't you use the duty cycle to get the current?It is not the only problem to measure the voltage across a shunt very accurately. If your MCU only wakes up for a fraction of a millisecond you need to sample quite often. Do you really need to know the instantaneous current or is it sufficient to know the power consumption over a period of time (e.g. 1-10 ms)? If so, you could integrate the current (using an analog circuit) and sample less often.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: March 11, 2021, 10:57:19 am
content: A possible solution is to put several shunt resistors in series (as you have already done) and then put a diode parallel to the shunt resistors with the highest value. This limits the maximum burden voltage to a diode drop per shunt resistor.When the voltage drop gets over 100mV or so (Also temperature dependent), the diode starts conducting some current, but you can partially compensate for that in software. To limit burden voltage and dissipation in the diode you can short circuit it with a relay or MOSfet when that shunt resistor is not in use.It's all a tradeoff between number of components, price, speed, accuracy, burden voltage and some other factors.

author: Renate
author_rank: Super Contributor
timestamp: March 11, 2021, 11:55:16 am
content: Quote from: super7800 on March 10, 2021, 09:33:32 pm24 bits accuracy on 10 millivolts?That's pretty good shooting there, pardner.Edit:The TI INA226 uses +/- 80 millivolts for 15 bit and sign.The TI INA219 can do +/40 millivolts for 12 bit and sign.It only does 15 bit and sign at +/- 320 millivolts.

author: super7800
author_rank: Regular Contributor
timestamp: March 22, 2021, 04:28:51 pm
content: thank you to everyone who has responded, your input has helped me greatly.@Renate its a 24 bit adc, but i know already that i'm not going to get 24 effective bits.@Doctorandus_P good idea with the diode used to limit burden voltage, with a relay to switch it off. I will look more into that thanks.@larsdenmark good point, but with my newest design I have added additional, although very cheap, ADCs with fast sampling rates to better handle that.@wizard69 yes, sensing in the powersupply is the way to go, but not for this project. this is a "handheld" device, and is designed to be much more "universal". I also agree that reed relays would be great, but i think i'm fairly decided on my current dual shunt amplification paths, as I think that gives me more options. This project is very heavily integrated in software controls and algorithms to control it.here is my current design, although i'm thinking of changing the x10 section to something else, perhaps an instrumentation amplifier. I have added two (fairly cheap) fast sample rate ADCs that the FPGA will use to run some control algorithms, which I wont discuss here unless someone is interested.attached is the new design.