Home
Atmel QTouch Library User Guide
Contents
1. Sampling capacitor SNSK PB1 Rs Microcontroller Used for touch licati application SS DC SNS 3 Select the Compiler after checking with the version of the compiler on the top of the table 4 Select the library file from the last two columns of the table based on the configuration that the user wants to use Atmel QTouch Library User Guide Page 34 Rev 8207C AT42 06 09 AIMEL 4 1 From last before column for ONLY KEYS configuration and 4 2 From last column for KEYS ROTORS SLIDERS configuration 5 Inthe touch_lib_api h provide values to the PORTS and DELAY CYLES depending on the need Ex define OT DELAY CYCLES 1 define QT SNS D define OT SNSK B Meaning that the user should provide the desired combination of the ports taken from step No 2 D and B in this case and measurement at 1 charge cycle time DELAY CYCLES can have values of 1 2 3 4 5 10 25 50 After selecting the library file the user links the library file with the main c application program file including the header file touch api h after editing it to include the code for the host application program 6 1 6 Memory requirements and Example Projects for each of the library When the user uses the channels across ports SNS and SNSK the memory requirements for the library are as follows Table 6 4 Memory requirements Library Maximum Maximum Example projects Data memory
2. ATMEL filter la 0 filter rl El filter i 1 channel signals il Channel signals i fiiter 1 0 filber i 1 7 2u ka The signal values processed by the Atmel Touch code library are now the mean of the last two actual signal values 3 4 5 2 Example 2 Averaging the Last Four Signal Values 1 Add a static variable in the main module filter for channel signals static uinti6 t filter QT_NUM_ CHANNELS 4 2 Add a filter function prototype to the main module example signal filtering function Static void filter data mean 4 void 3 When configuring the Atmel Touch library set the callback function pointer set callback function at filter callback filter data mean A 4 Add the filter function void filter data mean 4 void d CSR t i Shift previously stored channel signal data Store new channel signal data x Set library channel signal data mean of last 4 values E for 1 Ou 1 lt QT NUM CHANNELS i filter i 0 filter 1 1 filter i 1 filter 1 2 filter i 2 filter 1 3 filter i 3 channel signals il channel signals 1 filter i 0O filter i 1 filter i 2 filcer i l 3 7 4u Es The signal values processed by the Atmel QTouch Library are now the mean of the last four actual signal values Atmel QTouch Library User Guide Page 14 Rev 8207C AT42 06 09 AIMEL 3 4 5 3 Example 3 Using the Media
3. unsigned char PORTC struct First unsigned unsigned unsigned unsigned unsigned unsigned unsigned unsigned struct Elements 77 First unsigned unsigned unsigned unsigned unsigned unsigned unsigned unsigned a Elements seen char char char char char char char char seen char char char char char char char char Oy in main PORTC_BitoO PORTC_Bitl PORTC_Bit2 PORTC_Bit3 PORTC_Bit4 PORTC_Bit5 PORTC_Bit6 PORTC_B1t7 8 in main PORTC_PORTCO PORTC_PORTC1 PORTC_PORTC2 PORTC_PORTC3 PORTC_PORTC4 PORTC_PORTC5 PORTC_PORTC6 PORTC_Dummy 7 106 volatile A PORTE Atmel QTouch Library User Guide Bytes Bytes PRPRPERPRPRERB Bytes 7 disp 7 Cisp PRPRPRPRPRERP Ley a ATMEL disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp disp PRPRPRPRPRRE IUT I On LU NH disp disp disp disp disp disp disp disp Page 44 I OO UT NH I On LU GA NH Rev 8207C AT42 06 09 AMEL KT O Headquarters International Atmel Corporation Atmel Asia Atmel Europe Atmel Japan 2325 Orchard Parkway Unit 1 5 amp 16 19 F Le Krebs 9F Tonetsu Shinkawa Bldg San Jose CA 95131 BEA Tower Millennium 8 Rue Jean Pierre 1 24 8 Shinkawa USA City 5 Timbaud Chuo ku Tokyo 104 0033 Tel 1 408 441 0311 418 Kwun Tong Road BP 309 Ja
4. 21 libvig2_8qt_k r90 22 libvig2 8at krs r90 23 libvig3_8qt_k r90 24 libvig3 8at krs r90 25 libvig4_8qt_k r90 26 libvig4 8at krs r90 27 libv3g1 8at k r90 28 libv3g1 8at krs r90 29 libv3g2_8qt_k r90 30 libv3g2 8at krs r90 31 libv3g3_8qt_k r90 32 libv3g3_8qt_krs r90 33 libv3g4_8qt_k r90 34 libv3g4 8at krs r90 35 libv3g5_8qt_k r90 36 libv3g5_8qt_krs r90 37 libuc3a0128 16at k a 38 libuc3a0128 16at krs a 39 libuc3a0256 16at k a 40 libuc3a0256 16at krs a 41 libuc3a0512 16at k a 42 libuc3a0512 16at krs a 43 libxmi28ai gnu 8at k a 44 libxmi28ai gnu 8at krs a 45 libxm128al_iar_8qt_k r90 46 libxm128al_iar_8qt_krs r90 The library follows specific naming convention for all the configurations and devices supported The general naming convention would be as follows Atmel QTouch Library User Guide Page 28 Rev 8207C AT42 06 09 ATMEL 6 1 2 1 For the devices supported by the AVR GCC libvPgQ_8qt_R a Which specifies the library is generated for corevP Core number of Device group gQ of the AVR device for the 8 channel QTouch with the configuration R for sensors Here vP stands for versionP of core of AVR device to be used P can take values of 25 4 51 5 gQ stands for groupQ of core of AVR device to be used Q can take values of 1 2 and 3 only if P is 5 R stands for configuration based on users need R can take k if configuration is only keys krs if configuration is keys rotors sliders Alternativly specific devices are
5. The library disables interrupts for time critical periods during touch sensing These periods are generally only a few cycles long and so host application interrupts should remain responsive during touch sensing However any interrupt service routines ISRs during touch sensing should be as short as possible to avoid affecting the touch measurements or the application responsiveness As a rule of thumb the combined durations of any ISRs during a capacitive measurement should be less than 1 ms This can be tested during system development by checking the burst duration on the touch channels on an oscilloscope If the burst duration varies by more than 1 ms when the user is not touching any sensors then ISRs could adversely affect the measurements Please note that none of the API functions should be called from a user interrupt 3 3 Frequency of operation Vs Charge cycle dwell cycle times Table 3 1 Frequency of operatoion Frequency of MCU Cycle time Suitable Charge Cycle times or Microcontroller us Suitable Dwell Cycle times MHz us 1 10 cycles 0 25us to 2 5us 0 125 1 10 cycles 0 125us to 1 25us 2 25 cycles 0 2us to 2 5us 0 0625 2 25 cycles 0 125us to 1 5625us 3 50 cycles 0 15us to 2 5us 3 4 Sensor Measurements 3 4 1 Avoiding Cross talk In Atmel QTouch library variants that use QTouch adjacent sensors are not measured at the same time This prevents interference due to cross talk between adjacent chan
6. Category Factory Settings General Options Multi file Compilation g Assembler Custom Build Language Code Optimizations Output List Preprocessor D A Build Actions te ignore standard include directories TOOLKIT_DIRGSINC deet TOOLKIT_DIRSMNCACLIBS Debugger LOR Additional include directories one per line ICEZ JTAtSICE ITAGICE mkII Dragon Preinclude file Simulator RS Third Party Driver Defined symbols one per line Preprocessor output to file e DEBUG INTERFACE _ROTOR_SLIDER WINAVR GCC Go to Project configuration Options gt Custom Options gt Then Add the Directive D_DEBUG_INTERFACE_ in the space provided for the directives before building the project Atmel QTouch Library User Guide Page 26 Rev 8207C AT42 06 09 m t 32gm example Project Options E Lal Custom Compilation Options V All files Au all Femove Par main mg Z che adwart 2 Remove Include Linker Options Directories D_ROTOR_SLIDER_ a Us k funsigned char funsigned bithields pack struct Libraries Fshork enums de Memory Settings Edit Add External Tools Custom Options W Use WindVA avT gEC CAWinalvR 2009031 bin avr qcc ese make C AWin VR 2009031 3 utils binkmake exe Cancel Help 6 Library variants 6 1 QTouch Acquisition 6 1 1 Introduction Variants of the Atmel QTouch Library run on a range of Atmel chips This section lists the variants
7. Code required memory required GCC libavr25g91 8at k a 3982 avr25g1_8qt example libavr25g1_8qt_krs a 4042 12 8 libavr25g2_8qt_k a 12 3590 avr25g2_8qt_example 12 libavr25g2_8qt_krs a 4050 libavr4g1_8qt_k a 2902 avr4g1_8qt_example libavr4gl_8qt_krs a 4026 libavr4g2_8qt_k a 2910 avr4g2 Bot example libavr4g2_8qt_krs a 4034 libavr51g1_8qt_k a 2938 avr51g1_8qt_example libavr5lg1_8qt_krs a 4106 libavr51g2_8qt_k a 2938 avr5192 Bot example libavr51g2_8qt_krs a 4106 libavr5gl1_8qt_k a 2938 avr5g1 Bot example Atmel QTouch Library User Guide Page 35 Rev 8207C AT42 06 09 ATMEL TJ JS TI libavr5g2_8qt_k a 2930 avr592 Bot example libavr5g2_8qt_krs a 4098 libuc3a0256 16qt_ krs a 213 _10qt_ vig Bot example libvigi Bot k r90 1792 libvigi Bot krs r90 2922 libv1g2 8at k r90 1800 v1g2 Bot example libyig2 Sat krs r00 2930 libvig3_8qt_k r90 1770 v1g3_8qt_example libvig3_8qt_krs r90 2894 libvig4_8qt_k r90 1778 vig4 8gt example libvig4 Bot krs r90 2902 libv3g1_8qt_k r90 1830 v3g1 Bot example libv3g1_8qt_krs r90 2988 libv3g2_8qt_k r90 1822 v3g2_8qt_example libv3g2_8qt_krs r90 2980 libv3g3_8qt_k r90 1830 v3g3_8qt_example libv3g3_8qt_krs r90 141 2988 libv3gq4_8qt_k r90 1830 v3g4 Bot example libv3g4_8qt_krs r90 141 2988 libv3g5_8qt_k r90 1830 v3g5_8qt_example Atmel QTouch Library User Guide Page 36 Rev 8207C AT42 06 09 AIMEL libv3g5_8qt_krs r90 141 2988 libxm128al_
8. N unsigned char DDRC_Bit4 disp unsigned char DDRC Bit5 disp a unsigned char DDRC_Bit6 77 Gasp 7 unsigned char DDRC_Bit7 77 diop GE IK struct Elements 8 Bytes 1 First seen in burst_10_BC unsigned char DDRC_DDCO 1 disp 0 unsigned char DDRC DDCi 1 disp 1 Atmel QTouch Library User Guide Page 42 Rev 8207C AT42 06 09 unsigned unsigned unsigned unsigned unsigned unsigned b 3 char char char char char char Lo volatile A DDRC In module main union Elements First seen in main unsigned char DDRC struct Elements 1 First seen in main unsigned unsigned unsigned unsigned unsigned unsigned unsigned unsigned Fa struct Elements First unsigned unsigned unsigned unsigned unsigned unsigned unsigned unsigned b 3 char char char char char char char char seen char char char char char char char char DDRC_DDC2 Lt 7 disp 2 DDRC DDC3 L Ee 2 DDRC_DDC4 L 7 disp 4 DDRC_DDC5 l 7 Cisco 5 DDRC_DDC6 i 7 disp 6 DDRC_DDC7 t 7 disp 7 E 3 Bytes 1 oy Bytes 1 7 DDRC_Bit0O L 7 disp 0 DDRC_Bitl 1 7 disp 1 DDRC_Bit2 L 77 disp 2 DDRC Bit3 L 7 dispi 3 DDRC_Bit4 1 7 disp 4 DDRC_Bit5 1 7 dispose 5 DDRC_Bit6 1 7 disp 6 DDRC_Bit7 1 7 disp 7 8 Bytes 1 in main 7 DDRC_DDCO L f disp P DDRC_DDC1 L 7 disp 1 DDRC_DDC2 i ze diop 2 DDRC_DDC3 b 77 d
9. gt touch status sensor states bit O is set Similarly the rotor on channels 3 to 5 is sensor 1 and the keys on channels 6 and 7 are sensors 2 and 3 respectively However the code could be re arranged as follows enable rotor at enable rotor CHANNEL 3 CHANNEL 5 NO AKS GROUP 16 HYSI 6 25 RES 8 BIT 0 enable keys at enable key CHANNEL 6 AKS GROUP 2 10 HYST 6 25 at enable key CHANNEL 7 AKS GROUP 2 10 HYST 6 25 enable slider at enable slider CHANNEL 0 CHANNEL 2 NO AKS GROUP 16 HYST_6_25 RES 8 BIT 0 e 1 e 1 Now the rotor is sensor 0 the keys are sensors 1 and 2 and the slider is sensor 3 So the order in which the user enables the sensors is the order in which the sensors are numbered Depending on his requirement the user can enable the sensors configured to corresponding channels Inthe sensor deltas array the values reported are for each sensor not for each channel The order of the values reported depends on the order in which the sensors are enabled In the example above sensor deltas 07 would report the overall delta for the rotor on channels 3 to 5 sensor deltas 1 and sensor_deltas 2 would report the delta values for the two key sensors on channels 6 and 7 respectively and sensor_deltas 3 would report the overall delta for the slider on channels 0 to 2 Atmel QTouch Library User Guide Page 11 Rev 8207C AT42 06 09 ATMEL 3 2 Interrupts
10. listed like UC3A0512 and xm128a1 6 1 2 2 For devices supported by IAR EWAR libvPgQ_8qt_R r90 Which specifies the library is generated for corevP Core number of Device group gQ group of core number for AVR of the AVR device for the 8 channel QTouch with the configuration R for sensors Here vP stands for versionP of core of AVR device to be used P can take values of 1 and 3 gQ stands for groupQ of core of AVR device to be used Q can take values of 1 2 3 4 and 5 only if P is 3 R stands for configuration based on users need R can take k if configuration is only keys krs if configuration is keys rotors sliders Alternativly specific devices are listed like xm128a1 Atmel QTouch Library is based on QTouch technology and provides eight sensing channels These channels can be configured as keys rotors or sliders depending on the library variant Versions of the library are also available providing between one and fity cycle charge pulses 6 1 3 Compatibility with Compilers The QTouch Library is supported by following versions of compilers The user of the libraries is recommended to use the same versions for compatibility issues Table 6 1 Compilers supporting QTouch Library Tool Version IAR Compiler 5 20 3 Atmel QTouch Library User Guide Page 29 Rev 8207C AT42 06 09 ATMEL Embedded Workbench 5 20 IAR library builder 1 03R GCC AVRStudio 4 16 build 638 WinAVR 20090313 6 1 4 Appendix f
11. Atmel QTouch Library User Guide Rev 8207C AT42 06 09 ATMEL 1 Introduction The Atmel s QTouch Library provides support for both IAR and GCC compilers for capacitive keys rotors and sliders in Atmel firmware applications It is provided as a library file and C header file for linking with user code This guide explains the library operation and how it is used in firmware applications This guide should be read in conjunction with the following documents e Atmel s QTouch Library Overview e Atmel s QTouch Library Datasheet 2 Adding Touch Sensing to an Application 2 1 Introduction The Atmel QTouch Library is added to an application by linking in the library file including the library header file and calling the functions defined in the application programming interface API Figure 1 1 shows a typical configuration how the channels are configured to the microcontroller based on Atmel s touch technology QTouch and QMatrix in which the Atmel QTouch Library has been added to a host application running on an an Atmel AVR microcontroller The library supports eight touch channels numbered 0 to 7 Channels 0 to 2 have been configured as a rotor sensor channels 3 to 5 have been configured as a slider sensor and channels 6 and 7 are configured as key sensors The host application calls the library to configure these sensors and to make and process capacitive measurements Figure 2 1 Typical of interf
12. Eer NOT SUPPORTED NOT SUPPORTED GCC libuc3a0128 16gt k libuc3a0128 16at kr KEE AT32UC3A0256 GCC libuc3a0256_16qt_k libuc3a0256_16qt_kr ll KEE a AT32UC3A0512 ATxmegai28A1 A B C D E F IAR libxmi28ai iar 8dt libxm128a1l ar Hot k r90 krs r90 GCC libxm128al_gnu_8qt libxm128al_gnu_8qt k a krs a The libraries that are supported as listed in the table is only supported provided the device memory requirements are also satisfied For AT32UC3A devices IAR version 1 Charge Delay cycle is not supported 2 3 4 5 10 2 are supported For the GCC version 1 and 2 Charge Delay Cycles are not supported 3 4 5 25 50 are supported For ATxmega128A1 devices GCC version 1 2 3 Charge Delay Cycles are not supported 10 25 50 are supported For the IAR version 1 Charge Delay cycle is not supported 2 3 10 25 50 are supported A B A B a A B NOT SUPPORTED NOT SUPPORTED a libuc3a0512_16qt_k libuc3a0512_16qt_kr Sa 4 5 4 5 6 1 5 Table Usage Table 6 2 gives the various devices along with the libraries supported by both the IAR and GCC compilers along with the usage of different combinations of ports The user can refer the table as below 1 Select the device that needs to have the QTouch library on 2 Check the port availability for the selected device from appendix of libraries and select the combination of the ports based on the user application reguirement from the table below The user should be aware that t
13. L 2 NO AKS GROUP 16 HYST 6 25 RES 8 BIT 0 enable rotor at enable rotor CHANNEL 3 CHANNEL 5 NO _AKS GROUP 16 HYST 6 25 RES 8 BIT 0 J3 enable keys at enable key CHANNEL 6 AKS GROUP 2 10 HYST_6 25 at enable key CHANNEL 7 AKS GROUP 2 10 HYST_6 25 initialise touch sensing at init sensing configure timer ISR to fire regularly init _timer_isr enable interrupts enable interrupt loop forever for test flag is it time to measure touch if time to measure touch clear flag it s time to measure touch time to measure touch 0 measure touch sensors at measure sensors current time ms JI host application code goes here timer ISR fires every MEASUREMENT PERIOD MS void timer_isr void set flag it s time to measure touch time to measure touch lu update the current time current time ms MEASUREMENT PERIOD MS Atmel QTouch Library User Guide Page 24 Rev 8207C AT42 06 09 ATMEL 5 Touch Data Debug interface The user is provided with a main c file and a header file touch lib api h In main c file the user is provided with a default debug protocol which can be used for communication with the PC through the USB bridge The user can call the function report_debug_data void for using the debug protocol to send the debug data from the microcontroller to the AVR QTouch Studio Void
14. ROTORS SLIDERS configuration After selecting the library file the user links the library file with the main c application program file including the header file touch_api h after editing it to include the code for the host application program Atmel QTouch Library User Guide Page 38 Rev 8207C AT42 06 09 AIMEL 6 2 4 Schematics Figure 6 2 Schematics showing the configuration of QMairix circuit with ATMEL s AVR microcontroller Sensors X Y RXO 0 0 RYm CSO C m Typical values RX 1k RY 1k Port count Port requirements RYBO RYBm X generic I O pin YA generic I O pin YB ADC port SMP generic I O pin Vref AINO Comparator The port I O pin should be in consecutive order Table 6 7 Library I O configurations Line label 8 channel configuration 32 channel configuration not used in this configuration PORTB4 not used in this configuration PORTB5 Atmel QTouch Library User Guide Page 39 Rev 8207C AT42 06 09 ATMEL PORTCO PORTCO PORTD7 PORTD7 VREF PORTD6 PORTD6 Table 6 7 Channel configuration Atmel QTouch Library User Guide Page 40 Rev 8207C AT42 06 09 Channel 17 Channel 18 Channel 19 Channel 20 Channel 21 Channel 22 N A Channel 23 N A Channel 24 N A Channel 25 N A Channel 26 N A 6 2 5 Memory requirements and Example Projects for each of by the library Table 6 8 Memory requirements Library Maximum D
15. Unsigned Bitfields funsigned bitfields Frequency le MW Pack Structure Members fpack struct SEH Oe Ke DIS Son w Short Enums Lisbortenums w Create Hex File i Generate Map File W Generate List File Cancel Help Atmel QTouch Library User Guide Page 7 Rev 8207C AT42 06 09 ATMEL QTouch Then Add the Directive D ROTOR SLIDER_ in the space provided for the directives before building the project avralel Got example Project Options E a Custom Compilation Options d All files all Remove map atmegal 28 c gdwarf 2 Include Linker Options ld Directories Us ungigned char SH unsigned bithelds k pack struct Eshort enums D DEBUG_INTERFACE_ Libraries de Ve Se Ip ROTOR 5 LIDER Add 4 External Tools Custom Options W Use Wind awT QCC C AWinaWR 2009031 Jsbin awT gCC ee make C AWinaVR 2009031 3 utils binkmake exe UK Cancel Help 2 3 1 2 For ONLY KEYS configuration If the user wishes to use ONLY KEYS configuration then the user has to follow these steps IAR EWAVR Go to project options in IAR work bench gt C C compiler gt Preprocessor Tab Then remove the Directive ROTOR_SLIDER_ if exists in the space provided for the directives before building the project WINAVR GCC QMatrix Go to Project configuration Options gt General Options gt Select the type of configuration that the user wishes to use from the Drop down of Active conf
16. VR 20090313 Atmel QTouch Library User Guide Page 37 Rev 8207C AT42 06 09 Library to be used K Library to be used Krs ATtiny48 ie _8qm_dxx_k r90 libv1 8aqm dXX_ krs r90 e le SUPPORTED NOT SUPPORTED r90 libt88 8qm dXX k a libt88 8qm dXX panne f e WW ATmega48 libv1 8qm dXX _k r90 libv1i 8am dxx _krs r90 NOT SUPPORTED NOT SUPPORTED ATmega88 libv1 8qm dXX _k r90 libv1i 8am dXX _krs r90 libm88 8qm dXX _k a libm88 8qm dXX _krs a ATmega88 libv1i 32qm dXX libvi 32qm dXX Libmes _32qm dXX _k a libm88 32am dXX XX stands for the delays cycles XX 1 2 3 4 5 10 25 50 6 2 3 Table Usage The Table gives the various devices along with the libraries that were supported by both the IAR and GCC compilers along with the usage of different combinations of ports The user can refer the table as below 1 Select the device that needs to have the QMatrix touch library on 2 Select the library file from the last two columns of the table based on the configuration that the user wants to use 2 1 From last before column for ONLY KEYS configuration and 2 2 From last column for KEYS ROTORS SLIDERS configuration 3 Select the Compiler after checking with the version of the compiler on the top of the table 4 Select the library file from the last two columns of the table based on the configuration that the user wants to use 4 1 From last before column for ONLY KEYS configuration and 4 2 From last column for KEYS
17. a324PA A B C D GCC EC Got Tk a libv5g3_8qt_krs a use Atmega324P use Atmega324P when compiling when compiling Atmega325 ABCDEFG AR libvigs Sat k r90 f libv3g3 Bat krs T907 Amegas250P ABCDEFG Aimegas25P ABCDEFG DE BCD Atmel QTouch Library User Guide Page 31 Rev 8207C AT42 06 09 ATMEL pC libv593 8at k a libv5g3_8qt_krs a Atmega3290P A B C D E F G mal Atmega329P A B C D E F G ee ees Atmega32C1 B C D E Atmega32HVB A B C Atmega32M1 B C D E besen on EE mue 2 en Atmega32U4 B C D E F Atmega32U6 A B C D E F Atmega406 A B C D E TT ES EE Ee Atmega640 A B C D E F G _ Atmega644P A B C D ee e ee eee I Atmega645 A B C D E F G ni Atmega6450 A B C D E F G Atmega649 A B C D E F G Ae Atmega6490 A B C D E F G Aimega6AC SCDE E S l a Aimega64M SCDE seng ATPWM216 B C D E LM ATPWMSTE BODE een ee ee ee EE ATUSB646 A B C D E F ATUSB647 A B C D E F tr Atmega128A A B C D E F G GCC libv51gl1_8qt_k a libv51g1_8qt_krs a use Atmegal28 when use Atmegal28 when Atmega1280 A B C D E F G NE Atmega1281 A B C D E F G ee ree eee Atmega1284P A B C D Atmel QTouch Library User Guide Page 32 Rev 8207C AT42 06 09 AIMEL po CEL ibV51g2_8qt_k a libv51g2_8qt_krs a ATUSB1287 A B C D E F libv3g5_8qt_k r90 libv3g5_8qt_krs r90 libv51g2_8qt_k a libv51g2_8qt_krs a ATUSB1286 A B C D E F libv3g5_8qt_k r90 libv3g5_8qt_krs r90 libv51g2_8qt_k a libv51g2_8qt_krs a AT32UC3A0128 Tee ere
18. acing the Atmel s Touch library with the host application Atmel QTouch Library User Guide Page 2 Rev 8207C AT42 06 09 ATMEL a fe 4 e channel 0 channel 1 channel 2 channel 3 ica lt gt Be channel 4 ged channel 5 channel 6 channel 7 eo Ana y Q The Atmel QTouch Library only runs when called from the host application It uses no timers interrupts or other chip resources apart from ROM RAM some register variables and GPIO It only supports touch sensing the host application must provide any other functionality required such as reading switches driving LEDs communicating with other processors etc 2 2 Host Application Program Flow Adding Touch Sensing to an Application The general flowchart for use of the Atmel QTouch Library is shown in Figure 1 2 The steps are as follows The host application optionally calls qt_reset_sensing to reset all channels and touch sensing parameters to their default states This step is only required if the host wants to dynamically reconfigure the library at runtime The host application calls qt_enable_key at enable rotor and or gt enable slider as required to configure the touch sensors The host application calls gt init globals to intialize the global threshold parameters used by the library If the user wishes to change these threshold parameters he can edit the gt
19. ata Memory Maximum Code Example projects required memory required libt88 8qm_dXX_k a 3824 t88 8gm example libt88 8am dXX krs a 4599 t88 Bom example libm88 8am dXX k a 3188 m88 Som example libm88 8am dXX krs a 4607 m88 Bom example libm88 32am dXX k a 3609 m88 329gm example Atmel QTouch Library User Guide Page 41 Rev 8207C AT42 06 09 AIMEL libm88 32am dXX krs a 5040 m88 329gm example libvi 8am dXX k r90 2310 vi 8am example libvi 8am dXX krs r90 3548 vi Bom example Lil 32am dXX k r90 2357 vi 32am example libvi 32am dXX krs r90 3599 vi 32am example XX stands for the delays cycles XX 1 2 3 4 5 10 25 50 7 Known Issues 7 1 Linker warning 7 1 1 SFRB Warning The Library generates a linker warning with SFR register when some of the devices are used These warnings need to be ignored Warning w6 Type conflict for external entry A DDRC in module burst 10 BC against external entry in module main class struct union field base types do not match for field base class struct union field names do not match DDRC_DDC7 vs DDRC Dummy7 In module burst 10 BC union Elements 3 Bytes 1 First seen in burst 10 BC unsigned char DDRC Struct Elements 8 Bytes 1 First seen in main unsigned char DDRC_Bit0O unsigned char DDRC_Bitl unsigned char DDRC_Bit2 unsigned char DDRC_Bit3 disp disp JF eh eg 1 disp PRPRERPRPRPERE N A Oh Us GA it CH
20. available along with their resource usage and a note of any limitations on the chip operating conditions The library uses chip resources This has implications for the resources available to the host application The actual resource usage depends on the chip the library facilities the sensing technology and the number of sense channels In general a library needs some GPIO pins some code space in the chip flash some RAM for storing channel and sensor data some register variables and will have a minimum stack size requirement The library is linked into host applications running on Atmel chips The host application is subject to the chip operating conditions voltage temperature and so on listed in the datasheet for the device The following sections list any known restrictions on the operating conditions for touch sensing to work correctly Atmel QTouch Library User Guide Page 27 Rev 8207C AT42 06 09 AMEL 6 1 2 QTouch acquisition method library List of libraries included 1 libavr25g1 Got k a 2 libavr2591 Bot krs a 3 libavr25g2 8at k a 4 libavr25g2_8qt_krs a 5 libavr4gl1_8qt_k a 6 libavr4gl1_8qt_krs a 7 libavr4g2_8qt_k a 8 libavr4g2_8qt_krs a 9 libavr5lgl1_8qt_k a 10 libavr5lgl1_8qt_krs a 11 libavr51g2_8qt_k a 12 libavr51lg2 8qt_krs a 13 libavr5gl1_8qt_k a 14 libavr5gl1_8qt_krs a 15 libavr5g2_8qt_k a 16 libavr5g2 8at krs a 17 libavr5g3_8qt_k a 18 libavr5g3_8qt_krs a 19 libvigi 8qt_k r90 20 libvigl_8qt_krs r90
21. d 8 bit number setting a sensor detection threshold 4 3 2 Enumerations The API uses the enumerations listed in Table 3 3 Atmel QTouch Library User Guide Page 17 Rev 8207C AT42 06 09 ATMEL Table 4 3 Enumerations aa e wales nos SSS Sensor_t SENSOR_TYPE_UNASSIGNED Type of sensor that needs to be configured SENSOR TYPE KEY SENSOR TYPE ROTOR SENSOR TYPE SLIDER aks group t NO AKS GROUP Which AKS group if any a sensor is in AKS GROUP 1 AKS GROUP 2 AKS GROUP 3 AKS GROUP 4 AKS GROUP 5 AKS GROUP 6 AKS GROUP 7 NO AKS GROUP sensor is not in an AKS group and cannot be suppressed AKS GROUP x sensor is in AKS group x The channel s in a sensor channel_t CHANNEL 0 CHANNEL 1 CHANNEL 2 CHANNEL 3 CHANNEL 4 CHANNEL 5 CHANNEL 6 CHANNEL 7 Number of channels 1 recal threshold t resolution t Atmel QTouch Library User Guide HYST_50 HYST_25 HYST_12_5 HYST 6 25 RECAL 100 RECAL 50 RECAL 25 RECAL 12 5 RECAL 6 25 RES 1 BIT RES 2 BIT RES 3 BIT RES 4 BIT RES 5 BIT RES 6 BIT RES 7 BIT RES 8 BIT A sensor detection hysteresis value This is expressed as a percentage of the sensor detection threshold HYST_x hysteresis value is x percent of detection threshold value rounded down Note that a minimum value of 2 is used as a hard limit Example if detection threshold 20 then HYST_50 10 50 percent of 20 HYST_25 5 25 percent of 20 HYST_12_5 2 12 5 percent o
22. ed for time based library operations such as drifting The GPIO internal pull ups must be disabled when calling the library Setting the PUD bit in the MCUCR register does this The library must be called often enough to provide a reasonable response time to user touches During a call to the library functions the main host application code is not running There is thus a trade off between the processor time available to the host application the power usage of the system and the system responsiveness A sufficient stack size for both host application and the library The host application stack must be large enough for the library plus its own operation when calling library functions plus any enabled interrupts that may be serviced during a library function call The library stack requirements for different configurations are shown in Table 1 1 Table 2 1 Library stack requirements Configuration CSTACK size RSTACK size ONLY KEYS KEYS Din 8 Din e 0 2 3 1 Configuration selection Based on the requirement the user can select the configuration by editing the project options and thereby adding the pre processor directive ROTOR_SLIDER_ 2 3 1 1 For KEYS ROTORS SLIDERS configuration If the user wishes to use KEYS ROTORS SLIDERS configuration then the user has to follow these steps JAR EWAVR Go to project options in IAR work bench gt C C compiler gt Preprocessor Tab Atmel QTouch Library User Guide Page 5 R
23. ev 8207C AT42 06 09 ATMEL Then Add the Directive ROTOR_SLIDER_ in the space provided for the directives before building the project Options for node 301 6qt example Category General Options Assembler Custom Build Build Actions Linker Debugger CCF ICE 0 JTASICE JTAGICE mkII Dragon Simulator Third Party Driver WINAVR GCC Factory Settings Multi file Compilation E Language Code Optimizations Output List Preprocessor D 4 A ignore standard include directories TOOLKIT _DIRGSINC TOOLEIT_DIRSSINCCLIB Additional include directories one per line wem Hremchude file Defined symbols one per line Preprocessor output to file NDEBLIG E DTOUCH Ej DEBUG INTERFACE ROTOR SLIDER Go to Project configuration Options gt General Options gt Active Configuration QMatrix Select the type of configuration that the user wishes to use from the Drop down of Active configuration Tab Atmel QTouch Library User Guide Page 6 Rev 8207C AT42 06 09 m t 32gm example Project Options E Include Directories e Libraries p ge Memory Settings Custom Optio Active Configuration m88 _32qm_d1_krs Edit Configurations moo szgm di k Use External Mak pere m mag sqm did kr moo szam dek mee som d krs Output File Hame m88_32qm_example elt Output File Directory m88_32qm_d1_krs D Heese atmega88 i Unsigned Chars funsigned char i
24. f 20 HYST_6_25 2 6 25 percent of 20 1 but set to the hard limit of 2 A sensor recalibration threshold This is expressed as a percentage of the sensor detection threshold RECAL_x recalibration threshold is x percent of detection threshold value rounded down Note a minimum value of 4 is used Example if detection threshold 40 then RECAL_100 40 100 percent of 40 RECAL_50 20 50 percent of 40 RECAL_25 10 25 percent of 40 RECAL_12_5 5 12 5 percent of 40 RECAL 6 25 4 6 25 percent of 40 2 but value is limited to 4 For rotors and sliders the resolution of the reported angle or position RES_x_BIT rotor slider reports x bit values Example if slider resolution is RES_7_BIT then reported positions are in the range 0 127 Rev 8207C AT42 06 09 AIMEL 4 3 3 Structs The API uses the struct listed in Table 3 4 The global variable gt touch status of this type is declared and shows the current state of all enabled sensors Section 3 4 Table 4 4 Struct Field Type gt touch status t sensor states uint8_t The state on off of the library sensors Bit n state of sensor n 0 not in detect 1 in detect Rotor_slider_values uint16 t Rotor angles or slider positions These values are valid when sensor states shows that the corresponding rotor or slider sensor is in detect Board_info_t qt_max_num_rotors_sli uint8_t Maximum number of rotors and slider
25. he table below lists the complete combinations available but shrinks based on the device that should be supported Table 6 3 Port availability for touch sensing SNSK SNS A B C D E F G H A AA B AB C AC BC D AD BD CD E AD BE CE DE F AF BF CF DF EE G AG H Atmel QTouch Library User Guide Page 33 Rev 8207C AT42 06 09 Ae en JE Not supported SNSK PORT SNS PORT Supported combination of ports In case of the SNS C and SNK B on two different ports the user should mount the sensors onto the corresponding pins such as PCO PBO PC1 PB1 PC2 PB2 so on In this case channel 0 will be on PCO PBO pins channel 1 will be on PC1 PB1 pins and so on up to channel 7 will be on PC7 PB7 pins UC3 up to pin 15 In case of the SNS A and SNSK A on the same port the user should always have the configuration as PAO PA1 PA2 PA3 PA4 PA5 PA6 PA7 In this case channel 0 will be on PAO PA1 pins channel 1 will be on PA2 PA3 pins and so on up to channel 4 will be on PA6 PA7 pins For AVR and XMEGA devices only 4 channels are supported when using SNS and SNSK ports on the same port while 16 channels are supported on UC3 The sample schematic for using the port pins for SNS and SNSK looks similar to the one in figure 6 1 Figure 6 1 Schematic of mounting a channel using QTouch technology Rs Series Resistor Cs Sample capacitor PB1 PortB biti and PC1 PortC bit1
26. iar_8qt_k r90 1812 libxm128a1_iar__8qt_k_example libxm128al_iar_8qt_krs r90 3066 libxm128a1_iar__8qt_krs_example 6 2 QMatrix acquisition 6 2 1 Introduction Variants of the Atmel QTouch Library run on a range of Atmel chips This section lists the variants available along with their resource usage and a note of any limitations on the chip operating conditions The library uses chip resources This has implications for the resources available to the host application The actual resource usage depends on the chip the library facilities the sensing technology and the number of sense channels In general a library needs some GPIO pins some code space in the chip flash some RAM for storing channel and sensor data some register variables and will have a minimum stack size requirement The library is linked into host applications running on Atmel chips The host application is subject to the chip operating conditions voltage temperature and so on listed in the datasheet for the device The following sections list any known restrictions on the operating conditions for touch sensing to work correctly 6 2 2 Compatibility with Compilers The libraries are supported based on the following versions of compilers The user of the libraries is recommended to use the same versions for compatibility issues Table 6 5 Compilers supporting QTouch Library IAR Compiler 5 20 3 IAR library builder 1 03R GCC AVR Studio 4 16 build 638 WinA
27. iguration Tab Atmel QTouch Library User Guide Page 8 Rev 8207C AT42 06 09 m 32gm example Project Options Active Configuration m88 32gm dt k Edit Configurations mes szam di k mag szam di kre Use External Mak mee 32qm_d1 Ok mag sqm did kr moo szam dek moo sqm d2 kr Include Directories Output File Name m88_32qm_example elt ke Output File Directory m88 32gm d kk D Libraries esas atmega88 M Unsigned Chars funsigned char i Unsigned Bitfields funsigned bitfields m Frequency hz P f w Fack Structure Members fpack struct Optimization Us bd S M Short Enums fshort enums Memory Settings A ke Create Hex File W Generate Map File i Generate List File Custom Optio Cancel Help QTouch Go to Project configuration Options gt Custom Options gt Then remove the Directive D ROTOR_SLIDER_ in the space provided for the directives before building the project Atmel QTouch Library User Guide Page 9 Rev 8207C AT42 06 09 ATMEL avralgi Bot example Project Options Lal Custom Compilation Options VH All files se Kai main alimegal 28 c Include Linker Options Directories z Funsigned char em funsigned bitfislds pack struct Fshort enume Libraries DEBUG INTERFACE LA Memory Settings External Tools Custom Options w Use WindivA aVT QCC CAWindVR 2003031 SOIT avr qcc exe make C AWindVA 2009031 3 utils binkmake exe Cancel Hel
28. init globals and supply the parameters The host application calls qt_init_sensing to initialize the library Thereafter the host application regularly calls qt_measure_channels to make capacitive measurements After each call it can check the global variable gt touch status to see if any sensors are in detect and the angle or position of any enabled rotors or sliders Figure 2 2 Flowchart for Using the Atmel QTouch Library in a Host Application Atmel QTouch Library User Guide Page 3 Rev 8207C AT42 06 09 ATMEL qt_reset_sensing gt enable xxx gt init sensing gt init globals qt measure channels check at touch status Atmel QTouch Library User Guide Page 4 Rev 8207C AT42 06 09 ATMEL 2 3 Host Application Requirements The host application must meet certain criteria for touch sensing to work correctly One has to have the data sheet downloaded and ready before starting to use the main c and touch_api h file Check if the debug ports and pins used are valid for the selected device Check that the CLKPR register is available for the selected device If not remove the CLKPR statements MCUCR register is available and if so disable pullups Check if the timer registers and bitfields used are correct and change them if necessary t must track the current time This information is passed to the code library as an argument to the function qt_measure_sensors This is us
29. is function one or more sensors must have been enabled using the appropriate at enable xxx function and fat init sensing must have been called 4 8 6 ot calibrate sensing This function forces a recalibration of all enabled sensors This may be useful if for example it is desired to globally recalibrate all sensors on a change in application operating mode Void gt_calibrate_sensing void 4 8 7 qt_reset_sensing This function disables all sensors and resets all library variables for example gt di to their default values This may be useful if it is desired to dynamically reconfigure sensing After calling this function any required sensors must be re enabled and qt_init_sensing must be called before qt_measure_sensors is called again 4 8 8 gt get sensor delta sensor number This function returns the delta value for a given channel Atmel QTouch Library User Guide Page 23 Rev 8207C AT42 06 09 ATMEL int16 t at get sensor delta uint8 t sensor 4 9 Example Host Application The following code sample shows how a host application could configure and use the Atmel Touch Library flag set by timer ISR when it s time to measure touch static uint8 t time to measure touch Ou current time set by timer ISR uint16 t current time ms 0 void main void initialise host app pins watchdog etc init_system enable slider at enable slider CHANNEL 0 CHANNE
30. isp 3 DDRC_DDC4 1 7 disp 4 DDRC DDC5 1 disp 5 DDRC DDC6 1 disp 6 DDRC Dummy7 1 disp Lo volatile A DDRC Warning w6 burst 10 BC against external entry in module main class struct union field base types do not match for field base do not match In module burst_10 BC union Elements AIMEL class struct union PORTC PORIC vs PORTC Dummy 3 Bytes First seen in burst 10 BC unsigned char PORTC struct First unsigned unsigned unsigned unsigned unsigned unsigned Atmel QTouch Library User Guide Elements seen char char char char char char 8 in main PORTC_Bit0 PORTC_Bit1 PORTC Bit2 PORTC_Bit3 PORTC_Bit4 PORTC_Bit5 Bytes RR RREH L wi L ey disp disp disp disp disp disp Page 43 O B amp ND H e 1 Type conflict for external entry _A_PORTC in module Rev 8207C AT42 06 09 field names unsigned char PORIC Bit6 unsigned char PORTC_Bit7 ae struct First unsigned unsigned unsigned unsigned unsigned unsigned unsigned unsigned Fd Elements 8 1 1 Bytes seen in burst 10 BC char char char char char char char char PORTC PORICO PORTC PORTC PORTE PORTC2 PORTC PORTES PORTC_PORTC4 PORTE PORTES PORTC PORIC6 PORTE PORIC _ io volatile A PORTC In module main union Elements 4 3 First seen in main
31. last three actual signal values Atmel QTouch Library User Guide Page 16 Rev 8207C AT42 06 09 AIMEL 4 Application Programming Interface 4 1 Introduction This section defines the API that the Atmel QTouch Library offers to host applications This API is generic and the facilities offered by a particular version of the library are related to the capabilities of the device concerned Touch sensing can be configured globally to determine for example how quickly environmental changes are tracked Individual sensors can be configured to assign channels to them and set their touch sensing parameters Once touch sensing has started the host application can call the library to make touch measurements It can then read the touch status for example which keys are touched 4 2 Manifest Constants The API defines the manifest constants listed in Table 3 1 that document the library The library has been built using these values and they SHOULD NOT be changed Table 4 1 Manifest Constants Manifest Constant QT_NUM_CHANNELS The number of touch channels supported by the library QT_MAX_NUM_ROTORS_SLIDERS The maximum number of rotors or sliders supported by the library 4 3 Type Definitions 4 3 1 Typedefs The API defines the typedefs listed in Table 3 2 Table 4 2 Typedefs Typedef Notes An unsigned 8 bit number Uint16 t An unsigned 16 bit number Int16_t A signed 16 bit number Threshold_t An unsigne
32. n of the Last Three Signal Values 1 Add a static variable in the main module filter for channel signals static uinti6 t filter QT_NUM CHANNELS 3 2 Add filter function prototypes to the main module example signal filtering function Static void filter data median 3 void Static uint16 t median 3 uint16_t d0 uint16 t d1 uinti6 t d2 3 When configuring the Atmel Touch library set the callback function pointer set callback function at filter callback filter data median 3 4 Add the filter functions void filter data median 3 void d ints E i Shift previously stored channel signal data Store new channel signal data Set library channel signal data median of last 3 values e for i Ou i lt QT NUM CHANNELS i d filter i 0 filter 1 I1 filter i 1 filter i 2 filter i 2 channel signals il channel_signals i median 3 filter i 0 filter i 1 filter i 2 uint16 t median _3 uint16 t d0 uint16 t dl uint16 t d2 uinti6 t rtnval if d0 gt di d Ltt dai s d2 4 d rtnval d1 else if d0 gt d2 rtnval d2 else renval d0 else if di lt d2 d rtnval dl else if d0 lt d2 Atmel QTouch Library User Guide Page 15 Rev 8207C AT42 06 09 Ae rtnyal d2 rtnval d0 return rtnval The signal values processed by the Atmel QTouch Library are now the median of the
33. nction enables a key sensor Void at enable key channel t channel aks group t aks group threshold t detect threshold hysteresis t detect hysteresis The parameters are as follows channel which touch channel the key sensor uses aks_group which AKS group if any the sensor is in detect_threshold the sensor detection threshold detect_hysteresis the sensor detection hysteresis value The sensor number corresponding to the key depends on the order in which sensors are enabled The first sensor enabled is sensor 0 the second is sensor 1 and so on The current state of the key on or off can be checked in qt_touch_status sensor_states 4 7 3 ot enable rotor This function enables a rotor sensor Void ot enable rotor channel t from channel channel t to channel aks group t aks group threshold t detect threshold hysteresis t detect hysteresis resolution t angle resolution uint8 t angle hysteresis The parameters are as follows e from channel the first channel in the rotor sensor e Io channel the last channel in the rotor sensor e aks_group which AKS group if any the sensor is in detect_threshold the sensor detection threshold e detect_hysteresis the sensor detection hysteresis value e angle_resolution the resolution of the reported angle value e angle_hysteresis the hysteresis of the reported angle value The sensor number corresponding to the rotor depends on the order in which senso
34. nels but means that some sensor configurations take longer to measure than others For example if an 8 channel chip is configured to support 8 keys then the library will measure the keys on channels 0 2 4 and 6 simultaneously and then the keys on channels 1 3 5 and 7 If the same device is configured say to support 4 keys putting them either on all the odd channels or on all the even channels means that they can all be measured simultaneously This means the library calls are faster and the device can use less power So it is recommended that the channels are configured accordingly Atmel QTouch Library User Guide Page 12 Rev 8207C AT42 06 09 AIMEL 3 4 2 Multiple measurements The library will automatically perform multiple measurements on a sensor in certain conditions typically when sensors are calibrating filtering into detect or filtering out of detect Multiple measurements are performed to resolve these situations before returning to the host application This means that some calls to measure the sensors take longer than others 3 4 3 Measurement Limit In Atmel Touch library variants that use QTouch measurements on a channel are automatically stopped when they reach a value of 8192 pulses In this case a signal level of 1 will be reported for the channel This limit is long enough for practical uses of QTouch sensing and traps hardware fault conditions such as shorted out sampling capacitors 3 4 4 Linki
35. ng Library functions When building a host application library functions will only be linked in if they are actually called This means that code space can be saved in the host application if it does not call the optional functions qt_reset_sensing and qt_calibrate_sensing This may not always be possible 3 4 5 Filtering signal measurements The Atmel QTouch Library API contains a function pointer called at_filter_callback You can use this hook to apply filter functions to the measured signal values If the pointer is non NULL the library calls the function after it has made capacitive measurements but before it has processed them 3 4 5 1 Example 1 Averaging the Last Two Signal Values 1 Add a static variable in the main module filter for channel signals Static uint16 t filter OT NUM CHANNELS 2 2 Add a filter function prototype to the main module example signal filtering function static void filter data mean 2 void 3 When configuring the Atmel Touch library set the callback function pointer set callback function at filter callback filter data mean 2 4 Add the filter function void filter data mean 2 void d uint8 t 1 Shift previously stored channel signal data x Store new channel signal data Set library channel signal data mean of last 2 values FE for 1 Ou i lt QT NUM CHANNELS i Atmel QTouch Library User Guide Page 13 Rev 8207C AT42 06 09
36. nges to specifications and product 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 s products are not intended authorized or warranted for use as components in applications intended to support or sustain life 2009 Atmel Corporation All rights reserved Atmel Atmel logo and combinations thereof AVR AVR Studio and others are registered trademarks QTouch QMatrix and others are trademarks of Atmel Corporation or its subsidiaries Other terms and product names may be trademarks of others Rev 8207C AT42 06 09
37. nit_sensing and gt measure sensors functions there are two additional touch sensing commands available to the host application These are the qt_calibrate_sensing and qt_reset_sensing functions Atmel QTouch Library User Guide Page 22 Rev 8207C AT42 06 09 AIMEL 4 8 3 qt_init_globals This function initializes the global threshold parameters void qt_init_globals void The threshold parameters are globally available and to the user to configure them The user is provided with this function where he can change the values of the parameters according to the needs 4 8 4 gt init sensing This function initializes touch sensing Void at init sensing void Any sensors required must be enabled using the appropriate ot enable xxx function before calling this function This function calculates internal library variables and configures the touch channels and must be called before calling gt measure sensors 4 8 5 gt measure sensors This function performs a capacitive measurement on all enabled sensors The measured signals for each sensor are then processed to check for user touches releases changes in rotor angle changes in slider position etc void gt measure sensors uint16 t current time ms The parameter is as follows current time ms the current time in ms The current state of all enabled sensors is reported in the gt touch status struct Before calling th
38. or Libraries Table 6 2 QTouch acquisition method library Ports Library to be used K Library to be used Krs Supported Attiny43u A B ee a ee ee Attiny44 A B e oe Attiny45 i met l us Attiny461 A B aen hf Attiny84 A B M a es e Attiny85 bag Ee Attiny861 A B i E E Ee Attiny48 A B C D T e S Attiny88 A B C D D II e Atmega8515 A B C D E bes ee re S Atmega8535 ABCD ESSZ T MBS bec e NE Atmega8A B C D GCC libv4gl1_8qt_k a libv4gl1_8qt_krs a use Atmega8 when use Atmega8 when RimegaaeP BCD E ee eee Atmega88PA B C D GCC libv4g2_8qt_k a libv4g2_8qt_krs a use Atmega88P when use Atmega88P when Atmega8HVA A B C ete e ATPWM2 B C D E ee re eee ATPWM2B B C D E en LN S e Atmel QTouch Library User Guide Page 30 Rev 8207C AT42 06 09 ATMEL ATPWIME BCDE ATPWM3B BCDE Ser ABCDE F G Sege ABCDE Atmegat63 ABCDE Rimegat 63 ABCD Atmegai6A A B C D GCC EE Bat _ SS a libv5g2 Got krs a use Atmegal6 when use Atmegal6 when compileing compileing Atmega323 A B C D libv3g2_8qt_k r90 libv3g2_8qt_krs r90 libv5g2_8qt_k a libv5g2_8qt_krs a DEE AECH GCC EE Bat Ce a libv5g2 8at krs a use Atmega32 when use Atmega32 when compiling compiling ATCAN32 ABCDE ATCAN64 ABCDE a Atmega164P A B C D Atmega165P A ODE Atmega168PA B S D GCC EE Bat E7 a libv5g3_8qt_krs a use Atmegal68P use Atmegal68P when compiling when compiling Atmega169P ODE Atmega16HVA ABC Atmega16U4 B C D E Atmeg
39. p 2 4 Example Host Application The Atmel QTouch Library evaluation kit includes a complete example host application This comprises an IAR project or AVR Studio GCC project in which a supplied library and header file are linked into an example application The kit evaluation board is supplied pre programmed with this application Each version of the library is provided with the example host application project file in binary to help the user start up with the touch library These example project files can be found from the library variant section described later in this document Atmel QTouch Library User Guide Page 10 Rev 8207C AT42 06 09 AIMEL 3 Using the Atmel s QTouch Library 3 1 Sensing Channels 3 1 1 Disabled Channels All sensing channels are disabled by default The host application can use unused sensing pins as GPIO 3 1 2 Sensor Order Sensors are numbered in the order in which they are enabled For example consider this code fragment ZE enable slider at enable slider CHANNEL 0 CHANNEL 2 NO AKS GROUP 16 HYST_6_25 RES 8 BIT 0 enable rotor at enable rotor CHANNEL 3 CHANNEL 5 NO_AKS GROUP 16 HYSI 6 25 RES 8 BIT 0 enable keys at enable key CHANNEL 6 AKS GROUP 2 10 HYST 6 25 at enable key CHANNEL 7 AKS GROUP 2 10 HYST 6 25 In this code the slider on channels 0 to 2 will be sensor O as it is the first enabled sensor The slider is in detect if
40. pan Fax 1 408 487 2600 K T et 78054 Saint Quentin en Tel 81 3 3523 3551 EE Yvelines Cedex Fax 81 3 3523 7581 rong hong France de Tel 33 1 30 60 70 00 Fax 852 2722 1369 Fax 33 1 30 60 71 11 Product Contact Web Site Technical Support Sales Contact http www atmel com avr atmel com www atmel com contacts Literature Request www atmel com literature 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 ATMEL S TERMS AND CONDITIONS OF SALE LOCATED ON ATMEL S WEB SITE 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 OF 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 cha
41. report_debug_data void This function bit bangs the data available from the library through the USB bridge to tool called Hawkeye which can be analyzed The data send by this debug function include board info t which captures the information related to the board used Type of board used 0 if TS2080A and 1 if TS2080B list will be expanded when new kits are released Maximum number of rotors and sliders that the library supports The user can change the id for the board according to the need by changing the values in the structure Channel_signals The signal data related to each channel Channel_reference The reference data related to each channel Sensor_deltas The difference when the sensor is detected Qt_touch_status The states of each sensor configured Sensor_config debug information related to each sensor However based on the user s requirement the same data can be transferred through the debug protocol that the user wishes to use For using the default touch data debug interface the user has to enable the directive _DEBUG_INTERFACE_ in the project configuration options as below IAR EWAVR Go to project options in IAR work bench gt C C compiler gt Preprocessor Tab Then Add the Directive DEBUG_INTERFACE_ in the space provided for the directives before building the project Atmel QTouch Library User Guide Page 25 Rev 8207C AT42 06 09 AIMEL Options for node y3e1_qt_examnple
42. rs are enabled The first sensor enabled is sensor 0 the second is sensor 1 and so on The current state of the rotor on or off can be checked in qt_touch_status sensor_states The rotor value is in qt_touch_status rotor_slider_values Which array element is used depends on the order in which sensors are enabled the first rotor or slider enabled will use rotor_slider_values O the second will use rotor_slider_values 1 and so on The reported rotor value is valid when the rotor is on 4 7 4 qt enable slider This function enables a slider sensor Void at enable slider channel t from channel Atmel QTouch Library User Guide Page 21 Rev 8207C AT42 06 09 ATMEL channel t to channel aks group t aks group threshold t detect threshold hysteresis t detect hysteresis resolution t position resolution uint8 t position hysteresis The parameters are as follows i from_channel the first channel in the slider sensor li to_channel the last channel in the slider sensor lil aks_group which AKS group if any the sensor is in IV detect_threshold the sensor detection threshold v detect hysteresis the sensor detection hysteresis value vi position_resolution the resolution of the reported position value Vii position_hysteresis the hysteresis of the reported position value The sensor number corresponding to the slider depends on the order in which sensors are enabled The first sen
43. s and sent as debug information gt touch lib config data t gt recal threshold Sensor detect integration DI limit Default uint8_t value 4 qt_di uint8_t Sensor drift hold time in units of 200 ms Default value 20 20 x 200 ms 45 that is hold off drifting for 4 seconds after leaving detect gt drift hold time uint8_t Sensor maximum on duration in units of 200 ms For example 150 recalibrate after 30s 150 x 200 ms 0 recalibration disabled Default value O recalibration disabled Sensor negative drift rate in units of 200 ms Default value 20 20 x 200 ms 4s per LSB gt neg drift rate Sensor positive drift rate in units of 200 ms Default value 5 5 x 200 ms 1s per LSB qt_pos_drift_rate recal_thre Sensor recalibration threshold Default shold_t RECAL_50 recalibration threshold 50 percent of detection threshold gt touch lib measure data t channel_signals uint16 t The measured signal on each channel Channel references uint16 t The reference signal for each channel Ot touch status qt_touch_ The sensor states as described above in this status t table 4 4 Per channel Touch Sensing Configuration In library variants based on the QMatrix technology the data array listed in Table 4 5 is available to the host application Atmel QTouch Library User Guide Page 19 Rev 8207C AT42 06 09 AIMEL Table 4 5 Struct qt_burst_length uint16_t The burst length on each QMatrix channel in units of pul
44. ses Default value 64 pulses 4 5 Touch Sensing Data The data arrays listed in Table 3 8 are available within the API These are useful during system development to check that touch sensing is operating as expected Table 4 6 Touch Sensing Data Arrays channel signals uint16 t EE measured signal on each channel Channel references uint16 t The reference signal for each channel The delta value for a given sensor may be obtaing by calling at get sensor delta sensor number 4 6 Hook For User Functions The function pointer ot filter callback is provided as a hook for user supplied filter functions This function is called after the library has made capacitive measurements but before it has processed them The user can use this hook to apply filter functions to filter the measured signal values according to his needs By default the pointer is NULL and no function is called 4 7 Configuring Sensors The functions listed in Table 3 9 are used to assign channels to sensors and to configure the sensor parameters 4 7 1 Configuration Functions The functions listed in Table 3 9 are used to assign channels to sensors and to configure the sensor parameters Table 4 7 Functions gt enable key Enable a key sensor Ot enable rotor Enable a rotor sensor Ot enable slider Enable a slider sensor Atmel QTouch Library User Guide Page 20 Rev 8207C AT42 06 09 AIMEL 4 7 2 ot enable key This fu
45. sor enabled is sensor 0 the second is sensor 1 and so on The current state of the slider on or off can be checked in fgt touch status sensor states The slider value is in qt_touch_status rotor_slider_values Which array element is used depends on the order in which sensors are enabled the first rotor or slider enabled will use rotor_slider_values O the second will use rotor_slider_values 1 and so on The reported slider value is valid when the slider is on 4 8 Measuring and Checking the Touch Status 4 8 1 Touch Status Functions Once all required channels have been configured as keys rotors or sliders touch sensing is initialized by calling the function qt_init_sensing see Section 3 10 3 The host application can then perform a touch measurement by calling the function at measure sensors See Section 3 10 4 passing in as a parameter the current time in milliseconds The library uses this information for timed events such as calculating how long a sensor has been in detect After calling qt_measure_sensors the host application can check the state of the enabled sensors by reading the qt_touch_status variable see Section 3 4 on page 3 3 The host application should call qt_measure_sensors on a regular basis so that any user touches are promptly detected and any environmental changes are drifted out 4 8 2 Additional Sensing Commands In addition to the qt_i
Download Pdf Manuals
Related Search
Related Contents
"user manual" Manual del usuario EA121AL([上カップ付]スプレーガン)取扱説明書 - 作業中 Wiley Adobe Creative Suite 4 Design Premium Digital Classroom, (Book and Video Training) DW311 Sierra Reciproca VV Serra Sabre VS MANUAL DE GC64 電池式デジタル圧力計 Warnung! - Falkenjagd Arat NS1295 holder SERVICE MANUAL SL Series Servo User`s Manual, GFK-1581B Copyright © All rights reserved.
Failed to retrieve file