Well, the MCUs and analog switches arrived a few days ago. I've made a very basic breakout PCB for the analog switches, and have started prototyping with them. I haven't done anything with the MCUs yet (and nor has the programmer arrived, so I couldn't do much more than make the breakout anyway).
On a slightly different note, I installed KiCAD on a different machine to check out opening the schematics (which I should have done long ago), and found a couple of issues. The worst, which is now fixed, is that the cache library didn't include the analog switch symbol. The other issue is that a few of the component footprints that I've made have pads with rounded rectangles – which requires a KiCAD version more recent than the latest Stable release. That would have happened because when I installed several months ago I chose the Unstable package (on Linux) as the alternative was the very old stable version – and since then, I've updated, and still have the unstable version. I'm not going to change the footprints to rectangle, because the PCB editor is a real pain about updating footprints, and also it would require a fair bit of layout work.
Also, I've changed my mind about building it: I will, but as a bench meter. I'll do it with several smaller / less complex PCBs (e.g. using the STM32F373 breakout I designed), no battery (or maybe a 9 V battery), no USB, and probably a higher voltage rail for the op-amps too.
Now for the initial results:
- I rediscovered that parasitic capacitance combined with a 10 megohm input impedance creates a very effective low-pass filter – with a significantly lower bandwidth than I'd like. I did realise this earlier, and decided then that I'll just play tricks in software to compensate (although that reduces effective resolution in that range).
- The switch off leakage is very low (max 5 nA @ 25 C, max 50 nA @ 85 C), in fact lower than anything else I've seen, but is still very significant when dealing with a few megohms. I've thought of a few ways of combating this.
For dealing with leakage, there's two scenarios to consider: the input voltage divider for higher voltages, and the gain selection for the lower voltages and the output current sense. In both cases, the issue is leakage current flowing through the switch, altering the ratio. I can't just calibrate it out, because the actual current will be extremely temperature-dependent.
On the input voltage divider, I could potentially connect the (buffered) division result to the COM-side resistor, between it and the switch (which connects it to COM). But that's positive feedback into the op-amp, and the input offset voltage might upset things too. However I'm not sure what else is possible, so probably the route I'll take. There's a couple of ways I could actually do it: have a second set of switches to connect it in (and a NOT gate each, because I don't have enough GPIOs), or connect it to the same location via a moderate-value resistor. I've tested them both slightly, and both seem to work. I don't like the former because of the component and layout implications, but I don't like the latter because it would force me to use the buffered version of COM (to deal with the current through the resistor when that range is on) which makes problems from the input offset voltage of that op-amp. However, I think I can handle the maths for the latter (and besides I probably have the same thing on the low-voltage ranges), so it is the option I'll go for – unless you can give me some better ideas!
For the low-voltage input and output current sense amplification, I could do the same thing, although I would have to add op-amps to buffer the value to feed back. The other way would be to have an amplifier for each ratio, and select which one to use – probably better, but more hardware.
I haven't updated the circuit for any of these changes yet, because I still haven't decided what to do – and I don't want to do it over again. And I just noticed I messed up the output current sense amplifier gain resistors, but I'm not fixing it until I'm sorting out the rest.