16
Application Report SWRA362B – June 2011 – Revised December 2014 RemoTI™ Capacitive Touch Sensing ............................................................................................................. Low-Power Wireless Products ABSTRACT As consumers become accustomed to elegant touch interfaces on a variety of devices, these capabilities are becoming more expected on a greater number of devices. The CC253x devices used in RF4CE applications provide hardware support for Capacitive Touch Sensing (Capacitive Sensing), and enable RF4CE manufacturers to design a wider range of devices with Capacitive Sensing capabilities using a cost-effective approach. This application report provides information about how to use this hardware capability in the RemoTI software environment as well as other user-selected designs. Project collateral and source code discussed in this application report can be downloaded from the following URL: http://www.ti.com/lit/zip/swra362. Contents 1 Introduction to Capacitive Sensing ........................................................................................ 2 2 Capacitive Sensing Application ............................................................................................ 8 3 Integrating Capacitive Sensing in Custom Solution ................................................................... 13 4 Limitations and Tips........................................................................................................ 14 5 References .................................................................................................................. 14 List of Figures 1 Capacitive Sensing Principle ............................................................................................... 2 2 Part of Schematic Showing Capacitive Buttons SW1 to SW5 ......................................................... 3 3 Pin Configuration and Voltage Levels vs Time .......................................................................... 4 4 Rise Time With (t 2 ) and Without (t 1 ) Touch ............................................................................... 6 5 Detection and Statistics Update Ranges ................................................................................. 7 6 Capacitive Sensing Integration Architecture ............................................................................. 8 7 Detection Fails: Statistics Are Not Updated While the True Base Increases....................................... 10 8 Detection Fails: Statistics Are Tracked Off the True Base............................................................ 11 9 Front Panel Reference Design: Front ................................................................................... 12 10 Front Panel Reference Design: Back .................................................................................... 12 List of Tables 1 Peripheral I/O Pin Mapping, TIMER 1 .................................................................................... 2 2 Pin States ..................................................................................................................... 3 3 Timer Allocation .............................................................................................................. 3 4 List of Parameters to Configure HalCapSense .......................................................................... 9 5 Buttons and Respective Software Debounce Times .................................................................. 11 6 Data Written to UART and When Written ............................................................................... 13 RemoTI is a trademark of Texas Instruments. ZigBee is a registered trademark of ZigBee Alliance. All other trademarks are the property of their respective owners. 1 SWRA362B – June 2011 – Revised December 2014 RemoTI™ Capacitive Touch Sensing Submit Documentation Feedback Copyright © 2011–2014, Texas Instruments Incorporated

RemoTI™ Capacitive Touch Sensing

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: RemoTI™ Capacitive Touch Sensing

Application ReportSWRA362B–June 2011–Revised December 2014

RemoTI™ Capacitive Touch Sensing

............................................................................................................. Low-Power Wireless Products

ABSTRACTAs consumers become accustomed to elegant touch interfaces on a variety of devices, these capabilitiesare becoming more expected on a greater number of devices. The CC253x devices used in RF4CEapplications provide hardware support for Capacitive Touch Sensing (Capacitive Sensing), and enableRF4CE manufacturers to design a wider range of devices with Capacitive Sensing capabilities using acost-effective approach.

This application report provides information about how to use this hardware capability in the RemoTIsoftware environment as well as other user-selected designs.

Project collateral and source code discussed in this application report can be downloaded from thefollowing URL: http://www.ti.com/lit/zip/swra362.

Contents1 Introduction to Capacitive Sensing ........................................................................................ 22 Capacitive Sensing Application ............................................................................................ 83 Integrating Capacitive Sensing in Custom Solution ................................................................... 134 Limitations and Tips........................................................................................................ 145 References .................................................................................................................. 14

List of Figures

1 Capacitive Sensing Principle ............................................................................................... 22 Part of Schematic Showing Capacitive Buttons SW1 to SW5 ......................................................... 33 Pin Configuration and Voltage Levels vs Time .......................................................................... 44 Rise Time With (t2) and Without (t1) Touch ............................................................................... 65 Detection and Statistics Update Ranges ................................................................................. 76 Capacitive Sensing Integration Architecture ............................................................................. 87 Detection Fails: Statistics Are Not Updated While the True Base Increases....................................... 108 Detection Fails: Statistics Are Tracked Off the True Base............................................................ 119 Front Panel Reference Design: Front ................................................................................... 1210 Front Panel Reference Design: Back.................................................................................... 12

