Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Using COMP to measure a capacitive sensor?

We have been using nRF52832 and nRF52840 processors in our board for a few years happily. Now we are evaluating a new type of sensor (confidential) that behaves like a variable capacitor. There are various solutions to measure a capacitor value, but all require external circuit. I'm trying to see if there is a way to use just the nRF52 (and a few passives) to do this. The PIC family of processors use a component called CTMU that can be used to accurately measure capacitors just using a known resistor.

In reading more, the CTMU is a current source and a comparator used to measure the capacitance. I was wondering if there's any way to use the COMP to measure a capacitance, using either a method similar to the CTMU or using it as an oscillator and measuring the frequency. But, while there are a lot of notes about capacitive sensing for buttons, I could not find anything on measuring capacitances.

Is this something that could be done? If so, any pointer to get started would be welcome (we are still using the nRF5 SDK, given our long codebase investment)

  • It's equivalent to a floating capacitor. Thanks for that link, I'll look into it ASAP

  • I like to do stuff like this for floating inputs, even when voltages on Csensor are outside rail-rail. Charge Cref, connect to  Csensor, connect to SAADC then measure voltage on Cref. Change of VCrefBeforeSample to VCrefAfterSample gives measurement. Repeat. Or if Csensor has a voltage and is not passive, discharge Cref, connect to Csensor then connect to SAADC and measure; this latter is useful for CCD or photodiodes (equivalent to capacitive sensors) which have a tiny signal voltage sitting on a large pedestal (aka offset) voltage.

    //                                       +--------------------------------------------------------------------+
    //                                       |                              nRF52832/nRF52840                     |
    //                      +------#---------0---< Switch o/p PWM or just toggle                                  |
    //                      |      |         |                                                                    |
    //                      |      |         |    VDD            VDD              VDD                             |
    //                      |      |         |   --#--          --#--            --#--                            |
    //                      |      |         |     |              |                |                              |
    //                      |      |         |     | Charge       |   Option       |   Option                     |
    //                      |      |         |     +-|   Drive    +-|   13k        +-|   160k                     |
    //                      |      |         |       |<- High       |<- Pullup       |<- High                     |
    //  Floating            |      |         |     +-|            +-|              +-|   Bias                     |
    //  Sensor              |      |         |     |              |                |                        SAADC |
    //     +--------/~/---0 | 0--------------O-----#--------------#----------------#------------#------#--> P0.nn |
    //     |               \'      |         |     | Discharge    |   Option       |   Option   |      |    Ref   |
    //     |                \      |         |     +-|   Drive    +-|   13k        +-|   160k  +++     |    Int   |
    //     |                0      |         |       |<- Low        |<- Pull         |<- Low   | |   -----        |
    //     |                |      |         |     +-|            +-|   Down       +-|   Bias  | |   -----        |
    //   -----            -----    |         |     |              |                |           +++     | 2.5pF    |
    //   -----            -----    |         |     |              |                |            |1M0   |          |
    //     | C              | Cref |         |   =====          =====            =====        =====  =====        |
    //     |                0      |         |    ===            ===              ===          ===    ===         |
    //     |                /      |         |     =              =                =            =      =          |
    //     |               /,      |         |                                                                    |
    //     +--------/~/---0 | 0--------------0-----+    <== Gnd or use 2nd SAADC Input                            |
    //                      |      |         |     |                                                              |
    //                      |      |         |   =====                                                            |
    //                      +------+         |    ===                                                             |
    //                                       |     =                                                              |
    //                                       +--------------------------------------------------------------------+
    // SPDT Switch, select one with single-supply and negative input voltage capability
    //  https://www.analog.com/media/en/technical-documentation/data-sheets/max4762-max4765.pdf
    

    Best to use SPDT Switch, select one with break-before-make, single-supply and negative input voltage or "outside rail-rail" capability
      eg max4762-max4765.pdf

    'nother edit: this link might be useful, I gave some more background an working with a capacitive sensor of a few pF slower-sampling-for-saadc

Related