The divider / protection part has quite some issues:
The divider is quite high impedance and the leakage from schottky diodes for clamping there would likely be a significant issue for the accuracy. The FETs as switch for the divider choice would conduct with negative voltage due to the parasitic internal diode.
Okay, I think this is something that confuses me. This is what I though the 2.5 V offset would be for. Negative voltages would be "cancelled" out(still resulting in positive input) up to -2.5 V but the idea was then that the MCU would get an overload signal and switch range.
The idea with the relay is a bit unclear - if engaged there would be little resistance in the path to provide current limiting for the protection. The clamping diode t GND would limit the negative input to only some -200 mV.
My idea was that this would be the 0 - 2V range and the voltage could pass directly to the input buffer without being divided.
The 2 OP-amps as window comparators would be too much load to the high impedance input. As shown they would act between 0 and 5 V and thus trip on negative voltage. Another point is that the LM358 and similar is not Rail to Rail and thus not working at the upper limit. I would prefer a true comparatorer over the LM358. One would likely still need an extra FET buffer to avoid loading the input.
Yeah, I think this is something I don't really have intuition and experience for with high impedance and load. This shows my digital background thinking of ideal voltages.
I just had a look at the LM358 datasheet, I must have confused it with another op amp, I thought it could drive much closer to the rails, or I may have been looking at the low side where it can get closer to the rail and assumed the same for the upper rail.
The extra level shifters with MOSFETs look odd - one should get away with a simpler solution, e.g. with suitable and gates.
Suitable in what way? The MCU does have some 5 V tolerant pins but I chose to avoid handling different voltages on the MCU side. Working with 5 V for the AND gates meant I could use a dual gate package and handle the output from the window comparators.
I'd like to know what alternative solutions there are though but it was how I solved the mix of logic voltages.
For the problem of allowing a +- input with a 0-5 V ADC, I would consider the input amplifier with a +-5 V range and than a divider at the output of the amplifier. So the input and amplifier would be for +-5 V and than a 1:1 divider (e.g. 2 x 1 K) towards a buffered 5 V reference. This way 5 V would stay at 5 V and -5 V would be mapped to 0 V. A downside would be a bit higher impedance to the ADC and thus a limited bandwidth. There is also a bit load current to the amplifier, but likely still acceptable.
I made a quick sketch in KiCAD, did I understand you correctly? I assume lower bandwidth means slower to react to change in the input voltage which would be absolutely fine.
I assume there would still be a input ranging and protection section.
For the reference the LM4040 seems to be reasonable OK with a capacitance at the output. The DS gives 1 µF as an example in the output impedance curves and they don't look too bad, especially with 1 mA reference current. So one should get away without and extra buffer. I would suggest to plan with an additional RC damping element. So something like 5-10 µF to ground as buffer capacitor and another 10 µF with a series resistor of some 5-10 ohms to ground as extra damping element. The reference drive current (e.g. 1 mA) should come from a stable voltage (like 6 V derived from the 5 V) unless the 7 V supply would be very stable.
The LM4040 is rather noisy and can have a quite high TC. One may want the option for a higher grade reference (e.g. max6070 or ref. 3450).
From my measurements the LM4040 was pretty good, I believe I measure it to around 5.00010 V or so. I didn't check with an oscilloscope, it's probably a bit noisy and i saw some changes in the uV level but for my purposes this is more than enough. I'm not trying to push any limits, it's more about learning the design process and getting something that works. Once I have a hang of it I might be more interested in seeing how good I can get it. I've tried to use parts that I already have at home or are relatively cheap since failure of the first design felt like a possibility.