List of Tables

1 Peripheral I/O Pin Mapping, TIMER 1 .................................................................................... 22 Pin States ..................................................................................................................... 33 Timer Allocation .............................................................................................................. 34 List of Parameters to Configure HalCapSense .......................................................................... 95 Buttons and Respective Software Debounce Times .................................................................. 116 Data Written to UART and When Written ............................................................................... 13

RemoTI is a trademark of Texas Instruments.ZigBee is a registered trademark of ZigBee Alliance.All other trademarks are the property of their respective owners.

1SWRA362B–June 2011–Revised December 2014 RemoTI™ Capacitive Touch SensingSubmit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 2: RemoTI™ Capacitive Touch Sensing

Sensor Pad

GroundSolder

Mask

Signal

Trace

PCB

Material

Introduction to Capacitive Sensing www.ti.com

1 Introduction to Capacitive Sensing

NOTE: RemoTI is Texas Instrument’s implementation of the ZigBee® RF4CE network protocolstandard. Additional information about RF4CE is available at www.zigbee.org/rf4ce;information about RemoTI is located at www.ti.com/RemoTI.

Capacitive Sensing, or Capacitive Touch Sensing, is based on the concept of measuring the alteredcapacitance of a sensor or touch pad in the presence of a pressure source, such as a finger. Figure 1illustrates this principle.

Figure 1. Capacitive Sensing Principle

The capacitance can be found by measuring the rising and falling time when charging and discharging thecapacitor. The measurement is done by starting a timer at the instance of charging and discharging, andthen capturing the event when the capacitor is charged and discharged. Note that there is more than oneway to connect the capacitor to the GPIO ports of the chip.

The CC253x family of RF system-on-chip devices contain hardware features that enable CapacitiveSensing functionality. The following resources are available:• Timers:

– Timer 1 (16-bit, five channels)– Timer 3 (8-bit, two channels)– Timer 4 (8-bit, two channels)

• Individually-configurable GPIOs associated to timer channels

The different buttons are connected to a dedicated GPIO for control of the charging/discharging, while theassociated pin in the next phase is configured as a peripheral and operates as an input for the Timer 1capture mode. There are five channels available on Timer 1 that allow up to five buttons to operate inparallel. More channels are available on Timer 3 and Timer 4, but with less accurate performance. Theusage of Timer 3 and 4 is not encouraged and this report will focus on Timer 1 usage.

Timer 1 has five channels, but these channels can be mapped to GPIOs in two different ways. Thisapproach allows up to nine different GPIOs that service one button each; see the extract fromSWRU191 x ( Ref. 3) in Table 1. For even more channels and a more comprehensive system, see alsoReference 7.

Table 1. Peripheral I/O Pin Mapping, TIMER 1P0 P1 P2Periphery/

Function 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 4 3 2 1 0

TIMER 1 4 3 2 1 0

Alt. 2 3 4 0 1 2

2 RemoTI™ Capacitive Touch Sensing SWRA362B–June 2011–Revised December 2014Submit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 3: RemoTI™ Capacitive Touch Sensing

+3.3 V

R115.1 MW

R105.1 MW

R95.1 MW

SW1

SW2

Vol Up

Vol Down

SW3

SW4

SW5

Ch Up

Ch Down

Standby

STDBY

CH_DN

VOL_DN

CH_UP

VOL_UP P1_1

P1_0

P0_6

P0_7

P1_2

www.ti.com Introduction to Capacitive Sensing

In our implementation, two pairs of buttons share a resistor to reduce the overall part count. Figure 2illustrates the relevant schematic portion; see also Reference 5.

Figure 2. Part of Schematic Showing Capacitive Buttons SW1 to SW5

Figure 3 shows the voltage level at each pin and the complete configuration. Table 2 and Table 3 list thepin states and timer allocation for Figure 3, respectively .

Table 2. Pin States

State Control Direction Level Input ModeA GPIO Output Low —B GPIO Output High —C Peripheral: Timer1 Input — 3-state

Table 3. Timer Allocation

State DescriptionT0 Assigned to Timer 1 Channel 0T1 Assigned to Timer 1 Channel 1T2 Assigned to Timer 1 Channel 2T3 Assigned to Timer 1 Channel 3T4 Assigned to Timer 1 Channel 4

