Touch sensor touch. Scheme and detailed description

Touch sensors (touch sensors) come in different operating principles, such as resistive (conductive films), optical (infrared), acoustic (SAW), capacitive, etc. This project is an experiment with a capacitive touch sensor. This kind of sensor is well known as the pointing device used in tablet PCs and smartphones.

Principle of capacitive touch sensor

The capacitive touch sensor detects the change in capacitance that occurs on the electrode from being covered by a conductive object, such as a finger. There are several methods for measuring capacitance. This project uses the integration method that is used in the capacitance meter. The change in capacitance Cx is quite small, around 1pF to 10pF, but it will be easily detected because the capacitance meter has a measurement resolution of 20pF. Also, the objects to be detected must be grounded in order to create a Cx circuit according to the operating principle. However, it works well even if the human body is isolated from the ground. This may be due to the following reason.

Hardware

Software

First, calibrate each point (get a reference time to Cs) and then run a scan at a constant period. When the integration time has increased and exceeds the threshold, it will decide "detected". The hysteresis needs a threshold, or the output will not be stable at half touch. The measurement time for each point is equal to the integration time, so this can be done very quickly.

The capacitance meter measures integration time with a resolution of one cycle (100 ns) with an analog comparator and input clamp. However, this feature is not available on all I/O ports. To implement a touch sensor on any I/O port, integration time is measured by polling software, and the resolution becomes 3 cycles (375ns). AT normal condition the number of time report is about 80, and it is enough for touch buttons.

Conclusion

As a result, I can confirm that a capacitive sensor can be easily implemented on a conventional microcontroller. plastic pad can be up to 1mm thick (depending on dielectric constant) for good performance. When the ATtiny2313 is used for the touch sensor module, it can have 15 touch points. The control program used in this project is experimental and has not been tested in dirty environments such as noise and interference, so any anti-noise algorithm may be required for real use.

List of radio elements

Designation Type Denomination Quantity NoteScoreMy notepad
u? MK AVR 8-bit

ATtiny2313-20PU

1 To notepad
R1-R8 Resistor

1 MΩ

8 To notepad
R9-R16 ResistorR9-R168 To notepad
C1 electrolytic capacitor100uF1 To notepad
C2 Capacitor100 nF1 To notepad
D1-D8 Light-emitting diode 8

Page 1


Touch sensors are used simply to detect the fact of contact with an object. A simple microswitch can serve as a touch sensor. Mechanical stress sensors are used to measure the magnitude of the force that occurs at the point of contact. Typically, strain gauges are used as sensors that measure forces.

In lathes, touch sensors are used to control the dimensions of the workpiece, the machined part, and cutting edge tool. Issues of diagnosing robots (anthropomorphic and portal robots are used, built-in lathe, and external, operating in a cylindrical coordinate system) are considered in Chap.


To measure wear by direct methods, touch sensors are used, which register either dimensional wear or, when they move, wear along rear surface. The design of the sensor is shown in fig. 4.8, a. Case 4 is fixed on the movable unit / machine. An alternating magnetic field is created in the electromagnet winding, causing the tip to oscillate. When the tip touches the block, its vibrations are disturbed, which is recorded electronic system 8 with amplifier 7, and the coordinates correspond to the measured size. The sensor is protected from chips. It is used on CNC machines and in GPS not only to measure wear, but also to determine the actual coordinates of the tool blade tip in order to automatically correct control programs.


The principle of operation of a wire tactile sensor (touch sensor) is shown in fig. 5.26. The robot automatically follows the coordinates of two base points A and B, determined by a tactile sensor on corner connection, according to the corrected program, finds the required place to start welding (point C), if the deviation of the butt joint from its original position is caused by its parallel displacement. If the displacement of the butt joint from its original position is caused by its parallel displacement with a turn relative to the welding point, then to correct the positioning program of the burner robot in starting point welding, it is necessary to determine the coordinates of at least three base points on the connection elements with a sensor.


Zero heads are usually constructed on the basis of touch sensors, which are widely used as electric, radio and vibration contact sensors. These heads, also called touch heads, are divided into two classes: with a variable and a fixed zero position of the measuring tip.

