All about car tuning

Touch sensor circuits. Non-contact sensors: overview, principle of operation, purpose. Sensor switch. Structure and internal connections

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 a pointing device used in tablet PCs and smartphones.

Principle of capacitive touch sensor

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

Hardware

Software

First, calibrate each point (obtain a reference communication time with Cs) and then run a constant period scan. When the integration time has increased and exceeds the threshold, it will decide “detected”. Hysteresis requires a threshold, or the output will not be stable when half touched. 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 clock cycle (100 ns) with an analog comparator and input clamp function. However, this feature is not available on all I/O ports. To implement a touch sensor on any I/O port, the integration time is measured by software polling and the resolution becomes 3 clock cycles (375ns). In normal condition, the time reporting number is about 80, which is enough for touch buttons.

Conclusion

As a result, I can confirm that a capacitive sensor can be easily implemented on a regular microcontroller. The plastic cover can be up to 1mm thick (depending on the dielectric constant) to work well. When ATtiny2313 is used for 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 actual use.

List of radioelements

Designation Type Denomination Quantity NoteShopMy notepad
U? MK AVR 8-bit

ATtiny2313-20PU

1 To notepad
R1-R8 Resistor

1 MOhm

8 To notepad
R9-R16 ResistorR9-R168 To notepad
C1 Electrolytic capacitor100 µF1 To notepad
C2 Capacitor100 nF1 To notepad
D1-D8 Light-emitting diode 8

For some electrical devices, there is a need for touch activation, that is, the start or end of operation must occur with a simple touch of a finger to the touch contact. This can be used in circuits of electronic locks, alarms, and ordinary equipment, which simplifies its activation and deactivation (you just need to touch it).

In this article I propose a fairly simple electronic circuit for a touch switch that can be assembled by almost anyone. This circuit consists of only a few electronic components, the main ones of which are bipolar transistors, which act as signal amplifiers. The sensor wire itself (which needs to be touched) is connected to the input (base) of the first transistor. The output of the transistor produces a signal amplified hundreds of times, which is fed to the next element. The second transistor amplifies the previously amplified signal even more, and the third stage of the circuit does the same. As a result, from an extremely small signal coming from the sensor, we obtain a current that can light an LED (or turn on a relay that will control one or another device).

Let me remind you that a bipolar transistor is a semiconductor element that has three terminals (emitter, collector and base). It is capable of amplifying the electrical signal by 10-1000 times. When a small signal (somewhere from 0.6 to 0.7 volts) is applied to the control pin, we can obtain an electric current and/or voltage of a much larger value at the output.

The base is the control electrode relative to the emitter. That is, a certain voltage is supplied from the power source to the base (through a limiting resistor creating a certain bias) and the collector. When the voltage between the base and emitter is up to 0.6 volts, the transistor will still be closed (it will not pass current through itself relative to the emitter and collector). By increasing the voltage between the base and emitter from 0.6 to somewhere up to 0.7 volts, we gradually open the transistor from a completely closed state to a completely open state. Consequently, the transistor plays the role of a variable resistor, which is controlled by small currents and can change its resistance from infinitely large to practically zero (it still exists, albeit very small).

Resistors in the circuit of a simple touch switch, located in the collector circuit, act as current limiters. Their ratings are 1 megaohm, 1 kiloohm and 220 ohm. You can install small power, small in size (the currents in the circuit are quite small). This electrical circuit uses bipolar transistors of the KT315 type (suitable with any letter index). These transistors are old-fashioned, you can find them anywhere, and they cost pennies (if you buy them). You can replace them with KT3102 or any others with similar characteristics. These transistors have n-p-n conductivity (beginners should take this into account). You can put transistors and reverse conductivity (pnp) of the KT361 or KT3107 series into the circuit, but then you will need to change the polarity on the power supply (connect minus to plus and vice versa).

I would like to note that this electrical circuit of the sensor is not fixed, that is, the output device will be triggered and work only when you touch the input sensor. As soon as you stop touching the sensor, the output device will also turn off.

Initially, in the circuit of a simple touch switch, I installed a regular LED at the output, which simply lit up when the sensor was touched. If you put a small relay instead of an LED, then you can already have a switch at the output of the circuit, which can be connected to various electrical devices (bell, light bulb, motor, etc.). In parallel with the relay coil, you will need to solder an electrolytic capacitor of small capacity (somewhere from 100 to 1000 microfarads, and with a voltage no less than that of the power source). And also connect a diode (reverse connection), which will eliminate the influence of self-induction voltage occurring on the relay coils on the circuit itself. Any diode will do!