3SWRA362B–June 2011–Revised December 2014 RemoTI™ Capacitive Touch SensingSubmit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 4: RemoTI™ Capacitive Touch Sensing

HAL_CAPSENSE_MODE_DOWN HAL_CAPSENSE_MODE_UP

DISCHARGE DISCHARGE DISCHARGE

CHARGE CHARGE CHARGE

P1_2V

P1_0V

P1_1V

P0_7V

P0_6V

P1_2 Config

P1_0 Config

P1_1 Config

P0_7 Config

P0_6 Config

Timer Capture

Timer Capture

Timer Capture

Timer Capture

Timer Capture

Channel DownT3

Volume UpT1

Volume DownT2

StandbyT0

Channel UpT4

A

A

A

A

A

A

B

B

B

B

B

B

No No

No

No

No

No

No

No

No

No

Yes

Yes

Yes

Yes

Yes

C

C

C

C

C

AL

LR

EP

EA

TE

DA

LL

RE

PE

AT

ED

t

Share Resistor Share Resistor

Poll Interval Poll Interval

Introduction to Capacitive Sensing www.ti.com

Figure 3. Pin Configuration and Voltage Levels vs Time

4 RemoTI™ Capacitive Touch Sensing SWRA362B–June 2011–Revised December 2014Submit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 5: RemoTI™ Capacitive Touch Sensing

www.ti.com Introduction to Capacitive Sensing

1.1 Setting Up the TimerHow the timer is set up defines the precision and range of operation. When a pressure source such as afinger is present, the capacitance decreases differently depending on the distance of the finger from thescreen, the geometric properties of the finger, and whether or not the finger actually touches the screen. Itis good to have an understanding of the physical properties of capacitors; keep in mind that capacitance isa physical property that depends on the geometry of the conductors and on the conductivity of the mediumbetween them. If the finger touches the surface of a button, the dielectric medium no longer includes asmuch air, but instead only tissue and likely plastic. Interested readers are encouraged to read Chapter 3 ofReference 1.

As a consequence, it is important to design the buttons such that false detection is avoided. The referencedesign presented here uses circular conductors to represent the area of a singular button. This designgives the best performance for discrete behavior. In other words, it has the least field leakage, whichmeans that presence of a touch at one button is less likely to affect nearby buttons. It does, however,mean that this design is not useful for proximity detection.

It is quite difficult to measure capacitance without affecting the measurements. To combat this problem, acoarse estimate is used as a baseline for setting up the timer; it is then configured and tracked in real timeand adjusted accordingly. For our implementation, the baseline rise/fall time is measured in the area of25 µs to 75 µs. Thus, each tick on the timer should correspond to this magnitude. However, it is alsoimportant to be able to measure much greater rise/fall times in the presence of a pressure source such asa finger. A tick speed of 2 MHz gives two ticks per microsecond. With a 16-bit timer, this speed allows upto 65,536 ticks, or 32.768 ms. This number of ticks is much more than necessary, but reduces thelikelihood of a timer overflow. (An overflow could be easily handled, but that would add unnecessarycomplexity to our design.)

To obtain a tick speed of 2 MHz on the CC253x devices, set the global prescaler for Timer 1, Timer 3, andTimer 4 to 001b.

CLKCONCMD.TICKSPD = 001b

This value gives a timer tick speed of 16 MHz, given a clock source that is greater than or equal to16 MHz (see Section 9.1 of Ref. 3). The Timer 1 prescaler is set to 01b, or a division by 8.

T1CTL.DIV = 01b

This configuration gives a tick speed for Timer 1 of 2 MHz.

5SWRA362B–June 2011–Revised December 2014 RemoTI™ Capacitive Touch SensingSubmit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 6: RemoTI™ Capacitive Touch Sensing

t0 t1 t2

VDD – 0.3V

VDD

[V]

t

Introduction to Capacitive Sensing www.ti.com

Figure 4 compares the effects on rise time with and without a touch. t1, in blue, is without touch pressure;t2, in red, is with touch pressure.

Figure 4. Rise Time With (t2) and Without (t1) Touch

