Component tester : Capacitor
The charge curve of a capacitor is
Vc=Vcc*(1-exp(-t/RC))
The idea is to charge the capacitor up to ~ 70% and look how much time it took
The formula is then inverted to :
C= -t/R*(ln(1-ADC/4095)
The problem is C can go from 1pF to 400 uF, that's a 400000000 factor
So what we will do is charge up to 10% using the 20 k resistor and lookup how much time it took
Depending on the result, we'll select the right resistance and do it again.
That initial sampling does not need to be accurate, it's just to select the right resistor.
The idea is we aim at a charge time of ~ 200 ms so the errors are neglectable.
For mid values and high values capacitor that works fine (C above ~200 pF or so)
We poll the ADC with slow sampling period until we get over ~ 70% and compute the capacitance value from there. It does not need to be exactly 70% since we have the matching ADC value.
The limit is here is the sampling period is a few us, which is fine if R*C is big compared to 1us.
For low value cap, R*C is not that big, so we take the higher resistance AND use a fast ADC (1us) so that the error is not too big. The accuracy will be worse, but at least the measurement error is not big from the start.
Right ?
Does not work.
Why is that ?
Because the ADC has a internal parasitic capacitance that depends on its setting.
With slow ADC, the parasitic capacitance is ~ 1 pF or so, which is very small compared to the cap range.
With fast ADC (1us), the parasitic capacitance is ~10 pF (estimated).
Vc=Vcc*(1-exp(-t/RC))
The idea is to charge the capacitor up to ~ 70% and look how much time it took
The formula is then inverted to :
C= -t/R*(ln(1-ADC/4095)
The problem is C can go from 1pF to 400 uF, that's a 400000000 factor
So what we will do is charge up to 10% using the 20 k resistor and lookup how much time it took
Depending on the result, we'll select the right resistance and do it again.
That initial sampling does not need to be accurate, it's just to select the right resistor.
The idea is we aim at a charge time of ~ 200 ms so the errors are neglectable.
For mid values and high values capacitor that works fine (C above ~200 pF or so)
We poll the ADC with slow sampling period until we get over ~ 70% and compute the capacitance value from there. It does not need to be exactly 70% since we have the matching ADC value.
The limit is here is the sampling period is a few us, which is fine if R*C is big compared to 1us.
For low value cap, R*C is not that big, so we take the higher resistance AND use a fast ADC (1us) so that the error is not too big. The accuracy will be worse, but at least the measurement error is not big from the start.
Right ?
Does not work.
Why is that ?
Because the ADC has a internal parasitic capacitance that depends on its setting.
With slow ADC, the parasitic capacitance is ~ 1 pF or so, which is very small compared to the cap range.
With fast ADC (1us), the parasitic capacitance is ~10 pF (estimated).
- It is in the same range as what we want to measure
- It actually acts as a voltage divider, and will prevent the cap to fully charge, breaking the computation.
i.e. if the parasitic cap is 10pf and the actual cap is 10pF, after a while the actual cap will be charged at VCC/2. So we'll never reach 70%.
So for the moment, we'll just keep a mediumly fast ADC and average over N value
The result is not that bad. We'll need to get back later on that.
Do you discharge the capacitor before/after measuring?
ReplyDeleteDoes it makes sense to measure the discharge instead of the charge?
Any protection against pre-charged capacitors?
1- Yes, both before and after
ReplyDelete2- It should be the same , apart that you'll have to wait to fully charge it beforehand. It can take a lot of times for big cap (~ 5 sec for 400 us cap)
3- Not really, only the discharge resistor (400 Ohm) to cap the current