During this webseminar we will discuss a number of topics including what exactly ismTouch Capacitive Touch Sensing. We will go on to describe sensor constructionas well as a detailed discussion on the various components of the sensor’s interfacecircuitry to a PIC Microcontroller. So let’s get started…

z Microchip provides a multitude of resources to

What exactly is mTouch? Well, mTouch is an alternative to traditional mechanical

pushbuttons with some distinct advantages. The system is completely sealed, hasno mechanical components that will wear with time and provides a modern lookingdesign. Most importantly, Microchip offers a royalty-free license along with amultitude of resources to aid in the development of your own mTouch applications.

First, we have the touch sensor itself. As the Capacitive Touch Sensing nameimplies, this sensor will produce a varying capacitance that will interact with arelaxation oscillator circuit. When the capacitance from the sensor changes, forexample when touched by a finger, the oscillator’s frequency will change.

εr Relative Dielectric Constant (unit-less)

A Area of Plates (meters)

d Distance between plates (meters)

Recalling the equation for capacitance, we can see that there are a number ofvariables that could change the capacitance produced by our touch sensors. As wewill see, the most important variables that we will be concerned with is Area anddistance. From this equation we can see that the greater the Area, the greater thecapacitance. As the distance becomes larger, the capacitance drops. Keep this inmind as we proceed through this presentation. So…how do we build a sensor?

z Copper (Cu) pads (thickness exaggerated)

A copper pad is next introduced. The shape of this pad is not very important.Therefore, we have the freedom to shape the sensor aesthetically to suit aparticular design. However, the area of the pad is very important. The larger thepad, the better the sensitivity and a sensor touch will be more easily detected by therest of the system. As you can see in the slide above, a natural parasiticcapacitance to grounds elsewhere in the system has been introduced here which Ihave labeled Pad Capacitance or Cp

Next, a touch surface is applied in the form of either Window glass or Plexiglas.Other materials could be used as long as the dielectric constant of the material isevaluated for functionality. Typically it is best to design a thin touch surface.Remember back to the capacitance equation, as distance increases, thecapacitance will effectively decrease. Therefore, using a surface that is very thinproduces a more sensitive system.

11 How does it work?

z Introduction of finger produces a parallel

A finger touch will add a second capacitance in parallel with the pad’s capacitance.The iron in an individual’s blood creates strings of capacitors between every surfaceof their body. So, when someone creates a capacitance by moving his or her handinto close proximity of another conductor, it creates a capacitance essentiallycoupled to ground.

12 Equivalent Circuit

CP

Sensor Capacitance (CS) = CP

CP CF

Sensor Capacitance (CS) = CP + CF

Looking at equivalent circuits, we have the capacitance from the pad alone and thena parallel combination of pad capacitance and the finger capacitance which addtogether to form a total sensor capacitance labeled Cs. We should mention herethat the capacitance introduced by the finger is known to be very small in the areaof 5-15pF. Therefore, we will want to ensure that the capacitance created by ourpad is small as well to ensure that a touch is sensed. Further information onphysical design guidelines can be found in application note number AN1102referenced at the end of this webseminar.

So, we now know how to create a sensor that varies capacitance with the touchfrom a finger. But how do we use this information to detect a sensor touch. Thisleads us to our next component in the system, the relaxation oscillator.

The RC time constant for a charging capacitor is calculated by multiplying the

system’s resistance by its capacitance as shown above. Remembering that the RCtime constant represented by the Greek letter Tau, is the time it takes to charge acapacitor to about 63% of its supply voltage and five times this time constant is thetime to charge the capacitor to within 1% of the supply. The sensor capacitancealone with no finger introduced will create a steeper charging time as shown above.

The RC circuit discussed in the previous slide is interfaced with the dual comparatormodule with SR Latch found on newer PIC Microcontrollers. The Voltage across theSensor capacitor labeled Vcs is used as the inverting input to both comparators.

Microcontrollers set to approximately 2/3 of the supply voltage. Comparator 2 willneed an external reference. Therefore, we use a simple voltage divider to produce avoltage of ¼ the supply voltage on the Comparator’s non-inverting input. The 0.1µFcapacitor is added to reject high frequency noise from the power supply and ensurea stable lower limit voltage.

We are using the comparator to create a window of operation. If the voltage acrossCs drops below ¼ Vdd, the output of comparator 2 will go HIGH. Looking closely atcomparator 1 notice that the output’s polarity is inverted. Therefore, if the voltageacross Cs rises above 2/3 Vdd, the comparator 1 output will go LOW. Bothcomparator 1 and comparator 2 outputs enter into the SR Flip-Flop’s Set and Resetinputs respectively. Let’s explain how this will work.