One sequence of charging, or discharging, is repeated every HAL_CAPSENSE_POLLING_VALUE ms bydesign; refer to Figure 3 and Table 4. This timing allows for detection of touches that decrease thecapacitance such that the rise/fall time can be up to HAL_CAPSENSE_POLLING_VALUE ms. BecauseTimer 1 has five channels, five capacitors can be measured during this time span. Depending on how thecapacitors are connected, another set may be measured in the next sequence. How many suchsequences are allowed depends on the number of GPIOs available and on the user experience. A typicalbutton press must last for at least the period of two detection sequences plus the number of different setsof capacitors.

6 RemoTI™ Capacitive Touch Sensing SWRA362B–June 2011–Revised December 2014Submit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 7: RemoTI™ Capacitive Touch Sensing

µt1

(µ - 2σ2 )t1 t1(µ + 2σ2 )t1 t1

(µ + 4σ2 )t1 t1

Detect TouchUpdate Statisticsa b

www.ti.com Introduction to Capacitive Sensing

1.2 Detecting a TouchThere are two primary considerations when we approach the design: the definition of a defined touch andthe definition of a valid sample.

A touch is registered by the device if the measured capacitance exceeds the base capacitance by at leasta defined threshold: HAL_CAPSENSE_THRESHOLD_MIN_DETECT. In this implementation, we track themean rise time, µt, and the variance, σ2.t, by a running mean and variance algorithm. Therefore, we candynamically (and more precisely) define the threshold.We have set the threshold, Δtthreshold, to the maximum of HAL_CAPSENSE_THRESHOLD_MIN_DETECT andHAL_CAPSENSE_THRESHOLD_MULTIPLIER_DETECT times the variance; that is,

Δtthreshold = max (HAL_CAPSENSE_THRESHOLD_MIN_DETECT,HAL_CAPSENSE_THRESHOLD_MULTIPLIER_DETECT ● σ2.t) (1)

The second (and very important) concern is when a sample should count as a valid sample. We havedefined that a sample is valid whenever it is within the limits of the max(HAL_CAPSENSE_THRESHOLD_MIN, HAL_CAPSENSE_THRESHOLD_MULTIPLIER ● σ2.t) from the meanµt. This period is denoted as b in Figure 5. For a, in Figure 5, statistics are updated with µt – 2σ2.t as thesample value.

Figure 5. Detection and Statistics Update Ranges

7SWRA362B–June 2011–Revised December 2014 RemoTI™ Capacitive Touch SensingSubmit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 8: RemoTI™ Capacitive Touch Sensing

HalDriver

Application HalCapSense

Scheduler

Application Initialization

Routine

Hal_

Process

Event

osal_start_timerEx

Call

Hal_ProcessEvent

Optional Application

Reset Call

OSAL (Operating System Abstraction Layer)

HalCapSenseInit(Initialize: Peripherals, Timers)

HalCapSensePoll(Read timer values, restart

charging/discharging sequence)

HalCapSenseRead(Run through all buttons)

HalCapSenseUpdateBase(Update statistics and

detect touch)

HalCapSenseReset(Reset statistics)

HalCapSenseConfig(Assign callback function, start first

timer expire event from OSAL,hal_driver will take care of

subsequent timer expiration)

If any touch is detected,report back

to application

Capacitive Sensing Callback Function

Capacitive Sensing Application www.ti.com

2 Capacitive Sensing ApplicationThis section describes the software implementation for both the Capacitive Sensing driver and theintegration with the RemoTI stack.

2.1 IAR WorkspaceThe standalone project is preconfigured with a new target: CC2531_FrontPanel. Three configurationsexist:• CC2531F256• CC2531F256-HEX• CC2531F256_SB

CC2531F256 is used for debugging, CC2531F256-HEX builds a .hex image that can be downloaded viathe SmartRF Flash Programmer, and CC2531F256_SB invokes a post-build tool that prepends the SerialBootloader to the binary in a .hex image.

To enable the output of statistics over the UART, be sure to build with UART_STATS defined.

2.2 ArchitectureThe Capacitive Sensing hardware driver is written similar to most RF4CE modules, as shown in Figure 6.The application calls an initialization routine, HalCapSenseInit(), as well as subscribes to the functionby calling HalCapSenseConfigure(SA_CapSenseCback). In this case, SA_CapSenseCback is thefunction that the application would like the HalCapSense module to call in when detecting a touch.

Figure 6. Capacitive Sensing Integration Architecture

During runtime, the HalDriver calls osal_start_timerEx() on behalf of the HalCapSense module. Italso receives the timer expired event from OSAL, and subsequently calls the polling routine ofHalCapSense, HalCapSensePoll().