P.S. Please note that the LED has polarity! If you place it incorrectly, it will not light up. If using a relay, consider the output current of the transistor. That is, KT315 can have a current of no more than 100 milliamps at its output. Consequently, if you install a large switch whose coil consumes large currents, the transistor may fail. You need to install a relay with the appropriate current on the coil or install a more powerful bipolar transistor at the output of the circuit.

This article presents some basic designs for capacitive touch sensors and discusses how to deal with low- and high-frequency noise.

Previous article

Measuring Change

If you read the previous article, then you know that the essence of capacitive touch sensors is the change in capacitance that occurs when an object (usually a human finger) approaches the capacitor. The presence of a finger increases capacity because:

  1. introduces a substance (i.e. human flesh) with a relatively high dielectric constant;
  2. provides a conductive surface that creates additional capacitance in parallel with the existing capacitor.

Of course, the fact that the capacitance changes is not particularly useful. In order to actually implement a capacitive touch sensor, we need a circuit that can measure capacitance with enough precision to identify the increase in capacitance caused by the presence of a finger. There are various ways to do this, some quite simple, others more complex. In this article, we will look at two main approaches for implementing capacitive touch functionality: the first is based on the time constant of the RC (resistor-capacitor) circuit, and the second is based on frequency shifts.

RC circuit time constant

You may also feel a sense of college nostalgia when you see an exponential curve that plots the voltage as a capacitor charges or discharges. Perhaps someone, looking at this curve for the first time, realized that higher mathematics still has some relation to the real world, and even in the age of robots working in the vineyards, there is something attractive in the simplicity of discharging a capacitor. Either way, we know that this exponential curve changes when either the resistor or the capacitor changes. Let's say we have an RC circuit consisting of a 1 MΩ resistor and a capacitive touch sensor with a typical capacitance (without a finger) of 10 pF.

We can use a general purpose I/O pin (configured as an output) to charge the capacitor to a logic high voltage. Then we need to discharge the capacitor through a large resistor. It is important to understand that you cannot simply switch the output state to logic low. An I/O pin configured as an output will drive a logic low signal, that is, it will create a low-impedance connection between the output and ground. Thus, the capacitor will quickly discharge through this low resistance - so quickly that the microcontroller will not be able to detect the subtle temporary changes created by small changes in capacitance. What we need here is a pin with a high input resistance that will cause almost all of the discharge current to flow through the resistor, and this can be achieved by configuring the pin to act like an input. So, first you set the pin to be a logic high output and then the discharge stage is called by changing the operating mode of the pin to the input. The resulting voltage will look something like this:

If someone touches the sensor and thereby creates an additional 3 pF capacitance, the time constant will increase as follows:

By human standards, the discharge time is not much different, but a modern microcontroller can certainly detect this change. Let's say we have a timer with a clock speed of 25 MHz; we start the timer when we switch the output to input mode. We can use a timer to track discharge time by configuring the same pin to act as a trigger that triggers a capture event ("capture" means storing the timer value in a separate register). The capture event will occur when the discharge voltage crosses the logic low threshold of the output, for example 0.6 V. As shown in the following graph, the difference in discharge time with the 0.6 V threshold is ΔT = 5.2 µs.

With a timer clock period of 1/(25 MHz) = 40 ns, this ΔT corresponds to 130 clock cycles. Even if the capacitance change is reduced by a factor of 10, we will still have a difference of 13 cycles between the untouched sensor and the touched sensor.

So the idea is to charge and discharge the capacitor repeatedly, controlling the discharge time; if the discharge time exceeds a predetermined vice, the microcontroller assumes that the finger has come into "contact" with the touch sensor capacitor (I wrote "contact" in quotes because the finger never actually touches the capacitor - as mentioned in the previous article, the capacitor is separated from external environment with varnish on the board and the device body). However, real life is a little more complex than the idealized discussion presented here; sources of error are discussed below in the Real-Life section.

Variable capacitor, variable frequency

In a frequency variation based implementation, a capacitive sensor is used as the "C" part in an RC oscillator such that a change in capacitance causes a change in frequency. The output signal is used as an input to the counter module, which counts the number of rising edges or falling edges that occur during the measurement period. When an approaching finger causes the sensor capacitance to increase, the frequency of the oscillator output signal decreases, and thus the number of edges/falls also decreases.

The so-called relaxation oscillator (oscillator whose passive and active nonlinear elements do not have resonant properties) is a basic circuit that can be used for this purpose. This requires several resistors and a comparator in addition to the touch sensor capacitor. This seems to cause more problems compared to the charge/discharge method discussed above, but if your microcontroller has a built-in comparator module, it's not too bad. I won't go into detail about the circuitry of this oscillator because, firstly, it is discussed in many other places, and secondly, it is unlikely that you will want to use this oscillator method when there are many microcontrollers and individual chips that offer High-performance capacitive touch functionality. If you have no choice but to create your own capacitive touch sensor circuit, I think the charge/discharge method described above is simpler. Otherwise, make your life a little easier by choosing a microcontroller with dedicated capacitive touch sensor hardware.

