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.

capacitive sense touch interfacing with MSP430

 

Hello folks,

I've six  capacitive sense touch keys to be interfaced with 6 pins of Port1, MSP430. On sensing key touch, the 430 should alert an interrupt. Detecting the interrupt flag as high, a pulse should be generated on the respective pin of Port2 (6 pins here again).

I wish to configure the MSP430, such that:

 

All the port pins of P1 should be alert towards the six keys at once. That is - rise in capacitance on any key should be detected - not by polling each key. This can't happen in software. So I would need to configure the 430 such that its internal hardware causes it to behave in parallel. How can this be done?

 

For interrupt generation, I first thought:

- Use external resistors for each pin of Port1 to form an RC circuit with each key. Let the circuit charge. Let Timer_A generate an interrupt when the charging time crosses a certain threshold; threshold because beyond this level, would mean "key pressed".

- But here again, there's only one Timer_A. So I could configure the 430 to respond to each pin at a time. That's not parallel.

 

And then, even though each pin of P1 can carry its own interrupt, the Interrupt Vector Table is common for all pins. So in case I want six different ISRs running for each key - because obviously each key would hold a different function - would that be possible with a simple switch case?

 

Thank you,

Krishna.

  • Hi Krishna,

    TI has an experimenter board dealing with capacitive buttons - the MSP-EXP430FG4618 (http://focus.ti.com/docs/toolsw/folders/print/msp-exp430fg4618.html) and also two application notes (http://focus.ti.com/mcu/docs/litabsmultiplefilelist.tsp?sectionId=96&tabId=1502&literatureNumber=slaa363a&docCategoryId=1&familyId=342 and http://focus.ti.com/mcu/docs/litabsmultiplefilelist.tsp?sectionId=96&tabId=1502&literatureNumber=slaa379&docCategoryId=1&familyId=342 ). Both cover the basics and have some software you can use as reference.

    You can use a switch/case for shure; something like:

    // Port1 interrupt service routine
    #pragma vector=PORT1_VECTOR
    __interrupt void vPort_1_ISR(void)
    {
      switch (P1IFG)       
      {
        case 1: break
        case 2: break;
        case 4: break;
        case 8: break;
     ...
      }
    }

    But it depends on your application; in most cases it is better to use global flags to distinguish between different states and keep the interrupt service routine short and fast.

    Rgds
    aBUGSworstnightmare

     

  • Hi Bugs,

    Thank you for the response. I'm currently using the experimenter's board you mentioned. I've previously gone through the links you provided. They talk about polling. They try to determine the corresponding key on which there was an increase in capacitance. But I do not want to determine that using software polling. How can I scan all the capacitive sense touch keys in parallel?

    You spoke about switch( P1IFG) enclosing case statements. But  how will the flag go high in the first place. MSP430 does not have capacitance sensors. So when the capacitance on a key increases, it is the RC charging/ discharging time on Timer_A that tells us that the key has possibly been pressed. When the time crosses a certain threshold, then it is confirmed that the key has been pressed, and thus an interrupt is generated. But here, I've only one Timer_A. And I must use the same Timer for determining the charging times for any of the 6 keys pressed. For this, I would have to connect all the port pins in an OR fashion(i.e. in parallel) to the Timer_A, so that a charge flow on any of them would start the timer count. Can that be done? Further, how do we know if the charge flowing is from key 1/2/...6. Without knowing that, how do I set off an ISR respective to each key_press.

    I've to know which key has been pressed in order to say:

    key_press detected on Port 1.1. Hence

         P1OUT |= BIT1;              /* Take the active key high to charge the pad */
        _NOP( ); _NOP( ); _NOP( );     /* Allow a short delay for the hard pull high to really charge the pad */
        P1IES |= BIT1;              /* Configure a port interrupt as the pin discharges */
        P1IE |= BIT1;
        P1DIR &= ~BIT1;
        timer_count = TAR; 
    /* Timer notes the time */

    But then, the whole point is, that it is only after activating the timer than we can know which key has been pressed. But the catch is, that in order to activate the timer, I've to know which key has been pressed.

    So even before approaching the timer, Port pins should be intelligent enough to know that the respective RC circuit connected to them is on charge. Looks like I would need capacitive sensors in the first place to rise a pulse on respective port pins if a rise in capacitance is detected. Then the timer could enter the scene later to determine if it is a valid key_press.

     

    Hope I was lucid,

    Krishna.

     

     

     

  • I don't know how it is done by the experimenters board. How is it done?

    I did it using the TimerB and its CCRx registers:

    TimerB is set up to generate a square wave output of a suitable frequency.
    With the raising edge, the output of TimerB will charge the touchpads through diodes (e.g. BAT42).
    All (up to 6) pads are connected to the input pins of TBCCR1..6.
    With the falling edge, the capacitors formed by the pads will start to discharge through the input resistance of the CCRx pins, finally triggering the capture event. On the next raising edge you can trigger an interrupt and read out the captured values and determine whether the capacitance has changed (capture value raised/lowered).
    With the proper software, this process will be self-adjusting to material tolerances, additional cover films, changes in humidity and temperature etc.

    You'll be even able to detect how 'quick' a pad has been pressed or whether it was a slide form one pad to the next. At elast in theory, I didn't write code for that (yet).

**Attention** This is a public forum