From an application point of view, the actual operation of HalCapSense is hidden. Once configured, theapplication receives a callback only if a touch is detected. Because touch detection is binary (present/notpresent), the module itself does not notify of a release. There are many parameters that should beconfigured to optimize performance; refer to Table 4.

8 RemoTI™ Capacitive Touch Sensing SWRA362B–June 2011–Revised December 2014Submit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 9: RemoTI™ Capacitive Touch Sensing

www.ti.com Capacitive Sensing Application

If for some reason the application wants to reset the operation of HalCapSense, it may callHalCapSenseReset(). This call sets all buttons to an unconfigured state and resets the statistics foreach button. This call is equivalent to a power-on-reset from the perspective of the HalCapSense. SeeTable 4 for a more detailed scenario.

2.3 Optimizing PerformanceThis section addresses the most important issue: how to configure the operation of detecting a touch,establishing what parameters can be modified, and defining what the effects are. Table 4 provides a list ofparameters that can be modified. Note that these parameters are recommended only when a tick speed of2 MHz is used.

Table 4. List of Parameters to Configure HalCapSense

RecommendedValue

(Given 2-MHzMacro Ticks) Description

200 Number of samples used beforeHAL_CAPSENSE_ADV_TRACK_MAX_COUNTupdating the variance.

5 A minimum threshold in number ofHAL_CAPSENSE_THRESHOLD_MINticks.

10 A minimum threshold for detection inHAL_CAPSENSE_THRESHOLD_MIN_DETECTnumber of ticks.

61 Short software debounce in ms.HAL_CAPSENSE_DEBOUNCE_VALUE_SHORTImplemented and used byapplication, not by the HalCapSensemodule itself.

333 Long software debounce in ms.HAL_CAPSENSE_DEBOUNCE_VALUE_LONGImplemented and used byapplication, not by the HalCapSensemodule itself.

2 Threshold is equal to this numberHAL_CAPSENSE_THRESHOLD_MULTIPLIERtimes σ2.t, if that product is greaterthanHAL_CAPSENSE_THRESHOLD_MIN.

4 Threshold for detection is equal toHAL_CAPSENSE_THRESHOLD_MULTIPLIER_DETECTthis number times σ2.t, if that productis greater thanHAL_CAPSENSE_THRESHOLD_MIN_DETECT.

16 Polling interval in ms.HAL_CAPSENSE_POLLING_VALUE0 If there is a need for some iterationsHAL_CAPSENSE_NOF_SETTLING_ITERATIONS

to settle, this parameter allows theseiterations.

666 Optional reset period, used fromHAL_CAPSENSE_RESET_PERIODapplication to reset the statistics.

9SWRA362B–June 2011–Revised December 2014 RemoTI™ Capacitive Touch SensingSubmit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 10: RemoTI™ Capacitive Touch Sensing

t0

VDD – 0.3V

VDD

[V]

t

t

(µ - xσ )t1 t1

(µ + xσ )t1 t1

µt1

µ

Statistics

UpdatedDetection Range

2 2,2

, 1 2old k new

old k

σ σσ +

+=

Capacitive Sensing Application www.ti.com

The running mean and average algorithms are sample-based algorithms.HAL_CAPSENSE_ADV_TRACK_MAX_COUNT sets the number of samples required before the variance isstored and used for detection; see Detection Range in Figure 5, Figure 7, and Figure 8. When thevariance is updated it is averaged in. This calculation is not a true averaging, because the latestcontributions are weighted equally as all the earlier ones.

(2)

When all buttons are left untouched, the variance is typically 0, given only two ticks-per-µs resolution.However, when a finger is present at one button, it may affect some other button. To help prevent falsedetection at the other button(s), the variance may typically increase and the decision range exceeds thedefault minimum. One can disable this feature altogether by settingHAL_CAPSENSE_THRESHOLD_MULTIPLIER(_DETECT) to 0. The decision range is then fixed and givenby HAL_CAPSENSE_THRESHOLD_MIN(_DETECT).

2.3.1 Remedying Failing ScenariosThere are two scenarios which can make the Capacitive Sensing misbehave. This section describes thetwo scenarios and suggests how to remedy the situation.