Let us consider the features of the devices indicated above when they are used as a touch sensor in the specific conditions of a mercury electrolysis shop.


The sensing of the grips and other executive bodies of the manipulator is performed by gripping force sensors 6 and touch sensors 7 when the PR interacts with the external environment.

Welding part of PR includes: welding rectifier; welding torch; mounting brackets; welding wire feed mechanism; workpiece touch sensor for welding; touch sensor control device; required amount cables; an inert gas cylinder, a reducer with a flow meter and a gas heater; hoses and sleeves.

About how to screw a capacitive touch sensor to the microcontroller. This idea seemed quite promising to me, touch keys would suit some devices much better than mechanical ones. In this article I will talk about my implementation of this useful technology based on STM32 Discovery development board.

So, just starting to master the STM32, I decided as an exercise to add the ability to detect touches to the device. Having started to deal with the theory and practice of the above article, I repeated the scheme of my friend "a. It worked perfectly, but I, a lover of minimalism, wanted to simplify it by getting rid of unnecessary elements. In my opinion, an external resistor and a power path turned out to be superfluous. All this already in most microcontrollers, including the AVR and the STM32.I mean the pull-up resistors of the I / O ports.Why not charge the record and our fingers through them?In anticipation of a catch, I put together a circuit on a breadboard, which, to my Surprisingly, it worked the first time. Actually, it’s even ridiculous to call it a circuit, because all we need is just to connect the contact plate to the leg of the debug board. The microcontroller will take care of all the work.

What is the program like? First, two functions:
The first outputs to the sensor leg (zero pin of register C) logical "0"

Void Sensor_Ground (void) ( GPIOC->CRL = 0x1; GPIOC->BRR |= 0x1; )

The second one sets the same output to the input, with a pull-up to power.

Void Sensor_InPullUp (void) ( GPIOC->CRL = 0x8; GPIOC->BSRR |= 0x1; )

Now, at the beginning of the polling cycle, call Sensor_Ground(), and wait for some time to discharge to the ground all the residual charge on the sensor. Then we reset the count variable, which we will consider the sensor charging time and call Sensor_InPullUp().

Sensor_Ground(); Delay(0xFF); //simple empty counter count = 0; Sensor_InPullUp();

Now the sensor starts charging through an internal pull-up resistor with a value of about tens of KΩ (30..50KΩ for STM32). The time constant of such a circuit will be equal to a few cycles, so I changed the quartz resonator on the debug board to a faster one, 20 MHz (by the way, I did not immediately notice that the quartz turns out to be changed on the STM32 Discovery without soldering). So we count the processor cycles until a logical unit appears at the input:

While(!(GPIOC->IDR & 0x1)) ( count++; )

After exiting this loop, the variable count will store a number proportional to the capacity of the sensory plate. In my case with a 20MHz chip, the count value is 1 for no pressure, 7-10 for the lightest touch, 15-20 for normal touch. It remains only to compare it with the threshold value and remember to call Sensor_Ground() again so that the sensor is already discharged by the next polling cycle.
The resulting sensitivity is enough to confidently determine touches on naked metal platforms. When the sensor is covered with a sheet of paper or plastic, the sensitivity drops three to four times, only confident pressing is well defined. To increase the sensitivity in the case when the sensor needs to be covered with a protective material, you can increase the clock frequency of the microcontroller. With the STM32F103 series chip capable of operating at frequencies up to 72 MHz, even millimeter barriers between the finger and the sensor will not interfere.
Compared to the "a" implementation, my approach is much faster (on the order of a dozen cycles to poll one sensor), so I did not complicate the program by setting up timer interrupts.

Finally, a video demonstrating the operation of the sensor.

Main.c of the test program.

To the microcontroller

Thanks to the user for a very useful article STM32F ARM microcontrollers. Quick start with STM32-Discovery, to the user for the idea and intelligible theoretical description.

