Touch button design based on 8-bit MCU

Publisher:Serendipitous33Latest update time:2014-11-19 Source: 21ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  0 Introduction

  MCU (Micro Controller Unit) is the Chinese name for multi-point control unit, also known as single chip microcomputer. It refers to the integration of computer CPU, RAM, ROM, timer and multiple I/O interfaces on a single chip with the emergence and development of large-scale integrated circuits to form a chip-level computer, which can perform different combination controls for different application scenarios.

  In applications that require a user interface, traditional electromechanical switches are being replaced by capacitive touch sensing controls. The touch sensing software can detect the touch of a human hand by controlling the RC charge and discharge time consisting of a resistor and the touch electrode capacitance. The change in RC charge and discharge time due to the change in electrode capacitance can be detected, then filtered, and finally sent to the host system through a dedicated I/O port or I2C/SPI interface. The components BOM required by the software library is low cost because only two resistors are needed per channel to realize the touch detection function.

  1 RC induction principle

  The RC sampling principle is to sense the human body's touch on the capacitive touch sensor (button, roller or slider) by measuring the tiny changes in the capacitance of the touch electrode.

  The electrode capacitance (C) is periodically charged and discharged through a fixed resistor (R). The capacitance value depends on several parameters: electrode area (A), relative dielectric constant of the insulator ( ), relative humidity of the air ( ), and the distance between the two electrodes (d). The capacitance value can be obtained by the following formula

Figure 1 RC voltage detection
Figure 1 RC voltage detection

  When a fixed voltage is applied, the voltage at increases or decreases accordingly as the capacitance value changes, as shown in Figure 2.

Figure 2 Measuring charging time

Figure 2 Measuring charging time

 

  The capacitance value (C) is obtained by calculating the charging time ( ) required for the voltage to reach the threshold. In touch sensing applications, the capacitance value (C) consists of two parts: fixed capacitance (electrode capacitance, ) and capacitance (sensing capacitance, ) caused by the human hand when the hand touches or approaches the electrode. Using this principle, it is possible to detect whether the finger touches the electrode.

Figure 3 Touch Sensing

Figure 3 Touch Sensing

  This is the basic principle used by the sensing layer in touch sensing software to detect human touch.

  2 Hardware Implementation

  Figure 4 shows an implementation example. An RC network is formed by R1, R2 and the capacitor (about 5pF) in parallel with the capacitor electrode ( ) and the finger capacitor ( ). By measuring the charge and discharge time of this RC network, the touch of the human hand can be detected. All electrodes share a "load I/O" pin. Capacitor R2 (10K?) is optional and is used to reduce the impact of noise.Figure 4 Capacitive touch sensing implementation example

Figure 4 Capacitive touch sensing implementation example

3 Software Implementation

  This chapter describes the implementation of the touch sensing RC principle.

  3.1 Charging time measurement principle

  To ensure robust capacitive touch sensing applications, the charge time measurement needs to be sufficiently accurate.

  A simple timer (no IC function required) and a series of simple software operations are used to periodically check whether the voltage on the sensing I/O port reaches the threshold.

  3.2 Basic Measurements

  Use a normal timer to measure the charging time. Before charging the capacitor, the timer counter value is recorded. When the voltage on the sampled I/O port reaches a certain threshold ( ), the timer counter value is recorded again. The difference between the two is the charging or discharging time.Figure 5 Timer counter value

Figure 5 Timer counter value

  3.3 Oversampling

  The purpose of oversampling is to measure the time it takes for the input voltage to reach high and low levels ( and ) with the accuracy of the CPU clock. In order to cover all value ranges, each measurement is delayed by one CPU clock cycle compared to the previous measurement. [page]

 

Figure 6 Input voltage measurement
Figure 6 Input voltage measurement

  3.4 Principle of input voltage measurement

  To improve stability under voltage and temperature variations, the electrode is measured twice in succession: the first measurement is the charging time of the capacitor until the input voltage rises to . The second measurement is the discharge time of the capacitor until the input voltage drops to . The following figure and the table below detail the operation flow on the sensing electrode (sense I/O) and the load I/O pin.

Table 2 Capacitor charge and discharge measurement steps
Table 2 Capacitor charge and discharge measurement steps

3.5 Effects of Touch

  The capacitance value of the electrode ( ) depends on several main factors: the shape and size of the electrode, the wiring between the touch sensing controller and the electrode (especially the ground coupling), and the material and thickness of the dielectric panel. Figure 8 illustrates this "touch effect". The time (i.e. the moment when the level is reached) is longer than that; similarly, the time to drop to the level is also longer than that.

