Capacitance measurement circuit using STM32

Thread Starter

kunal burman

Joined Nov 2, 2018
13
Hello,
I want to design Capacitance measurement circuit from 1 nF to few farads and resistance 2 wire measurement (40 MOhm)?
Please can anyone guide me!
Kind Regards
 

MrChips

Joined Oct 2, 2009
26,797
What is the capacitance range and accuracy/resolution you want to measure?
What technique are you planning on using?

I can measure capacitance with a single GP I/O digital pin. No ADC required.
 

Thread Starter

kunal burman

Joined Nov 2, 2018
13
Hello, i want to measure Capacitances from pF to few farads. Accuracy should be like within 5 %. I have just used till now with RC circuits. My main Controller is STM32L476.
Can you share your model for measuring Capacitances?
 

MrChips

Joined Oct 2, 2009
26,797
Hello, i want to measure Capacitances from pF to few farads. Accuracy should be like within 5 %. I have just used till now with RC circuits. My main Controller is STM32L476.
Can you share your model for measuring Capacitances?
I put the capacitor under test between a GPIO pin and ground. Then I put a resistor R across the capacitor.

1) Set the GPIO pin to output and send high to charge the capacitor.
2) Set the GPIO pin to input and allow the capacitor to discharge.
3) Trigger an interrupt on the falling transition.
4) Repeat the process.
5) Measure the time it takes for N such cycles to take place, using a timer module. Select N to suit the range and resolution required.
6) Convert to capacitance.
 

Thread Starter

kunal burman

Joined Nov 2, 2018
13
I put the capacitor under test between a GPIO pin and ground. Then I put a resistor R across the capacitor.

1) Set the GPIO pin to output and send high to charge the capacitor.
2) Set the GPIO pin to input and allow the capacitor to discharge.
3) Trigger an interrupt on the falling transition.
4) Repeat the process.
5) Measure the time it takes for N such cycles to take place, using a timer module. Select N to suit the range and resolution required.
6) Convert to capacitance.
Hello, thank you for the information. Please can you tell me the measurement ranges for Capacitance that you can measure and resistor vale that you have used?
 

MrChips

Joined Oct 2, 2009
26,797
For low capacitance measurements you want the resistor to be as high as possible, but no higher than 1/10 of the input resistance of the GPIO port. Try 100kΩ for starters.

10pF // 100kΩ has a time constant of 1μs. The STM32 is fast enough to handle this.

100μF // 100kΩ has a time constant of 10s, i.e. it would take at least 10 seconds to get a reasonable measurement.
For larger values of capacitance you may want to reduce the value of the resistor to 10kΩ or 1kΩ.
 

Thread Starter

kunal burman

Joined Nov 2, 2018
13
For low capacitance measurements you want the resistor to be as high as possible, but no higher than 1/10 of the input resistance of the GPIO port. Try 100kΩ for starters.

10pF // 100kΩ has a time constant of 1μs. The STM32 is fast enough to handle this.

100μF // 100kΩ has a time constant of 10s, i.e. it would take at least 10 seconds to get a reasonable measurement.
For larger values of capacitance you may want to reduce the value of the resistor to 10kΩ or 1kΩ.
Hello, thank you once again, I wanted to know if I use 1 Megaohm then will it work ? and how to calculate time constant?
 
Top