This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR2633: Conversion of capacitance into counts

Part Number: MSP430FR2633
Other Parts Discussed in Thread: CAPTIVATE-PGMR

Hi,

I am trying to figure out what formula does the MSP430FR2633 controller follow to convert capacitance into counts. I read at another post that this controller is particularly good at sensing change in capacitance. So, how can I calculate analytically the conversion of delta in capacitance to delta in counts? What I am trying to do is create a script that will automate the calculation of the conversion count and conversion gain, providing as input the relative change in capacitance before and after touch, and the targeted sensitivity. I do take into consideration parasitic capacitance from traces as well.

Thank you in advance,

Giannis

  • Hello Giannis,

    There isn't a given formula that describes capacitance vs. conversion counts. The CapTIvate peripheral measures relative changes in capacitance without knowing what the baseline capacitance is and expresses the change in capacitance as the measured delta.
    I can provide you with additional information but I want to understand why you need a script for calculating the conversion count and gain parameters. Knowing more about what you are trying to do will help me provide you with the right information.
  • Hi Dennis,

    Thank you for your reply.

    In our team, we can compute via simulation the capacitance change (ΔC) when a finger hovers over a touch sensor. This ΔC is quite different depending on the actual placement of the finger over specific areas of the layout of the sensor (central area or near the edges). As a result, different capacitance change is observed. This change may be on the order of 0.1 - 1% (edges vs central). So, depending on the sensitivity we need to achieve, we can configure the controller with different setups.

    A somehow similar reasoning applies for the case of proximity sensors as well.

    What we are trying to do, is automate - as best as possibly of course - the process of calculating the conversion count and conversion gain parameters, given a targeted sensitivity and response time. So, we think that a formula that describes the conversion of ΔC into counts would be extremely useful. Or whatever additional information you think would be suitable.

    Hope these help, but I can follow up as well.

    Thank you in advance,
    Giannis
  • Hi Giannis,

    Yes, this helps. Let me see what I can come up with for you.
  • Hi Giannis,

    I have some information that should be what you are looking for.

    First, please refer to application report SLAA843, Sensitivity, SNR, and design margin in capacitive touch applications.

    In this document, take a look at page 7.  There is a formula that illustrates percent change in capacitance based on the conversion_gain, conversion_count and the delta count.  For what you are trying to do, there is a quadratic equation that will allow you to calculate the conversion_gain or conversion_count for a given delta and given percent change in capacitance. To simplify this for you I have attached a spreadsheet that performs these calculations for you and describes the formulas.

    Next, I want to point your attention to table 4 on page 13.  Since you are looking at very small changes in capacitance (< 1%) you must consider that with very high sensitivities, the measured %change can be at or near the noise floor of the device, which will contribute an error.  I would recommend that you read through this section to understand the limitations.

    Also, I would like to point out that if this is critical for your application or study, I would recommend using the MSP43FR2676 (second Gen) device.

    Let me know if this helps.

    CapTIvate_PredictNeededConversionCount.xlsx

  • Hello Dennis,

    Thank you very much for your response.

    Let me describe what we did. We used the MSP CapTIvate MCU Development Kit (www.ti.com/.../MSP-CAPT-FR2633) for a quick experiment. We set up 900 as conversion count and 600 as conversion gain. We measured the reference capacitor of 1.0pF. (We got LTA = 852.) 

    Using the same conversion count and gain, we measured the reference capacitor of 1.1pF. We got 847 counts. Therefore, by following the formula of the spreadsheet, ΔCx = 4.17%. However, the actual relative difference in the capacitance is 10%. What mistake do we make?

    Thank you in advance,

    Giannis

  • Hello Giannis,
    what are the tolerances of your reference capacitors and what the reference capacitor to junction capacitance value could be?
  • Hi Tom,

    Yes, you did answer my initial question! Thank you very much!

    However, we went one step further and moved on to apply the formulas that you provided. And that's where I have a next question. So, should I move on in this topic, or mark it as resolved and create a new one? Please advise.

    To answer your question, I don't know what the tolerance of the capacitors is, nor the junction capacitance value. We just used the internal reference capacitors of the controller and tried to apply the formulas you provided.

    Best,
    Giannis
  • Hi Giannis,

    My suggestion would be to set the convertion_gain to 100 and perform test over and let me know what you get.
  • Hi Dennis,

    For conversion_gain=100 the LTA was 857 (1 pF enabled) and we get 824 counts with the "touch" (1.5 pF enabled).

    Konstantinos

  • Something not right here.
    Let me run this by the team for comments.
  • Hello Konstantinos,

    I setup an experiment with the MSP430FR2633 EVM kit (CAPTIVATE-PGMR + MSP430FR2633 MCU PCB only) and did the following:

    1. created a single self capacitive button in the Captivate design center using channel CAP0.0.
    2. imported and programmed the MCU.
    3. set conversion_gain = 100, conversion_count = 500.
    4. in real time I see LTA = Conversion Count = 492.
    5. connect 1pf capacitor to CAP0.0
    6. Conversion Count drops to 277.
    7. Using the formula provided I calculate a 16% change.

    Formula: ((conversion_gain/count)-(conversion_gain/conversion_count))
    conversion_gain = 100
    Conversion Count = 492
    count = 277 (this is the actual reported count).

    Now this tells me that when I added 1pf to the baseline capacitance of the MCU + traces + connector (which is unknown at this point) I see a 16% change. I can now back calculate what the baseline capacitance is:
    (Where Cx = unknown or baseline capacitance)

    1.16 = (Cx + 1pf)/Cx
    1.16Cx = Cx + 1pF
    1.16Cx - Cx = 1pF
    Cx(1.16-1) = 1pF
    Cx(0.16) = 1pF
    Cx = 1pF/0.16
    Cx = 6.25pF

    Now that we know what the baseline circuit capacitance is I add a 1.5pf capacitor and repeat the same measurements.
    This time I see:
    count = 230.
    Doing the calculation tells me there is a 23% change.
    Knowing that Cx = 6.25pF then (6.25 + 1.5)/6.25 = 1.24 or 24% change.

    Next I change the conversion_gain = 200 and repeat the same measurements and calculations and get 16% with 1pf and 24% with 1.5pF.

    Now I set my conversion_gain back to 100 and change the conversion_count from 500 to 300 and repeat.
    I get the same results.

    This time I'll bump the conversion_gain way up to 800 and repeat.
    Once again I get essentially the same values.

    See if you can duplicate what I have done.
  • Hello Dennis,

    Thank you, your answer was very enlightening.

    I will try to duplicate what you describe. 

    I have a question: The known capacitors that you used (1pF and 1.5pF) , are the reference capacitors of the CapTIvate peripheral ?

    Konstantinos

  • Exactly.

    I attached my code.  Should give you some idea how to setup and use the internal ref caps.

    7318.main.c
    /* --COPYRIGHT--,BSD
     * Copyright (c) 2017, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     * --/COPYRIGHT--*/
    //*****************************************************************************
    // Development main.c for MSP430FR2633, MSP430FR2533, MSP430FR2632, and
    // MSP430FR2532.
    //
    // This starter application initializes the CapTIvate touch library
    // for the touch panel specified by CAPT_UserConfig.c/.h via a call to
    // CAPT_appStart(), which initializes and calibrates all sensors in the
    // application, and starts the CapTIvate interval timer.
    //
    // Then, the capacitive touch interface is driven by calling the CapTIvate
    // application handler, CAPT_appHandler().  The application handler manages
    // whether the user interface (UI) is running in full active scan mode, or
    // in a low-power wake-on-proximity mode.
    //
    // The CapTIvate application handler will return true if proximity was
    // detected on any of the sensors in the application, which is used here
    // to control the state of LED2. LED1 is set while the background loop enters
    // the handler, and is cleared when the background loop leaves the handler.
    //
    // \version 1.80.00.30
    // Released on March 26, 2019
    //
    //*****************************************************************************
    
    #include <msp430.h>                      // Generic MSP430 Device Include
    #include "driverlib.h"                   // MSPWare Driver Library
    #include "captivate.h"                   // CapTIvate Touch Software Library
    #include "CAPT_App.h"                    // CapTIvate Application Code
    #include "CAPT_BSP.h"                    // CapTIvate EVM Board Support Package
    
    volatile uint16_t raw;
    uint16_t* pRaw;
    volatile uint16_t rawRefCap;
    
    void CAPT_updateSensor_withRefCap(tSensor *pSensor, uint8_t ui8LPM, uint8_t ui8RefCap);
    extern tElement BTN00_E00;
    
    void main(void)
    {
    
    	//
    	// Initialize the MCU
    	// BSP_configureMCU() sets up the device IO and clocking
    	// The global interrupt enable is set to allow peripherals
    	// to wake the MCU.
    	//
    	WDTCTL = WDTPW | WDTHOLD;
    	BSP_configureMCU();
    	__bis_SR_register(GIE);
    
    	//
    	// Start the CapTIvate application
    	//
        CAPT_initUI(&g_uiApp);
    
        CAPT_calibrateUI(&g_uiApp);
    
    	CAPT_updateSensor(&BTN00, g_uiApp.ui8AppLPM);
    	raw = BTN00_E00.pRawCount[0];
    
    	CAPT_updateSensor_withRefCap(&BTN00, g_uiApp.ui8AppLPM,CAPT_REFERENCE_CAP__SELF_1P0PF);
    	rawRefCap = BTN00_E00.pRawCount[0];
    
    	while(1);
    
    } // End main()
    
    void CAPT_updateSensor_withRefCap(tSensor *pSensor, uint8_t ui8LPM, uint8_t ui8RefCap)
    {
        uint8_t ui8Cycle = 0;
        uint8_t ui8SavedCntFilter;
    
        pSensor->bSensorUpdating = true;
    
        //
        // If count filter is disabled,
        // context save the current filter then
        // set to zero to workaround ROM fxn neglecting
        // the status of the enable bit
        //
        if (pSensor->bCountFilterEnable == false)
        {
            ui8SavedCntFilter = pSensor->ui8CntBeta;
            pSensor->ui8CntBeta = 0;
        }
    
        //
        // Load sensor parameters
        //
        MAP_CAPT_applySensorParams(pSensor);
        MAP_CAPT_applySensorFreq(CAPT_OSC_FREQ_DEFAULT,pSensor);
    
        //
        // Load first cycle and start the conversion
        //
        //A0272918
        MAP_CAPT_enableRefCap(pSensor->pCycle[ui8Cycle]->pElements[0], ui8RefCap);
    
        MAP_CAPT_loadCycle(pSensor, ui8Cycle, CAPT_OSC_FREQ_DEFAULT, true);
        MAP_CAPT_startConversion(&g_bEndOfConversionFlag);
    
        for(ui8Cycle=1; ui8Cycle < pSensor->ui8NrOfCycles;ui8Cycle++)
        {
            //
            // Wait for conversion to complete, then unload the previous cycle
            //
            MAP_CAPT_blockOnFlag(&g_bEndOfConversionFlag, ui8LPM);
            MAP_CAPT_unloadCycle(pSensor, ui8Cycle-1, 0, true);
    
            //A0272918
            MAP_CAPT_disableRefCap();
    
            //
            // Load next cycle and start the conversion
            //
            MAP_CAPT_loadCycle(pSensor, ui8Cycle, CAPT_OSC_FREQ_16MHZ, true);
            //A0272918
            MAP_CAPT_enableRefCap(pSensor->pCycle[ui8Cycle]->pElements[0], ui8RefCap);
    
            MAP_CAPT_startConversion(&g_bEndOfConversionFlag);
    
            //
            // Process previous cycle results
            //
            CAPT_processFSMCycle(pSensor,(tCycle *)pSensor->pCycle[ui8Cycle-1]);
        }
    
        //
        // Wait for conversion to complete, then unload the previous cycle
        //
        MAP_CAPT_blockOnFlag(&g_bEndOfConversionFlag, ui8LPM);
        MAP_CAPT_unloadCycle(pSensor, ui8Cycle-1, 0, true);
    
        //A0272918
        MAP_CAPT_disableRefCap();
    
        //
        // Cleanup
        //
        MAP_CAPT_cleanupAfterConversion();
    
        //
        // Process last Cycle
        //
        CAPT_processFSMCycle(pSensor,(tCycle *)pSensor->pCycle[ui8Cycle-1]);
    
        //
        // Process the sensor
        //
        CAPT_processSensor(pSensor);
        if (pSensor->pvCallback != NULL)
        {
            pSensor->pvCallback(pSensor);
        }
    
        //
        // Restore saved count filter for ROM fxn workaround
        //
        if (pSensor->bCountFilterEnable == false)
        {
            pSensor->ui8CntBeta = ui8SavedCntFilter;
        }
    
        pSensor->bSensorUpdating = false;
    }
    

  • Hi Konstantinos,

    I was curious if you are making progress.

  • Hi Dennis,

    Thanks for your quick response.

    I will do the experiment on Monday and I'll get back to you as soon as I am done.

    Konstantinos

  • Hi Konstantinos,

    I haven’t heard from you for a couple of days now, so I’m assuming you were able to get everything working the way you wanted.
    If this isn’t the case, please click the "This did NOT resolve my issue" button and reply to this thread with more information.
    If this thread locks, please click the "Ask a related question" button and in the new thread describe the current status of your issue and any additional details you may have to assist us in helping to solve your issues.

  • Hello Dennis,

    I am sorry for the delay, but in the last week I didn't have much time to replicate your suggestions. 
    I am on it this week and I'll post my findings as soon as I am done.

    Konstantinos

  • Hi Dennis,

    I’ve tested the procedure you recommended and everything is working as expected.

    e.g. for conv_count = 500 and conv_gain = 100 I measure 493 for the LTA and when I connect the 1pF ref cap the counts drop at 274 resulting in 16.2% change and 6.2 pF baseline capacitance. Likewise, for the sets of values 500-200, 600-100 and 600-200 I get essentially the same percentage change.

    Thanks a lot for your guidance.

    Konstantinos

**Attention** This is a public forum