Both scenarios relate to the actual rise/fall time and the tracking of the respective event. The precedingsections explain the tracking of the rise/fall times. There are situations, however, that are difficult to track.If something is left on the capacitor after touching it, the new actual rise/fall time will change abruptly; as aresult, the new samples will be outside of the range that is tracked (see Figure 5). Now, all future sampleswill be detected as touches. This scenario is shown in Figure 7.

Figure 7. Detection Fails: Statistics Are Not Updated While the True Base Increases

Another scenario can occur if the ranges where statistics are updated and where a touch is detected arenot well defined. As a result, touches on nearby buttons may cause the tracking to increase such that therange where statistics are updated cover a typical touch; see Figure 8. Now, a typical touch will not bedetected.

10 RemoTI™ Capacitive Touch Sensing SWRA362B–June 2011–Revised December 2014Submit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 11: RemoTI™ Capacitive Touch Sensing

t0

VDD – 0.3V

VDD

[V]

t

µt

t2µ

Update Statistics

t t(µ + xσ2 )t t

(µ - xσ2 )

Actual

Base

www.ti.com Capacitive Sensing Application

Figure 8. Detection Fails: Statistics Are Tracked Off the True Base

The HAL_CAPSENSE_RESET_PERIOD can be used as a self-repair mechanism. It is used in the sampleapplication after the last touch has debounced. Thus, when the application believes there is no touch, itresets the HalCapSense module. This call is useful to recover quickly from the second scenario explained;see Figure 7. The device will also recover from this scenario if the button is left untouched for a period oftime, because of the downwards-tracking shown as a in Figure 5.

It also allows the user to recover from the first scenario explained; where touches are always detected.The application would have to define a constraint to the length in time of a continuous touch, and issue areset if this constraint has been exceeded. Note that this use case has not been implemented in thesample application. It is left up to the designer to select how long a series of detected button presses canbe.

2.4 Application FunctionalityThis application is based on the RNP project for the CC2531, and includes the RTIS, RemoTI Surrogatelayer. See Section 4.4 of Reference 2 for a discussion of RNP operation via a virtual serial port over aUSB interface.

Apart from the RNP functionality, the LEDs are toggled when a touch is registered. The buttons areorganized to reflect a typical usage as a front panel, as shown in Figure 9. To further reflect the typicaluse of the buttons, they have different software debounce times, as Table 5 summarizes. Figure 10 showsthe reverse side of the board.

Table 5. Buttons and Respective Software Debounce Times

Debounce TimeButton Macro (ms) LED

Standby HAL_CAPSENSE_DEBOUNCE_VALUE_LONG 333 4Volume Up HAL_CAPSENSE_DEBOUNCE_VALUE_LONG 333 1Volume Down HAL_CAPSENSE_DEBOUNCE_VALUE_LONG 333 2Channel Up HAL_CAPSENSE_DEBOUNCE_VALUE_LONG 333 1Channel Down HAL_CAPSENSE_DEBOUNCE_VALUE_LONG 333 2

11SWRA362B–June 2011–Revised December 2014 RemoTI™ Capacitive Touch SensingSubmit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 12: RemoTI™ Capacitive Touch Sensing

Capacitive Sensing Application www.ti.com

Figure 9. Front Panel Reference Design: Front

Figure 10. Front Panel Reference Design: Back

12 RemoTI™ Capacitive Touch Sensing SWRA362B–June 2011–Revised December 2014Submit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 13: RemoTI™ Capacitive Touch Sensing

www.ti.com Capacitive Sensing Application

2.5 Execution Sequence

Step 1. Build the project.Step 2. Connect the mini-USB cable to the front panel to apply power.Step 3. Connect the CC Debugger and download the image.Step 4. Execution of the CapSenseApp begins immediately.

2.6 Additional Help for Improving User ExperienceIf the project is built with UART_STATS defined, a simple UART output is set up in this manner: flowcontrol disabled, 8-bit transfer enabled, one stop bit is set (high), and the start bit is low.

Simply strap a cable from Pin 3 on the front panel reference design (see Ref. 5; see also Figure 10) toP1_7 on a SmartRF05 Evaluation Board, for example (see Ref. 6), and then connect this board to a serialport on a computer.

What is written to the UART depends on what is detected; denote charge time t, then refer to Table 6 for alist of possible outputs over the UART.

Table 6. Data Written to UART and When Written

Statement 1 byte 4 bytes 4 bytes 4 bytesTouch detected x (2) tx µtx σ2.txΔt > Δtthreshold_detect

(1)

