Академический Документы
Профессиональный Документы
Культура Документы
Silicon Labs
In this section, we are going to cover the Silicon Labs Capacitive Sensing solutions.
1
Agenda
What are we measuring?
SAR operation
C8051F93x-92x implementation
C8051F700 implementation
2
What Are We Measuring?
Capacitance
If two metal plates are placed with a gap between them and a voltage is applied to one of
the plates, an electric field will exist between the plates
Any two conductive objects can be used for the plates of the capacitor
When using capacitive sensing for touch applications the capacitor is typically formed by
a PCB element and the conductive object in proximity
Capacitor parameters
Area — capacitance is directly proportional to the area of the plates
Dielectric — capacitance is directly proportional to the relative permittivity of the material
between the plates (air, glass, plastic, etc.)
Distance — capacitance is indirectly proportional to the distance between the two plates
A
Capacitor d ΔV
Dielectric
plates
where:
Є0 is the permittivity of free space
Єr is the relative permittivity of the dielectric material
A is the area of the plates
D is the distance between the plates
When using capacitive sensing for touch applications the PCB trace typically acts as
one plate of the capacitor. When a conductive object (such as a finger for touch
sensing) comes into proximity it acts as the other plate and air is the dielectric. As
the object moves closer to the pad the capacitance changes based on the equation
for capacitance shown. The constants in the equation represent the value for the
dielectric constant of the material, i.e. air, glass etc. The value for A is a measure of
the area of the pad used for the sensor capacitor and d represents the distance
between the two plates. So you can see, for touch applications, as the finger moves
closer to a pad the value for d is reduced which then increases the capacitance.
єr is the relative static permittivity (sometimes called the dielectric constant) of the
material between the plates
A is the area of each plate
D is the separation between the plates.
3
Capacitive Sensing Technology
What are capacitive sensing switches?
They are external capacitors that are influenced by
the presence of conductive objects such as a finger
They are also known as contact-less switches
Touch sensitive switches are found in a variety of consumer products including home
appliances, MP3 players and cell phones. A touch sensitive switch is a switch that is
implemented as a trace on a printed circuit board. The architecture of the trace creates a
capacitive element. Touching this trace with a finger creates a change in capacitance, which
is detectable using a variety of techniques. Capacitive sensing has received a lot of attention
lately due to the fact that it can replace mechanical switches that have a tendency to wear
out and break. Capacitive Sensing switches can be as simple as a trace on a PCB that forms
one plate of a capacitor and an object that is in close proximity to the pad represents the
other plate. With respect to human interface it is often a person’s finger that becomes the
second plate of the capacitor. When a person’s finger moves closer to the pad the
capacitance changes inversely with the distance. As the distance between the finger and the
pad decreases the capacitance increases. We can use several measurement techniques to
quantify the capacitance and provide a “pressed” or “not pressed” button state.
There are many applications for this technology, not just switches although that is probably
the most common. Industrial Applications can take advantage of capacitive sensing. There
are many industrial applications where detection can be done using a capacitive sensor, such
as detection of the water level in a tank.
4
How Is The Capacitance Change Detected?
Charge transfer
Charging a sensor capacitor and then transferring that charge into an
integrating capacitor over several cycles
There are many different techniques to measure the change in capacitance. Resistor-
Capacitor charge timing measures how long it takes to charge or discharge a capacitor. In
this case you discharge a capacitor and then apply a voltage to the RC network and measure
the time it takes to cross a threshold. Charge transfer involves charging a sensor capacitor
and then transferring that charge into an integrating capacitor over several cycles. The
voltage change on the capacitors gets exponentially smaller. You can then compare the
integrating capacitors voltage to a reference voltage or measure it with an ADC and
determine the time associated with it. The relaxation oscillator method builds an oscillator
which uses the sensor capacitor as a timing element. The C8051F900 family is capable of
implementing the relaxation oscillator method and generates the oscillator using an
integrated comparator. In order to build the oscillator we have to charge the sensor capacitor
to a specified upper threshold voltage. Once that value is reached we then discharge the
sensor capacitor to a specified lower threshold voltage. Using this method the oscillation
period is inversely proportional to the sensor capacitor value. As capacitance increases the
oscillator frequency decreases. The C8051F700 family uses a successive approximation
technique to compare the sensor capacitor ramp with a known time base.
5
The Relaxation Oscillator (RO)
How a relaxation oscillator works
Charge a capacitor until it reaches a certain voltage threshold
Once the threshold is reached, discharge the capacitor until it
reaches a lower threshold
The frequency of the relaxation oscillator is indirectly proportional to
the value of the capacitor
C > Inactive Capacitance
C = Inactive Capacitance
Here we will take a closer look at the relaxation oscillator method. As mentioned on the
previous slide, the relaxation oscillator method builds an oscillator which uses the sensor
capacitor as a timing element. The diagram shows the relationship of the comparator
reference voltages and the output waveform. The reference voltages used for the
comparisons in this example are the 2/3 and 1/3 VDD points. The exponential voltage rise
occurs from the 1/3VDD point and continues to the 2/3VDD point. At that point the
comparator output toggles and causes a change in current flow. This change causes the
voltage to decay back down to the 1/3VDD point and then the cycle repeats. We will take a
look at this cycle in more detail in some of the following slides. Using this method the
oscillation period is inversely proportional to the sensor capacitor value. As capacitance
increases the oscillator frequency decreases.
6
Charge Timing Using SAR
V
ISENSOR
IREF
t
MSB Bit Decision LSB Bit Decision
(Bit 15) (Bit 0)
The SAR implementation is based on the principle of capacitance that as you source a
constant current then the voltage output will increase over time. This is based on the
equation dV = I/C dt. The comparison point of the generated voltage is set to a constant
voltage over all cycles. This constant voltage is also used as the reference point for the
charge time of a reference capacitor. When all bit values have been determined the ramp
rate of the sensor capacitor will be equal to that of the reference capacitor.
7
Relaxation Oscillator (RO)
Implementation
8
RO Capacitive Sensing Implementation (1 of 3)
The next several slides show how the relaxation oscillator actually works. The slides
describe the inactive state behavior of the relaxation oscillator. By inactive state we mean
that a finger is not moved on or off the switch, and so the capacitance of the switch is the
same.
In this configuration, the output of the comparator is ‘1’ when the positive input is greater
than the negative input. In the initial state, we can assume the capacitor is at 0V or less than
2/3 VDD. The comparator output is then logic ‘1’ or VDD. This has two effects: 1) the
resistor network gets simplified to what is shown on the right and this sets the threshold to
2/3 VDD, which is shown in blue in the graph. 2) The switch capacitor is charged by the
output of the comparator through the feedback resistor. This is shown by the red line in the
graph.
9
RO Capacitive Sensing Implementation (2 of 3)
10
Once the voltage on the capacitor gets charged to 2/3 VDD, the output comparator becomes
logic 0, which has two effects. 1) The resistor network gets simplified to what is shown on
the top right and the positive input is changed to 1/3 VDD. 2) The capacitor, which is
charged to 2/3 VDD, now starts discharging through the feedback resistor.
10
RO Capacitive Sensing Implementation (3 of 3)
11
The final step of the cycle is the same as the first. Once the voltage on the switch capacitor
reaches 1/3 VDD, the output of the comparator switches to logic 1 or VDD, which starts the
charge process again. This repetitive scenario gives us our oscillation frequency based on
the value of the RC time constant of the feedback resistor and the sensor capacitor we are
trying to measure.
11
Putting Your Finger on the Switch
By touching the switch directly with a finger the capacitance increases
RC
The additional capacitance increases the time constant, thereby
reducing the output frequency
12
When using Capacitive Sensing the PCB trace acts as one plate of the capacitor.
When a finger comes into proximity it acts as the other plate and air is the dielectric.
As the finger moves closer to the pad the capacitance changes based on the equation
for capacitance shown. The constants in the equation represent the value for the
dielectric constant of the material, i.e. air, glass etc. The value for A is a measure of
the area of the pad used for the sensor capacitor and d represents the distance
between the two plates. So you can see as the finger moves closer the value for d is
reduced which then increases the capacitance. Keeping in mind the relaxation
oscillator operation from the previous slides we noted that as capacitance increases
the frequency of oscillation decreases.
єr is the relative static permittivity (sometimes called the dielectric constant) of the
material between the plates
A is the area of each plate
D is the separation between the plates.
12
How to Detect the Change
There are two ways to measure the change in frequency
Measure the frequency
Count the number of relaxation oscillator cycles over a fixed period of time
Measure the period
Count the number of system clock cycles over a fixed number relaxation cycles
The example code installed with the IDE counts the system clock cycles during one
relaxation oscillator cycle
Inactive State
13
There are two ways to measure the change in the relaxation oscillator frequency. There is a calibration step that needs to be
performed first in order to measure a count value with no finger present on the pad. This would be considered the idle, steady
or inactive state. The first measurement technique uses two timers. The first timer is clocked by the relaxation oscillator (RO
timer) and the second is used to generate the fixed time base (Fixed Timer). At the overflow of the Fixed Timer the value of
the RO Timer value is read. If the RO Timer value is less than the inactive state value from a calibration then it is determined
that there is a valid button press. When measuring the period we use a timer that is clocked by the system clock (System
Timer). The comparator output in this case is used to provide a capture event. The captured value is compared to a calibrated
value and if the system clock counts are higher then the capacitance is greater causing the capture period to be longer, thus
allowing more system clocks. When this condition exists it is considered to be a valid button press. With the relaxation
oscillator solution, this is the minimum amount of cycles we can count and still get an accurate results. We cannot use a
sampling period shorter than 1 relaxation oscillator cycle and achieve repeatable measurements.
13
Charge Timing Implementation
14
Successive Approximation (CS Module)
IREF ISENSOR
VREF SAR
CREF
CSENSOR
15
The successive approximation (SAR) method uses a pair of current sources to drive current
into separate capacitors. The first is the reference capacitor denoted as CREF and the other is
CSENSOR. The current source denoted as IREF is a fixed current used to drive the CREF
capacitor to provide a constant ramp voltage. The second current source denoted ISENSOR
sources a variable current to the sensor capacitor. After each measurement cycle the SAR
logic will change the value of ISENSOR, attempting to get the ramp rate the same as the
reference capacitor.
15
Putting Your Finger on the Switch
By touching the switch directly with a finger the capacitance increases
Inactive Switch
Active Switch
Charge Time
16
As with the relaxation oscillator, when using Capacitive Sensing the PCB trace acts
as one plate of the capacitor. When a finger comes into proximity it acts as the
other plate and air is the dielectric. As the finger moves closer to the pad the
capacitance changes based on the equation for capacitance from the earlier slides.
Keeping in mind that as a finger moves closer the value for d is reduced which then
increases the capacitance. Keeping in mind the SAR operation from the previous
slides we note that as capacitance increases the comparison point for the threshold
voltage decreases.
16
Successive Approximation
IREF
ISENSOR
17
Let’s take a closer look at the successive approximation steps in determining the value of
the ISENSOR source. The SAR will set the current source to the mid-scale and drive the
ramp until the timeout period expires as governed by the reference capacitor charge time.
Mid-scale for the 16 bit current source is 0x8000. At this point the voltages are compared.
If the sensor capacitor has charged to a value that is greater than the reference as shown in
the figure then there was too much current and the MSB value is then set as a zero
(conversely, if the current did not reach the threshold then that means there wasn’t enough
current and the MSB is then set to a one). Since the previous bit was set low the next
weighted bit is set to the a value lower and half of the setting or at 0x4000. The charge
cycle is started again and the voltages are once again compared. In the example above we
see that with this new value the voltage didn’t make it to the threshold point meaning we
need to supply more current to the sensor capacitor. This bit is then set as a one and the
next value is again the halfway point to the mid-scale voltage or 0x6000. This process
continues all the way to the last bit at which time the ramp rates of the two capacitors are
equal.
17
CS Module Advantages
No external components required
IREF ISENSOR
VREF SAR
CREF
CSENSOR
18
The SAR implementation eliminates the need to provide any external components
and can monitor capacitance just by connecting to the pad of the MCU. All of the
components necessary to implement CapSense are integrated on chip. Another
benefit is the fact that the implementation uses a differential measurement for the
sensor capacitor and the reference capacitor thus providing very high rejection to
power supply noise. The SAR sampling method is not affected by DC offsets as the
relative change in the voltage and the time period for that change is dependent on
the capacitance. Also, the sampling time is very short minimizing the affects of low
frequency noise. The design provides filtering for any high frequency interference
that may cause inadvertent switch actuation. Since the peripheral is self timed it can
run autonomously from the CPU which means the CPU can be in a low power state
and be woken up by a switch actuation event.
18
Capacitive Sensing In System
19
Designing Touch Sensitive Switches
On the PCB there are two main factors that affect the switch
capacitance and how much it changes
Size, shape and placement of the switch pattern on the PCB
The characteristics of the trace that connects the switch to the MCU
20
Now that we understand how Capacitive Sensing works, let’s take a look at the
system implementation. Our main goal in designing CapSense switches is to
maximize the change in capacitance between the inactive state and a finger press.
In order to accomplish our goal we have to keep in mind the equation for
capacitance that we discussed earlier and is shown here for reference. When
looking at this we see that the areas we can control are the pad dimensions which
relate to the quantity A in the equation. This directly relates to the size and shape of
the switch pattern. We also control d which is the distance from the pad of our
assembly and the dielectric constant relating to the material we use to cover the pad.
One thing that tends to get overlooked is the characteristics of the trace that
connects the switch to the MCU. Being connected to the switch pad, all capacitance
we add in the form of trace capacitance increases our inactive state capacitance.
20
Initial Configuration
Performed for each switch individually
Even if all the switches are the same size and shape, their location on
the board will affect their inactive state capacitance
Performed during development or production test
The results should be programmed to Flash
Three step procedure
1. Measure the sensing method output with nothing on the switch (inactive state count)
2. Measure the sensing method output with the switch active (active state count)
3. Set the threshold to a value between the two measurements
The threshold value determines the sensitivity
Sensitivity
Active to Inactive Count
21
Traditional System Signal to Noise
SNR is affected by different system level parameters
Capacitive sensing pad layout
External stimuli
Proximity to other conductive objects
Electrical interference
Ground planes
Environmental affects like temperature
Dielectric material and thickness and contaminants on the switch
1. Calculate the mean for the inactive and the active state
1 n 1 1 n 1
B B(t )
n 0
A A(t )
n 0
2. Calculate the peak noise value for the inactive state.
N S max( B(t )) B
22
There are many system level considerations when implementing Capacitive sensing.
The responsiveness of a switch in the application is dependent on the pad size, the
dielectric material type and thickness as well as the layout and how the PCB is
oriented and what is in proximity to the pad. Once all of these factors are in place,
only characterization of the switch can really provide the information required for
the firmware to make the determination as to whether or not the switch is in the
inactive state or the active state. In order to provide adequate margin between the
two states all of the design considerations mentioned must be structured such that
the maximum signal to noise ratio can be realized. This is required so suitable
threshold levels can be identified. This slide explains the traditional signaling
details required to characterize the system. In literature you can find that a suitable
signal to noise ratio for Capacitive sensing for touch applications is 5 to 1. The
equations listed above outline the traditional method to calculate the system level
signal to noise ration of the switches.
22
System Characterization (1 of 3)
Can be conservative based on increased SNR capability of the C to D converter
Calculate the inactive and active baselines
1 n 1 1 n 1
AB AB (t )
n 0
IB I B (t )
n 0
Calculate the standard deviation of the noise for the inactive and active state and
determine the safe zone
SafeZoneItoA A B A I B 3.3 x I B
SafeZone AtoI A B
3.3 x A I B I
Determine the thresholds of the signal
23
System Characterization (2 of 3)
Initial Configuration
Even if all the switches are the same size and shape, their location on the
board will affect their inactive and active state capacitance
75% * SafeZoneItoA
SafeZoneItoA
Inactive State noise
3.3 σ Inactive State MEAN
Here we see the preceding equations represented graphically for the inactive to
active state transition. From the graph you can see that the standard deviations for
both steady state values are used for determining the safe zone. The threshold is set
to 75% delineated by the green hash mark.
24
System Characterization (3 of 3)
Store the operating parameters to the flash
The threshold values determine the sensitivity
SafeZoneItoA
75% * SafeZoneAtoI
Inactive State noise
1σ Inactive State MEAN
25
Here we see the preceding equations represented graphically for the active to
inactive state transition. This graph differs from the one on the preceding slide in
that the active state noise being considered is now 3.3 standard deviations about the
mean instead of 1 standard deviation when going in the reverse direction. The
threshold is set to 75% of the safe zone this time delineated by the red hash mark.
25
Periodic Configuration
Perform similar procedure as initial configuration during normal operation to
account for a dynamic operating environment
Some relevant factors are:
Water, oil, or other materials on the switch
Changes in supply voltage
Change in humidity and temperature
These factors can affect the capacitance of the switch or the charge/discharge
profile
If the effects are large enough, the incorrect measurements can lead to false switch
events
26
Once a system is deployed, there may be environmental effects that change the characteristics of the
switch. An example would be a touch panel outside or an industrial environment where some oil or
other material can get on the switch. When it rains the water would change the properties by altering
the dielectric constant thereby changing the capacitance we would measure. Another effect could be
as simple as differences in finger sizes. To compensate for these problems, periodic configuration (or
baselining) compares runtime baseline values to calibrated reference baseline values and scales the
thresholds appropriately. The inactive baselines are a way to determine the offset between inactive
capacitance measured during calibration and inactive capacitance measured at runtime. The active
baselines are a way to determine how much the channel's gain has changed. Without periodic
configuration, calibrated active and inactive threshold values can become invalid as conditions
around the device change.
Determining the threshold values is an important part of the Capacitive sensing system. Following
the guidelines ensures reliable switch actuation when the system is deployed. All of these
measurements should be tailored to the system. For example, the value of the noise should be
determined in the environment that the system will be used. The active region should be set to a
value that takes into account the distance of the finger to the pad due to dielectric gap as well as
possible offset positions (which would reduce the output). These values are generated during the
development phase of the project and can be stored in flash. The sensitivity margins provide the
capability to enhance the detection algorithms in order to adjust for environmental affects such as
temperature drift. The inactive measurement can be continually updated as long as it is below the
noise threshold. Keep in mind this is only a recommendation for standard switch implementations.
There are many applications that may require deviating from these guidelines.
26
Different Switch Arrangements
Solid pads
Square pads and round pads
Round pads have uniform field lines around the pad and are preferred
Have similar sensitivity
Highest sensitivity
Interleaved pads
Reduces pad area and increases parasitic capacitance
Not recommended
Effects of grounding
Grounding around switches reduces sensitivity by absorbing some of the field lines
The smaller the gap the more parasitic capacitance
The gap should be sized according to the thickness of the dielectric material
Necessary if no ground reference to the object in proximity
Hatched ground planes minimize desensitizing parasitic capacitance while providing
good noise reduction
27
Now let’s put what we learned to use. There are different topologies to consider
when generating the Capacitive Sensing pads. When designing the pads we have to
keep in mind that the field currents are going to try and find their way to ground
whether it is a ground connection or a virtual ground represented by a finger. The
most common type of pad is the solid circular pad. This provides the highest
sensitivity because of the area based on our equation for capacitance. Without any
grounding, all of the field lines would be directed from the positive pad to the lower
potential represented by the finger. There are also designs that interleave pads.
These methods reduce the flux density to the finger because of reduced area and
parasitic capacitance, thereby reducing sensitivity, and are not recommended.
Another topology is to surround the pad with a ground or guard. The size of the gap
between the pad and the ground changes the field lines which affect the parasitic
capacitance. This shows up as a smaller net change in capacitance.
27
Effects of the Switch Size and Shape
1
pF A B C
1 8.4 4.8 6.4 2
It is easy to see that the bigger the switch and the more
traces there are within a certain area, the more inactive
state capacitance the switch has
Both of these factors make the switch more robust
28
Let’s take a look at some of these using real examples. The table shows
measurements taken from the pad topologies shown. The values in the table are
marked according to the letter and number designations from the figure. For
example, A4 is the largest circular pad with a small gap to the ground ring. The
values represented in the table show the inactive state capacitance (capacitance with
no finger present). Since we are trying to measure the relative change in
capacitance we would like to start with a low inactive state capacitance which
provides greater dynamic range. You can see the coupling of the interleaved pads
increases the inactive state capacitance and the solid pad enables us to get a lower
inactive state capacitance.
28
Effects of Trace Length
The trace that connects the switch to the MCU input pin
should be as short as possible to minimize the total parasitic
capacitance added to the switch
29
Parasitic capacitance in the PCB design affects the measurement capability. When
we talk about parasitic capacitance we are referring to the voltage potential that
exists along the length of the trace, therefore, longer traces have a higher
susceptibility to parasitic capacitance. This is important in reaching our goal of
increasing the relative change in capacitance when using this method for switches
and is often an area overlooked. The value of trace capacitance adds to the overall
inactive state capacitance of the Capacitive Sensing switch. In order to reduce the
effects of trace capacitance shorter, narrower traces, which exhibit lower overall
capacitance, are recommended. In addition to the inactive capacitance value of the
trace, its proximity to noisy signals and grounds affect the overall performance of
the system. Long traces are no big deal unless they are surrounded by conductive
objects (like traces or grounds) at a different voltage potential (parasitic) or, and just
as important, neighbored by other conductive objects with changing voltage
potential (noise), such as traces from other nearby capacitive sensors. Why are
these factors important? It is desirable to have at least a 0.5% change in the
capacitance between the inactive state and the active state. For example, if the total
capacitance of the switch and parasitic capacitances is 200 pF, the change in
capacitance when you put your finger on the switch should be at least 1 pF.
Overall, we want to reduce parasitic capacitance on the trace and at the sensor to
maximize the sensitivity.
29
Switch Arrangements—Size and Shields
Switch size
Same size as the expected conductive object recommended
Shields
Plane layer at the same voltage potential as the pad
Introduces no parasitic capacitance
Increase sensitivity by forcing all field lines to the approaching
conductive object
Shield
30
When designing the Capacitive sensing pad the overall dimensions of the object you
are trying to sense should be considered. For example, the conductive object shown
in the slide is much smaller than the Capacitive sensing pad shown. With the
conductive object of this size we would have unnecessarily oversized the pad. The
same guidelines hold true when the conductive object is the human finger. Another
aspect of switch design is the concept of shielding. In most instances we are
familiar with using grounds as shields in order to block unwanted noise. However,
when we are driving the pad capacitance with our excitation source (like the
relaxation oscillator) and if we add a ground under the pad we will induce a voltage
potential difference and thus a parasitic capacitance. There will be field lines from
our pad that are attracted to the lower voltage potential. But what happens if we use
a plane that is at the exact same potential as the pad we are exciting as shown in the
figure? Since we now have the same voltage potential between the two plates there
is no capacitance. All field lines that are generated from the pad are directed to the
conductive object we place near the pad while blocking the unwanted parasitic
capacitance.
30
Effects of Different Materials for the Dielectric
The type of material on top of the switch affects the inactive state
capacitance and the active change in capacitance
Recommendations
Use the thinnest material possible to maximize the change in capacitance
Use materials with a higher dielectric, such as glass, to increase the
absolute capacitance of the switch
This increases the relative change in capacitance when compared to the trace
and other parasitic capacitances
31
We discussed different areas that we can control in the design of the pads in order to
increase the sensitivity and robustness of the switch. The first area we covered was
the pad area and we saw that larger solid pads increased our sensitivity. The next
area we can control is the dielectric material and the distance d from the pad. Most
Capacitive Sensing pads have an overlay of some sort, like glass. The thicker the
glass the farther away from the pad we are for the touch. Remember that
capacitance goes down with an increase in distance so the material we place on top
of the switch should be as thin as possible and still meet the application
requirements. Also, the material chosen influences the capacitance via its dielectric
constant. Using materials with a high dielectric constant will increase the
sensitivity. Here are some materials that were tested in application note AN338
from Silicon Labs. A link to the appnote can be found at the end of this
presentation.
31
Design Considerations Summary
The circular switches have the lowest inactive
capacitance and also exhibit the largest relative
change in capacitance when the switch is active
Use the thinnest possible material with the highest dielectric constant
Ensure that there is no gap between the board and the covering material
32
The advantage of having the lowest inactive capacitance is that it takes a shorter
amount of time to measure one period when considering the relaxation oscillator
method. The SAR technique conversion time is constant regardless of the value of
the capacitance. This provides a consistent measurement from pad to pad. The
advantage of having the largest change in capacitance is that it is easier to detect.
The solid circular pad met both design goals, lower inactive capacitance and a high
sensitivity. Using the thinnest possible material to meet the design goals enables the
largest change in capacitance to be detected and therefore makes the design more
robust. By maximizing the change in capacitance that can be detected the threshold
and calibration algorithms can potentially be simplified reducing code space. When
adding the material over the switches it is important to make sure there is no air gap.
Air has a low dielectric constant compared to materials such as glass. Ensuring that
there is no gap will ensure that the highest change possible will occur when the
switch is active. Certain adhesives from 3M (such as 467 or 468) provide good
bonding of the dielectric material while providing a uniform area and high dielectric
constant. See application note AN338 for more information regarding capacitive
sensing and measurement results of different materials.
32
C8051F93x Implementation
33
Capacitive Sensing RO Implementation
34
Let’s take a look at how to implement the Capacitance Sensing using the C8051F9xx family
from Silicon Labs. The relaxation oscillator itself is implemented using only the
comparator. Remember from our earlier discussion about how the relaxation oscillator
works. We have the resistor network used to set the comparator threshold and the feedback
resistor to provide the current path to charge and discharge the capacitor. The comparators
on the C8051F93x/92x family of devices include the charging mechanism for the switch
capacitors that are connected to the comparator multiplexer as well as automatically
configuring the varying voltage threshold on chip. All that is required is to connect the pad
to the pin of the MCU. The comparator output also can be used as the capture source for
the timer.
34
C8051F93x/92x Comparator Block Diagram
35
The left side shows a simplified block diagram of the comparator peripheral when
configured for Capacitive Sensing mode. The positive input multiplexer is
configured to set the voltage threshold. The negative input multiplexer can select
between the different GPIO pins that are connected to touch sensitive switches. The
output of the comparator (CP OUT) has three functions. The first is to help set the
voltage threshold, which is the resistor network in the top left. The second is to
charge and discharge the capacitor through the Rfeedback resistor. The third
function is the the output frequency of the relaxation oscillator.
The simplified diagram on the left shows one configuration where the positive input
sets the threshold and the negative input is connected to the switches. The
comparator multiplexers can switch roles and the positive input can be connected to
the switches and the negative input can set the threshold. The positive input
multiplexer can connect to 12 different GPIO pins and the negative input
multiplexer can connect to 11 different GPIO pins for a total of 23 possible inputs.
The right side shows the block diagram simplified even further to show the
configuration for one touch sensitive switch.
35
RO Capacitive Sensing with Other MCUs
The capacitive sensing solution can be implemented on other
Silicon Labs MCU families using only passive components
Silicon Labs MCU families other than the C8051F93x/92x family can
interface up to 12 switches directly or more with an external
analog multiplexer
36
36
Adding Multiple Switches
37
37
The Comparator Module
38
38
The Timer Module
Comparator 0 is used as the capture event for the timer module.
Allows for measuring the period of the relaxation oscillator using the system
clock (SYSCLK)
39
39
Benefits Of The Implementation
Low MCU overhead
443 bytes code space for one switch and only one additional byte for
each additional switch
Only requires one comparator and one timer
Efficient algorithm allows the MCU to go into low-power mode and wake up
periodically to detect a switch event
Less than 0.05% CPU utilization
Simple configuration
Easy to perform with any material on the switch
40
Simple Configuration
All configurable parameters are obtained the same whether the dielectric is plastic, glass,
just the PCB trace alone, or anything else that typically covers the switch.
Capacitive Sensing
ToolStick Base Adapter
Daughter Card
Part Numbers:
CAPTOUCHSENSESK — Capacitive Sensing Starter Kit
CAPTOUCHSENSEDC — Capacitive Sensing Daughter Card
41
Let’s take a look at some of the hardware available to check out Capacitive Sensing.
The ToolStick base adapter can connect to the Capacitive Sensing daughter card.
This card implements the touch pads as 4 solid round pads with a ground guard.
The sample code provided allows customers to play with the sensitivity of the
switches and see how Capacitive Sensing might work in their application.
41
What Can You Do With the Kit?
Sensitivity
Active to Inactive Threshold
The development tool is a good starting point for implementing your own system.
You can play with the values in the source code provided in order to see how
varying the threshold value affects the trip point of the switch. You can also take
this a step further to see how environmental affects change the capacitance values.
Even by blowing on the board, the humidity of your breath can change the dielectric
constant and cause false positives depending on sensitivity settings.
42
C8051F700 CS Implementation
16-bit SAR converter
32 channel input multiplexor
Single channel or multi-channel scanning using auto scan
Hardware accumulator
Window logic threshold to trigger an event when an active state is detected
43
Let’s take a look at how to implement the Capacitive Sensing using the C8051F700 family
from Silicon Labs. The 16 bit SAR block itself is implemented as a complete stand alone
block and generates it’s own time base. This allows it to run autonomously from the CPU
and provides the capability to wake the CPU from a low power state. Also integrated is a
20 bit accumulator that can add 1, 4, 8 or 16 scans and then provide the division using a
simple shift function. Using this hardware accumulator and simple shift function provides a
low overhead averaging function to reduce the affects of noise in the system. The window
comparator is software programmable and is set based on the system level performance of
the pad configurations. After the inactive and active signal levels are determined and a
suitable threshold is obtained the window comparator can be set to trigger an event when
the active switch threshold is met. This is useful to reduce CPU overhead and also for low
power modes. The conversion of the CS0 module is capable of being generated from
several sources including software trigger, all of the timers and auto-scanning. All of the
required components for Capacitive sensing are integrated on chip. Therefore, we can
connect the Capacitive Sense pad directly to the pin of the MCU.
43
Benefits of the CS Implementation
Increased sensitivity to change in capacitance
Hardware accumulator
Decreases system noise
Reduces CPU overhead
Simple configuration
Easy to perform with any material on the switch
44
44
Results
45
CS0 vs. RO Set-up
Set-up
C8051F700 and C8051F930 daughter cards used
Similar layout
Similar pad dimensions. The pads were simple as they were designed just for demo purposes.
1/8” dielectric material
Measured parameters
Inactive state counts
Active state data
Calculated parameters
Determine the mean of the inactive data
Determine the noise of the inactive data
Determine the mean of the switched active state data
1/8” overlay
Calculate the Signal level
Calculate the SNR and thresholds
Capacitive Sensing
ToolStick Base Adapter
Daughter Card
46
The hardware used to compare the relaxation oscillator method and the Capacitive
Sensing Module (CS0) was the ToolStick daughter cards. The overlay material was
placed on the switches and the data was accumulated viat the ToolStick Base
Adapter. The inactive measurements were taken and then a finger press on the
overlay material for each of the boards. The results are found on the next slides.
46
RO System Signal to Noise Example
The RO method did not perform as well as the CS0 module. In order to use the RO
method the pad would have to be redesigned and special consideration would have
to be given to the overlay material and the thickness as well as the layout of the
board. These factors were not even really considered on the F700 board as it was
also just designed as a demo where a finger can be placed directly on the PCB.
47
CS0 System Signal to Noise Example
C8051F700 daughter card with 1/8” overlay (raw data)
Inactive state ave. = 19942
Active state ave. = 20353
Active State MEAN
*Inactive state noise1 = 26.7
**Inactive state noise2 = 17.2 **SNR= 23.5
Signal = 20353-19942 = 411
*SNR1 = 411/26.7 = 15.4
**SNR2 = 411/17.2 = 23.5
Inactive to Active Threshold
Signal (S)
Noise threshold = 164
OFF threshold = 246
ON threshold = 369
Active to Inactive Threshold
Inactive State noise (N)
*The value of noise used is 3.3 standard deviations from the mean
**The value of noise used is the peak value from the mean
48
Here is an example using simulated data on a finger press using the CapSense
module. The inactive measurement yields an average value of 19942. The active
state measurement yields a average value of 20353. The difference of the average
values gives us our signal level and in this case is 411. Once the signal is obtained
the threshold values can be determined. For example, to set the value for the ON
threshold we calculated 90% of the signal (.9 * 411). This value is then added to
the inactive mean to give is the actual threshold value in either counts (for the
relaxation oscillator method) or 16 bit sample (using the SAR method). The other
values are found in the same manner. There are two ways to measure the noise in
the system. The first s using the standard deviation and the statistical value to
encompass a percentage of the data points. The next way is to take the maximum
value of the of the inactive data and subtract the mean to find the peak. Both values
are shown above.
48
CS0 Actual System Design Example
Front panel display and touch pad input PCB with 1/8” overlay
Raw data used—no oversample
Active State MEAN
Inactive state ave. = 16436.7
Active state ave. = 16736.57
*Inactive state noise1 = 16.86
**Inactive state noise2 = 11.3 **SNR= 26.5
Signal = 16736.57 - 16436.7 = 299.87
Signal (S)
*SNR1 = 299.87/16.86 = 17.8
**SNR2 = 411/17.2 = 26.5
Noise threshold = 120
OFF threshold = 180
ON threshold = 270
Inactive State noise (N)
*The value of noise used is 3.3 standard deviations from the mean
**The value of noise used is the peak value from the mean
49
Here is an example using actual data from a completed system. The CS0 module
was used in this example to accumulate single data points. The mean for the
inactive counts and the active state were calculated and are shown on the side bar.
The overall SNR in this system just using raw samples was 26.5 if using the
standard method to calculate SNR. When using the more conservative approach our
SNR measured 17.8 which is still 3.56 times better than what has been considered
the accepted SNR for touch sense applications.
49
CS0 Actual System Design Example (Averaged)
Front panel display and touch pad input PCB with 1/8” overlay
16x hardware-based oversample
Active State MEAN
Inactive state ave. = 16387.5
Active state ave. = 16736.69
*Inactive state noise1 = 4.78
**SNR= 99.7
**Inactive state noise2 = 3.5
Signal = 16736 - 16387 = 349
Signal (S)
*SNR1 = 349/4.78 = 73
**SNR2 = 349/3.5 = 99.7
Noise threshold = 114
OFF threshold = 170
ON threshold = 256
Inactive State noise (N)
*The value of noise used is 3.3 standard deviations from the mean
**The value of noise used is the peak value from the mean
50
Here is an example using actual data from a completed system. The samples in this
example were derived using a hardware averaging function. Sixteen samples were
accumulated and averaged using hardware. This approach requires no CPU
overhead to sum the sample and then perform the averaging function.
Oversampling by 16 should decrease the noise by a factor of 4. The overall SNR
will increase as a result.
50
CS0 vs. RO Conclusions
51
Learn More at the Education Resource Center
Visit the Silicon Labs website to get more information on Silicon Labs products,
technologies and tools.
The Education Resource Center training modules are designed to get designers up
and running quickly on the peripherals and tools needed to get the design done.
http://www.silabs.com/ERC
http://www.silabs.com/mcu
http://www.silabs.com/CapTouchSense
AN338: Capacitive Sensing Solution
AN367: Understanding Capacitive Sensing Signal To Noise Ratios and Setting
Reliable Thresholds
AN366: QUICKSENSE™ Firmware API
AN418: Baselining in the QUICKSENSE™ Firmware API
52
Visit the Silicon Labs Education Resource Center to learn more about the MCU
products.
52
www.silabs.com/MCU
53