UPD. After the comments "a I decided to look into clocking and found that by default STM32 Discovery is set to the clock frequency
(HSE / 2) * 6 = 24 MHz, where HSE is the frequency of the external crystal. Accordingly, changing the quartz from 8 to 20 MHz, I made the poor STM work at 60 MHz. So, firstly, some of the conclusions are obviously not entirely correct, and secondly, what I was doing could lead to chip failures. In case of such failures in the microcontroller there is a HardFault interrupt, using it, I checked more high frequencies. So, the chip starts to fail only at 70 MHz. But although the controller digests this particular program at 60 MHz, when using peripherals or working with Flash memory, it can behave unpredictably. Conclusion: treat this topic as an experiment, repeat only at your own peril and risk.

A capacitive sensor is one of the types of non-contact sensors, the principle of operation of which is based on a change in the dielectric constant of the medium between two capacitor plates. One lining serves touch sensor circuits in the form of a metal plate or wire, and the second is an electrically conductive substance, for example, metal, water or the human body.

When developing a system automatic start supply of water to the toilet for a bidet, it became necessary to use a capacitive presence sensor and a switch that have high reliability, resistance to changes in external temperature, humidity, dust and supply voltage. I also wanted to eliminate the need for a person to touch the controls of the system. The requirements could only be provided by sensor circuits operating on the principle of capacitance change. Finished scheme satisfying necessary requirements I couldn't find it so I had to develop it myself.

The result was a universal capacitive touch sensor that does not require adjustment and responds to approaching electrically conductive objects, including a person, at a distance of up to 5 cm. The scope of the proposed touch sensor is not limited. It can be used, for example, to turn on lighting, systems burglar alarm, determining the water level and in many other cases.

Electrical circuit diagrams

Two capacitive touch sensors were needed to control the flow of water in the toilet bidet. One sensor had to be installed directly on the toilet, it had to give a logical zero signal in the presence of a person, and in the absence of a logical unit signal. The second capacitive sensor was supposed to serve as a water switch and be in one of two logical states.

When a hand was brought to the sensor, the sensor had to change the logical state at the output - from the initial single state to go to the state of logical zero, when the hand was touched again from the zero state to go to the state of logical one. And so on ad infinitum, until the sensor switch receives a logical zero enable signal from the presence sensor.

Capacitive touch sensor circuit

The basis of the capacitive touch presence sensor circuit is a master square-wave generator, made according to classical scheme on two logic elements of the chip D1.1 and D1.2. The oscillator frequency is determined by the values ​​of the elements R1 and C1 and is chosen at about 50 kHz. The frequency value has practically no effect on the operation of the capacitive sensor. I changed the frequency from 20 to 200 kHz and visually did not notice any effect on the operation of the device.

With 4 chip output D1.2 signal rectangular shape through the resistor R2 enters the inputs 8, 9 of the D1.3 chip and through the variable resistor R3 to the inputs 12.13 D1.4. The signal arrives at the input of the D1.3 chip with a slight change in the slope of the pulse front due to installed sensor, which is a piece of wire or a metal plate. At the input D1.4, due to the capacitor C2, the front changes for the time required to recharge it. Due to the presence of a tuning resistor R3, it is possible to set the pulse fronts at input D1.4 equal to the pulse front at input D1.3.

If you bring your hand or metal object, then the capacitance at the input of the DD1.3 microcircuit will increase and the front of the incoming pulse will be delayed in time, relative to the front of the pulse arriving at the input of DD1.4. to "catch" this delay, about inverted pulses are fed to the DD2.1 chip, which is a D flip-flop that works in the following way. On the positive edge of the pulse arriving at the input of the microcircuit C, the signal that was at the input D at that moment is transmitted to the output of the trigger. Therefore, if the signal at the input D does not change, the incoming pulses at the counting input C do not affect the level of the output signal. This property of the D trigger made it possible to make a simple capacitive touch sensor.

When the capacitance of the antenna, due to the approach of the human body to it, at the input of DD1.3 increases, the pulse is delayed and this is fixed by the D trigger, changing its output state. The HL1 LED serves to indicate the presence of the supply voltage, and HL2 to indicate the proximity to the touch sensor.

