APPLICATION NOTE
Atmel AT03816: QMatrix Control Panel for In-Home Display
Atmel QTouch
Features
• Supports up to seven QMatrix® keys • SPI slave interface • LEDs • Provision for touch data • ISP programming interface • Powered from USB or external supply
Introduction
The reference design demonstrates implementation of seven QMatrix keys and SPI slave communication on Atmel® ATtiny4313 device. The SPI slave can be interfaced to any SPI master for reading the status of touch keys. The design consists of LED for visual indication.
Figure 1. QMatrix Reference Design.
42179A−QTOUCH−09/2013
Atmel AT03816: QMatrix Control Panel for In-Home Display [APPLICATION NOTE] 42179A−QTOUCH−09/2013
2
Table of Contents
1. Hardware ............................................................................................. 3 1.1 QMatrix Sense Circuitry .................................................................................... 4 1.2 LEDs ….. ........................................................................................................... 4 1.3 Communication Interface .................................................................................. 5 1.4 Power Supply .................................................................................................... 5
1.4.1 USB Supply ........................................................................................ 5 1.4.1.1 On-Board Regulator .......................................................... 5
1.4.2 External Supply ................................................................................... 5 1.5 ISP Interface ..................................................................................................... 5 1.6 GPIO Pin Mapping ............................................................................................ 6
2. Touch Data .......................................................................................... 7
3. SPI Communication Interface .............................................................. 8
4. Firmware .............................................................................................. 9 4.1 User Application Code Implementation ............................................................. 9 4.2 User Application Code Requirements ............................................................... 9 4.3 Application Code Flow ...................................................................................... 9
5. Schematic .......................................................................................... 10
6. PCB Layout ........................................................................................ 11
7. Bill of Materials (BOM) ....................................................................... 12
8. References ......................................................................................... 13
9. Revision History ................................................................................. 14
Atmel AT03816: QMatrix Control Panel for In-Home Display [APPLICATION NOTE] 42179A−QTOUCH−09/2013
3
1. Hardware The reference design hardware can be divided into the following major blocks.
• QMatrix sense circuitry • Power supply circuitry • Communication interface • Programming interface • LEDs
Figure 1-1 shows a block diagram view of the reference design. More details about each block are provided in the next sections.
Figure 1-1. System Block Diagram.
The reference design can also be configured to work independently in standalone mode without using SPI communication interface.
This reference design is ideal for applications like In-home display systems for energy monitoring systems, control panel of a Smart Home system, portable network devices, and similar applications that use dedicated touch MCU.
Atmel AT03816: QMatrix Control Panel for In-Home Display [APPLICATION NOTE] 42179A−QTOUCH−09/2013
4
1.1 QMatrix Sense Circuitry QMatrix sensor electrode consists of X-electrode (Transmitter) and Y-electrode (Receiver). To realize X by Y matrix of QMatrix sensors X+2Y+ 2 physical I/O pins are required. Figure 1-2 represents Atmel ATtiny4313 GPIO pin assignment to QMatrix sense circuitry.
Figure 1-2. GPIO Pin Assignment.
1.2 LEDs LED D1 is controlled by GPIO PA1 of ATtiny4313 device. It sinks current from PA1-pin. LED D1 is configured to provide indication for sensor touch event detection. PA1 is multiplexed with debug clock (DBG_CLK) pin. Jumper provision on header J4 is given to switch between DBG_CLK and LED D1. So, when Debug functionality is selected in the application the LED indication for touch event does not work.
LED D0 acts as power indication for the MCU. This is connected between supply line of the ATtiny4313 device and ground.
Atmel AT03816: QMatrix Control Panel for In-Home Display [APPLICATION NOTE] 42179A−QTOUCH−09/2013
5
1.3 Communication Interface The SPI header (J1) on the board has Serial Peripheral Interface (SPI) communication lines. Figure 1-3 shows the communication header available on the PCB.
Figure 1-3. Communication Header.
1.4 Power Supply The reference design can be powered by using any of the following power supply sources.
1.4.1 USB Supply The reference board can be powered with the Mini-B USB header (U3) available on the board. The USB also acts as a source of power to the on-board voltage regulator (U1) and LED D1.
1.4.1.1 On-Board Regulator A linear dropout regulator (U1), which is mounted on the board, acts as a regulated power supply source to the Atmel ATtiny4313 device (U2). LED D1 is not powered by this regulator.
1.4.2 External Supply Provision is given on the board to provide supply in the range of 1.8V to 4.5V using external power sources like standard bench supply.
Please refer to application note Atmel AT02259: QTouch® Schematic and Layout Checklist for more details on power supply considerations.
1.5 ISP Interface The ATtiny4313 device can be programmed using the ISP interface. The on-board ISP header can be used for programming the device. Figure 1-4 shows the ISP programming header available on the PCB.
Figure 1-4. Programming Header.
1 2 3 4 5 6
J6
RESET
MISOSCK MOSI VDD
GND
4.7KR12
VDD
ISP
R131K
R141KR15MISO
SCK
MOSI SS 1
2 3 4
J1
SPI
1K
http://www.atmel.com/Images/Atmel-42094-QTouch-Schematic-and-Layout-Checklist_Application-Note_AT02259.pdf�http://www.atmel.com/Images/Atmel-42094-QTouch-Schematic-and-Layout-Checklist_Application-Note_AT02259.pdf�http://www.atmel.com/Images/Atmel-42094-QTouch-Schematic-and-Layout-Checklist_Application-Note_AT02259.pdf�
Atmel AT03816: QMatrix Control Panel for In-Home Display [APPLICATION NOTE] 42179A−QTOUCH−09/2013
6
1.6 GPIO Pin Mapping
Table 1-1. GPIO Pin Mapping.
Function ATtiny4313 MCU pin Header - pin
Debug Data(DBG_DATA) PA0 J4-Pin3
Debug Clock (DBG_CLK) PA1 J4- Pin2
Touch LED (D1) PA1 J4- Pin1
SS PB4 J1-Pin1
MOSI PB5 J1-Pin2
MISO PB6 J1-Pin3
SCK PB7 J1-Pin4
Note: The QMatrix design should comply with the design guidelines provided in Section 5.6.7.3 of the QTouch Library user guide.
Atmel AT03816: QMatrix Control Panel for In-Home Display [APPLICATION NOTE] 42179A−QTOUCH−09/2013
7
2. Touch Data The firmware supports QDebug protocol for analyzing touch data using the QTouch Analyzer. The Atmel QT™600 USB interface board is used for communication interface between the reference board and QTouch Analyzer. Refer Figure 2-1 for interfacing details between reference board and QTouch Analyzer.
Figure 2-1. Block Diagram View of Reference Board Interface with QTouch Analyzer.
The reference board sends touch data using one way Bit-Bang SPI. User can only visualize the channel signal, reference and delta values on the QTouch Analyzer. One way Bit-Bang SPI does not allow modifying touch configurable parameters from QTouch Analyzer.
GPIO pins PA0, PA1 of the Atmel ATtiny4313 are configured as debug data (DBG_DATA) and debug clock (DBG_CLK) pins respectively. PA1 is multiplexed with LED D1. So, select appropriate jumper settings on header J4 to use PA1 pin for touch data. To analyze touch data, power the reference board through QT600 USB interface board.
For interfacing with QTouch Analyzer, necessary connections have to be made between reference board and QT600 USB interface board as shown in Table 2-1.
Table 2-1. Connections between Reference Board and QT600 USB Interface Board.
Interface Reference board QT600 USB interface board (QTOUCH DATA Header)
One way SPI (Bit-Bang)
GND (TEST POINT) SS (PIN5)
DBG_DATA ( Pin3 of J4 header) MOSI(PIN6)
DBG_CLK ( Pin2 of J4 header) SCK(PIN8)
GND (Pin1 of J2 header) GND(PIN9)
VCC (Pin2 of J2 header) VDD(PIN10)
Atmel AT03816: QMatrix Control Panel for In-Home Display [APPLICATION NOTE] 42179A−QTOUCH−09/2013
8
3. SPI Communication Interface The Universal Serial Interface (USI) module on the Atmel ATtiny4313 supports both three-wire mode and two-wire mode. Three-wire mode is compliant to the SPI and it can be configured to work in SPI Mode0 or Mode1. The USI module is configured as SPI slave and operates in SPI Data Mode0 with 1MHz clock. The ATtiny4313 slave device is set to operate at 8MHz. The firmware consists of Slave Select (SS) pin functionality implementation. Figure 3-1 shows the necessary pin connections required between master and slave device for SPI communication.
Figure 3-1. ATtiny4313 USI (SPI Slave) Module Connection Details.
Atmel AT03816: QMatrix Control Panel for In-Home Display [APPLICATION NOTE] 42179A−QTOUCH−09/2013
9
4. Firmware The firmware for the reference design is only available for IAR™ tool chain. It consists of:
• Custom QMatrix library that supports seven keys. The touch library does touch data acquisition and post processing sequentially on all configured sensors
• SPI slave driver to send status of the configured keys to Host device through SPI Interface • LED control for LED D1 to indicate touch detection
To analyze touch data using QDebug interface, select Debug mode in project configuration settings.
4.1 User Application Code Implementation The Slave Select (SS) functionality is implemented using external pin change interrupt on GPIO PB4.
Host MCU periodically requests the slave for touch status by pulling the SS pin low. This will generate an external pin change interrupt. The firmware will update the touch status in SPI data register and enables SPI interrupt. Subsequently the host initiates the SPI data transfer to read the touch status. Host terminates SPI communication by pulling SS pin high. As soon as SS pin is pulled high, slave disables SPI interrupt and initiates touch acquisition process. The periodicity for touch acquisition will depend on how frequently the host MCU will request for touch status.
4.2 User Application Code Requirements 1. The touch acquisition periodic interval is set to 50ms using the macro QT_MEASUREMENT_PERIOD_MSEC
in touch_config.h file. This macro needs to be adjusted if the SPI communication interval is different than 50ms. The current_time_ms_touch variable is updated based on this interval that is needed for time-based library operations such as drift compensation. This information is passed to the library as an argument to the qt_measure_sensors() API.
2. After power-on reset the first touch acquisition takes around 150ms due to sensor calibration. The first SPI communication by host MCU after device power up should only be initiated after 150ms delay.
4.3 Application Code Flow
Figure 4-1. Application Code Flow.
Atmel AT03816: QMatrix Control Panel for In-Home Display [APPLICATION NOTE] 42179A−QTOUCH−09/2013
10
5. Schematic
Figure 5-1. Schematic.
x y
Key
1
x y
Key
4
x y
Key
5
x y
Key
6
x y
Key
2
x y
Key
3
x y
Key
7
X0
X1
X2
X3
Y0
10nFC4
1kR10
470k
R11
YB
YA
X4
X5
X6
X0X1
X2X3X4X5
X6
VDD
GND
GND
SCK
MISO
MOSI
YBYASM
PSS
SMP
1kR3
1kR4
1kR5
1kR6
1kR7
1kR8
PA2(RESET/dw)
19
PD0(RXD)
20
PD1(TXD)
1
PA1(XTAL2)
2
PA0(XTAL1)
3
PD2(XCK/INT0)
4
PD3(INT1)
5
PD4(T0)
6
PD5(OC0B/T1)
7
GND
8
VCC
18
(UCSK/SCL/PCINT7)PB7
17
(MISO/DO/PCINT6)PB6
16
(MOSI/DI/PCINT5)PB5
15
(OC1B/PCINT4)PB4
14
(OC1A/PCINT3)PB3
13
(OC0A/PCINT2)PB2
12
(AIN1/PCINT1)PB1
11
(AIN0/PCINT0)PB0
10
(ICP)PD6
9PP
21
U2
ATtiny4313-MU
100nF
C3
GND
GNDVOLTAGEREGULATOR
4µ7
C2
4µ7
C1
VIN
3VOUT
2
GND
1VOUT_PAD
4
LMS8117AMP-3.3
U1
VCC-3.3
VCC_5V
12
34
56
J6
RESET
MISO
SCK
MOSI
VDD GND
1kR9
GND
RESET
4.7K
R12
VDD
R13
1K
R14
1K
R15
MISO
SCK
MOSI
SS
VBUS
1
D-
2
D+
3
GND
5
SHIELD1
6
SHIELD2
7
ID4
SHIELD3
8
SHIELD4
9
U3
USBMiniB
VCC_5V
GND
21
TouchLED
D1
21
D0
PowerLED
1kR1
330R
R2
VCC
DBG_CLK
DBG_DATA
12
3
J3
VCC_5V
VCC-3.3
VCC
VCC
1 2 3
J4
12
J2
GND
VCC_5V
0RR16
0RR17
1 2 3 4
J1
DBG_CLK
DBG_DATA
12 J5
VCC
VDD
ISP
GND
TP1
J5Header
*********
Forpo
wer
consu
mption
measure
ment
J3Head
er
**********
ForUSBSu
pply:
***************
‐Con
nect
Pin2&
Pin3
Forvo
ltag
eregu
latorsupply:
***************************
‐Con
nect
Pin1&
Pin2
Forextern
alsup
ply:
*******************
‐Con
nect
Pin
2&Pin3
‐Pr
ovidepoweronJ2
header
‐Ope
njumpers
R16
,R17
J2Header
**********
Provisionto
connect
external
powersu
pply
1K
Atmel AT03816: QMatrix Control Panel for In-Home Display [APPLICATION NOTE] 42179A−QTOUCH−09/2013
11
6. PCB Layout
Figure 6-1. Top Layer.
Figure 6-2. Bottom Layer.
2 1
3 2 1
321
6
9
7
8
10
10
1 2 1 2
1 2
41 2 3
5 3 1
246
1
21
2 1
3 2 1
321
10
10
211 241 2 3
2 1
21
2 1
2
1
2 1
21
5 3 1
246
1
2
1
2
1
2
1
2
1
2
1
2
1 2
12
1 2
1
2
3
4
2
1
12
1 2
1
2
1
1
2
Atmel AT03816: QMatrix Control Panel for In-Home Display [APPLICATION NOTE] 42179A−QTOUCH−09/2013
12
7. Bill of Materials (BOM)
Table 7-1. BOM.
Description Designator Qty. Value
Ceramic capacitor, SMD 0603, X7R, 16V, ±10 % C1, C2 2 4µ7
Ceramic capacitor, SMD 0603, X7R, 50V, ±10 % C3 1 100nf
Ceramic capacitor, SMD 0603, X7R, 50V, ±10 % C4 1 10nf
LED, red, wave length = 575nm, SMD 0805, ±70° D0 1 Power LED
LED, green, wave length = 575nm, SMD 0805, ±70° D1 1 Touch LED
1x4 pin header, 2.54mm pitch, THM J1 1 SPI header
1x2 pin male SMT header (terminal strip), 2.54mm pitch 5.84mm height J2 1 2 pin header
1x2 pin male SMT header (terminal strip), 2.54mm pitch 5.84mm height J5 1 2 pin header
1x3 pin header, 2.54mm pitch, THM J3 1 3 pin header
1x3 pin header, 2.54mm pitch, THM J4 1 3 pin header
2x3 pin header, 2.54 mm pitch, THM J6 1 ISP header
Thick film resistor, SMD 0603, 1/10W, 1% R1, R3, R4, R5, R6, R7, R8, R9, R10, R13, R14, R15
12 1kΩ
Thick film resistor, SMD 0603, 1/10W, 1% R2 1 330Ω
Thick film resistor, SMD 0603, 1/10W, 1% R11 1 470kΩ
Thick film resistor, SMD 0603, 1/10W, 1% R12 1 4.7kΩ
Thick film resistor, SMD 0603, 1/10W, 1% R16, R17 2 0Ω
0.7mm PTH 1.27mm pad for test pin TP1 1 0.7mm PTH 1.27mm Pad
3.3V 1A low dropout linear regulator SOT223_4 U1 1 LMS8117AMP-3.3
AVR® 8-bit RISC MCU U2 1 ATtiny4313-MU
USB Mini-AB Connector, SMD U3 1 MUSB-05-F-AB-SM-A
Atmel AT03816: QMatrix Control Panel for In-Home Display [APPLICATION NOTE] 42179A−QTOUCH−09/2013
13
8. References 1. Atmel ATtiny4313 datasheet 2. Atmel AT02259: QTouch Schematic and Layout Checklist, application note 3. AVR319: Using the USI module for SPI communication on tinyAVR® and megaAVR® devices, application note 4. Atmel QTouch Library User Guide
http://www.atmel.com/Images/doc8246.pdf�http://www.atmel.com/Images/Atmel-42094-QTouch-Schematic-and-Layout-Checklist_Application-Note_AT02259.pdf�http://www.atmel.com/Images/doc2582.pdf�http://www.atmel.com/Images/doc2582.pdf�http://www.atmel.com/Images/doc2582.pdf�http://www.atmel.com/Images/doc2582.pdf�http://www.atmel.com/Images/doc2582.pdf�http://www.atmel.com/Images/doc8207.pdf�
Atmel AT03816: QMatrix Control Panel for In-Home Display [APPLICATION NOTE] 42179A−QTOUCH−09/2013
14
9. Revision History Doc. Rev. Date Comments
42179A 09/2013 Initial document release
Atmel Corporation 1600 Technology Drive San Jose, CA 95110 USA Tel: (+1)(408) 441-0311 Fax: (+1)(408) 487-2600 www.atmel.com
Atmel Asia Limited Unit 01-5 & 16, 19F BEA Tower, Millennium City 5 418 Kwun Tong Road Kwun Tong, Kowloon HONG KONG Tel: (+852) 2245-6100 Fax: (+852) 2722-1369
Atmel Munich GmbHBusiness Campus Parkring 4 D-85748 Garching b. Munich GERMANY Tel: (+49) 89-31970-0 Fax: (+49) 89-3194621
Atmel Japan G.K.16F Shin-Osaki Kangyo Building 1-6-4 Osaki, Shinagawa-ku Tokyo 141-0032 JAPAN Tel: (+81)(3) 6417-0300 Fax: (+81)(3) 6417-0370
© 2013 Atmel Corporation. All rights reserved. / Rev.: 42179A−QTOUCH−09/2013
Atmel®, Atmel logo and combinations thereof, AVR®, Enabling Unlimited Possibilities®, megaAVR®, QTouch®, 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.
http://www.atmel.com/�
1. Hardware1.1 QMatrix Sense Circuitry1.2 LEDs1.3 Communication Interface1.4 Power Supply1.4.1 USB Supply1.4.2 External Supply
1.5 ISP Interface1.6 GPIO Pin Mapping
2. Touch Data3. SPI Communication Interface4. Firmware4.1 User Application Code Implementation4.2 User Application Code Requirements4.3 Application Code Flow
5. Schematic6. PCB Layout7. Bill of Materials (BOM)8. References9. Revision History