Tracking down x (2) µtx σ2.txΔt < – Δtthreshold(3) Δt =

tx –

µt

Send data for all 0 t0 µt0 σ2.t0Every HAL_CAPSENSE_ADV_TRACK_MAX_COUNTbuttons.samples 1 t1 µt1 σ2.t1

2 t2 µt2 σ2.t23 t3 µt3 σ2.t34 t4 µt4 σ2.t4

(1) Δtthreshold = max (5 µs, 2 × σ2.t µs)(2) x represent the detected button index(3) Δtthreshold_detect = max (2.5 µs, 4 × σ2.t µs)

4 bytes are transmitted per 16-bit value; 1 byte represents four bits as an ASCII character .

This information could help users choose the correct values in Table 4 for a specific implementation.for(I=3; I > -1; I--) {

temp = btnBaseCapMeanOld[btnId] >> (4*I);temp &= 0x0F;if(temp < 10) uartPutc((temp + '0'));else uartPutc(((temp - 10) + 'A'));

}

3 Integrating Capacitive Sensing in Custom SolutionTo add Capacitive Sensing capabilities to your custom solution, simply add the HAL_CAPSENSE module toyour project. Make sure there is no conflict with the Timer 1 usage; otherwise, all timer-related macrosmust be redefined. The polling routine HalCapSensePoll() calls the macros CAP_DISCHARGE(mode)and CAP_CHARGE(mode) with the mode alternating between HAL_CAPSENSE_MODE_UP andHAL_CAPSENSE_MODE_DOWN. To configure the charging/discharging mechanism to your layout, edit thesubsequent calls from the macros CAP_DISCHARGE(mode) and CAP_CHARGE(mode). Refer to Figure 3for a better understanding of this mechanism.

13SWRA362B–June 2011–Revised December 2014 RemoTI™ Capacitive Touch SensingSubmit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 14: RemoTI™ Capacitive Touch Sensing

Limitations and Tips www.ti.com

4 Limitations and TipsBecause the rise/fall time is a continuously increasing function of presence, it could happen that thepresence of a pressure source is not detected as a touch but taken as part of the statistics. The statisticswould then be off, and no touch would be detected, until statistics are recalibrated. This event is a slightlybetter case than that shown in Figure 8. However, the statistics may recalibrate slowly, and you may wantto invoke the reset functionality.

It makes good sense to thoroughly analyze the end product. Make sure the physical design is as optimalas possible for your desired behavior.btnBaseCapTrackCounter is updated every iteration. Therefore, even though some button may betouched (and therefore, the respective statistics not updated), the counter is global so it continues to keepcounting. This condition could be remedied by giving each button its own counter; however, that techniquecould increase RAM usage even more.

If your physical implementation is very stable and not affected by changes in temperature, etc., you mayfind that you do not need to track the base rise/fall time. In this case, you could save all the variables usedto track the statistics.

There exist dedicated microcontrollers that can handle more buttons. See MSP430 LaunchPad for a verygood example of a more comprehensive capactive touch system ( Ref. 7).

5 ReferencesUnless otherwise noted, these document are available through the Texas Instruments website atwww.ti.com.1. Cheng, D. K. (1989). Field and Wave Electromagnetics (second edition). New York: Addison Wesley.2. RemoTI Sample Applications. Texas Instruments user guide. SWRU201B3. CC253x/CC2540 System-on-Chip Solution. Texas Instruments user guide. SWRU191B4. CC2533, RF/IF, and ZigBee Product Information. Texas Instruments website.5. STB_Front_Panel Schematic, Rev B.6. SmartRF05EB version 1.8.1 schematics. Available at: SmartRF05EB_1_8_1_Schematics7. Capacitive Touch BoosterPack (430BOOST-SENSE1). Product information page. MSP430 LaunchPad

14 RemoTI™ Capacitive Touch Sensing SWRA362B–June 2011–Revised December 2014Submit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 15: RemoTI™ Capacitive Touch Sensing

www.ti.com Revision History

Revision History

Changes from A Revision (April 2013) to B Revision .................................................................................................... Page

• Updated Figure 3. ......................................................................................................................... 4• Updated information in Section 1.1. .................................................................................................... 5

NOTE: Page numbers for previous revisions may differ from page numbers in the current version.

15SWRA362B–June 2011–Revised December 2014 Revision HistorySubmit Documentation Feedback