An example of an embedded module based on a relaxation oscillator is the capacitive sensor peripheral in the EFM32 microcontrollers from Silicon Labs:

The multiplexer allows the oscillation frequency to be controlled by eight different touch sensor capacitors. By quickly switching between channels, the controller can effectively control eight touch buttons simultaneously, since the operating frequency of the microcontroller is very high compared to the speed of finger movement.

Work in reality

A capacitive touch system will be affected by both high-frequency and low-frequency noise.

High frequency noise causes discharge time or edge count measurements to vary slightly from sample to sample. For example, the fingerless charge/discharge circuit discussed above might have a discharge time of 675 cycles, then 685 cycles, then 665 cycles, then 670 cycles, and so on. The significance of this noise depends on the expected change in discharge time when the finger is raised. If the capacitance increases by 30%, then ΔT will be 130 cycles. If our high-frequency variations are only ±10 clock cycles, then we can easily distinguish signal from noise.

However, a 30% capacitance increase is close to the maximum capacitance change we can expect. If we only get a 3% change, the ΔT is 13 cycles, which is too close to the noise level. One way to reduce the impact of noise is to increase the amplitude of the signal, and you can do this by reducing the physical distance separating the printed capacitor and the finger. However, often the mechanical design is limited by other factors and you can no longer increase the signal level. In this case, you need to reduce the noise level, which can be achieved by averaging. For example, each new discharge time may be compared not with the previous discharge time, but with the average of the last 4 or 8 or 32 discharge time measurements. The frequency shift method described above automatically involves averaging because small changes around the center frequency will not significantly affect the number of cycles counted over a measurement period that is longer than the oscillation period.

Low-frequency noise refers to long-term changes in sensor capacitance without touching a finger; these changes may be caused by environmental conditions. This type of interference cannot be averaged out because the changes may persist over a very long period of time. Thus, the only way to effectively deal with low-frequency noise must be adaptive: the threshold used to detect the presence of a finger cannot be a fixed value. Instead, it must be adjusted regularly based on measured values ​​that do not show significant short-term changes, such as those caused by the approach of a finger.

Conclusion

The implementation methods discussed in this paper show that capacitive touch detection does not require complex hardware and software. However, it is a versatile, reliable technology that will provide significant performance improvements over mechanical alternatives.

Touch sensor for Arduino

The module is a touch button; a digital signal is generated at its output, the voltage of which corresponds to the levels of logical one and zero. Refers to capacitive touch sensors. We encounter this kind of data input devices when working with the display of a tablet, iPhone or touchscreen monitor. If on the monitor we click on an icon with a stylus or finger, then here we use an area of ​​the board surface the size of a Windows icon, touching it only with a finger, the stylus is excluded. The basis of the module is the TTP223-BA6 chip. There is a power indicator.

Controlling the rhythm of melody playback

When installed in the device, the touch area of ​​the surface of the module board is covered with a thin layer of fiberglass, plastic, glass or wood. The advantages of a capacitive touch button include a long service life, the ability to seal the front panel of the device, and anti-vandal properties. This allows the touch sensor to be used in devices operating outdoors in conditions of direct contact with water droplets. For example, a doorbell button or household appliances. An interesting application in smart home equipment is replacing light switches.

Characteristics

Supply voltage 2.5 - 5.5 V
Touch response time in various current consumption modes
low 220 ms
normal 60 ms
Output signal
Voltage
high log. level 0.8 X supply voltage
low log level 0.3 X supply voltage
Current at 3 V supply and logical levels, mA
low 8
high -4
Board dimensions 28 x 24 x 8 mm

Contacts and signal

No touch - the output signal has a low logical level, touch - the sensor output is logical one.

Why does it work or a little theory

The human body, like everything around us, has electrical characteristics. When a touch sensor is triggered, our capacitance, resistance, and inductance appear. On the bottom side of the module board there is a section of foil connected to the input of the microcircuit. Between the operator's finger and the foil on the bottom side there is a layer of dielectric - the material of the supporting base of the module's printed circuit board. At the moment of contact, the human body is charged with a microscopic current flowing through a capacitor formed by a section of foil and a person’s finger. In a simplified view, current flows through two series-connected capacitors: foil, a finger located on opposite surfaces of the board, and the human body. Therefore, if the surface of the board is covered with a thin layer of insulator, this will lead to an increase in the thickness of the dielectric layer of the foil-finger capacitor and will not disrupt the operation of the module.
The TTP223-BA6 microcircuit detects an insignificant microcurrent pulse and registers a touch. Due to the properties of the microcircuit, working with such currents does not cause any harm. When we touch the body of a working TV or monitor, microcurrents of greater magnitude pass through us.