Figure 8 Touch effect example
Figure 8 Touch effect example

3.6 Multiple measurements and removal of high-frequency noise

  In order to improve the measurement accuracy and remove high-frequency noise, it is necessary to measure and multiple times before deciding whether any key is effectively "touched".

Figure 9 Types of measurements

Figure 9 Types of measurements

  Note: The figure below illustrates an example of noise removal. If the number of measurements (N) is set to 4, then a complete measurement of one electrode will consist of 4 correct "Batch Group Measurements" (BGs).

  Figure 10 shows the situation where all measurements are valid without the influence of noise. In this example, each measurement in the continuous group of measurements is valid, allowing a complete measurement to be completed very quickly.

Figure 10 Example 1

Figure 10 Example 1

  Figure 11 shows a situation where there is some noise that makes some measurements invalid (i.e., r1 and r2). In this example, the continuous group measurement BG3 is repeated several times until all the measurements in it are valid and the group measurement passes.

Figure 11 Example 2

Figure 11 Example 2

  Figure 12 shows that there is a lot of noise, which makes the number of invalid group measurements reach the maximum limit (for example, 20). In this case, the entire electrode measurement is invalid.

Figure 12 Example 3

Figure 12 Example 3

Reference address:Touch button design based on 8-bit MCU

Previous article:Design of Carbon Monoxide Monitoring Alarm Based on ADuC834
Next article:PIC16F84A single chip microcomputer LED light circuit and source program

Recommended ReadingLatest update time:2024-11-16 20:37

Design of a large LED screen control system based on MCU+FPGA
introduction If you take a look at the current market, you will find that most small and medium-sized LED display systems use traditional single-chip microcomputers as the main control chip. However, single-chip microcomputers with less internal resources and slower running speeds are difficult to meet the needs of la
[Embedded]
Design of a large LED screen control system based on MCU+FPGA
C51 MCU timer simulates single-channel output PWM
Preface This blog post is developed based on STC89C52RC and Keil5 C51 environment; If there are any deficiencies, please give me more advice; Things Needed Timer 0; Pin P1.0; code show as below: #include STC89C5xRC.H #define ENABLE 1 #define DISENABLE 0 typedef unsigned char uchar8; sbit P1_0 = P1^0; bit Flag
[Microcontroller]
Design of digital thermometer based on single chip microcomputer control
Temperature is a physical quantity that people often need to measure and control in their daily lives. Traditional thermometers have the disadvantages of slow response, troublesome reading, low measurement accuracy, and large errors. In certain specific occasions, the equipment has extremely high requirements for tempe
[Microcontroller]
Design of digital thermometer based on single chip microcomputer control
[MCU Framework][APP_KEY] Using soft timer to implement key scanning
Example: Initialize anywhere: app_key_init(); void demo(void) {     bsp_led_toggle(LED0); } // The button trigger event will jump to the corresponding function. Here we demonstrate single click to execute the demo function. button_fun_callback_t button_fun_callback = {     {BUTTON0, BUTTIN_SINGLE_CLICK, demo} }; T
[Microcontroller]
51 single chip microcomputer program - key control single digital tube display
#include   unsigned char code table ={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,}; // Display value table 0-9   void main (void) {     while(1)                               //main loop {       P1 = 0x01;                             //Open the digital tube bit selection   P3 = 0xff;   swit
[Microcontroller]
[51 microcontroller] keil establishment project and burning software operation (1)
Keil build project 1. Enter the main interface 2. Project - Create a new μVision project 3. Select a device. Atmel-AT89C52 4. Create a new blank page and save it in C file format (.c) 5. Double-click the source group-add the C file to the source group 6. Goal setting Output-check Create HEX File (check i
[Microcontroller]
[51 microcontroller] keil establishment project and burning software operation (1)
How domestic core MCUs help the development of automotive electronics
 The gradual maturity of the IoT ecosystem and the electronic intelligence of automobiles have become the twin engines of MCU development. With these two applications at the core and combined with new technologies such as 5G and AI, MCU is rapidly penetrating into various segments.   In the domestic market, domestic M
[Automotive Electronics]
How domestic core MCUs help the development of automotive electronics
Next-generation energy-efficient microcontroller designs extend battery life
When designing a battery-powered product, one obviously wants the battery to last as long as possible. Energy-sensitive product applications can be broadly divided into energy metering systems, home and building automation, security, and medical systems (Figure 1). These products are typically built around a micro
[Power Management]
Next-generation energy-efficient microcontroller designs extend battery life
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号