Touch switch circuit

The capacitive touch sensor circuit can also be used to operate the touch switch, but with a little refinement, since it needs not only to respond to the approach of the human body, but also to remain in a steady state after the removal of the hand. To solve this problem, it was necessary to add another D trigger, DD2.2, to the output of the touch sensor, connected according to the divider-by-two circuit.

The capacitive sensor circuit has been slightly modified. To eliminate false positives, since a person can bring and remove his hand slowly, due to the presence of interference, the sensor can output several pulses to the counting input D of the trigger, violating the necessary switch operation algorithm. Therefore, an RC chain of elements R4 and C5 was added, which for a short time blocked the possibility of switching the D trigger.


The trigger DD2.2 works in the same way as DD2.1, but the signal to the input D is not supplied from other elements, but from the inverse output of DD2.2. As a result, on the positive edge of the pulse arriving at input C, the signal at input D changes to the opposite. For example, if in the initial state there was a logical zero at pin 13, then by bringing your hand to the sensor once, the trigger will switch and a logical unit will be set at pin 13. The next time the sensor is acted upon, a logical zero will again be set at pin 13.

To block the switch in the absence of a person on the toilet, a logical unit is supplied from the sensor to the input R (setting zero at the trigger output, regardless of the signals at all its other inputs) of the DD2.2 microcircuit. At the output of the capacitive switch, a logical zero is set, which is fed through the harness to the base of the switching switching transistor solenoid valve in the power supply and switching unit.

Resistor R6, in the absence of a blocking signal from the capacitive sensor in the event of its failure or a break in the control wire, blocks the trigger at input R, thereby eliminating the possibility of spontaneous water supply to the bidet. Capacitor C6 protects input R from interference. LED HL3 serves to indicate the water supply in the bidet.

Structure and details of capacitive touch sensors

When I started designing a bidet sensor system, the most difficult task for me seemed to be the development of a capacitive presence sensor. This was due to a number of restrictions on installation and operation. I did not want the sensor to be mechanically connected to the toilet lid, since it must be removed periodically for washing, and did not interfere with sanitization the toilet itself. Therefore, I chose the capacitance as the reacting element.

Presence sensor

According to the above published scheme, I made a prototype. Capacitive sensor parts are assembled on printed circuit board, the board is placed in a plastic box and closed with a lid. To connect the antenna, a single-pin connector is installed in the housing, and a four-pin RSh2N connector is installed to supply the supply voltage and signal. PCB connected with solder connectors copper conductors in PTFE insulation.

The touch capacitive sensor is assembled on two microcircuits of the KR561 series, LE5 ​​and TM2. Instead of the KR561LE5 chip, you can use the KR561LA7. Chips of the 176 series, imported analogues, are also suitable. Resistors, capacitors and LEDs will fit any type. Capacitor C2, for stable operation of the capacitive sensor when operating in conditions of large temperature fluctuations environment you need to take with a small TKE.

The sensor is installed under the platform of the toilet, on which it is installed drain tank in a place where, in the event of a leak from the tank, water cannot enter. The sensor body is glued to the toilet bowl using double-sided adhesive tape.


The antenna sensor of the capacitive sensor is a piece of copper stranded wire 35 cm long in PTFE insulation, glued with transparent tape to the outer wall of the toilet bowl a centimeter below the plane of the glasses. The sensor is clearly visible in the photo.

To adjust the sensitivity of the touch sensor, it is necessary, after installing it on the toilet, by changing the resistance of the tuning resistor R3 to make the HL2 LED go out. Next, put your hand on the toilet lid above the location of the sensor, the HL2 LED should light up, if you remove your hand, go out. Since the human thigh by mass more hands, then during operation the touch sensor, after such a setting, will work guaranteed.

The design and details of the capacitive touch switch

The capacitive touch switch circuit has more details and a housing was needed to accommodate them bigger size and for aesthetic reasons, appearance the housing in which the presence sensor was placed was not very suitable for installation in a conspicuous place. The rj-11 wall socket for connecting the phone drew attention to itself. It fit true to size and looks good. Having removed everything superfluous from the outlet, I placed the printed circuit board of the capacitive touch switch in it.


