Electronic – arduino – RC circuit: C appears to increase in size with frequency

arduinocapacitor

I've come up with an RC circuit, which is using the output pins of a NodeMCU board to create an AC current for measuring conductivity of a liquid.

What I'm actually measuring is the discharge time of the capacitor, and that's what this question is about. At low frequencies (1-2 kHz) the measured time is exactly as expected based on the capacitance of 47 nF, knowing that the input pin flips when the voltage reaches 50%. That's the time I'm measuring: from fully charged to 50%.

Now at higher frequencies (by lowering the value of the load resistor) the capacitor appears to go up in size, at 120R I'm getting discharge times of around 7200 nanoseconds, that gives me a capacitance of about 120 nF.

How could this be possible?

Other possibly relevant information: the capacitor appears to be a film type (it's a rectangular block); the whole setup is operating on a solderless breadboard (I know there may be stray capacitance in there but that doesn't matter here – I don't care as much about the actual value of the cap as I care about it being constant).

J1 is three GPIO pins of the NodeMCU. The EC probe I replaced by resistors of various value just to measure the response, which I expect to be linear. C1 is first fully charged by the pins 1 and 2 (it gets 100 microseconds for that, RC is just over 15 microseconds), then discharged over pin 3 while pin 1 measures the voltage, flipping when the voltage drops below 50%. All in all a very basic RC circuit. I expect that lowering the value of the resistor over J2 decreases the time linearly – but it doesn't.

At 33k discharge time about 800 us, R/t/0.5 = 48 nF.

At 10k discharge time about 235 us, R/t/0.5 = 47 nF.

At 330R discharge time about 12 us, R/t/0.5 = 73 nF.

At 120R discharge time about 7 us, R/t/0.5 = 120 nF.

My timing is in the 12.5 ns resolution (80 MHz clock speed) so that's not the problem. Being a few ticks off doesn't explain this.

enter image description here

Best Answer

Now at higher frequencies (by lowering the value of the load resistor) the capacitor appears to go up in size.

Your IO pin that drives the resistor isn't capable of supplying tens of mA current whilst maintaining an output voltage at Vcc. Basically, it's output resistance is in series with R1 hence, the lower you make R1 the more of a problem it becomes.