Low consumption mode

After power is applied, the touch sensor is in low power mode. After triggering for 12 seconds, the module goes into normal mode. If no further contact occurs, the module will return to low current consumption mode. The speed of the module's response to touch in various modes is given in the characteristics above.

Working together with Arduino UNO

Load the following program into the Arduino UNO.

#define ctsPin 2 // Contact for connecting the touch sensor signal line
int ledPin = 13; // Contact for LED

Void setup() (
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ctsPin, INPUT);
}

Void loop() (
int ctsValue = digitalRead(ctsPin);
if (ctsValue == HIGH)(
digitalWrite(ledPin, HIGH);
Serial.println("TOUCHED");
}
else(
digitalWrite(ledPin,LOW);
Serial.println("not touched");
}
delay(500);
}

Connect the touch sensor and Arduino UNO as shown in the figure. The circuit can be supplemented with an LED that turns on when the sensor is touched, connected through a 430 Ohm resistor to pin 13. Touch buttons are often equipped with a touch indicator. This makes it more convenient for the operator to work. When we press a mechanical button, we feel a click regardless of the reaction of the system. Here the novelty of the technology is a little surprising because of our motor skills that have developed over the years. The pressure indicator saves us from an excessive feeling of novelty.

A. V. Skuryatin, Moscow

The touch sensor was created during an experimental study of the kacher process in a bipolar transistor, described by V. I. Brovin.

The circuit proposed for repetition is an amplifier that is highly sensitive to the electromagnetic field created by external devices. When the input contact of the circuit is connected to the antenna, the LED signals the presence of electromagnetic field radiation and interference from electrical equipment. The LED will also indicate the fact of touching the contact, since the role of the antenna in this case is performed by the human body. Hence the name - touch sensor. Another name for the circuit is active antenna.

The schematic diagram of the touch sensor is shown in Figure 1.

The circuit resembles a self-oscillator based on an n-p-n transistor structure. One of the terminals of winding L1 is connected directly to the input pin X1. The polarity of the VD1 LED does not matter. Resistor R2 limits the current through the LED and, thereby, determines the brightness of its glow when the sensor is triggered.

The touch sensor is assembled on a breadboard measuring 40 × 40 mm. The appearance of the structure is shown in Figure 2.

Figure 2. Appearance of the touch sensor.

Windings L1 and L2 are located on a common frame with two winding sections and a tuning ferrite core. The outer diameter of the frame is 10 mm, the length of the core is 23 mm, the thread diameter at the base of the core is 6 mm. In the design shown in Figure 2, L1 is wound on the top section, L2 on the bottom. Each coil contains 100 turns of PEL 0.2 wire. The windings are included according to. Using a screwdriver, the core is screwed into the frame. LED VD1 - any of the AL307 series. A grounding petal is used as X1. Touching it causes the LED to light up.

In parallel with VD1, you can connect a measuring device, for example, a multimeter in voltage measurement mode, which will allow you to evaluate the level of field strength. In this case, the external antenna can be a piece of mounting wire several centimeters long. Setting up the circuit will come down to choosing the length of the antenna and finding the position of the core at which the voltage on the LED is maximum.

The circuit is not picky about the choice of element base. For example, in the original version of the circuit, a KT815G transistor was used, the resistance of resistor R1 was 100 kOhm. Two coils on a rod ferrite core of a long-wave magnetic antenna from a radio receiver were used as L1 and L2. The coils could be moved along the core. When moving the coils, phenomena were observed that did not contradict the law of electromagnetic induction, in contrast to the scheme proposed in. When the coils were significantly removed from each other and without a ferrite core, the circuit stopped working.

The circuit can find practical application not only in the design of field strength meters, but also in automation and signaling devices. The touch sensor can be connected to the microcontroller. To do this, you should perform an analog-to-digital voltage conversion on the VD1 LED, possibly using the resources of the microcontroller itself, if it contains a built-in ADC.

In conclusion, it should be noted that there are many touch sensor circuits based on field-effect transistors and not containing inductive elements. Perhaps their work is more effective in many cases, but the design presented in this article is an example of an original technical solution and is aimed at beginner radio amateurs.

Literature

  1. Brovin V.I. The phenomenon of transfer of energy of inductances through the magnetic moments of a substance located in the surrounding space, and its application. - M.: MetaSintez, 2003 - 20 p.
  2. Krylov K. S., Lee Jaeho, Kim Young Jin, Kim Seunghwan, Lee Sang-Ha. Patent for invention No. 2395876. Active magnetic antenna with ferrite core.