Posted by Burke on Jun 4, 2010 in
Capacitive Touch,
General,
Input
When you are designing a system that has a sensor that must be sampled, eliminating noise from the readings should be one of your concerns. Averages and other low-pass filters do a good job at smoothing the signal which reduces the amount of white noise, but if the sample rate of your system is a harmonic of the noise’s frequency a different approach is needed.
First, we need to understand what is going on in the system that is causing us to change our sampling behavior. The picture below shows a normal sensor signal that has been injected with a single-frequency noise signal. The sampling rate occurs at a harmonic frequency to the noise and so the samples are not occurring at random locations on the noise – they are following a harmonic sine wave.

If each sample is processed individually, the system will have to filter out the sine wave which could slow the response time. If multiple samples are added together or averaged, the resulting stream of samples will look like they have a large increase in the amount of white noise. This will have to be filtered out which will decrease the sensitivity of the sensor.
The solution to this problem is to slightly jitter the sampling rate of your system. Instead of sampling every X ms, sample every X+Y ms, where Y is a random value that is much smaller than X. For example, if your system is sampling once every 10 ms, then the sampling rate may be jittered by +/- 25 µs. (TIP: To create a simple, pseudorandom number, you can take the least significant bits from the previous sample and add them to the sampling rate timer. It’s not perfectly random, but it should be random enough.)
The result of this technique will be that your system will sample with the behavior shown in the picture below. Notice how the samples are still following the sample rate, but now they are more randomly distributed throughout the injected noise signal. Now if the system processes one sample at a time, it will see a small amount of increase white noise which will be solved with a simple averaging filter. If the system takes several samples and combines them before processing them, the white noise should naturally eliminate itself and the samples will hover around the normal sensor signal.

