View detail for Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad

APPLICATION NOTE
Atmel AT01486: Low Cost Capacitive Touch TV Control
Keypad
Atmel QTouch
Features
•
Atmel® QTouchADC design based on Atmel ATtiny20
• Optimal hardware design
• Customized firmware
•
•
•
•
•
•
Six capacitive touch keys
Analog voltage output on touch detection
Buzzer indication on touch detection
Power management
TPI programming for ATtiny20
5V operation
Description
TV Control Touch Keyboard is designed to be drop-in replacement for an existing
electromechanical (resistive ladder) type TV controller. This keyboard outputs
respective analog voltage (DC output) on touch detection. The output voltage level is
dependent upon the supply voltage to the MCU.
Figure 1.
TV Control Touch Keyboard
It is based on Atmel QTouchADC technology. Although it is designed for TV control
application, it can be used for any other application which requires up to six keys.
42208A−QTOUCH−10/2013
Table of Contents
1. Introduction .......................................................................................... 3 1.1 QTouchADC ...................................................................................................... 3 2. Hardware Design ................................................................................. 4 2.1 Block Diagram ................................................................................................... 4 2.2 Buzzer Driver .................................................................................................... 4 2.3 Low Pass RC Filter ........................................................................................... 5 2.4 TPI Programming .............................................................................................. 5 3. Analog Output ...................................................................................... 6 3.1 PWM Signal Generation .................................................................................... 6 3.2 PWM Resolution ............................................................................................... 6 3.3 D.C Voltage Output ........................................................................................... 7 3.4 Noise Margin for PWM Output .......................................................................... 7 3.4.2 Transient Analysis Model .................................................................... 8 4. Pin Configuration ................................................................................. 9 4.1 QTouchADC Sensing ........................................................................................ 9 4.2 Analog Output ................................................................................................... 9 4.3 Buzzer ............................................................................................................... 9 5. Firmware ............................................................................................ 10 5.1 Application Code Flow .................................................................................... 10 5.2 Sensitivity Tuning in Firmware ........................................................................ 11 5.2.1 Over-sampling .................................................................................. 11 5.2.2 Detect Threshold (NTHR) ................................................................. 11 5.2.3 Charge Share Delay (CSD) .............................................................. 11 5.3 Files in Firmware ............................................................................................. 11 6. Schematic Design .............................................................................. 12 7. PCB Layout ........................................................................................ 13 8. Component List .................................................................................. 14 9. Recommended Reading .................................................................... 14 10. Revision History ................................................................................. 15 Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
2
1.
Introduction
1.1
QTouchADC
QTouchADC is the newest Atmel sensing algorithm that is implemented by oversampling a standard SAR ADC. The
QTouch® devices charge a sense electrode of unknown capacitance to a known potential. The electrode is typically a
copper area on a PCB (could be any conductive material, including ITO).
QTouchADC only requires 1-series resistor and 1-pin per channel. No other external components are required.
Compared with standard QTouch technology, QTouchADC offers faster acquisition times with shorter burst lengths,
resulting in lower power consumption.
The QTouchADC method works by sharing charge between the ADC’s internal sample-and-hold capacitor and the
sense electrode capacitance. In the initial state, an amount of charge is built-up on an untouched sensor to set the
sensor's reference level. As the finger makes contact with the sensor, it couples with the electric field of the sensor.
When a sensor is touched the effective capacitance of the sensor electrode increases. This affects the amount of
charge shared between the electrodes. Further charge transfers (conversions) from that sensor result in an increased
signal level compared to the untouched state. If the difference between the reference level and the signal level is
greater than the user-determined threshold (your delta), a touch is detected.
Figure 1-1. QTouchADC Sensing
Detailed technical description of the QTouchADC technology can be found in the application note Atmel AVR3001:
QTouchADC Measurement and Tuning.
Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
3
2.
Hardware Design
2.1
Block Diagram
The keypad consists of the following basic components:
1)
2)
3)
4)
5)
Atmel ATtiny20 Microcontroller.
Six self capacitance sensor electrodes.
PWM based analog output using low pass RC filter.
Buzzer for audio indication.
6-pin TPI Programming Header.
Figure 2-1. Block Diagram of TV Control Touch Keyboard
2.2
Buzzer Driver
The buzzer is driven using a transistor. The switching signal to the transistor is provided from the ATtiny20 device using
hardware PWM. The buzzer is driven with 50% duty cycle at 4kHz for 80ms on touch detection.
Figure 2-2. Buzzer Drive Circuit
VCC
R8
10k
R7
100R
LS1
1
2
BPT1403H5 LF
Q1
BC847W
GND
Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
4
2.3
Low Pass RC Filter
Ideally an external DAC should be used to obtain analog signals from digital signal but they are relatively expensive.
Another option is to use an R-2R ladder, but it is also difficult to construct and requires a lot of GPIOs.
A simple low cost technique is to use a RC filter to convert PWM signals to DC voltage. The Atmel ATtiny20
microcontroller generates output in PWM mode with varying duty cycle. A passive low pass filter is used to convert the
digital PWM to analog voltage.
Figure 2-3. RC Filter Circuit
O/P
1
2
DNP
C3
4.7uF
C2
100nF
150R
R9
GND
Low-pass filter circuit consists of a resistor in series with a load, and a capacitor in parallel with the load. The capacitor
exhibits reactance and block low-frequency signals. At higher frequencies the reactance drops, and the capacitor
effectively functions as a short circuit.
2.4
TPI Programming
The ATtiny20 supports TPI Programming. TPI is a very tiny programming interface for the newer TINY line of AVR®s
with limited pins. Since the small sized tinyAVR®s lacks on-chip debugging circuit, the TPI protocol uses a new
programming interface of three pins, in a half-duplex protocol.
Figure 2-4. TPI Header
A six pin TPI header is provided for the same. TPI programming can be done using AVRISP mkII and Atmel STK®600.
When the device's RSTDSB pin is set only High Voltage Programming can be used to program the chip. Since the
RESET line needs to be raised to +12V for programming, this is currently only supported by the newer STK600
programming board.
Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
5
3.
Analog Output
The board communicates the touch status to the host controller through ANO pin. The output is RC filtered PWM signal.
There is a specific output voltage for each key.
PWM output will be generated during key press. In the idle state, when none of the touch keys are touched, the PWM
output will be held high.
3.1
PWM Signal Generation
The PWM signal is generated using 16-bit Timer/Counter1 module of the Atmel ATtiny20. The Timer is configured to
16-bit Fast PWM mode. The System clock frequency in this case is 4MHz and clock prescaler has been disabled. The
timer period is set to 34 counts for the PWM frequency of 117kHz.
Figure 3-1. PWM Signal for ON/OFF Key
3.2
PWM Resolution
The PWM resolution is dependent on many factors such as
•
•
•
•
System clock frequency
Waveform generation mode used
Clock prescaler
TOP value
Higher clock frequency will allow for larger number of clock ticks within the given time period required for a specified
frequency in this case 117kHz. The waveform generation mode defines whether 8, 9, 10, or 16-bit PWM resolution can
be achieved, the clock prescaler can divide the timer clock by a predetermined scale, and the TOP value determines
the end of each counting cycle. The resolution of the PWM output can be calculated as follows:
Resolution = (1/34) * VCC
Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
6
3.3
D.C Voltage Output
Table 3-1.
Analog Output Values
KEY
ANALOG OUTPUT (VCC = 5V)
DUTY CYCLE
IDLE STATE
5.0V
-
ON/OFF
2.7V
54.38%
MENU
3.4V
68.58%
PROG +
1.7V
34.25%
PROG -
3.9V
77.16%
VOL +
2.4V
48.56%
VOL -
4.4V
85.72%
TV/AV*
1.3V
25.69%
* PROG + and PROG – need to be touched together to activate the TV/AV function.
3.4
Noise Margin for PWM Output
Conversion from digital to analog would carry some ripple voltage in the output. The Low pass filter has to be designed
to maintain the tolerable noise margin in the system.
The settings in the hardware and firmware have been done to have a noise margin below 0.02V. The theoretical ripple
voltage of the system is 0.015154V.
Figure 3-2. Representative View of Analog Voltage Signal after Filtering
The resistor (R) has been chosen to have a low value of 150Ω so as to minimize the drop in voltage after the filtering
effect. Since the PWM frequency is in kHz range, the cut-off frequency is selected in Hz so as to provide significant
attenuation to the high frequency signal.
1
2
The C value was calculated using the above formula after selecting 225Hz as the cut-off frequency.
Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
7
3.4.2
Transient Analysis Model
→
→ VOUT(s)
PWM signal
R = 150Ω
C = 4.7µF
Table 3-2.
Transient Analysis of the RC Low Pass Filter
TRANSIENT ANALYSIS PARAMETER
VALUE
1418.43971631
1418.43971631
Transfer function
Cut-frequency
Peak-to-peak ripple voltage
Duty cycle = 50%
Settling time (0% to 90%)
225.75169
∆
0.015154
0.0016233
Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
8
4.
Pin Configuration
4.1
QTouchADC Sensing
The touch sensing is done using the internal ADC module of the microcontroller. Thus pins which are connected to the
ADC module are connected to the sensor electrodes.
Table 4-1.
4.2
Pin Configuration of Sense Pins
FUNCTIONALITY
MCU PIN #
MCU PIN NAME
KEY0
12
PORTA1
KEY1
11
PORTA2
KEY2
10
PORTA3
KEY3
9
PORTA4
KEY4
8
PORTA5
KEY5
7
PORTA6
Analog Output
The analog output is generated by using the PWM module of the microcontroller.
Table 4-2.
4.3
Pins Configuration for Analog Voltage Output
FUNCTIONALITY
MCU PIN #
MCU PIN NAME
ANALOG OUTPUT
5
PORTB2 (OC0A)
Buzzer
The buzzer is driven using PWM module of the microcontroller.
Table 4-3.
Pin Configuration for Buzzer
FUNCTIONALITY
MCU PIN #
MCU PIN NAME
BUZZER
6
PORTA7 (OC0B)
Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
9
5.
Firmware
The firmware of the TV Control Touch Keyboard has two basic parts. The touch library which performs the capacitive
touch measurements and the User Application Code which takes care of PWM generation and buzzer output based on
the sensor states. Refer to Section 6.4 of Atmel QTouch Library 5.0 User Guide for details of firmware flow and
configuration.
5.1
Application Code Flow
Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
10
5.2
Sensitivity Tuning in Firmware
In QTouchADC method does not use any external components. All sensitivity tuning parameters are to be adjusted in
the firmware using the following parameters. Refer to the Section 2 of Atmel AVR3001: QTouchADC Measurement and
Tuning for better understanding of the optimal settings for good sensitivity.
5.2.1
Over-sampling
Increasing the over-sampling increases the sensitivity of the sensors. This parameter is to be modified in the Linker
Options in the IAR™ IDE.
/* Default value: 1.
Values: 1u, 4u and 16u */
#define DEF_QT_BURST_LENGTH
5.2.2
(0x01u)
Detect Threshold (NTHR)
Increasing the detect threshold decreases the sensitivity. This parameter can be modified in the touch_config_tiny20.h
file.
/* Sensor detection threshold value.
Range: 1u to 255u. */
#define DEF_QT_SENSOR_0_THRESHOLD
#define DEF_QT_SENSOR_1_THRESHOLD
#define DEF_QT_SENSOR_2_THRESHOLD
#define DEF_QT_SENSOR_3_THRESHOLD
#define DEF_QT_SENSOR_4_THRESHOLD
#define DEF_QT_SENSOR_5_THRESHOLD
5.2.3
(6u)
(6u)
(6u)
(6u)
(6u)
(6u)
Charge Share Delay (CSD)
Increasing the charge share delay time allows for increased time for charge transfer between sensor electrode and
sampling capacitor. For good sensitivity it is necessary to ensure that full charge transfer takes place. This parameter
can be modified in the touch_config_tiny20.h file.
/* Range: 1, 2, 4, 8 or 10 internal System Clock cycles.
CAUTION: Do NOT append 'u' or () in this case. */
#define DEF_QT_DELAY_CYCLES
1
5.3
Files in Firmware
The source code contains the following files:
FILENAME
DESCRIPTION
libtiny20-6qt-k-0rs.r90
Touch Library file for QTouchADC on Atmel ATtiny20
touch_api_tiny20.h
Touch Library API file
touch_config_tiny20.h
Configuration file for setting of tuning parameters
main.c
User application code
Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
11
Schematic Design
6.
Figure 6-1. Schematic of the Atmel ATtiny20 Based TV Control Touch Keyboard
TP1
VOL+
DNP
C1
VCC
O/P
1
2
6
4
2
DNP
C4
VCC
TPI
GND
100nF
GND
TP2
3.3n
PROG+
U1 ATtiny20-SSU
5
3
1
1
2
3
4
5
6
7
TP8
C3
4.7uF
C2
100nF
150R
R9
VCC
PB0
PB1
PB3/RESET
PB2
PA7
PA6
GND
PA0
PA1
PA2
PA3
PA4
PA5
14
13
12
11
10
9
8
TP7
R1
R2
R3
R4
R5
R6
1k
1k
1k
1k
1k
TP3
ON/OFF
TP4
MENU
1k
Place resistors as close to uC
TP5
GND
PROGVCC
R8
10k
R7
100R
TP6
VOL-
LS1
1
2
BPT1403H5 LF
Q1
BC847W
GND
Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
12
PCB Layout
7.
The design for the TV Control Touch Keyboard follows a dual layer construction. The sensors are on the top layer which
is to be covered by a dielectric front panel. The bottom layer has the components and the necessary routing and ground
loading. FR4 PCB substrate material is recommended for optimal performance.
Figure 7-1. PCB Layout - Top Layer
1
1
1
1
1
1
0
Figure 7-2. PCB Render – Top Layer
Figure 7-3. Bottom Layer
1
1
1
2
1
2
1
2
1
2
1
2
1
2
2
2
3
1
1
7
8
2
2
3
1
2
1
2
6
9
5
10
4
11
3
12
2
13
1
1
2
1
1
3
1
1
1
1
0
5
1
1
2
2
4
6
1
1
14
2
1
2
1
Figure 7-4. PCB Render – Bottom Layer
Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
13
8.
9.
Component List
DESIGNATOR
COMPONENT TYPE
COMPONENT VALUE
FUNCTIONALITY
U1
MCU 14pin-SOIC
ATtiny20
R1, R2, R3, R4, R5, R6
SMD resistor (0603)
1k
Series resistor for Touch
R7
SMD resistor (0603)
100E
Buzzer drive resistor
R8
SMD resistor (0603)
10k
Transistor bias resistor
R9
SMD resistor (0603)
150E
Low Pass Filter (R)
C2
SMD capacitor (0603)
4.7µF
Low Pass Filter (C)
Q1
Transistor
BC847W
Buzzer Drive
LS1
Piezo Buzzer
Buzzer
Recommended Reading
•
•
•
AVR3001: QTouchADC Measurement and Tuning
Atmel QTouch Library 5.0 User Guide
QTAN0079: Buttons, Sliders and Wheels Touch Sensor Design Guide
Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
14
10.
Revision History
Doc. Rev.
Date
Comments
42208A
10/2013
Initial document release
Atmel AT01486: Low Cost Capacitive Touch TV Control Keypad [APPLICATION NOTE]
42208A−QTOUCH−10/2013
15
Atmel Corporation
Atmel Asia Limited
Atmel Munich GmbH
Atmel Japan G.K.
1600 Technology Drive
Unit 01-5 & 16, 19F
Business Campus
16F Shin-Osaki Kangyo Building
San Jose, CA 95110
BEA Tower, Millennium City 5
Parkring 4
1-6-4 Osaki
USA
418 Kwun Tong Road
D-85748 Garching b. Munich
Shinagawa-ku, Tokyo 141-0032
Tel: (+1)(408) 441-0311
Kwun Tong, Kowloon
GERMANY
JAPAN
Fax: (+1)(408) 487-2600
HONG KONG
Tel: (+49) 89-31970-0
Tel: (+81)(3) 6417-0300
www.atmel.com
Tel: (+852) 2245-6100
Fax: (+49) 89-3194621
Fax: (+81)(3) 6417-0370
Fax: (+852) 2722-1369
© 2013 Atmel Corporation. All rights reserved. / Rev.: 42208A−QTOUCH−10/2013
Atmel®, Atmel logo and combinations thereof, AVR®, Enabling Unlimited Possibilities®, QTouch®, STK®, tinyAVR®, and others are registered trademarks or
trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others.
Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this
document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES
NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF
INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no
representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time
without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in,
automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.