To fix the printed circuit board, a short post was installed at the base of the case, and a printed circuit board with touch switch parts was screwed to it with a screw.


The capacitive sensor sensor was made by gluing a sheet of brass to the bottom of the socket cover with Moment glue, after cutting out a window for the LEDs in them. When the lid is closed, the spring (taken from a flint lighter) contacts the brass sheet and thus provides electrical contact between the circuit and the sensor.


The capacitive touch switch is attached to the wall using one self-tapping screw. For this, a hole is provided in the body. Next, the board, connector is installed and the cover is fixed with latches.


The setting of the capacitive switch is practically the same as the setting of the presence sensor described above. For tuning, you need to apply the supply voltage and adjust the resistor so that the HL2 LED lights up when a hand is brought to the sensor, and goes out when it is removed. Next, you need to activate the touch sensor and bring and remove your hand to the switch sensor. The HL2 LED should blink and the red HL3 LED should light up. When the hand is removed, the red LED should remain lit. When the hand is brought up again or the body is removed from the sensor, the HL3 LED should go out, that is, turn off the water supply in the bidet.

Universal PCB

The capacitive sensors presented above are assembled on printed circuit boards, which are slightly different from the printed circuit board shown in the photo below. This is due to the combination of both printed circuit boards into one universal one. If you assemble the touch switch, then you only need to cut track number 2. If you assemble the presence sensor, then track number 1 is removed and not all elements are installed.


The elements necessary for the operation of the touch switch, but interfering with the operation of the presence sensor, R4, C5, R6, C6, HL2 and R4, are not installed. Instead of R4 and C6, wire jumpers are soldered. The chain R4, C5 can be left. It will not affect work.

Below is a drawing of a printed circuit board for knurling using the thermal method of applying tracks to the foil.

It is enough to print the drawing on glossy paper or tracing paper and the template is ready for the manufacture of a printed circuit board.

Trouble-free operation of capacitive sensors for the touch control system of water supply in the bidet has been proven in practice for three years of continuous operation. No failures were recorded.

However, I want to note that the circuit is sensitive to powerful impulse noise. I received an email asking for help with setup. It turned out that during the debugging of the circuit there was a soldering iron with a thyristor temperature controller nearby. After turning off the soldering iron, the circuit worked.

There was another case. The capacitive sensor was installed in the lamp, which was connected to the same outlet as the refrigerator. When you turn it on, the light turns on and when you turn it off again. The issue was resolved by connecting the lamp to another outlet.

A letter came about the successful application of the described capacitive sensor circuit for adjusting the water level in storage tank from plastic. In the lower and upper parts, it was glued with silicone along the sensor, which controlled the on and off of the electric pump.

Capacitive touch sensor

The main element necessary for the implementation of a system of capacitive sensors is a variable capacitor. He must have simple design and sensitivity to touch. Since the sensing element is built as an "open" capacitor, electric field can interact with an external capacitive object, in our case, a finger. Figure 1 shows a top and side view of a capacitive sensor implemented directly on the board.

Rice. one.

As shown in Figure 1, a capacitor forms between the conductive layer and ground. The interaction of the conductive layer and the conductors surrounding it creates a base capacitance, the value of which can be measured. The basic capacitance of such a sensor is about 10 pF. When the conductor, i.e. finger, approaching an open capacitor, as a result of interference electric field, the capacitance of the capacitor changes. Due to the capacitance of the finger, the capacitance of the sensor increases even without being touched. By measuring the capacitance of the sensor and comparing each result with the base capacitance, the microcontroller can determine not only the fact that the button was pressed, but also the sequence of switching on, which is used to implement more complex interfaces, such as sliders.

The sensitivity of the sensor depends on the distance between the conductive and ground layers. The recommended distance is 0.5 mm. In addition, the overall sensitivity of the system depends on the thickness of the board: as the thickness of the board decreases, the sensitivity decreases. The recommended board thickness is 1…1.5 mm.