Copyright © 2011–2014, Texas Instruments Incorporated

Page 16: RemoTI™ Capacitive Touch Sensing

IMPORTANT NOTICE

Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, enhancements, improvements and otherchanges to its semiconductor products and services per JESD46, latest issue, and to discontinue any product or service per JESD48, latestissue. Buyers should obtain the latest relevant information before placing orders and should verify that such information is current andcomplete. All semiconductor products (also referred to herein as “components”) are sold subject to TI’s terms and conditions of salesupplied at the time of order acknowledgment.TI warrants performance of its components to the specifications applicable at the time of sale, in accordance with the warranty in TI’s termsand conditions of sale of semiconductor products. Testing and other quality control techniques are used to the extent TI deems necessaryto support this warranty. Except where mandated by applicable law, testing of all parameters of each component is not necessarilyperformed.TI assumes no liability for applications assistance or the design of Buyers’ products. Buyers are responsible for their products andapplications using TI components. To minimize the risks associated with Buyers’ products and applications, Buyers should provideadequate design and operating safeguards.TI does not warrant or represent that any license, either express or implied, is granted under any patent right, copyright, mask work right, orother intellectual property right relating to any combination, machine, or process in which TI components or services are used. Informationpublished by TI regarding third-party products or services does not constitute a license to use such products or services or a warranty orendorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property of thethird party, or a license from TI under the patents or other intellectual property of TI.Reproduction of significant portions of TI information in TI data books or data sheets is permissible only if reproduction is without alterationand is accompanied by all associated warranties, conditions, limitations, and notices. TI is not responsible or liable for such altereddocumentation. Information of third parties may be subject to additional restrictions.Resale of TI components or services with statements different from or beyond the parameters stated by TI for that component or servicevoids all express and any implied warranties for the associated TI component or service and is an unfair and deceptive business practice.TI is not responsible or liable for any such statements.Buyer acknowledges and agrees that it is solely responsible for compliance with all legal, regulatory and safety-related requirementsconcerning its products, and any use of TI components in its applications, notwithstanding any applications-related information or supportthat may be provided by TI. Buyer represents and agrees that it has all the necessary expertise to create and implement safeguards whichanticipate dangerous consequences of failures, monitor failures and their consequences, lessen the likelihood of failures that might causeharm and take appropriate remedial actions. Buyer will fully indemnify TI and its representatives against any damages arising out of the useof any TI components in safety-critical applications.In some cases, TI components may be promoted specifically to facilitate safety-related applications. With such components, TI’s goal is tohelp enable customers to design and create their own end-product solutions that meet applicable functional safety standards andrequirements. Nonetheless, such components are subject to these terms.No TI components are authorized for use in FDA Class III (or similar life-critical medical equipment) unless authorized officers of the partieshave executed a special agreement specifically governing such use.Only those TI components which TI has specifically designated as military grade or “enhanced plastic” are designed and intended for use inmilitary/aerospace applications or environments. Buyer acknowledges and agrees that any military or aerospace use of TI componentswhich have not been so designated is solely at the Buyer's risk, and that Buyer is solely responsible for compliance with all legal andregulatory requirements in connection with such use.TI has specifically designated certain components as meeting ISO/TS16949 requirements, mainly for automotive use. In any case of use ofnon-designated products, TI will not be responsible for any failure to meet ISO/TS16949.

Products ApplicationsAudio www.ti.com/audio Automotive and Transportation www.ti.com/automotiveAmplifiers amplifier.ti.com Communications and Telecom www.ti.com/communicationsData Converters dataconverter.ti.com Computers and Peripherals www.ti.com/computersDLP® Products www.dlp.com Consumer Electronics www.ti.com/consumer-appsDSP dsp.ti.com Energy and Lighting www.ti.com/energyClocks and Timers www.ti.com/clocks Industrial www.ti.com/industrialInterface interface.ti.com Medical www.ti.com/medicalLogic logic.ti.com Security www.ti.com/securityPower Mgmt power.ti.com Space, Avionics and Defense www.ti.com/space-avionics-defenseMicrocontrollers microcontroller.ti.com Video and Imaging www.ti.com/videoRFID www.ti-rfid.comOMAP Applications Processors www.ti.com/omap TI E2E Community e2e.ti.comWireless Connectivity www.ti.com/wirelessconnectivity

Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265Copyright © 2015, Texas Instruments Incorporated