cancel
Showing results for 
Search instead for 
Did you mean: 

Need support for promoting STM32L4 in Capacitive touch sensing applications

VK Verma
Senior

Posted on July 02, 2018 at 12:49

Hi Friends !

As discussed in my earlier post we have developed 44 Keys capacitive touch key pad with 4 layer PCB board in Matrix touch scheme between two touch TSC groups with Layer 1= top Digital track, Layer 2= shield and touch track, Layer 3= shield and Layer 4 = touch and digital track, based on STM32L452VET6 100 Pin LQFP package using TSC Peripheral and STM touch middle ware.

Although we are using these Touch IPs very frequently and successfully in Non Matrix touch scheme but this is first we have used it in this format to meet the customer requirement for 44 Nos of keys. I have attached Picture of top and bottom of the PCB for your kind reference.

We are facing calibration issues as keys are non sensitive when applied overlay of 1mm of acrylic. We have applied capacitors of upto 68nf but there is no change in the delta and no touch detected.

But without overlay there is the touch detection but poor calibration and response below is the screen shot for the same.

  

  1. Screenshot of STM Studio for both cases

           When in Ideal State

0690X0000060C8LQAU.pngWhen a key is pressed without overlay

0690X0000060C8bQAE.pngKindly advice how to calibrate it by increasing touch sensitivity.

Thanks and Best Regards,

VK Verma

st.mcu

‌

Majerle.Tilen.001

6 REPLIES 6
Amel NASRI
ST Employee
Posted on July 04, 2018 at 18:00

Hi

Verma.V.K

,

First, I would like to know if you have already reviewed the application note

https://www.st.com/content/ccc/resource/technical/document/application_note/19/12/dd/6b/8e/d2/49/fb/CD00276277.pdf/files/CD00276277.pdf/jcr:content/translations/en.CD00276277.pdf

: Guidelines to increase the number of touch sensing touchkeys?

When using matrix, please note that:

  • Touching one touchkey may induce sufficient capacitance change on other channels
  • Special care must be taken to avoid
    • Imbalanced electrodes
    • Columns and lines electrodes tracks too close in the user touchable area

It is recommended to have homogenous sized touchkeys so that each touchkey has the same sensitivity.

This simplifies the threshold setup and acquisition can be achieved using the same sampling capacitor value.

In all cases, you have to pay attention to &39ghost effect&39 as described in the application note.

Then, in order to increase touch sensitivity, please take into consideration the following:

  • Reduce air-gapâ€� between pcb and overlay
  • Decrease Rs (Sensor serial resistor)
  • Increase CTH and CTL values
    • htsc.Init.CTPulseHighLength = TSC_CTPH_16CYCLES
    • htsc.Init.CTPulseLowLength = TSC_CTPL_16CYCLES
  • Set Max Count value to 16383
    • htsc.Init.MaxCountValue = TSC_MCV_16383
  • Increase HCLK and set PulseGenerator Prescaler to 1 or 2:
    • htsc.Init.PulseGeneratorPrescaler = TSC_PG_PRESC_DIV1

I hope this bring you some help.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Posted on July 05, 2018 at 07:54

I have not made a touch board before, but Ive been working on one last week.

there should be no surface mount parts on the touch side, to reduce air spaces

I think this is your answer:

  Reduce air-gapâ€� between pcb and overlay   thanks

st.mcu

can you pour some thin goop between the PCB and the 1mm of acrylic ?. and be sure to remove all air bubbles

this will remove all airspaces and increase the sensing range.

It may actually work better with a thicker acrylic/goop.

maryam magdy
Associate II