The sensor capacitance without finger capacitance is about 5…10 pF.

The ground layer under the sensor shields it from other electronic components in the system. It also helps to maintain a constant base capacitance, which is required as a reference for every measurement.

Sensor design and user interface

The complete interface consists of the capacitive sensor itself (implemented on the board) as well as the dielectric between the sensor and the finger when it is touched.

Implementation of a capacitive sensor on a printed circuit board

Capacitive sensor dependencies can be displayed using the example of a conventional flat capacitor. Figure 2 shows its key elements.

Rice. 2.

The term "base capacitance" refers to the capacitance measurement of a sensor that has not been affected in any way. For simplicity, as a base capacitance, we take the capacitance of a capacitor formed by a conductive layer at the top of the printed circuit board and a ground layer at the bottom (bottom and top plates in Figure 2).

The distance d is determined by the printed circuit board. As mentioned earlier, as d decreases, the base capacitance increases and the sensitivity decreases. The specific capacitances of space (e 0) and material (e r) determine the dielectric constant of the board.

Sensor area A is usually limited by the size of the finger, calculated as the average between the finger of a child and an adult. Note that the area of ​​the sensor that is not covered by the finger is useless.

Thus, during the development process, it is necessary to minimize the basic capacitance of the sensor. A condition for good system sensitivity and reliability is to maximize the change in capacitance as the finger approaches the sensor. Of course, these two goals are mutually exclusive: as the sensor area increases to the size of a finger, the base capacitance increases, since it is proportional to A.

Rice. 3.

Figure 3 shows the button and slider layout used as an example in this document.

Rice. 4. Building layers (red - upper signal layer, blue - lower ground layer)

Figure 4 shows four options for placing the sensor on a printed circuit board, which differ in the construction of the ground layer.

Top left shows only the top signal layer: four sensor pads surrounded by the top ground plane; the bottom layer is not used. The upper right side of the figure shows the same board design with 25% ground coverage. Bottom left is the 50% infill version and right is the 100% infill version.

It is recommended to use multiple ground planes under each sensor to isolate the sensor elements from noise and other external changes that could cause a change in base capacitance. Obviously 100% padding, as shown in the left bottom corner Figure 4 provides maximum noise isolation and also increases base capacitance. To obtain the optimal ratio of noise isolation and base capacitance, it is customary to use an infill from 50% to 75%.

Insulating layer of the sensor

In this type of application, the insulating layer of the sensor is made of plastic. Thanks to this layer, the fingers do not come into direct contact with the sensor. The model presented in Figure 2 can be used to visualize the interaction interface between a finger and a capacitor. In this case, the lower lining acts as a sensor, and the upper one acts as the user's finger. It becomes clear that with an increase in the interaction area to the size of a finger, A increases, and the change in capacitance is maximized. As the insulation layer d increases, the change in capacitance decreases inversely. Key moment, which cannot be ignored, is the material from which the insulation is made. The dielectric constant of the insulating material as well as its thickness greatly influence the sensitivity and ease of use of a capacitive touch sensor. Table 1 lists the dielectric constants of some materials.

Table 1. Dielectric constants of materials

In addition to the insulator itself, important point is the connection of the sensor and the insulator. If the connection is loose and there are gaps, the capacitance of the sensor will change. Therefore, adhesive insulators are often used.

Using the MSP430 to Measure the Capacitance of a Touch Sensor

Now consider two methods for measuring the capacitance of the touch sensor.

Oscillator based measurement method

The first method is based on the use of an oscillator. This method can be implemented based on the MSP430, using its comparator and capacitive sensor as a tuning element. Any change in sensor capacitance will result in a change in frequency, which can be measured using Timer_A on the MSP430 microcontroller. Figure 5 shows an example of such a system.

Rice. 5.

Resistors R provide support for the comparator when Px.y is set high. This signal is opposite in polarity to the charging or discharging signal of the capacitance of the sensor (C sensor), which leads to long-term oscillations. With equal values ​​of resistance R, the boundary values ​​are 1/3 V cc and 2/3 V cc , the oscillation frequency is calculated by the formula:

