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.

Need help with Cap touch button on msp430f2618

hi,

can anyone point me in the right direction on how to use cap touch button with the msp430f2618. have worked with the msp430g2553 before but it had cap touch enabled i/o so im  a little lost.

  • Manjit Singh said:
    how to use cap touch button with the msp430f2618

    There are two ways. Eitehr you simulate the oscillation circuit of the G sereis cap-touch support externally (You'll need an inverter, a resistor, and connect the inverter output through a multiplexer into the timer external clock input), or you use a completely different charge/discharge approach.
    My own CapTouch on the 5438 works with TimerB. CCR0 is used in compare mode with toggle output mode to output a square wave with a (programmable) frequency. The timer itself runs in up mode.
    Teh CCR0 output charges the touch pads through a schottky diode (one diode per pad). The pads are connected to TBCCRx inputs in capture mode. So the high cycle of CCR0 charges the pads, Next cycle, the low output stops charging (but does not discharge them immediately because of the diodes). So they discharge through leakage, eventually triggering the 'falling edge' interrupt of the capture units. Then the time required to discharge can be read. The higher the count, the larger the capacitance of the pad and the closer the thumb to the pad.

    Works for up to 6 pads simultaneously with one TImerB7. (TimerA works too, but has usually less CCRs)

  • Hi,

    Thx for replying.

    For my project i will need 4 buttons so il try to use the same method with timer_b.
    i'ts a very intresting way of doing it.
    i will try to do a simple blink led the way you discibed.

    could you be kind and supply me with a demo code just on how to implement the function?

    regards

  • Manjit Singh said:
    could you be kind and supply me with a demo code just on how to implement the function?

    This is part of the code I wrote for my employer, so I'm sorry, but I cannot post it. (there's almost no MSP-related code form me that doesn't belong to my company)

  • ok, im trying it right now and getting a change in the square wave on touch the pad, but only when i touch it not on proximity.
    also i'm not quite sure on how to interupt on the compare  like you discribed. and at what frequency have you set on the timer? becuse when i set the freq to 50 khz my square only gets smaller on touch.

    regards

  • Manjit Singh said:
    ok, im trying it right now and getting a change in the square wave on touch the pad, but only when i touch it not on proximity.

    A touch will turn the capacitor into a resistive load. You must ensure that there is at least a small insulating layer between the pad and the finger.

    There might be a hardware problem. I used BAT42 diodes. Schottky. Not every diode is suitable (large or too small leakage, large voltage drop etc.). Check polarity. The anode goes to the CCR0 output, the (usually marked) kathode to the pads.

    For my own experients, I started with a piece of insulated wire instead of a pad. Last time I used it, the timer was running on 16MHz with a cycle count of 2000. So charge and detection cycle were 125µs each.

    The compare interurpt is enabled by setting CCIE bit in TBCCTL0. It will trigger a TIMER_B0_VECTOR interrupt each time the timer reaches the value in TBCCR0. On every second call, there is a new value in each TBCCRx register.
    The output mode to use is OUTMOD_4 (toggle).
    The timer runs in up mode, clocked by whatever clock speed you have.The higher the clock speed, the higher the resolution of the measured discharge time. However, the cycle time, which is controlled by the value in TBCCR0, depends on the application (size of the pads, surrounding GND traces or - bad thing - a GND layer below.

    The individual CCR registers are set for CM_NEG, CAP and the proper input pin (e.g. CCIS_CCIA). and of course need the pins to be configured for module usage.

**Attention** This is a public forum