In the slide above, note the SR Latch’s truth table. If the Set input is driven HIGH,the pin connected to the Q bar output of the latch will be driven LOW. If the Resetinput is driven HIGH, the pin connected to the Q bar output will be driven HIGH.Looking at the condition where both S and R inputs are HIGH, we notice that theoperation of the Latch will be in Reset mode since this Latch is Reset dominant.More importantly is the condition where both inputs are driven LOW. What happensin this condition is that the outputs of the Latch will hold the last know output values.As you will see, this will become important in the operation of our relaxationoscillator design.

In this slide, the graph on the right represents the voltage across the sensorcapacitor. We will indicate changes in the SR Latch state by highlighting theappropriate row in the SR Latch truth table in green. Starting at the very beginningof operation, device power-up, the voltage across the sensor capacitor is 0.Therefore, comparator 2 output goes HIGH while the inverted output of comparator2 goes low since both inverting inputs are less than the non-inverting input thresholdvoltages. This places the SR Latch into Reset driving the Q bar output to 1 which inturn charges the sensor capacitor.

As the voltage across the sensor cap increases it eventually surpasses the 1/4Vddthreshold, the non-inverting input voltage to Comparator 2. This causes the outputof Comparator 2 to go to 0. Referring to the SR latch truth table, this condition holdsthe last known output value on the Q bar output at 1 and the sense capacitorcontinues to charge.

Once the voltage across the sensor capacitor exceeds the internal voltagereference on the non-inverting input of comparator 1, the inverted comparator outputconnected to the Set input goes to 1 driving the Q bar output of the SR latch to 0.The sensor capacitor then starts to discharge.

We have implemented the RC circuit containing the sensor capacitor into a verygood relaxation oscillator. As the capacitance changes in the circuit, so will the RCtime constant, changing the frequency of oscillation.

Connecting the SR latch output on C2OUT to the Timer1 input pin (T1CKI), wecould use this square wave as the Timer1 clock source. Configuring TMR1 registerto increment on every positive edge of the square wave allows us to count thenumber of clock pulses. However, this isn’t enough to determine the frequency ofthe square wave. To do this will need to have a fixed period clock source to gate the16-bit TMR1 value to.

For this we use the Timer0 module. Here the PIC MCU is configured to generate aninterrupt when the TMR0 register overflows. Therefore, the interrupts will occur at afixed rate. We could detect a change in square wave frequency by observing achange in the TMR1 registers’ values on each TMR0 interrupt.

Therefore, on the next TMR0 interrupt, when we read the contents of the TMR1registers, we should get a smaller value than the previous interrupt. Using asoftware algorithm to compare both values, we can identify a sensor touch. In theabove diagram, the frequency difference is exaggerated in the interest ofhighlighting these changes. In reality, we can expect a frequency change ofbetween 1 and 5%.

To accurately detect a change in frequency of the relaxation oscillator, two variables

and one constant are used. The average variable: keeps a running average of 16previous samples from the TMR1 registers. This running average is used toeliminate noise created by changes in temperature, voltage and environment. Theraw variable: holds the current value in TMR1 registers, and the predetermined tripconstant: is the minimum difference between the raw data and the average value.

Implementing this in a software routine, on a TMR0 interrupt, the current data is

read into the raw variable, if the average value less the trip value is greater than theraw value, a sensor touch has occurred and the software responds accordingly.Otherwise, the sensor is determined to be untouched.

If a sensor touch has not occurred, the current value in TMR1 registers is averagedinto the 16-point running average. The TMR1 registers are always cleared at theend of every TMR0 interrupt routine and the CPU returns to whatever it was doingprior to the interrupt. This completes the basic system.

Multiple Sensors External

We can further enhance this design by using features available on newer PICMicrocontrollers. For example, multiple sensors can be easily used in our design byusing the programmable input selection of inverted inputs to both comparators.Notice in this example that both comparators are able to share the same input pin atone time.

The mTouch Software Development Tool is provided as a free download at

www.microchip.com providing an intuitive means of analyzing a capacitive system.This tool features the ability to communicate with your system via the PICKit SerialAnalyzer using the I2C protocol. Application critical information such as Tripthreshold and acceptable hysteresis signaling a sensor touch can easily determinedby visualizing sensor behavior.

The mTouch Capacitive Touch Sensing is a robust solution to traditional sensors

that significantly reduces failure due to worn mechanical parts. Furthermore, someliberty can be taken with shape of the touch pads adding some aesthetic diversity toyour design. Free licensing is provided by Microchip while making available anumber of supporting resources such as application notes, source code, themTouch Software Development Kit and an online design center.

z AN1104: Capacitive Multi-Button

z mTouch™ Design Center at

For more information on mTouch Capacitive Touch Sensing, please refer to theapplication notes listed above. Future mTouch webseminar topics will includelayout/design techniques, software algorithms and multi-button configurations. Youmay also be interested in visiting the mTouch Design Center atwww.microchip.com/mTouch. Here you will find links to the most current informationand resources for this technology.