fOSC = 1/

By counting the number of periods of oscillation during a given period of time, the frequency can be calculated and the capacitance can be measured. In this application, the resistance of the resistor RC is 100 kΩ. As a result, the oscillation frequency is approximately 600 kHz with a sensor capacitance of 10 pF.

The integrated 12 kHz VLO is used as a clock source. This signal is applied to the watchdog timer WDT. With each watchdog interrupt, the kernel examines the state of the Timer_A timer register, TAR. The difference between the last two register values ​​is calculated. In reality, the absolute value of the capacitance is not needed, only its change is interesting.

It is possible to build a system with several capacitive sensors. This requires the construction of a multiplexer on the comparator Comparator_A + (Figure 6).

Rice. 6.

To implement the system, one resistor is required for each sensor and three resistors for the comparator.

Resistor based capacitance measurement method

The second method for measuring the capacitance of the touch sensor is based on using an external resistor to charge or discharge the capacitive sensor. One of the MSP430 ports is used for charging or discharging, the charge or discharge time is measured using the built-in Timer_A timer. Figure 7 shows an example system using the MSP430 microcontroller to measure the discharge time of a capacitor.

Rice. 7.

With a capacitance value of C sensor = 10 pF and R = 5.1 M, the discharge time is about 250 µs. Px.y is configured as a high level output to charge the capacitor. It can be reconfigured as an input to discharge the C sensor through R. The maximum current through the MSP430 port is ±50 nA.

If the Px.y port supports interrupts (for the MSP430, these are ports P1.x and P2.x), the internal low signal can be used as a threshold at which they are generated. When this interrupt is received, the kernel parses the contents of the Timer_A timer register. The timer can use the internal DCO as the clock source. The frequency of the generated signal is 8 or 16 MHz (depending on the MSP430 family).

Rice. eight.

Figure 8 shows one measuring cycle. The timer starts counting from zero and at the moment when the voltage on the sensor reaches the threshold V IT , the timer value is read. Also, the timer can operate in the constant counting mode, while it is necessary to read its values ​​​​at the time of the beginning and end of the capacitor discharge and calculate their difference. With an increase in the capacitance of the sensor, the discharge time of the capacitor increases and the number of timer cycles increases during the measurement.

It was said above that one resistor is needed for each port. The circuit can be simplified by using one resistor for two ports. While measuring the capacitance of one of the sensors, the port connected to the second should have a low signal level, i.e. serves as a ground for discharging the capacitance. Another advantage of such a scheme is that the capacitance of each sensor can be measured in two directions: charging from zero to high level and discharging from V cc to a low level threshold. Figure 9 shows this method.

Rice. nine.

The counting of cycles must be done twice: during charging and discharging. At the same time, 50/60 MHz noise has less effect on the measurement result.

Software

After the measurement result is obtained, it must be programmatically interpreted. Power supply noise, clock offset, external 50/60 MHz noise can lead to poor decision making.

Sometimes, for efficiency, you can discard a few low-order bits of the result. This is acceptable if you only want to track the fact that the button was clicked. But if a higher resolution is required, this can no longer be afforded. Low-pass filtering and simple averaging of several results can help smooth out the noise. But to achieve low power consumption, the presence of low bits of the measurement result is more critical.

Sensor Base Capacitance Tracking

Without the ability to dynamically track changes in sensor capacitance, any kind of instabilities can lead to false detection of a button being pressed or “sticky”. Consider a variant with a simple button that has two states: on/off. If the result is shifted, it may approach the threshold at which the button is considered pressed, that is, a false positive will occur.

One method for tracking and adjusting base capacity is shown in Figure 10.

You need to pay attention to the fact that these actions are performed for each sensor separately. Calculation of the variable "Delta" and adjustment of "base" is done differently in RO and RC algorithms. In RO, the measured value decreases as the capacitance of the capacitor increases; and in RC the measured value increases.

