Design of inductive buttons based on embedded technology

Publisher:EternalWhisperLatest update time:2012-09-10 Keywords:Embedded Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
3 Hardware Design

The induction key based on ATmega48 is very simple in hardware design. Each key only needs one resistor and one capacitor to realize it. Usually, the induction electrode is distributed on the printed circuit board in the form of copper foil. The induction electrode can be designed into different sizes and shapes according to specific application needs. At the same time, the use of conductive media such as metal springs or conductive sponges can extend the key to a suitable length or height, as shown in Figure 2.

Sensing electrodes extended by metal springs

Figure 2 Sensing electrode extended by metal spring

Hardware Schematic

Figure 3 Hardware schematic diagram

In typical applications, the sampling capacitor C1 or C2 uses 22 nF, and the current limiting resistor R1 or R2 uses 1 kΩ. However, in actual application systems, the capacitance of the sampling capacitor and the resistance of the current limiting resistor need to be adjusted according to the sensitivity of the sensing button to achieve the best effect. The hardware schematic is shown in Figure 3.

4 Library installation and software configuration

To use the I/O port of the ATmega48 microcontroller as a sensor key input port, you first need to install the QTouch library Atmel_QTouch_Libraries. The latest version of the library is 4.3. After installation, you need to load the library file corresponding to the microcontroller into the project. Atmel's integrated development environment AVR Studio provides convenient settings. After creating a new project, you can add the library link file in the Project→Configuration Options→Libraries interface.

Secondly, you need to configure the I/O port. Set the corresponding macro definition parameters in the project configuration (Project→Configuration Options→Custom Options) interface, as shown in Figure 4.

AVR Studio project configuration interface

Figure 4 AVR Studio project configuration interface

D_QTOUCH_: Requires the use of the QTouch function library.

DSNSK=C and DSNS=C: means setting the ATmega48 PC port as the sensor key port.

DQT_NUM_CHANNELS=4: indicates the maximum number of available channels.

DQT_DELAY_CYCLES=1: indicates the charging and discharging cycle time of the sampling capacitor.

In addition, the header file of the library function needs to be added to the application system source program. The code is as follows:

#include "touch_api.h"

5 System Application

The application process is shown in Figure 5. After the system is initialized, the config_sensors() function is first called to configure the required I/O port as the sampling port of the sensing button, and the various states of each sensing button are initialized. Then the sensing parameters are set, including the button calibration threshold, positive drift value, negative drift value, maximum continuous sensing time, etc. Finally, in the main program of the application system, the library function qt_measuer_channels() needs to be called periodically to measure the sensing signal and detect the state of the button.

QTouch application process

Figure 5 QTouch application process

It should be noted that the sensing key acquisition uses a timer interrupt of the system, so the interrupt program in the application system will have a certain impact on it. This requires that during the key sensing process, the processing time of the interrupt service program of the application system should be as short as possible. When the capacitive sensing is working, the interrupt service program processing time should not exceed 1 ms, otherwise it will seriously affect the sensitivity of the sensing key and even cause the sensing key to malfunction.

The application system procedures are as follows:

int main( void ){

init_system();/*System initialization*/

config_sensors();/*Configure the I/O port as a sensor button*/

qt_init_sensing();/*Initialize the sensing sensor*/

qt_set_parameters();/*Sensing parameter settings*/

init_timer_isr();/*Timer setting for sensing buttons*/

qt_filter_callback = 0;/*Filter parameter selection*/

__enable_interrupt();/*Enable timer interrupt*//*Application main loop*/

while (1) {

if( time_to_measure_touch ) {

time_to_measure_touch = 0u; /*Continue to the next acquisition cycle*/

qt_measure_sensors( current_time_ms_touch );/*Sensor detection*/

}

KeyBuff = (qt_measure_data.qt_touch_status.sensor_states[0]);/*Get the sensor key status*/

.../*System applications*/

}

}

6 Conclusion

The embedded inductive button design based on Atmel QTouch technology simplifies the design difficulty, reduces the application cost of the system, saves the size and space of the printed circuit board, and the system application is stable and can be flexibly applied to various electronic products.

Keywords:Embedded Reference address:Design of inductive buttons based on embedded technology

Previous article:Design of induction button based on embedded technology1
Next article:Introduction to the working principles of various types of touch screens

Latest Analog Electronics Articles
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号