@Amel NASRI​  @VK Verma​  Hi can you please help me with my TSC on nucleo stm32l432kc. I'm still trying to implement a simple touch key. I'm using this code: [https://github.com/Rayling35/STM32Cube_FW_L4_V1.12.0/blob/master/Projects/STM32L476G-EVAL/Examples/TSC/TSC_BasicAcquisition_Interrupt/Src/main.c] but it stops at step #-6- "Check if the acquisition is correct (no max count) "

if (HAL_TSC_GroupGetStatus(&TscHandle, TSC_GROUP1_IDX) == TSC_GROUP_COMPLETED)

The above If condition is never true and thus the acquisition is never completed. Any idea what could be wrong?

T J
Lead

Hi,

I use this to initialise my set:

void initTSC(void){
   
                    htsc.Init.ChannelIOs = TSC_GROUP1_IO3 | TSC_GROUP2_IO3 | TSC_GROUP3_IO3 |                  TSC_GROUP5_IO3 | TSC_GROUP6_IO3 | TSC_GROUP7_IO3 | TSC_GROUP8_IO3;
                    htsc.Init.SamplingIOs =  TSC_GROUP1_IO4 | TSC_GROUP2_IO4 | TSC_GROUP3_IO4 | TSC_GROUP4_IO2
                                            | TSC_GROUP5_IO4 | TSC_GROUP6_IO4 | TSC_GROUP7_IO4 | TSC_GROUP8_IO4;
                        
          
                    htsc.Init.ShieldIOs = TSC_GROUP4_IO1;
                    /* Disable Schmitt trigger hysteresis on all used TSC IOs */
                    htsc.Instance->IOHCR = 0;  // (uint32_t)(~(htsc.Init.ChannelIOs | htsc.Init.ShieldIOs | htsc.Init.SamplingIOs));
                    /* Set channel and shield IOs */
                    htsc.Instance->IOCCR = (htsc.Init.ChannelIOs | htsc.Init.ShieldIOs);  
                    /* Set sampling IOs */
                    htsc.Instance->IOSCR = htsc.Init.SamplingIOs;  
                    /* Set the groups to be acquired */
                    htsc.Instance->IOGCSR = TSC_extract_groups(htsc.Init.ChannelIOs);
                    /* Clear interrupts */
//                    htsc.Instance->IER &= (uint32_t)(~(TSC_IT_EOA | TSC_IT_MCE));  
                    /* Clear flags */
                    htsc.Instance->ICR = (TSC_FLAG_EOA | TSC_FLAG_MCE);
                    //HAL_StatusTypeDef TSCIntError = HAL_TSC_Start_IT(&htsc);  //HAL_TSC_Start(&htsc);   
                    reStartTSC = true;
 
    
    
}

I have a worker thread running every mSecond:

    if(mSint) {
        mSint = false;
 
        static char startTSC = false; 
        if (reStartTSC)
        {
            reStartTSC++;
            if (reStartTSC > 25)      //repeats every 25mS
                {
                    reStartTSC = false;
                    HAL_StatusTypeDef x = HAL_TSC_Start_IT(&htsc);                   // process min/max within interrupt.
                }
        }
        

and this is the interrupt process

void HAL_TSC_ConvCpltCallback(TSC_HandleTypeDef* htsc)  {
    TSCCvtFlag = true;
    
    /* Clear interrupt flags */
    htsc->Instance->ICR = (TSC_FLAG_EOA | TSC_FLAG_MCE);
               
    {
        //save Counters.
                
        uint32_t * registerPtr = htsc->Instance->IOGXCR;         //__IO uint32_t IOGXCR[8];    // TSC
        for (int i = 0; i < 8; i++)
            TouchTable[i] =  (int16_t)(* registerPtr++);
    

maryam magdy
Associate II

@Community member​  Thanks for the code. Which board are you using? And for the code, can you tell me how did you define mSint and reStartTSC and TouchTable. I would like to see the complete code with the main method please.

T J
Lead

int16_t TouchTable[3][8]; // 3 groups of 8 sensors

uint8_t reStartTSC;

char mSint; //mS flag

uint16_t mS; // mSecond counter

// initialisation ///////////

void HAL_SYSTICK_Callback(void) {

   //   SysTick_Handler_Flag = true;

   mS++; // my 1000mS counter

   mSint = true;

   if (mS == 1000) {

       secondInt = true;

       mS = 0;

   }

}

hope it helps,