Capacitive touch sensing solution based on STM8 series 8-bit general-purpose MCU
[Copy link]
Compared with mechanical buttons and resistive touch buttons, capacitive touch buttons are not only durable, low-cost, simple and easy to install, waterproof and anti-fouling, but also provide functions such as rollers and sliders. However, capacitive touch buttons also have many problems. Because there is no mechanical structure, all detections are small changes in electricity, so they are much more sensitive to various interferences. ST has launched a capacitive touch sensing solution based on the STM8 series 8-bit general-purpose microcontroller platform for home appliance applications, especially induction cooker applications. There is no need to add a dedicated touch chip. Only a simple peripheral circuit can realize the capacitive touch sensing function, which is convenient for customers to develop secondary development.
2 Solution Introduction
ST's capacitive touch button solution detects the capacitance change caused by human touch through the charging/discharging time of a resistor-capacitor network composed of a resistor and the capacitor CX of the sensing electrode. As shown in Figure 1, when a person presses the button, it is equivalent to connecting a capacitor CT in parallel to the sensing electrode. The capacitance on the sensing electrode is increased, and the charging and discharging time of the sensing electrode will increase, thereby detecting the state of the button. The sensing electrodes can be directly drawn on the PCB board as buttons, rollers or sliders, or made into spring parts and inserted into the PCB board. Even if there is an insulating layer (glass, resin) between them, its detection performance will not be affected.
Figure 1 Working principle of STM8S capacitive touch button
The induction cooker uses the heating principle of magnetic field induction current to heat food. When heating, a strong magnetic field is generated by the coil under the panel. When the magnetic lines of force pass through the bottom of the pot made of a magnetic conductor, the pot cuts the alternating magnetic lines of force and generates eddy currents at the bottom of the pot, causing the bottom of the pot to heat up quickly, achieving the purpose of heating food. In this solution, the 44-pin STM8S105S4 is used as the main control chip of the key display board to control the scanning of 13 keys, the display of 24 LEDs and a 4-digit digital tube, the communication between I2C and the main board, and a SWIM interface is reserved for engineers to debug (as shown in Figure 2).
The STM8S105S4 uses the ST advanced STM8 core, with a Harvard structure with a 3-stage pipeline, a 3.0~5.5V operating voltage, an internal 16MHz RC that can provide an MCU 16MHz operating frequency, a low power mode and a peripheral clock shutdown function, and a total of 34 I/Os available. The STM8S105S4 has 2KB of RAM and 16KB of FLASH, as well as 1KB of EEPROM data memory with up to 300,000 erase and write cycles.
Figure 2 Principle of induction cooker keypad
3 Interference in the working environment of induction cooker
1. Electromagnetic interference
While heating the pot, the induction cooker also generates positive or reverse current to the induction electrode on the circuit board, which will shorten or increase the charging and discharging time of the key, which will have a great impact on the detection of the key and even cause malfunction. The common method is to use hardware shielding and zero-crossing detection to eliminate the impact of electromagnetic radiation on the key.
Hardware shielding
In the STM8S solution, ST provides the design specifications of the induction electrode and routing and the Driven Shield function shown in Figure 3 (providing the same driving signal as the key pin on the Shield line, the parasitic capacitance between the electrode and the Shield will not be charged and discharged), which can effectively reduce the impact of the parasitic capacitance of the induction electrode routing on the key sensitivity.
Figure 3 Driven Shield
zero-crossing detection
1) Hardware zero-crossing detection
Zero-crossing detection can be implemented by hardware. In hardware design, a hardware detection circuit for zero-crossing as shown in Figure 4 or Figure 5 can be added to judge the key state when the output of the B terminal is high, so as to detect the touch key when the electromagnetic radiation is minimum.
Figure 4 Hardware zero-crossing detection circuit 1
Figure 5 Hardware zero-crossing detection circuit 2
2) Software zero-
crossing detection Hardware zero-crossing detection increases the complexity of hardware circuit design and the cost of the solution. In our solution, we use software to perform zero-crossing detection for the working environment of the induction cooker, thereby reducing costs and effectively solving the interference of the main power circuit of the induction cooker on the touch keys.
2. Power grid interference
Because the quality of the domestic power grid is different, in some areas with poor quality, it is easy to affect the normal operation of the induction cooker touch keys. If the power supply cannot be isolated, you will see the difference in Figure 6 (blue means no key, red means the key is pressed), and these figures are only when the induction cooker is not powered on. When the induction cooker is working, the electromagnetic radiation generated will make the signal seen more chaotic. In the experiment, it was found that the key effect can be significantly improved by isolating from the external power grid or using software filtering.
Figure 6 Good quality power grid Poor quality power grid 1 Poor quality power grid 2
3. Impact of splashing water and oil
When using the induction cooker, water or oil often splashes onto the touch panel, which may cause false triggering of the key. This solution uses a special software algorithm to reliably distinguish between splashing water and oil and finger pressing.
4. Environmental adaptability
When the induction cooker is working, it will generate a lot of heat and moisture. The panel temperature/humidity and circuit board temperature/humidity will fluctuate in a wide range. As time goes by, the glass panel and PCB board will age at different levels, thus affecting the accuracy of key detection. In the ST solution, the automatic calibration function is implemented, and the environmental detection is provided in real time to realize the mechanism of environmental adaptation.
4 Summary
The solution provided by ST includes functions such as touch panel self-calibration, software filtering, software zero-crossing detection and environmental adaptation. The software algorithm is used as much as possible to shield the interference of various complex environments. It has the characteristics of low cost and reliable operation. Of course, in the application of other products, there will be some requirements that are different from the induction cooker environment. Here we only introduce some representative interferences. However, as long as you understand the working principle of capacitive touch, there are still many ways to deal with various application situations.
|