Interesting Webcast about microcontroller in Human Interface
Technical Editor Robert Cravotta explores processor and software-processing architectures and the impact they have on system and software development. Relevant architectures include microprocessors, microcontrollers, digital signal processors (DSPs), multiprocessor architectures, processor fabrics, coprocessors, and accelerators, plus embedded cores in FPGAs, SOCs, and ASICs.
Building a cap touch interface with a couple of comparators and the SR latch
With all the press and bluster about capacitive touch and all the custom peripherals that make it possible, I thought it might be a good idea to look into a solution that is a little more generic.
One simple method for measuring capacitance is to build the cap touch sensor into a relaxation oscillator as one of the frequency determining elements. For example, the figure below shows a generic oscillator circuit.
The two comparators form a windowing system that sets and clears the flip flop when the voltage across the sensor capacitor exceed 2/3 VDD or falls below 1/3 VDD. If this looks familiar to you, it should, it is the standard schematic for a 555 timer.
The frequency output is then routed into a counter, with a secondary counter driven by a stable clock source.
To do a conversion of the sensor value, both timers are cleared and then left to run free.
When Timer0 over flows, Timer1 is stopped and the value is retrieved. This value will be proportional to the frequency of the oscillator. If the exact value of the frequency is important, then we would need to design the system so that Timer0 timed out at a 10X multiple of 1 Hz, fortunately, the exact proportionality coefficient is not really important because we are only interested in a shift in the value.
Ok, that works for a one button system, how do we expand it into something more useful? Simple, we use the comparators on the microcontroller, because they also include 4:1 analog multiplexer so we can switch our relaxation oscillator to one of four inputs allowing a 4 buttons system. In fact, if we expand the same concept with an external analog multiplexer, we can push the number of buttons as high as we need. The only limitation will be the time required to measure the frequency of all those buttons.
See the figure below for an example.
Of course, if we are willing to get a little creative in our layout, we can chop down the number of inputs while still retaining the variety of button inputs. Below is an example of how 4 inputs can be expanded to cover 10 buttons.
In the example, buttons 1/3/7/9 are full buttons, while 0/2/4/5/6/8 are half buttons. The only challenge with this system is that we have to do some extra decoding on the output to determine which button is pressed. Fortunately, this is fairly easy, all you have to do is look for two buttons with the same shift. Note: it is usually easier to look for the half buttons first, and then if you don’t find one, look for single buttons.
For those that are interested, the dual comparator with a flip flop is available on the following small Microchip microcontrollers;
PIC16F616 / PIC16HV616 14 pin with PWM
PIC16F690 family 20 pin with PWM, USART, and SSP
PIC16F887 family 28/40 pin with 2PWM, UART, EEPROM, and MSSP
Touch Blog General Touch Screens
Touch Screen Article, Blog Aug 2009: Cassandra Backus, Charlie Riegert
Touch screens are user-friendly input devices that are becoming widely accepted in everyday human-machine interaction. From large industrial machines to groceries store check-out lines, all the way down to our cell phones and personal media players, touch screens are quickly becoming the standard interface.
It is important to understand that there is not a single perfect touch technology that fits every design and application. The three primary touch technologies each have different strengths and weaknesses. This chart highlights the main topics for consideration when choosing a touch technology: Cost/Optics/Sensor Life/ Integration Ease/ Multi Touch capability/ and Touch Object (the user input method)
Touch Technology Comparison Chart
Resistive technology easily dominates the touch market, accounting for over 80% of all touch designs, boasting several desirable qualities: low cost, ruggedness, ease of integration, and the ability to use any type of user input method (gloved hand/ stylus/ finger). The only major drawbacks for resistive technology are the optical quality of the sensor and its limited multi touch capability. This article will discuss the basic theory of resistive touch technology and address the crucial role of the resistive touch screen controller within a completed touch system, focusing on the embedded market.
Resistive Touch Technology
Resistive 4, 5, and 8-wire touch sensors consist of two facing conductive layers, held in physical separation from each other. The force of a touch causes the top layer to move and make electrical contact with the bottom layer. Touch position measurements are typically made by applying a linear voltage gradient across a layer or axis of the touch sensor. The touch position voltage for the axis can be measured using the opposing layer.
4 wired Diagram
The basic decoding of an 8-wire sensor is similar to a 4-wire. The difference is that an 8-wire sensor has four additional interconnects used to reference sensor voltage back to the controller. A touch system may experience voltage losses due resistance changes in the bus bars and connection between the controller and sensor. The losses can vary with product use, temperature, and humidity. In a 4-wire sensor, variations in the losses manifest themselves as error or drift in the reported touch location. An 8-wire touch sensor automatically adjusts for the changes, with the additional four reference lines. The reference lines allow the controller to know what the voltage is, at the touch sensor bus bars.
5 wire Diagram
5 wire resistive technology is a bit different and is designed to allow damage to the top layer without interfering with the touch solution. The voltage is not directly applied to the edges of the active layer, as it is for 4-wire and 8-wire sensors. The voltage is applied to the corners of a 5-wire sensor. To measure the X-axis, the left edge of the layer is driven with 0 Volts (ground), using connections to the upper left and lower left sensor corners. The right edge is driven with +5Vdc, using connections to the upper right and lower right sensor corners. To measure the Y-axis, the top edge of the layer is driven with 0 Volts (ground), using connections to the upper left and upper right sensor corners. The bottom edge is driven with +5Vdc, using connections to the lower left and lower right sensor corners.
Resistive Touch Electronics
Most resistive “touch controllers” on the market are basic analog-to-digital converters. They convert the raw electrical data from the sensor to a digital signal. The basic analog-to-digital converters can handle this operation, but still require more development to make them work properly as a touch screen controller.
To measure a touch position, the controller must drive the X axis and then the Y axis, creating a voltage divider where the voltage is sensed off the non-driven axis. While on the surface this is a simple concept, the sensor contains both resistive and capacitive elements that must be taken into account when designing this type of a device. These elements cause an associated RC rise time that varies both with pressure and the aging of the sensor. The analog-to-digital converter logic must be designed with this rise time in mind. In addition, filtering algorithms must be implemented to eliminate any invalid electrical data from the sensor. Calibration routines must also be defined, and then implemented, to map the electrical data to the visual display. Often, the analog-to-digital converter logic is designed around the characteristics, and anomalies, of a particular sensor. This can cause the integrator to pigeon-hole themselves into a single sensor sourced for the system. This can quickly turn sour, should the sensor no longer be sufficient for the system. This could be due to environmental damage to the sensor, manufacturer changes, or trying to implement the controller in a different application that requires a particular sensor construction, optic qualities, or durability. This then forces more engineering time to develop more algorithms for compensating for a different sensor to create a functioning system again.
As you consider touch screen controller options, investigate the details to be certain that you have a complete touch controller solution, rather than just an analog-to-digital convertor. A true turnkey touch screen controller should eliminate the need for reiterative engineering costs by providing filtered, reliable touch coordinates which ultimately provides for lower costs and quicker development cycles for embedded products.
The Difference Between Period Versus Frequency Measurement In Cap Touch
In a relaxation oscillator based capacitive touch system, the capacitance shift due to the user’s touch results in a frequency shift in the output of the relaxation oscillator. The shift is converted into a digital value is one of two ways; either the period of the oscillation is measured, or the frequency of the oscillation is measured. Both use on-chip timer peripherals, and both can generate equivalent resolutions, but there are some significant differences.
Let’s start by examining both systems;
Period measurement uses the output of the relaxation oscillator as a clock source for the first timer in the system. A second 16-bit timer is clocked by a high speed clock source, and gated by the output from the first timer. The first timer counts off a preset number of cycles from the relaxation oscillator, and the second timer counts the number of high frequency clock cycles that occur during the first counters timeout.
For example, let’s assume that the relaxation oscillator is running around 200kHz. Further, let’s assume that the second 16-bit timer is running from a 1MHz clock source. So, to get .1% resolution on the period, the second timer will have to count at least 1000 cycles, and that means that the second timer will have to count down 200 counts of the 200 kHz clock source. 200 counts from a 200 kHz source takes 1 milli-second, and during 1 milli-second, the second counter running from 1 MHz will count 1000 counts.
The frequency based system uses the output of the relaxation oscillator as a clock source for the second 16-bit timer and a fixed clock source for the first timer. In this case, .1% resolution requires a count of 1000 clock cycles by the second timer. That requires 5 milli-seconds and the first timer will have to be configured to provide a timeout for the 5 milli-seconds sample period.
As you can see, the period measurement system has some pretty significant advantages for moderate to low frequency oscillators, 1 milli-second versus 5 milli-seconds to determine a value of the same resolution. While this may seem like a clear cut advantage, there are some tradeoffs involved; One, the period measurement system requires a high frequency clock to drive the second 16-bit timer, while the frequency measurement system only requires a 5 milli-second gating signal to make its measurement. Two, the size of the timer driven by the relaxation oscillator output will affect the amount of noise energy passed through the timer to the final digital output value.
The clock speed required is an important issue, if the current consumption of the system is to be minimized. The period measurement system requires a 1 MHz, or higher, clock to provide a good resolution at the higher conversion rate. The frequency measurement system only requires a 200Hz clock (5 milli-second). If the 200 Hz signal is generated by the system Watch Dog Timer (WDT), then the current consumption, for just the first timer, will be 2-3 orders a magnitude lower just because the clock is significantly lower. In addition, using the WDT allows the system to perform frequency measurements while the system is in sleep mode.
The noise attenuation of a timer is due to the averaging nature of the timer. If a clock has edge jitter, dividing the clock by 2 will retain the same absolute jitter, but the period of the clock is 2x the original, so the overall percentage phase noise, is ½. In the period measurement system the devisor is 200 and in the frequency measurement system the devisor is 1000, so the frequency measurement system has 5 times more averaging which will attenuate phase noise by 5:1 over the period measurement system.
This gives us the basic trade off between the two systems;
1. Period measurement is faster, for the same resolution.
2. Frequency measurement has better noise filtering characteristics, and it is significantly lower power.
Choosing between the two methods is then determined by the requirements of the system, either low power/noise or higher scan rated for more responsive buttons.
The Difference Between Capacitive Touch & Capacitive Proximity Sensors
The only difference between a capacitive touch sensor and a proximity sensor is sensitivity. A proximity sensor is really just a very sensitive touch sensor. So, to make a proximity sensor, use the same basic design for a touch sensor, and then significantly increase the size of the sensor pad, reduce or eliminate the insulating cover, and crank up the sensitivity of the capacitance to digital converter.
Now, when the user’s hand comes near the proximity sensor, the capacitance will start to rise before their hand touches the sensor. All that is left to do is set the touch detection threshold such that the circuit triggers at the required distance. Typically a 2” diameter sensor, with only a solder mask covering, can easily achieve 3-5 inches of detection range.
Braille Interfaces
When I was in college, many years ago, I worked for a company that made CNC systems (computerized numeric controls) for milling machines and lathes. And, at one point in time they were actively considering a capacitive touch interface to get around contamination problems. To evaluate the technology, the company even purchased a Qwerty keyboard made with capacitive touch buttons.
At the time, I was so impressed by the technology that I failed to see the inherent flaw in the design. Basically, by using capacitive touch for the buttons, they created a keyboard that no touch typist could ever use because touch typists rest their fingers on the home row keys. With a capacitive touch keyboard, that means that the keyboard will always report a press on the home keys. Now, you could get around the problem by having the typist lift and press for home row keys, but that requires the user to modify their normal behavior just to get around your design problem, so really, it is not a very clean solution. What you really need is something that has the same dust and moisture resistance of capacitive, while requiring an actual press by the user to actuate the key.
OK, so much for the lesson in ergonomics, cap touch and Qwerty are a bad combination. What does this have to do with the rest of the user interface world? Well, I’ll tell you; there is one other group that relies on touch to identify buttons locations, blind people. That’s right; the ADA (Americans with Disabilities Act) requires that critical systems, such as elevators and access controls, must have user interfaces that support Braille labeling on their controls. And because Braille uses a series of raised bumps, which are ‘read’ by the user passing their filters over the bumps, capacitive touch is basically useless because the buttons will trigger when the user is trying to find/identity the buttons.
So, how do we solve the problem? We want to seal the interface to prevent contamination by moisture and dust, but we need a system that only responds to an actual press by the users. The answer is simple, use the new inductive touch technology. The inductive touch system uses a solid Fascia of plastic or metal, so it can be sealed, and it detects a user’s touch by detecting the minute deflection of the Fascia caused by the user’s press. This gives us the best of both worlds, a solid front panel (Fascia) with no cracks or gaps for contamination, and the light brush of the Braille labeling will not cause a false press when someone is just reading the Braille legend because it requires a stronger actuation force by the user to cause a press. Simple and elegant, we have a simple sealed keyboard, and it won’t trigger when someone passes their fingers over the legends
One final note; it has been 30 years since I saw the capacitive touch Qwerty keyboard, and though I thought it was a cool keyboard, I have no idea who built the thing so please don’t email asking for the manufacturer. Just accept the fact that the manufacture probably discontinued the design once they figured out that their product had such a market limiting feature.
How small can I create capacitive touch sensors, and how close together can the buttons be?
This is a recurring question with capacitive touch; how small can I make the buttons be, and how closely together can I pack the buttons? Unfortunately, there is no simple answer here, the minimum size of the buttons, and the minimum spacing is really a function of the thickness of the cover material, its characteristics, and the resolution of the capacitance to digital conversion system used.
If the buttons are close together, and the insulating cover is thick, then you have the cross coupling problem discussed in question 2. If the buttons are too small, then your design won’t create a significant amount of capacitance shift in response to a touch. Remember, the amount of capacitance shift generated by a touch is proportional to the area of the button, and inversely proportional to the thickness of the insulating cover; so large buttons, widely spaced, with a thin cover produce the greatest sensitivity. Small buttons, closely packed together under a thick insulating cover produce much less sensitivity, and they will cross couple, making an accurate touch detection more difficult.
Water doesn’t like capacitive touch :(
One of the factors that affect the amount of capacitance generated is the characteristics of the insulating material. This is quantified in the form of a material dependence constant known as Permittivity (e); the higher the permittivity of the insulating material, the higher the capacitance of the resulting capacitor. Permittivity is usually expressed as a function of the permittivity of free space(e0), and a relative permittivity number for the specific material(er). Glass and plastic have relative permittivity values in the range of 3 – 8, so they create capacitances that are 3 – 8 times greater than capacitors that use air as an insulator. Water, on the other hand, has a relative permittivity of 78.
This means that if water is covering a capacitive touch panel, and the user touches a sensor covered by the water, then the user’s finger will couple to every sensor covered by the water, almost as well as it couples to the sensor beneath the user’s finger. In addition, if the water also covers a ground, then the parasitic capacitance of the sensor will also significantly increase and couple potentially cause a false touch trigger.
When I touch a capacitive touch sensor, why do adjacent touch sensors react?
When you touch a sensor, you form a capacitance to ground that is a function of the area of the sensor, the characteristics of the insulating cover over the sensor, and the thickness of the insulating cover. You also form a capacitance to ground with any adjacent sensors, through the insulating cover. However, the effective area of the sensor is smaller because the path to the adjacent button is at an angle, and the distance between your finger and the adjacent button is greater as well.
This means that the amount of affect that a press will have, on an adjacent buttons, is determined the distance between the buttons, and the thickness of the insulating cover. To minimize this cross talk effect, separate the buttons as much as possible, and use the thinnest insulating cover possible.