Tags: Filter, Jitter, Noise, Sampling, Sampling Rate, Sensor, Signal
Posted by Stephen on Feb 13, 2009 in
General,
Input
Let’s take a look at the modern kitchen and the interaction we have with it today. If you where to standing in the middle of a modern kitchen, or even the local appliance store, you would find that mass about of buttons, knobs, colors displays, buttons that light up, make sounds, and even disappear when not needed. This could borders on overload for some.
When I look at the modern appliances, one vision that I remember as kid growing up was my Grandmother cooking lunch for me. It was not a fancy lunch, usually grilled cheese and soup, but the vision of her standing there with her apron on, oversized oven mitts, and wooden spoon in one hand will never leave my mind. The stove she used was not fancy, but efficient in how the user interacted with it with simple knobs that she could turn to adjust the temperature of the cooking surface.
Today, the style of the appliance is an important aspect when selecting one. Does it have buttons that light up, or is it stainless steel. What about a solid surface to clean? These are some of the items that my Grandmother would look at today. So how do you operate one of these modern cook top will still keeping your hands inside the oven mitts or even use the wooden spoon to press the off button? The answer to this question is simple…Inductive touch .
Image if you will a Grandmother standing in front of the stove as a child has just come in out of the cold from building a snowman in anticipation of warm soup. The Grandmother has on the classic oven mitts, as she just finished making chocolate chip cookies, and is stirring the soup as it begins to boil over the top of the pot. Instantly she reacts and uses the end of the spoon to press the off key while removing the pot from the hot burner.
The cook top that she is using has single face plate made of stainless steel for the control buttons. These buttons are etched or silk-screened on the faceplate providing the elegant look and feel demand by today’s consumers. But how was she able to use the end of the spoon to control the buttons. The inductive touch solution is a complement to the capacitive touch solutions out there today. Capacitive solutions make use of the person to change the value of a capacitor and this is hard to do with a wooden spoon. While the wooden spoon will not work for capacitive, it will work with inductive touch.
Inductive touch makes use of the metal or in this example the stainless steel ability to move. The movement is so small that the consumer will not even know that it is moving as it only moves about 10 – 20 microns. That is less than 1/1000 of an inch. This movement is sensed by a circuit that is mounted behind the user interface panel. Once the movement is sensed and debounced, the rest of the operation is the same as if there was a mechanical or capacitive button in the design.
Inductive touch technology is not a replacement for capacitive touch, but one that will work in different environments. For example capacitive touch can sense a finger just slightly above the user surface, where inductive can not. On the other side, when you clean capacitive buttons you will be pressing the buttons as you wipe across them. This is not the case with inductive touch as you need to physically press the button to create the deflection.
Now that I have introduced inductive touch to the blog, we will be adding further blogs talking more about the technology itself and some of the other uses for it.
Tags: Inductive Touch
Posted by Keith on Feb 4, 2009 in
Input
It is pretty much a given that any serious discussion of user interfaces and embedded design will eventually cover the subject of de-bouncing mechanical buttons. This simple intrusion of physics on the equally simple subject of user input has been a source of aggravation to more programmers than almost any other subject. Basically, all the screaming is about the mechanical bounce of switch contacts when the button is pressed. The problem is that the microcontroller is easily fast enough to see the multiple make-break transitions and report them as multiple key presses.
Most programmers handle this problem by sampling the input at a relatively slow rate, and then waiting for 3 consecutive low inputs before calling the button down. The release is generally taken to be the first high after a valid press. While this works and is relatively simple to implement, it does have an Achilles heal. If the contacts are closed, and the system is subjected to a shock, then bouncing contacts will be interpreted as a release followed by a new press.
One common method of fixing this problem is to just require 3 consecutive high inputs before calling the button released. The problem with this method is that a 3 sample system has to be fast enough to see at least one open during the bounce, while also slow enough to not see 3 closed samples during the bounce. Basically, 3 samples do not always allow enough of a window for the potential variability of the mechanical system. While we could expand out the system to 5 or 7, the overhead of keeping the last 5-7 samples become more complex, and more aggravating, plus the added de-bounce delay time will eventually become noticeable to the user. What we need is a system that starts the de-bounce process before the contacts stop bouncing.
The system that I use is based on the duty cycle of the bounce and it calls a button closed when the duty cycle exceeds 75%. I do this by using a single 3-6 bit counter, which I increment for every low sample, and decrement for every high sample. I also limit the counter so it can not roll over or under. When the count gets to 75%, I set the de-bounce output, and when it gets to 25%, I clear it. Using this system I can actually de-bounce the button before its contacts stop bouncing.
The C code for a single button is shown below;
Void poll_keys()
{
IF (swx_input() == 0)
IF (count < (max+1)) count++;
ELSE
IF (count > 0) count–;
IF (count >= (max*3/4)) button = 1;
IF (count <= (max/4) button = 0;
}
Tags: Mechanical buttons
Posted by Keith on Jan 19, 2009 in
Input
There has been a lot of hype and hoopla about capacitive touch recently. Some of it is deserved and some not. The best way to separate fact from fiction is a basic understanding of the basic technology.
Let’s start with EE-101; a capacitor is basically two isolated conductors separated by an insulator. That means that two cars sitting next to each other in the parking lot can potentially store a charge, two airplanes passing each other at 30,000 feet can store a charge, and two red blood cells in your veins can hold charge. The basic equation for capacitance is C = eoerA/D, where C is capacitance in Farads, eo is the permittivity of free space, er is the relative permittivity of the insulator between the plates, A is the area of the smaller plate, and D is the distance between the plates.
The fact that your blood cells are capacitively coupled to one another is actually the basis for capacitive touch. Because your blood cells can form capacitors, it means that every surface of your body is capacitively coupled to every other surface. So, when you touch a button on your cap touch microwave oven, you are basically capacitively coupling the button to the cabinet of the microwave through your body, and potentially some of the floor, walls, and other objects in the vicinity.
Now, I know, the buttons is coupled to all of these surfaces anyway because air is an insulator as well. The difference is that you body is mostly water, and water has a higher relative permittivity, than almost every other insulator, by at least a factor of ten. That is why we can produce a relatively large shift in the capacitance, even through a relatively thick insulator.
Alright, so we improve capacitive coupling between objects, and that increases the capacitance between the senor and ground. How do we use this effect to create a capacitive touch button? Well, there are several ways, we can charge and discharge the sensor capacitance and measure the time required, we can build an oscillator with the capacitor and measure its frequency, we can drive it with an AC voltage and measure the voltage generated across it, or we can use it to couple an AC signal between two sensors and measure the attenuation of the signal. All of these systems work, it is just a matter of cost and complexity. At the end of the day, what we need is a value corresponding the capacitance of the sensor.
Once we have the capacitance value, then we can use changes in its magnitude to determine when a user has touched the sensor. We do this by periodically measuring the capacitance and comparing it against a threshold value. Now we can’t use a fixed value for the threshold because the capacitance will change over time due to temperature and humidity variations, but we can create a tracking average that follows the untouched value of the sensor and use that to create our threshold.
While this may sound simple, I can assure you that this is where you will start pulling your hair out. Our averaging system is supposed to track the un-pressed capacitance of the sensor, the problem is that we don’t know when the sensor is about to be pressed. As the user brings their finger closer to the sensor, the capacitance of the sensor will start to climb, and that will pump up the average. In fact, the act of touching and holding the sensor will also move the average if we don’t gate it off during a touch. On top of this is the problem of cross talk, specifically, the increase or ‘pumping’ of sensor average of sensors adjacent to the touched sensor just because they share the same insulator. Think of it as a sideways capacitor on the slant between the finger and the other sensors.
What this means for our system is that measuring the capacitance is actually the easy part, determining what is and is not a touch is the real challenge. That is why most suppliers of capacitive touch systems supply several averaging options for their systems. Picking the right averager is in fact critical to the correct operation of the system. Choosing the wrong averager can cause degradation in the sensor sensitivity, or even a lock up condition that will prevent the system from detecting anything.
So, what kind of averaging systems are there?
The polled average just grabs an un-pressed value from the interface periodically (1-10 seconds) and uses that for the average. This is relatively simple, but has a draw back; it can loose sensitivity if it is suddenly placed in close proximity to another metal object. This causes the average value for all of the sensors to jump and when that happens the system’s thresholds are all in the wrong place and it looses sensitivity until a new average is acquired.
The continuous average system combines every 3rd – 5th value into a continuous running average. This overcomes the problem with the polled average, but has a different draw back. If the user holds the button for any length of time, the average will shift down to the pressed value and the difference indicating a touch will disappear. In addition, the average is now offset for the un-pressed value and will take time to recover. Some systems get around the disappearing touch problem by using a software flip flop then set on the negative shift and clears on the positive shift. The average can also be made to recover quicker by resetting the average to the current value whenever the current capacitance value is greater than the average.
The gated average system uses a continuous average system with a guard-band. If the difference between the average and the current capacitance value is less than the guard band, the current value is included in the average, if the current value is outside the guard band; it is not use in the average. This maintains the average near the un-pressed value regardless of how long the sensor is touched, and gets around the problem with the continuous average. But it has the possibility to lock up, particularly when a metal object is placed in the vicinity of the sensor. So if a gated average is used on a hand held device and the device is placed on a metal table top, there is the possibility that the system will stop working until it is removed from the table. There is also the possibility that the un-pressed capacitance value could shift while a button is pressed (due to a temperature / humidity change) which would put the un-pressed value outside the guard band with no way to recover.
A dual average system can solve the temperature drift problem by using two different averages, one for the un-pressed state, and a second for the pressed state. The un-pressed state average is then used to set the press threshold and the pressed state average is used to set the un-press threshold. That way the system always has a good threshold, which tracks environmental conditions, to determine both the press and release of the sensor.
There are also other averaging systems, many of which are proprietary, which have been optimized by specific user interface conditions. However, the systems mentioned here are some of the more common ones that have been published.
So, capacitive touch works because the iron in our blood makes millions of little capacitors that capacitively couple every surface of our body to every other surface. When we touch a capacitive sensor, this capacitive coupling increases the capacitance of the sensor. The capacitance of the sensor is measured using one of several different methods, and the software in the system detects the touch by comparing the current capacitance against the current average capacitance for the sensor. So, as you can see, it is not really rocket science; there are just has a few subtleties that make a cap touch design a little challenging, but your don’t have to understand field theory to make a cap touch system work.
Tags: Capacitive Touch, EE-101, Sensors