Sense voltage while isolating MCU ADC port

Ian0

Joined Aug 7, 2020
13,157
Those are contradictory opinions…
Not really.
Just a different way of achieving the low impedance necessary.
Microchip has a good explanation of how it all works (and all other SAR A/Ds work the same way)
http://ww1.microchip.com/downloads/en/appnotes/pic16-pic18-adc2-90003194a.pdf
If the analogue voltage source on page 4 is your capacitor, you can calculate how much the capacitor voltage will be affected by the connection of the A/D sample and hold capacitor through the internal resistance.
This is how it looks on SPICE,Screenshot from 2023-07-29 07-37-05.pngThe light green trace is the input voltage, which you can see is almost completely unaffected by the sampling.
The dark trace is the voltage on the sample and hold capacitor.
 

Attachments

ericgibbs

Joined Jan 29, 2010
21,454
Hi,
I would say that for an ADC input the R, C values are too high and are giving a poor overall response.
Also, the limited Vout range of 100 Units, combined with this response, will a given an unsatisfactory overall performance.

Especially when we do not know the range of applications for this ADC > STM.
E

EG57_ 1010.pngEG57_ 1009.png
 

Ian0

Joined Aug 7, 2020
13,157
Hi,
I would say that for an ADC input the R, C values are too high and are giving a poor overall response.
Also, the limited Vout range of 100 Units, combined with this response, will a given an unsatisfactory overall performance.

Especially when we do not know the range of applications for this ADC > STM.
E

View attachment 299347View attachment 299348
The TS is measuring a DC voltage (see post #1). I don't think the frequency response above 10Hz is relevant.
 

ericgibbs

Joined Jan 29, 2010
21,454
I am starting a project to read DC voltage from different sources, but the problem I find is that the voltage sources are not always ideal and stable so I fear for the ADC port of the MCU that would be doing the reads.
As I initially said this a new project but i would like to be able to use it in different applications like solar batteries, machine control or cars
How many devices will I make it’s a tough question to answer. Initially I will like to make 200-300 units and see how it goes
Refer posts #1, #23 and #35

How can you say I don't think the frequency response above 10Hz is relevant.
 

Ian0

Joined Aug 7, 2020
13,157
An unstable voltage source would suggest to me that some filtering is required.
I would speculate that if the TS is measuring the supply voltage, then his sample rate would be quite low, so an anti-aliasing filter would be required, especially with an unstable supply.
If the TS would confirm the sampling rate he is using, and state what data he is measuring on the supply (e.g its average voltage, or its noise, or its ripple) then I would be able to give a more considered opinion.
 

ericgibbs

Joined Jan 29, 2010
21,454
Hi Ian.
As we both agree, we need more application information, if we are to give our best advice.
From my point of view I would aim for the best possible usage of the full range of an ADC and this would mean a simple OPA front end.

Perhaps the TS would enlighten us, with a couple of actual projects he has on the bench.

If he is planning to make 200-300 units, he has got to get the design right, first time.

E
 

Thread Starter

Goxeman

Joined Feb 28, 2017
176
We could think of vans or trucks for example. In my opinion they are one of the worst environments that I could consider.

You can find trucks or vans with 24V and 12V where voltages vary depending on the different machines they have installed or the alternator.
 

Ian0

Joined Aug 7, 2020
13,157
We could think of vans or trucks for example. In my opinion they are one of the worst environments that I could consider.

You can find trucks or vans with 24V and 12V where voltages vary depending on the different machines they have installed or the alternator.
What information do you intend to gain concerning the power supply voltage?
 

Thread Starter

Goxeman

Joined Feb 28, 2017
176
What information do you intend to gain concerning the power supply voltage?
Battery level in general as data and fluctuations depending on the charges feeded by the battery. Sometimes the battery level is not affected by the charges for examples by other times it fluctuates
 

Thread Starter

Goxeman

Joined Feb 28, 2017
176
I see. Thanks Ian0, you truly have in consideration all posibilities with their side effects.

For what I have tested so far, even if with an impedance of around 34K and a capacitor of 100nF I have enough sample rate. I will try to make a sample of my circuit and try it in the different environments I want to use it.
 

Ian0

Joined Aug 7, 2020
13,157
As an example - if someone connects an inverter to your battery, it will take a current that varies from nothing to twice the average over a 10ms cycle (for a 50Hz inverter), which will create 100Hz ripple on the battery voltage.
If you are going to read correctly what is happening, then either:
you must sample at more than 200 samples per second
OR
you must filter out the 100Hz ripple.
If you don't you will get aliasing, your readings won't make sense - they will show ripple at the wrong frequency. If you sample every 1.001 seconds (which could happen if you intend to sample once a second and your clock isn't quite accurate enough) then your readings will show the voltage varying over a 10 second cycle, when actually it is varying at 100Hz.

It depends on whether you want to know how much ripple voltage there is, or whether you are not bothered, and just want to know the average battery voltage.
 

Thread Starter

Goxeman

Joined Feb 28, 2017
176
Indeed the most troublesome application of the ones I considered is the solar batteries of 24V, I was also studiying filtering of the signals but I found out that more and more solar systems are using 48V instead of 24V which is out the scope of my project. I would rather rethink the whole project making a difference between a design for batteries for solar home use and the rest (machines and trucks/vans).
 

Ian0

Joined Aug 7, 2020
13,157
Indeed the most troublesome application of the ones I considered is the solar batteries of 24V, I was also studiying filtering of the signals but I found out that more and more solar systems are using 48V instead of 24V which is out the scope of my project. I would rather rethink the whole project making a difference between a design for batteries for solar home use and the rest (machines and trucks/vans).
48V is very popular for solar (which is why I know about the inverter ripple) Also, it's a standard fork-lift-truck battery. I sample it at 1600 samples/second, for no better reason than that was the rate I used on the first version, and it worked, and I've reused the software on every other version since.
 

Thread Starter

Goxeman

Joined Feb 28, 2017
176
48V is very popular for solar (which is why I know about the inverter ripple) Also, it's a standard fork-lift-truck battery. I sample it at 1600 samples/second, for no better reason than that was the rate I used on the first version, and it worked, and I've reused the software on every other version since.
Nice. I guess that you are only considering a smaller voltage range? Something between 40V and 55V
 

Ian0

Joined Aug 7, 2020
13,157
Nice. I guess that you are only considering a smaller voltage range? Something between 40V and 55V
A 48V battery needs to get to 65V on equalisation charge, so I measure 0-80V.
I divide it down so that it is 2V for 48V (so the ADC actually reads the voltage for 1 cell). It is a 14-bit ADC (previously I used a 12-bit, but that is just what the processor happened to have). There is no circuit protection except for the impedance of the divider and the processor protection diodes - the input has never failed, even if set to the wrong voltage and even if the resistor to ground has gone missing. On the other hand, I also use current transformer inputs, and have several different circuits all of which are slightly suboptimal and some manage to blow up the ADC input.

The readings are IIR filtered which increases resolution to 22 bits at the expense of bandwidth.

Where there is a possibility of different battery voltages, I use a switchable divider so that I can choose between 24V, 48V, 108V and 216V. The switchable divider is a 6-pin header with two movable links.
 
Last edited:
Top