After completing the measurement, first of all, it is necessary to determine whether a touch has occurred. This can be done by comparing the obtained value with a threshold corresponding to the lightest touch that can be recognized. If it is determined that there was no touch, the base value is adjusted. How the adjustment takes place depends on the direction in which the change occurred.

As the capacitance measurement increases, it is recommended to adjust the base value more slowly. An increase in the result can mean not only a shift as a result of errors, but also as a result of the movement of the finger in the direction of the sensor. And if the base value adjusts quickly, the actual touch of the finger may not be noticed. To do this, it is recommended to adjust the base value by only one unit each measurement cycle (Figure 10).

Rice. ten.

Implementing a Regular Button Function

Button building is the most common use case for capacitive sensors. Figure 11 shows an example of building a system with four buttons.

Rice. eleven.

The threshold at which the decision is made that the button is pressed must be higher than the noise.

Slider Function Implementation

A more complex function, organized on capacitive sensors, is a slider. In this case, it is necessary to monitor the excess of several thresholds.

The easiest way to build a slider can be organized if several positions are defined for each sensor. The example below (Figure 12) considers a system where 16 positions are defined for each sensor. The result is a 64-position system.

Rice. 12.

DELTAMAX is the maximum capacitance value that can be reached. Then the range from 0 to DELTAMAX is divided into a certain number of Steps. Zero corresponds to the case when the button is not pressed. The position of the finger is determined by the maximum value. A more linear transfer characteristic of the system is achieved by interpolating the values ​​of all sensors.

Multiplexing sensors to build a slider

When building a slider, it is possible to expand the number of sensors with a limited number of input / output ports by means of multiplexing. In this case, several sensors are connected to one output. Additional sensor only increases the base capacity. However, with an increase in the base capacitance, at the moment of impact on only one of the sensors, the response of the sensor is less. Therefore, it is common not to connect more than two sensors together.

In order to determine which of the multiplexed sensors is affected, they need to be separated in space. An example of the location of sensors in such a system is shown in Figure 13.

Rice. thirteen.

Conclusion

The article discusses two methods for implementing capacitive touch sensors using the MSP430. Each of the methods has its own advantages and disadvantages. Let's consider the main ones.

  • Oscillator based method:

- Requires a microcontroller with Comp_A + comparator;
— The number of independent sensors is limited by the number of Comp_A+ inputs;
- Requires one external resistor R for each sensor, as well as a chain of three R;
— Sensitivity is limited by power consumption (programmable measurement time);

  • Resistor based method:

- Can be implemented on any MSP430 microcontroller;
- Up to 16 independent sensors (16 I / O ports working with interrupts);
— One external resistor R for every two sensors;
- Sensitivity is limited by the maximum frequency of the microcontroller (fixed measurement time);
— Minimum energy consumption;

The application can be extended and optimized by the user to implement the end device.

Full description various examples MSP430 applications, program sources, Additional information can be found on the website www.site in the section on microcontrollers.

Obtaining technical information, ordering samples, delivery -
e-mail:

New family of clock generators

Texas Instruments introduced a family programmable clock generators, with 1 to 4 PLL circuits. ICs allow you to generate up to 9 clock signals synthesized from a single input frequency. Each output supports in-system frequency programming up to 230 MHz. These features provide a number of advantages. These include lower power consumption, a faster design process, and the ease of changing clock speeds without having to redesign the system. These advantages will significantly reduce the cost of consumer applications, incl. IP set-top boxes, IP phones, digital media systems (digital TVs, streaming media devices, printers, navigation systems and portable devices).

The new clock generators are optimized to work with DaVinci TM (TI) processors to generate clocks for digital processors, audio ADCs or codecs, and Ethernet or USB controllers. The built-in voltage controlled crystal oscillator (VCXO) allows frequency synchronization of various data streams.

Composition of the new clock family
generators
Name PLL Output, V
CDCE949 4 2,5/3,3
CDCE937 3 2,5/3,3
CDCE925 2 2,5/3,3
CDCE913 1 2,5/3,3
CDCEL949 4 1,8
CDCEL937 3 1,8
CDCEL925 2 1,8
CDCEL913 1 1,8
About Texas Instruments

What else to read