This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF52 Csense_drv capacitance calculation.

Hello,

I have a question on how to calculate the capacitance based on oscillator relaxation for NRF52. For example, in the Csense_drv example, when pin is touched by finger, it generates digits (e.g. 850). My question is how I can calculate the capacitance based on the digits (here 850). Please excuse me if this is a duplicated question. I searched the forum but didn't find answer.

Thank you, -Lei

  • Hello Lei

    The relaxation oscillator functionality of the Csense driver is dependent on the use of the comparator, however due to anomaly 84 as listed in the nRF52832 errata the use of the comparator as a relaxation oscillator is not recommended as it is too unstable. If you still want to use it you can find the equation used to calculate the capacitance here. Because of this you will need to use the SAADC instead (the example is configured for this). The example sets an output pin high to charge the pad. After a timer runs out the pin is set low and SAADC sampling is started. The value it generates is dependent on the discharge time of the pad, which again is dependent on the capacitor value.

    In a RC network, the charge/discharge time of the capacitor is dependent on two things, the capacitance and the resistor limiting current flow to the capacitor. The time it takes to fully discharge the capacitor is roughly 5 tau (Rule of thumb), where tau (the time-constant of the RC network) is R*C.

    In this case there is no physical resistor, instead the current is affected by the GPIO output driver. Since the output driver does not present a constant resistance, calculating the actual capacitance from the SAADC value is not straightforward. Typically, one would not really care too much about calculating the actual capacitance value in capacitive sensing.

    I would recommend you perform controlled tests with a prototype of your pads, using a controlled signal generator and an oscilloscope. The layout of your pads would need to be as close to the actual implementation as possible. You can then find the capacitance for different situations (touching, not touching etc.), and then redo the experiment with the nRF and see what ADC values you get for the different capacitances.

    Best regards

    Jørn Frøysa

  • Hi Jorn,

    Thanks for the detailed explanation. If I want to connect a capacitive sensor, it is better to either use SAADC (but need to be firstly verified experimentally) or convert the capacitance to voltage before connecting to N52832 and then measure the voltage. Thanks, -Lei

Related