Freescale Semiconductor Reference Manual RDTOUCHEFRM Rev 1.0, 2/2006 Touch Panel System Using MC34940/MC33794 E-Field Sensors Reference Manual Developed by: Oscar Camacho Miguel Agnesi Diego Garay Brad Stewart This document contains information on a new product. Specifications and information herein are subject to change without notice. © Freescale Semiconductor, Inc., 2006. All rights reserved. PREFACE This Reference Manual provides all the design guidelines and considerations when designing a touch panel application using E-field sensors, which include the MC34940 and the MC33794. The manual also includes the installation and setup instructions for the Touch Panel System using MC33794 E-Field Sensor, MC68HC908QB8 Embedded MCU and the MC33993 Multiple Switch Detection Interface. It describes how to easily program the embedded MCU and the basic hardware configurations to start the demo. Even though this demo was designed with the Mc33794, all the principles used in this design also apply when using the MC34940. When replacing the MC33794 with the MC34940 in this reference design, be cautious of: • Different pinout • 7 electrodes instead of 11 • 3 MUX select lines (A,B,C) instead of 4 (A, B, C, D) AUDIENCE This document is intended for application developers who are setting up Freescale’s RDMC33794/MC34940 Reference Design. SUGGESTED READING • Additional documentation may be found at www.freescale.com • Design Reference manual. • Application note, AN1985: Touch Panel Applications using The E-field IC CONVENTIONS This document uses the following conventions: : Term or Value Definition Examples Terminal Names Terminal names are the physical connections and are shown in text as all upper case. ... the external supply voltage VSUP1. Terminal Values Terminal values are the currents to/from a terminal and are shown as upper and subscripted text. In Stop Mode the voltage regulator still supplies the MCU with VDD Decimal Values No special symbol attached to the number 1.0 34 Numbers Considered positive unless specifically noted as a negative value 5.0 -10 Blue Text Linkable on-line ... refer to Table 1, page 2 Touch Panel System, Rev. 1.0 2 Freescale Semiconductor Table of Contents Paragraph Number Page Number Chapter 1 Touch Panel System using the MC33794/MC34940 E-field Sensor 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 1.12 1.13 1.14 Designer Reference Manual ............................................................................................1 Introduction and Setup ....................................................................................................1 Introduction ......................................................................................................................1 Analyzer Board (Key Features) .......................................................................................2 E-field solution advantages .............................................................................................4 1.5.1 Touch panel basics................................................................................................4 Demonstrating Firmware .................................................................................................5 Setup Instruction User Guide ..........................................................................................5 On Board Test Points ......................................................................................................6 Downloading software to Demo .......................................................................................7 Operational Description ...................................................................................................7 1.10.1 Introduction ............................................................................................................7 1.10.2 Analyzer Board Electrical characteristics...............................................................7 1.10.3 Jumpers and Switches description .......................................................................8 1.10.4 MON08 Connector.................................................................................................8 1.10.5 TPB Connector ......................................................................................................9 1.10.6 Power supply .........................................................................................................9 1.10.7 Charge Pump.........................................................................................................9 1.10.8 E-field Sensor (MC33794/MC34940).....................................................................9 1.10.9 Op-amp................................................................................................................ 10 1.10.10Multiple Switch Detection Interface MC33993 (MC33993)................................. 10 Touch Panel Board ........................................................................................................10 1.11.1 AB connector ....................................................................................................... 10 1.11.2 TPB Electrodes Distribution................................................................................. 11 1.11.3 Block Diagram ..................................................................................................... 12 Schematics .................................................................................................................... 13 1.12.1 Analyzer Board Schematics................................................................................. 13 Hardware Design Considerations .................................................................................. 15 1.13.1 Analyzer Board .................................................................................................... 15 1.13.1.1 Introduction........................................................................................... 15 1.13.1.2 Op-Amp ................................................................................................ 15 1.13.1.3 Power Supply ....................................................................................... 16 1.13.1.4 Multiple Switch Detection Interface ...................................................... 16 1.13.1.5 E-field Sensor ....................................................................................... 17 1.13.1.6 Charge Pump Circuitry ......................................................................... 18 1.13.1.7 Buzzer (piezoelectric horn) Circuitry..................................................... 19 1.13.1.8 Serial Communication .......................................................................... 19 1.13.1.9 Micro Controller Programming and Debugging Circuitry ...................... 19 Touch Panel Board ........................................................................................................20 1.14.1 Introduction .......................................................................................................... 20 Touch Panel System, Rev. 1.0 Freescale Semiconductor TOC-1 Table of Contents 1.15 1.16 1.17 1.18 1.14.1.1 Pads Design ......................................................................................... 20 1.14.1.2 Single Pads ..........................................................................................21 1.14.1.3 Multiplexed Pads .................................................................................. 21 1.14.1.4 Continuous Pads .................................................................................. 21 PCB Considerations ...................................................................................................... 22 1.15.1 Electrode Size...................................................................................................... 22 1.15.2 Routing ................................................................................................................ 22 1.15.3 Grounding ............................................................................................................ 23 1.15.4 Shield................................................................................................................... 23 Mechanical Considerations ........................................................................................... 24 1.16.1 Glass.................................................................................................................... 24 1.16.2 TPB connector ..................................................................................................... 24 1.16.3 Other Considerations........................................................................................... 24 Software Design Considerations ...................................................................................25 1.17.1 Firmware Functional Description ......................................................................... 26 Flow Diagrams ...............................................................................................................30 Appendix A Bill of Materials .................................................................................................. 41 Touch Panel System, Rev. 1.0 TOC-2 Freescale Semiconductor List of Figures Figure Number Page Number Figure 1-1. Touch Panel System concept ...............................................................................2 Figure 1-2. MC33794/MC34940 Analyzer Board features ......................................................3 Figure 1-3. Touch Panel Board ...............................................................................................4 Figure 1-4. Touch Panel Basics ..............................................................................................5 Figure 1-5. Default jumpers setup ...........................................................................................6 Figure 1-6. Touch Panel Board electrodes distribution ......................................................... 11 Figure 1-7. Touch Panel System block diagram ................................................................... 12 Figure 1-8. Schematics .........................................................................................................13 Figure 1-9. Schematics Continued ........................................................................................ 14 Figure 1-10. Op-Amp Circuitry ................................................................................................ 15 Figure 1-11. E-field sensor output LEVEL and its amplified version LEVEL_AMP ................. 15 Figure 1-12. Power Supply Circuitry ....................................................................................... 16 Figure 1-13. MC33993's SPx and SGx terminals internal diagram .........................................16 Figure 1-14. MC33993 driving LED's circuitry ......................................................................... 17 Figure 1-15. MC33794/MC34940 Circuitry ............................................................................. 18 Figure 1-16. Charge pump circuitry ......................................................................................... 18 Figure 1-17. Buzzer circuitry ................................................................................................... 19 Figure 1-18. Serial communication circuitry ............................................................................19 Figure 1-19. MCU debugging and programming circuitry .......................................................20 Figure 1-20. Single Electrodes concept .................................................................................. 21 Figure 1-21. Multiplexed Electrodes Concept ......................................................................... 21 Figure 1-22. Continuous Pads concept ...................................................................................22 Figure 1-23. Electrical grounding considerations .................................................................... 23 Figure 1-24. GND terminal within AB board; running on batteries effect ................................ 23 Figure 1-25. Touch panel board mechanical considerations .................................................. 24 Figure 1-26. Main Program Flow ............................................................................................. 30 Figure 1-27. Initialization Ports ................................................................................................ 31 Figure 1-28. Calibrate Electrodes ........................................................................................... 32 Figure 1-29. Read Values ....................................................................................................... 33 Figure 1-30. Read Electrode ................................................................................................... 34 Figure 1-31. Verify Electrodes .................................................................................................35 Figure 1-32. Verify Keys .......................................................................................................... 36 Figure 1-33. Verify Mux Keys .................................................................................................. 37 Touch Panel System, Rev. 1.0 Freescale Semiconductor LOF-1 List of Figures Figure 1-34. Display Data ....................................................................................................... 38 Figure 1-35. Display ................................................................................................................ 39 Figure 1-36. Bar Graph ........................................................................................................... 40 Touch Panel System, Rev. 1.0 LOF-2 Freescale Semiconductor List of Tables Table Number Page Number Table 1-1. Default jumpers configuration ...............................................................................6 Table 1-2. Test points description ..........................................................................................6 Table 1-3. AB Electrical Characteristics .................................................................................7 Table 1-4. Analyzer Board jumpers and switches description ...............................................8 Table 1-5. MONO8 Interface to MC68HC908QB8 .................................................................8 Table 1-6. TPB connector terminal-out ..................................................................................9 Table 1-7. TPB to AB connector terminal-out ...................................................................... 10 Table A-1. Bill of Materials ................................................................................................... 41 Touch Panel System, Rev. 1.0 Freescale Semiconductor LOT-1 List of Tables Touch Panel System, Rev. 1.0 LOT-2 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor Chapter 1 Touch Panel System using the MC33794/MC34940 E-field Sensor 1.1 Designer Reference Manual This printed copy may be out of date. To verify you have the latest information available please refer to http://www.freescale.com for the most current revision. 1.2 Introduction and Setup 1.3 Introduction The Touch Panel System (TPS) is a development platform for the MC33794/MC34940/MC34940 E-field sensor and MC68H908QB8 low cost 8-bit micro controller: • MC33794/MC34940 can detect electric field variations in up to 9 electrodes and transform these variations into an analog signal. This signal can be interfaced directly with a 5V micro controller A/D module. Based on this E-Field sensor, this reference design detects human presence through glass or other dielectric materials. • Uses Freescale’s MC33993 for cost effectiveness. • MC33993 is also called a multiple switch detection interface and can drive 22 outputs using its configurable internal current sources. • Communicates directly with the MCU using a 4 wire SPI communication with no external components required. • User interface consists of an audio transducer (piezoelectric horn), two seven segments displays and six general purpose LED’s. The MC33993 device is used to drive both displays and the 6 LED’s directly. • Serial communication interface (SCI) is used for communication between the MCU and the PC and programs the micro controller using the serial bootloader software. • Platform works with an external power supply or 9V battery. • TPS is an enhanced version of KIT33794DWEVM. In addition to a battery operation option, user feedback is improved through 6 LED’s, two seven segment displays and an audio transducer. The main MCU is upgraded to a MC68H908QB8 micro controller which has a 10 bit resolution ADC, SPI and ESCI modules on chip. • TPS consists of two boards: the Analyzer Board (AB) and the Touch Panel Board (TPB). The Analyzer Board (AB) includes the E-field sensor, the micro controller, the MC33993, LED’s, serial port, displays and all hardware required for the application. In essence, the Analyzer Board (AB) is responsible for processing data and control of the application. • Second board is the Touch Panel board, which consists of the electrodes and a 15 terminal SMD connector to Analyzer Board. • Analyzer Board was designed with flexibility in mind allowing several different boards to be connected to it. This allows different Touch Panel Board configurations to be substituted easily through the SMD connector. • Demonstration software provides the electrode selection (multiplexing E-field inputs), output reading, calibration routines and user feedback control when a pressed condition is detected. Touch Panel System, Rev 1.0 Freescale Semiconductor 1 Touch Panel System using the MC33794/MC34940 E-field Sensor Figure 1-1 below shows the TPS concept. The populated board is called the Analyzer Board (AB) while the electrodes board is called the Touch Panel Board (TPB). Analyzer Board Touch Panel Board Figure 1-1. Touch Panel System concept 1.4 Analyzer Board (Key Features) The Analyzer board is a general-purpose board composed by a MC68HC908QB8 low cost micro controller, a MC33794/MC34940 E-field sensor, a multiple switch detection interface (MC33993) and various other peripherals. The features of this development tool are: • 10V power supply using integrated voltage doubler (charge pump) • MC33993 Multiple switch detection interface • MC68H908QB8 low-cost, low-terminal micro controller • DPDT Monitor mode/User mode selection switch • MON08 connector for debug and programming • Op-amp with amplitude and offset adjustment • One audio-transducer (piezoelectric horn) • Serial port (ESCI hardware module) • Two seven-segments displays • Jack for External power supply • MC33794/MC34940 E-field sensor • SPST ON/OFF switch • 15-terminal AB connector • 5V Power supply • 9v Battery holder • Six LED’s Touch Panel System, Rev 1.0 2 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor ON/OFF switch Battery Holder External Supply Jack Op-amp Electrodes board Connector Offset Adjustment Amplitude E-field Sensor Adjustment MC33993 Buzzer Serial Port MON08 Connector MC68H908QB8 MCU LED’s 7 segments displays Figure 1-2. MC33794/MC34940 Analyzer Board features Touch Panel System, Rev 1.0 Freescale Semiconductor 3 Touch Panel System using the MC33794/MC34940 E-field Sensor Touch Panel Connector (bottom side) Single Single Slider Bar Pads Multiplexed Multiplexed Multiplexed Slider Bar Pads Slider Bar Figure 1-3. Touch Panel Board 1.5 E-field solution advantages Advantages when using E-field sensor in touch panel applications compared to other solutions: • Lower cost since a single chip might control a wide range of pads depending on multiplexing • A wide range of objects and materials can be detected (people, metallic, non metallic, etc.) • No switches or mechanical parts to wear out or corrode • Physical wear and chemicals exposure protection • Lower power consumption • 3-D position determination • Higher temperature range • Reliable solution 1.5.1 Touch panel basics The following points give an introduction to the basic principle of detecting human presence in a touch panel application. Almost anything conductive can be part of an electric field sensor by being one of the capacitor plates. An electric dipole field created between an oscillating transmit electrode and virtual ground receiver electrode is intercepted by a hand. The hand can be modeled as a capacitor to a “virtual ground”. In this case, the human finger is the grounded capacitor plate while Touch panel electrode forms the other capacitor plate. Touch Panel System, Rev 1.0 4 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor Figure 1-4. Touch Panel Basics Recommended electrode size should be close to the size of a finger. The bigger the plate’s area and the lower the distance between them, the higher the sensitivity. The size of the electrode should correspond to the size of the object operating the panel. The area of the electrodes should be made as large as possible within this constraint. The number of possible touchpads can be increased by multiplexing electrodes. Potentiometers and slider bars can be simulated by changing the contact area within the electrode. For more information about multiplexing and continuous electrodes, See “Continuous Pads” on page 21. 1.6 Demonstrating Firmware The demonstration firmware performs three tasks: 1. Reads electrode values. 2. Sends values to the SCI interface. 3. Display electrode changes in LED’s and buzzer interfaces. 1.7 Setup Instruction User Guide The following steps provide a basic procedure to run firmware within the Touch Panel System. 1. Unpack Touch Panel Board (TPB) 2. Unpack Analyzer Board (AB) 3. Connect the AB with the TPB using the 15-terminal connector “JP2” and the TPB connector. 4. Configure AB jumpers The configuration jumpers in the analyzer board are JP1 and JP3. JP1 selects if the input to Micro controller’s AD channel is fed directly from the MC33794/MC34940 output terminal (LEVEL) or if the output signal is first amplified by the on-board op-amp with offset and amplitude adjustments. JP3 selects between two values of LP_CAP, 10nF and 1nF, the recommended value in the datasheet is 10nF. Touch Panel System, Rev 1.0 Freescale Semiconductor 5 Touch Panel System using the MC33794/MC34940 E-field Sensor The default jumper configuration is shown in Table 1-1 and Figure 1-5. Table 1-1. default jumpers configuration JP1 Position 1-2 (10nF) JP3 Position 1-2 (Non-amp LEVEL) JP1 1-2 JP3 1-2 Figure 1-5. Default jumpers setup 5. Power On AB • To power the AB make sure the battery or the external power supply does not exceed 15V • Place a common 9 volt battery on the battery holder with the appropriate polarity, • Or connect +9V center positive on the jack for external power supply. • Move “S1” to the “ON” position. NOTE: In order to avoid short circuit condition when connecting battery and external supply at the same time, the external power supply jack will disconnect the battery VCC terminal. 6. Configure User mode/MON08 Switch When running the loaded program in the demo, the USER/MON08 switch “S2” should be on the USER position; USER mode is also used when programming the micro controller using the serial bootloader tool. MON08 position of “S2” is used to program or debug the MC68H908QB8 using a MON08 programming pod. 1.8 On Board Test Points The Analyzer Board includes test points of the main signals. The purpose of these test points is for both testing the electrical performance of the board and to easily access the main signals involved in the application. Table 1-2 shows a description of the signals that can be observed in the test points. Table 1-2. Test points description Test point number Signal name Description TP1 GND System Ground, electrical reference test point. TP2 +5V 5V power supply output. TP3 +9V External power supply or battery voltage. After ON/OFF switch and reverse battery protection stages. Touch Panel System, Rev 1.0 6 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor 1.9 TP4 Offset DC signal entering Op-amp non-inverter inputs. Output of potentiometer R8. TP5 Level MC33794/MC34940’s output. Check Figure 1-9. TP6 PWR_IN Charge pump output, 10 volts typically measured TP7 Amp_Level Amplifier stage output, MC33794/MC34940’s output with adjustment in offset and amplitude. Check Figure 1-9 and Figure 1-1 Downloading software to Demo To download the firmware using the bootloader tool: 1. Make sure all the required programs are available in the programmer PC. You must have the *. S19 file to be downloaded into the MCU, software used for serial communications (i.e. TeraTerm), and the required bootloader already programmed into the demo board MCU. 2. Open and configure serial communications software (i.e. TeraTerm), setting serial port baud rate at 9600 bps, 8 bit, no parity, 1 stop bit and flow control set to none. Make sure the transmit delay is set to 3ms/char and 3ms/line in order to ensure a proper communication. 3. Make sure demo board jumpers are configured as desired and that the USER/MONO8 switch is set to USER. 4. Turn on the demo board while holding the SW1_IRQ button pressed, a “(p)rogram (w)ipe e(x)it” message should appear into the terminal screen. 5. Press “w” to wipe any data already loaded into the MCU flash. Note: this operation does not erase the bootloader code. 6. Press “p” and a “waiting…” message will appear. Use the terminal’s “Send File” option to send the.S19 file, a progress dialog will show up. 7. After code download the “(p)rogram (w)ipe e(x)it” message will appear again. Press “x” and the downloaded code will start running. 8. Each time the demo board is turned on without pressing the sw1_irq button at the same time the user code will be run directly. To download the firmware using a MONO8 pod: 1. Make sure the USER/MONO8 switch is set to MONO8 position. 2. Hook the MONO8 adapter into the X1 connector. Make sure the connector terminal alignment is correct to avoid any MCU damage. 3. Using CodeWarrior download the code to the demo board. Since this operation will erase the bootloader, make sure the interrupt vectors are located on the standard interrupt vector area. 4. Unplug the MONO8 connector and set the switch to USER position. 1.10 Operational Description 1.10.1 Introduction This section describes the electrical characteristics, user interfaces and connections for the Touch Panel System using E-field Sensors (TPS). 1.10.2 Analyzer Board Electrical characteristics Table 1-3. AB Electrical Characteristics Inputs/outputs Min Type Max Unit 7.2 9 15 V Board current consumption - 43 - mA Charge pump output voltage (PWR_IN) - 10 - V 0.6 - 5.1 V Input voltage (battery and external power supply) Op-amp output Touch Panel System, Rev 1.0 Freescale Semiconductor 7 Touch Panel System using the MC33794/MC34940 E-field Sensor 1.10.3 Jumpers and Switches description Table 1-4. Analyzer Board jumpers and switches description Jumper name Functional description JP1 • Position 1-2: Connects micro controller A/D input channel 3 to E-field output “LEVEL” directly. • Position 2-3: connects micro controller A/D input channel 3 to the Op-amp output. Op-amp adjusts gain and offset of “LEVEL” (E-field output). • Other: NOT valid JP3 • Position 1-2: E-field LPF filter capacitor = 10nF. • Position 2-3: E-field LPF filter capacitor = 1nF. • Other: NOT valid S1 • OFF: Power supply or battery is disconnected internally to all modules. • ON: Power up all AB modules S2 • USER: Microprocessor in user mode, firmware running. Also used when programming using serial bootloader. • MON08: microprocessor is ready to be programmed using the MON08 connector. 1.10.4 MON08 Connector MON08 Connector is a 16 terminal (8x2) male header, used for programming and debugging using the Multilink MON08 interface. The MON08 terminal header terminals are connected directly to some specific MCU terminals; those specific terminals are used by the micro controller to enter monitor mode and allow the flash programming and debugging modes. On the MC68HC908QB8 the MON08 connector follows the configuration shown in Table 1-5. Table 1-5. MONO8 Interface to MC68HC908QB8 MON08 terminal number MC68H908QB8 terminal number MC68HC908QB8 terminal description 1 NC - 2 16 VSS/GND 3 NC - 4 NC - 5 NC - 6 9 IRQ/PTA2 7 NC - 8 13 PTA0 9 NC - 10 5 PTA4 11 NC - 12 12 PTA1 13 4 PTA5/OSC1 14 NC - 15 1 VDD 16 NC - Touch Panel System, Rev 1.0 8 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor 1.10.5 TPB Connector The external connector JP2 is a 15x1 male terminal connector that extends electrodes terminals (E1-E9), Ref_A, Ref_B and Shield from the E-field sensor out the board. This connector is called TPB connector, since it is compatible with the 15 terminals female connector in the TPB. Table 1-6. TPB connector terminal-out terminal# Description terminal# Description terminal# Description 1 GND 6 E3 11 E8 2 SHIELD 7 E4 12 E9 3 SHIELD 8 E5 13 REF_A 4 E1 9 E6 14 REF_B 5 E2 10 E7 15 GND 1.10.6 Power supply There are two ways to power up the board; using a 9V battery or using a center positive 9V external power supply through the P1 jack. When a 9V external power supply is used to power up the analyzer board, the battery holder is disconnected from the board to avoid a short circuit condition. 1.10.7 Charge Pump The MC33794/MC34940 E-field sensor has a minimum requirement of 9.0V on Vpwr terminal. When using a 9V battery or an external power supply, fluctuations on the input voltage might make Vpwr voltage go out of specification. An Integrated switched capacitor voltage converter, LM2767, is used to ensure VPWR terminal 1 has the required 9V. The LM2767 converts power from the regulated 5V power supply (MC7805) to a 10V power supply. If the 9V external supply or battery goes down, the E-field sensor will work correctly as soon as the minimum input voltage requirements of MC7805 are met. NOTE: VPWR is the power supply of the analog portion of MC33794/MC34940 1.10.8 E-field Sensor (MC33794/MC34940) Freescale Semiconductor’s MC33794/MC34940 is intended for applications where non-contact sensing of objects is desired. When connected to external electrodes, an electric field is created. The main features of MC33794/MC34940 include: • Shield Driver for Driving Remote Electrodes Through Coaxial Cables • High-Purity Sine Wave Generator Tunable with External Resistor • Critical Internal Nodes Scaled and Selectable for Measurement • Support for up to 9 Electrodes and 2 References • +5.0 V Regulator to Power External Circuit • Watchdog and Power-ON Reset Timer • ISO-9141 Physical Layer Interface • Lamp Driver Output E1 through E9 are the E-field terminals designated for electrode placement. These terminals are responsible for detecting changes in the surrounding electric field. When a specific electrode channel is selected, all other unselected electrodes are grounded by an internal switch. REF_A and REF_B are used as electrodes as well; Unlike E1 through E9, these terminals are not grounded when not selected. These terminals allow known capacitors to be measured. By using capacitors at the low and high end of the expected range, absolute values for the capacitance on the electrodes can be computed. In this specific application, no absolute capacitance measurement is required; so REF_A and REF_B are used as electrodes as well. Communication with the MCU is done via A, B, C, D and LEVEL terminals; A, B, C and D are 5V logic terminals that select the specific electrode while LEVEL terminal, analog output, outputs a DC value proportional to the electric field present in the electrode. Touch Panel System, Rev 1.0 Freescale Semiconductor 9 Touch Panel System using the MC33794/MC34940 E-field Sensor Other features of MC33794/MC34940, such as the ISO-9141 physical layer interface, the lamp driver, watchdog reset and Power-on time are not used in this application. 1.10.9 Op-amp Depending on glass thickness, dielectric material or the specific application, the output voltage of the E-field sensor might require software algorithms or higher A/D resolution. Based on the above, the Touch panel system using E-field Sensors (TPS) incorporates a low cost op-amp, TS972, in order to provide amplification and offset to the LEVEL signal before entering MCU A/D channel. An additional explanation of the op-amp configuration used can be found “Hardware Design Considerations” on page 15. 1.10.10 Multiple Switch Detection Interface MC33993 (MC33993) LED’s are connected directly to SGx and SPx terminals (no external resistors are needed), configuring the wetting current, either on SG and SP terminals. A certain amount of current to the LED’s (16mA or 2mA) is injected and consequently they are turned On. To turn LED’s On/OFF the MC33993’s (MC33993) tri-state command is used. 1.11 Touch Panel Board The Touch Panel Board (TPB) is a passive board that ties directly to some of the MC33794/MC34940 E-field sensor terminals. A 4mm glass covering the electrodes is used as the touch pad. The TPB includes different kinds of pads using E-field electrodes for experimentation. The design of these electrodes is described in, “Hardware Design Considerations” on page 15. 1.11.1 AB connector Table 1-7 shows AB connector JP2 terminal-out. AB connector is a 15x1 female terminal header that connects TPB with AB. Table 1-7. TPB to AB connector terminal-out terminal# Description terminal# Description terminal# Description 1 GND 6 E3 11 E8 2 SHIELD 7 E4 12 E9 3 SHIELD 8 E5 13 REF_A 4 E1 9 E6 14 REF_B 5 E2 10 E7 15 GND Touch Panel System, Rev 1.0 10 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor 1.11.2 TPB Electrodes Distribution Figure 1-6 shows the electrode layout within the Touch panel board (TPB). TPB to AB connector 15 1 E7 E1 E2 E3 E4 E5 E6 E8 E9 Ref Ref A Ref B E1 E2 E3 E4 E5 E6 E3 E4 E2 E6 E4 E3 E6 E2 E1 E3 E5 E3 E 8 E1 E1 E4 E2 E 9 Figure 1-6. Touch Panel Board electrodes distribution Touch Panel System, Rev 1.0 Freescale Semiconductor 11 Touch Panel System using the MC33794/MC34940 E-field Sensor 1.11.3 Block Diagram This section shows the block diagram of the Touch Panel System. Battery (9V) On/Off Switch +5V Voltage Doubler 5V regulator 4 External supply (9V) DB9 V BAT Electrode Select MC68HC908QB8 “ Nitron” MCU MAX232 MC33794 E-Field Sensor Level SPI V BAT +5V DC Amp MONO8 DebugPort MC33993 MSDI Buzzer 7 segments Displays Gain Offset Adj. Adj. LED’ s 11 Electrodes TPB Connector REFA, REFB SHIELD Figure 1-7. Touch Panel System block diagram The main blocks are shown in Figure 1-7, orange blocks correspond to Freescale Semiconductor devices. A more detailed description is performed in “Hardware Design Considerations” on page 15. Touch Panel System, Rev 1.0 12 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor 1.12 Schematics MC68HC908QB8 MC33794 1.12.1 Analyzer Board Schematics Figure 1-8. Schematics Touch Panel System, Rev 1.0 Freescale Semiconductor 13 SQ-32WB MC33993 LM358 LM358 Touch Panel System using the MC33794/MC34940 E-field Sensor Figure 1-9. Schematics Continued Touch Panel System, Rev 1.0 14 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor 1.13 Hardware Design Considerations 1.13.1 Analyzer Board 1.13.1.1 Introduction The Analyzer Board uses the E-field sensor, the MC68HC908QB8 MCU, MC33993, audio transducer, serial port, etc. This section gives a quick explanation of each hardware block. 1.13.1.2 Op-Amp The Analyzer Board includes an amplifier with offset and gain adjustment. The reason for this amplifier is to provide higher sensitivity to the signal read by the MCU ADC converter. The amplifier circuit enables the user to zoom in the voltage range of interest and consequently achieve higher electrode reading changes for easier detection. Op-Amp provides offset adjustment and gain adjustment; offset adjustment is done by the potentiometer R8 while gain adjustment is by potentiometer R7. Figure 1-10. Op-Amp Circuitry The amplifier follows the configuration of an inverter amplifier (IC1A). The gain adjustment (Av) goes from 1 to 11, while the offset adjustment goes from 0.1V to 4.89V. A unitary gain inverter (IC1B) is added after the first stage to reestablish signal polarity. R2 and D3 are added at the op-amp output to protect MCU AD channel from voltages higher than 5.1V. Sometimes the output signal cannot be amplified as high as the op-amp allows due to its intrinsic characteristics. The multiplexed signal varies over time and amplitude; these variations are dependent on the switching speed of the A, B, C and D signals and on the electrodes construction itself. Figure 1-11 shows an oscilloscope graph of the “Level” and “Amp Level” test points in the Analyzer Board after adjusting op-amp offset and amplitude. It can be observed that the signal is periodic due to the constant reading of the different electrodes; the voltage steps observed are proportional to the electric-field detected on each electrode. LEVEL 1.0 V/div LEVEL_AMP 1.0 V/div Figure 1-11. E-field sensor output LEVEL and its amplified version LEVEL_AMP Touch Panel System, Rev 1.0 Freescale Semiconductor 15 Touch Panel System using the MC33794/MC34940 E-field Sensor Op-amp power supply is a derivation of +9V after a Low-pass filtering used for DC coupling. 1.13.1.3 Power Supply The board has two power supply sources, the +9V battery and external power supply. A charge pump after the +5V terminal generates the 10 volts input for the E-field sensor. When the external jack is connected, the negative terminal of the battery holder is disconnected to prevent a short circuit. +5V is used to power up the micro controller and RS232 transceiver when in USER mode. It is also the logic power supply VDD of MC33993, the piezo-electric buzzer and most of the 5V requiring circuitry. The non-regulated +9V signal is used to power up op-amp and MC33993 power side. For extra information about the charge pump, See “Charge Pump Circuitry” on page 18. Figure 1-12. Power Supply Circuitry 1.13.1.4 Multiple Switch Detection Interface The MC33993 Multiple Switch Detection Interface is designed to detect the closing and opening of up to 22 switch contacts. The switch status, either open or closed, is transferred to the microprocessor unit (MCU) through a serial peripheral interface (SPI); whenever a switch changes state, the micro controller is automatically alerted. The multiple switch detection interface (MC33993) was specially designed for automotive applications, nevertheless its features allows it to be used on aircraft, industrial control, process control, security systems and on critical systems requiring switching status verification for safety or control purposes. In this application we use the internal configurable current sources (2mA or 16mA depending on the programmed wetting current) to drive LED’s. The MC33993 communicates with MCU using just 4 wires SPI (3 wires if no feedback from the MC33993 is required). Using the MC33993 to drive LED’s have several advantages since just few MCU wires are used. Board space is reduced, no external polarization resistances are needed and current consumption and LED’s brightening can be changed configuring the wetting current. Figure 1-13. MC33993's SPx and SGx terminals internal diagram Touch Panel System, Rev 1.0 16 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor Figure 1-14 shows the connection of the two 7 segments displays, and the general purpose LED’s. Three SPI wires are used in the application (SI, SCK and CSB), SO is not used since we are just configuring MC33993 (sending commands through Slave input terminal) without feedback or status reading. MC33993 is supplied by +5V for the logic side and unregulated +9V which is the internal voltage of the SGx and SPx terminals. MC33993 S0-32WB Figure 1-14. MC33993 driving LED's circuitry 1.13.1.5 E-field Sensor The MC33794/MC34940 E-field sensor generates internally a 120Khz sine wave signal in an AC array to measure capacitance variations on each of the electrode channels. REFA and REFB terminals are used as electrodes terminals, as total 11 channels; REFA and REFB terminals can be individually selected to measure a known capacitance value. Unlike E1-E9, these two inputs are not grounded when not selected. LP_CAP terminal requires an external capacitor which is used within a low pass filtering stage to condition the output signal. This terminal can be used to determine the detected level before amplification or offset is applied. A 10 nF capacitor (recommended value) connected to this terminal will smooth the rectified signal and more capacitance will increase the response time. By changing the position of JP3 two different capacitors can be selected; if JP3 is on position 1-2, LP_CAP will have a 10nF capacitor and by moving jumper JP3 to the 2-3 position the selected LP_CAP value is 1nF. MC33794/MC34940’s supply terminal (PWR_IN) is connected to the charge pump output, Charge pump assures a minimum 10V supply to the E-field sensor keeping the chip on its specified operational range regardless variations of the system power supply. Other features like the lamp driver or the ISO-9141 transceiver available on MC33794/MC34940 are not used in this application. E1 through E9, REFA, REFB, GND and Shield terminals are tied to the external connector JP2, which is a standard 15x1 terminal connector for attaching Touch panel board or any other customized electrodes board. Touch Panel System, Rev 1.0 Freescale Semiconductor 17 Touch Panel System using the MC33794/MC34940 E-field Sensor Figure 1-15 shows the basic connections of the MC33794/MC34940 E-field sensor within the application. Figure 1-15. MC33794/MC34940 Circuitry 1.13.1.6 Charge Pump Circuitry As mentioned in MC33794/MC34940 documentation, VPWR should be higher than 9V. In this case the Touch Panel System using E-field sensors is supplied either for an external power supply or a 9V battery. Fluctuations on this input voltage or simply low battery conditions may result in malfunction of MC33794/MC34940. The charge pump produces 10V to assure a proper supply to the device. The charge pump is based on National Semiconductor’s LM2767. This IC doubles the 5V regulated signal having 10V nominal voltage at Vout (Pwr_in signal to MC33794/MC34940). Figure 1-16. Charge pump circuitry Touch Panel System, Rev 1.0 18 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor 1.13.1.7 Buzzer (piezoelectric horn) Circuitry The buzzer is controlled directly by a GPIO terminal of the microprocessor (PTB2), an NPN transistor is used as buffer switching ON/OFF. Figure 1-17. Buzzer circuitry 1.13.1.8 Serial Communication In case it is necessary to share data with the PC or for programming flash using serial bootloader tool, serial communication interface (SCI) is included in the system. Serial communication uses the ESCI module of the MC68H908QB8 micro controller, a RS232 transceiver and a DB9 connector. Figure 1-18. Serial communication circuitry NOTE: Communication is allowed only in USER mode. 1.13.1.9 Micro Controller Programming and Debugging Circuitry The system is based on a MC68HC908QB8, 8-bit, low cost micro controller. MCU selects each specific E-field channel, reads the output of the E-field sensor, and decides whether a touch or no-touch condition is present on each specific channel. It also sends commands to the MC33993 to drive the LED’s, toggle ON/OFF buzzer, and perform serial communication. The micro controller can be programmed using interface MON08 with the 16 terminals connector within Monitor mode or using serial bootloader tool in User mode. Selection between USER mode and MONITOR mode can be performed by switch “S2”. MC68HC908QB8 is used at 5V, no external crystal or oscillator is required running with internal oscillator. Touch Panel System, Rev 1.0 Freescale Semiconductor 19 Touch Panel System using the MC33794/MC34940 E-field Sensor Figure 1-19 shows connection between MCU and the MON08 debug and programming interface. Figure 1-19. MCU debugging and programming circuitry 1.14 Touch Panel Board 1.14.1 Introduction The Touch Panel Board has no components except for a 15x1 female terminal connector that attaches to the Analyzer Board. The TPB is just a simple double sized PCB with cooper traces. This section describes most of the considerations when designing electrodes for applications with MC33794/MC34940 and particularly the design of the touch pads. 1.14.1.1 Pads Design The TPB uses tree types of pads: single, multiplexed and continuous pads. Each one of these types is described in this section. Touch Panel System, Rev 1.0 20 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor 1.14.1.2 Single Pads Single Pads are designed using one E-field electrode channel per pad. This design is very simple and limits the touch panel to 11 pads (E1, E2…, E9, REFA and REFB). E1 E2 E3 E4 … Figure 1-20. Single Electrodes concept 1.14.1.3 Multiplexed Pads Multiplexed pads are formed by forming combinations of two or more electrodes per pad; this system is analogous to a matrix key pad where the number of touch pads can be increased using just a few electrodes terminals. E1 E2 E3 E4 … Figure 1-21. Multiplexed Electrodes Concept For example, using two electrodes per pad, E1 and E2 form a touch pad, E1 and E3 form other pad, as well E1 and E4, and then the same with all other electrodes combinations, this way, a total of 57 pads using the 9 electrodes and 2 references can be archived. Using “N” Electrodes per touch pad and “E” Electrode channels on the IC, the number of possible unique touch pads is given by: E ! + N N ! ( E − N )! The advantage of multiplexing electrodes is clear: the number of pads using a single E-field sensor can be highly increased. The major disadvantage is when multiplexing electrodes per pad, the area of the capacitor formed by each electrode is reduced and consequently reducing sensitivity. 1.14.1.4 Continuous Pads Continuous electrodes can be designed either Single or multiplexed; the main characteristic of this kind of pad is that the value of the capacitance read is different depending on where specifically the electrodes are touched. The idea is to create a change in the DC value read as a finger is moved within the pad. Slider bars are used like slide potentiometers. Figure 1-21 shows an example of continuous electrodes in both modalities: multiplexed and single. Touch Panel System, Rev 1.0 Freescale Semiconductor 21 Touch Panel System using the MC33794/MC34940 E-field Sensor Multiplexed Continuous pad Single Continuous pad Figure 1-22. Continuous Pads concept 1.15 PCB Considerations 1.15.1 Electrode Size When designing the electrodes for any application, one must take into account the physical size of the conductive electrode. The larger the electrode, the more range and higher sensitivity will be obtained. However, as the electrode size is increased, so is its susceptibility to interference, electrical noise, and “stray” electric-field paths in its surroundings. One of the key practices regarding electrode design is for the electrode’s area to correspond to the surface area of the object being detected. Touchpad applications, for example, would only require a size that suits the surface area of a finger. The size of the electrode should correspond to the size of the object operating the panel, such as a finger. The area of the electrodes should be made as large as possible within this constraint. 1.15.2 Routing The electrodes of a touchpad can be formed directly on Printed Circuit Boards (PCB) using copper circuit traces. When routing pads to electrode terminals, each trace must be the same distance from the others and routed following a star configuration. Following this recommendation output of the different channels is almost the same and reduces capacitive loading. Touch Panel System, Rev 1.0 22 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor 1.15.3 Grounding The hand can be modeled as a capacitor to a “virtual ground”, being the first plate of the capacitor. The E-field electrode or touch pad is the second plate. The dielectric material is the glass or acrylic between the two plates. Figure 1-23. electrical grounding considerations When a finger approaches the touch pad, it has to be referenced to the same E-field ground in order to find a return pad to the E-field sensor. When running with external power supply most of the time this reference is intrinsic since external power supply is physically grounded, as well as human body in contact with a physical ground. When running on external batteries this “reference” must be set externally since the battery is not physically grounded. It is recommended to reference the human body to the same Ground potential of the board. Analyzer board includes a GND terminal on the left upper corner as shown in Figure 1-24, GND terminal might be touched with left hand while the touch pads are used with the right one. GND terminal Note: Should be touched when running on batteries. Figure 1-24. GND terminal within AB board; running on batteries effect 1.15.4 Shield Shield terminal within the e-field sensor provides a buffered version of the returned AC signal from the electrode. Since it has nearly the same amplitude and phase as the electrode signal, there is little or no potential difference between the two signals thereby canceling out any electric field. Touch Panel System, Rev 1.0 Freescale Semiconductor 23 Touch Panel System using the MC33794/MC34940 E-field Sensor In touch pads applications “Shield” is used to drive a ground plane that is used behind the touch sensors electrodes at the backside layer of PCB, to cancel out any virtual grounds that could attenuate the AC signal. Typical application is to connect the Shield Drive to the shield of a coaxial cable used to connect an electrode to the corresponding electrode terminal. With correct shielding, coaxial cables or PCB layers can be used to connect remote electrodes up to a few meters away, while obtaining measurements as accurately as if the electrodes were directly connected to the IC. 1.16 Mechanical Considerations 1.16.1 Glass Touch panel system using E-field sensors (TPS) was tested with common glass as the dielectric; using the system without amplifier an accurate detection through a 4mm glass was obtained. Using the amplifier with approximately a gain of two and a proper offset adjustment the detection was through approximately 10mm. Glass is mounted over the PCB with the copper pads, the dimensions of the glass are shown in Figure 1-25. For testing purposes, the glass was patched with the PCB using a thin double sided tape. In the final application, the mechanical designers should determinate the best way to mount the dielectric with the electrode pads. The gap between glass and dielectric material and the PCB should be as constant as possible, even after a touch condition. Many times, when the panel is touched, variations in other electrodes or noise in the measurement can be presented if the gap is not constant. Minor changes in the gap between the plates of the capacitor will represent a considerable change in the E-field measurements; therefore mechanical design should be very strict regarding this constant. Double sided tape between 3.76 In 8.78 In 4.0 mm Thick Figure 1-25. Touch panel board mechanical considerations 1.16.2 TPB connector The TPB connector is an SMD 15 terminal connector mounted on the back side of the touch panel board (TPB). The TPB connector fits and is compatible with the 15 terminal connector JP2 in the analyzer board. Special care must be taken when the two boards are attached to each other, bending or moving the Touch panel board from Analyzer board might detach the connector from the PCB. 1.16.3 Other Considerations Many of the problems presented when noise is present in the reading of the electrodes are related with mechanical design. Some important mechanical considerations are listed below. Touch Panel System, Rev 1.0 24 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor The electrodes board should have a flat surface for the dielectric material mount. If vias are used on this board, shouldn’t be manufactured manually to avoid solder joints to hinder the mounting of the dielectric material. For the same reason, if components are required on the back of electrodes board, all those should be Surface Mount Technology (SMT). Touch pad electrode to glass gap must be constant, even after touch condition since small gap changes represent a considerable change in the output of the E-field sensor. If using fumed or painted glass, the dielectric constant of the glass is affected, testing must be performed for any new variable or material applied to the touch panel. 1.17 Software Design Considerations Demo board firmware demonstrates the functionality of the MC33794/MC34940DW device. Using the device as the main sensor for a 16 key keypad application, shows the possibilities of a larger system by multiplexing the electrodes. Two types of electrode configuration where used, a single electrode key configuration and two electrodes per key configuration. • Electrode value reading is done by the MCU device, by selecting the appropriate channel lines and then reading the value on the MCU A/D module. Differences on the read value represent changes on the electrode field meaning the electrode might be near the presence of a human finger. • Mixing different types of key configurations, multiplexed and not multiplexed results in a more complex software algorithm, for this project the routines where designed to get the best of both types of electrodes, but it is important to note that due to the mixed configuration the first thing to check is the key pressed configuration. And then use a different routine to find out the represented key according to the multiplexed or not multiplexed algorithm. • The Demo board is designed to be used as a stand alone application by giving user feedback through on board displays and buzzer, the board can also be connected to another device via the SCI port. • On Board displays are managed using an MC33993 device, which communicates to the MCU via an SPI bus while SCI communications are handled by the internal modules of the MCU. • Demo firmware is grouped in 2 files communications.c and main.c. • Communications.c is used for the SCI and SPI communication routines, as well as some timing delay routines. • Main.c is where the main routines are located, along with the functions more related to the core functionality of the E-Field keypad application. • ReadElectrode function is used to read the electrode values. This function will configure the electrode select lines PTA0, PTA1, PTB6 and PTB7 according to the desired electrode, and will wait to give some time to the electrode signal to stabilize, if needed this dead time can be used to send SCI data. • 32 samples of the electrode channel level are acquired to make an average of this value; the resulting value is stored in the appropriate INT16evalues location. • Sending data to the SCI interface is accomplished while waiting for the electrode value to stabilize in the function readElectrode. This implementation takes advantage of the periodicity in which the electrodes are readied in this application and at the same time improves the application using the dead time to accomplish this task. The standard SCI configuration is 8 bits, 9600 no parity, 1 stop bit. • The displayData function is used to display electrode changes in the on-board displays. In order to display the correct electrode changes, this function requires some tasks to be accomplished before calling this function. • Steps to make a valid use of displayData function: • The call readValues() function read the electrode value of each channel using readElectrode function; after readValues is completed, actual electrode values of all channels will be present on the INT16evalues array. • Call verifyElectrodes() searches for 3 electrode channels with greater value change using a delta value from the actual value and the calibration value of each channel. The electrodes will be registered on the MaxIndex1, MaxIndex2 and MaxIndex3 variables, the delta value will be stored according on the Max0,Max1 and Max2 variables. • The calibration value is a register of the value of the electrodes with out any change applied. This calibration routine is called in the initialization routine. • After MaxIndex variables are updated displayData function see if the keys are a valid combination and if the change is enough to consider the electrode touched. The functions verifyKeys() try to find a single electrode touched and if a possible multiplexed electrode is detected it will return the value 30 so verifyMuxKeys() must be called to find the multiplexed “button” value. • dispalyData() will then call the display function which will be responsible for sending the correct MC33993 commands to the MC33993D device to display in the on board display the change registered on the electrodes. • The VerifyKeys and VerifyMuxKeys parameters can be adjusted in the settings.h file. • Note: The firmware is designed to be downloaded into the board via serial port or using a MONO8 programmer. Using the serial boot loader requires a different interrupt vector location, for this propose the define of Touch Panel System, Rev 1.0 Freescale Semiconductor 25 Touch Panel System using the MC33794/MC34940 E-field Sensor SERIAL_DOWNLOADER modifies the standard interrupt vectors location to a new location where the code is compatible with the serial boot loader. This change is not compatible if a MONO8 programmer is used so SERIAL_DOWNLOADER must not be defined if no boot loader is used. 1.17.1 Firmware Functional Description Module: main.c Function: barGraph Syntax: void barGraph(unsigned char led) Parameters: led Return: none Description: Routine to handle the six led bar, if WALKING_LED is defined just one LED is turned on at a time; else all the LED’s below the received value are turned on. Module: main.c Function: calibrateElectrodes Syntax: void calibrateElectrodes(void) Parameters: none Return: none Description: Read each electrode value and store the result in the calibration register of each electrode. Module: main.c Function: display Syntax: void display(unsigned char left, unsigned char right) Parameters: left, right Return: none Description: Displays the hex value contained in the left and right bytes into the 7 segment displays using the MC33993 via SPI If a 255 value is received the display is turned off. Module: main.c Function: displayData Syntax: void displayData(void) Parameters: none Return: none Description: This function uses verifyKeys and verifyMuxKeys functions to find out if there is a key pad pressed. If a value different from 0 is found the corresponding value is displayed into the 7 segment displays and a beep is generated. Module: main.c Function: initPorts Syntax: void initPorts(void) Parameters: none Return: none Touch Panel System, Rev 1.0 26 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor Description: Initialize GPIOs, Oscillator, A/D module, Timers and external MC33993 chip. Module: main.c Function: main Syntax: void main(void) Parameters: none Return: none Description: Set up peripherals, get calibration value of electrodes and continuously scan the keys and take the appropriate action. Module: main Function: readElectrode Syntax: void readElectrode(unsigned char channel) Parameters: channel Return: none Description: Reads the selected channel and places the result into INT16evalue, channel takes on value from 1 to NUMBER_OF_ELECTRODES Module: main.c Function: readValues Syntax: void readValues(void) Parameters: none Return: none Description: Reads all electrodes using the readElectrode function. Module: main.c Function: verifyElectrodes Syntax: void verifyElectrodes(void) Parameters: none Return: none Description: Finds the three highest electrode change values and the corresponding electrodes are stored in the global variables MaxIndex0..MaxIndex2. Delta values are stored in Max0..Max2 Module: main.c Function: verifyKeys Syntax: unsigned char verifyKeys(void) Parameters: none Return: Key pad number if any are valid, or 30 if a multiplexed pad is detected. Description: Evaluates the data in Max0 and Max1 global variables, returns the represented electrode if valid, and a 30 if the combination seems to be a multiplexed electrode key. Module: main.c Touch Panel System, Rev 1.0 Freescale Semiconductor 27 Touch Panel System using the MC33794/MC34940 E-field Sensor Function: verifyMuxKeys Syntax: unsigned char veifyMuxKeys(void) Parameters: none Return: Key pad number represented by the electrode delta combination if any valid. Description: Verifies the values of Max0 and Max1 to find out if a valid key pad combination is present, returns the number of the key pad is any found. Module: main.c Function: _TOF_Interrupt Syntax: interrupt void _TOF_Interrupt(void) Parameters: none Return: none Description: Handler routine for the timer overflow interrupt, this routine stops the timer and turns off the beeper. Module: main.c Function: _KBD_Interrupt Syntax: interrupt void _KBD_Interrupt(void) Parameters: none Return: none Description: Handler routine for the keyboard interrupt, makes a beep and recalibrates the electrodes. Module: communications.c Function: delay10mS, delay100mS, delay1mS Syntax: void delay10mS(void), void delay100mS(void), void delay1mS(void) Parameters: none Return: none Description: Functions to wait for the specified amount of time using a for cycle. Module: communications.c Function: sendSCIchar Syntax: void sendSCIchar(unsigned char u8serialValue) Parameters: u8serialValue Return: none Description: Sends via SCI the u8serialValue Module: communications.c Function: sendSCIValue Syntax: void sendSCIValue(int u16serialValue) Parameters: u16serialValue Touch Panel System, Rev 1.0 28 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor Return: none Description: Converts the 16 bit value into a 3 digit hex value, and sends the three digits via SCI. Module: communications.c Function: sendSPI Syntax: void sendSPI(void) Parameters: none Return: none Description: Sends via SPI the bytes located on the global variable MSDI[0].MSDI[2] Touch Panel System, Rev 1.0 Freescale Semiconductor 29 Touch Panel System using the MC33794/MC34940 E-field Sensor 1.18 Flow Diagrams Start Configure MCU Turn off LED’s Read and store calibration value from electrodes Enable interrupts Test buzzer Read electrode values Verify electrode status against calibration values Display data according to modified electrodes Display walking LED or the max difference value on the electrodes according to WALKING_LED define Figure 1-26. Main Program Flow Touch Panel System, Rev 1.0 30 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor InitPorts Set bus speed to 12.8 MHz Trim MCU to +/- 5% Enable Reset and IRQ pins Disable Watchdog Enable Keyboard interrupt on PTA 2 Configure Timer 1 Configure ADC Configure SPI Configure SCI Initialize MSDI Return Figure 1-27. Initialization Ports Touch Panel System, Rev 1.0 Freescale Semiconductor 31 Touch Panel System using the MC33794/MC34940 E-field Sensor calibrateElectrodes Initialize all calibration values to 0 Do a dummy read Calibration value = Calibration value + Actual electrode value No Finished with 16 electrode readings Yes Calibration value = Calibration value / 16 Return Figure 1-28. Calibrate Electrodes Touch Panel System, Rev 1.0 32 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor readValues Counter = 0 Read electrode according to counter using readElectrode(channel) Counter++ No Counter > NUMBER_OF_ELECTRODES Yes Return Figure 1-29. Read Values Touch Panel System, Rev 1.0 Freescale Semiconductor 33 Touch Panel System using the MC33794/MC34940 E-field Sensor Read Electrode Select desired channel using lower 2 bits of port A and higher 2 bits of port B Yes SCI_ENABLED ? Send SCI value of last electrode read No Yes Channel = 10 Delay 2mS No Send SCI new line characters Send SCI space character Read 32 times the selected electrode and get an average of the readings Store average value on the electrode values array Return Figure 1-30. Read Electrode Touch Panel System, Rev 1.0 34 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor verifyElectrodes Max0..Max2 = 0 MaxIndex0...MaxIndex2 = 0 Counter = 0 Counter = Counter + 1 No Counter < NUMBER_OF_ELECTRODES Yes Delta = Calibration value of the electrode - Read value of the electrode Yes Delta > Max0 MaxIndex0 = MaxIndex0 + 1 MaxIndex1 = MaxIndex1 + 1 MaxIndex2 = MaxIndex2 + 1 Max2 = Max1 Max1 = Max2 MaxIndex2 = MaxIndex1 MaxIndex1 = MaxIndex0 Max0 = Delta MaxIndex0 = Counter No Return Delta > Max1 Yes Max2 = Max1 MaxIndex2=MaxIndex1 Max1 = Delta MaxIndex1 = Counter No Yes Delta > Max2 No Max2 = Delta MaxIndex2 = Counter Figure 1-31. Verify Electrodes Touch Panel System, Rev 1.0 Freescale Semiconductor 35 Touch Panel System using the MC33794/MC34940 E-field Sensor verifyKeys Max0 - Max1 < MUX_KEY_MAX_DIFFERENCE No Verify if single electrode conditions are valid Yes Possible multiplexed key No Invalid key condition Max1 > MUX_KEY_TRESHOLD Return 0 Yes Valid multiplexed key condition Return 30 No Valid key detected Return index of electrode with higher delta (MaxIndex0) Max0 < NO_MUX_TRESHOLD Return 0 Figure 1-32. Verify Keys Touch Panel System, Rev 1.0 36 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor verifyMuxKeys Yes Max0 <= MUX_TRESHOLD Return 0 No No MaxIndex0 and MaxIndex1 are a valid electrode key combination Return 0 Yes Return Key Number of the valid combination Figure 1-33. Verify Mux Keys Touch Panel System, Rev 1.0 Freescale Semiconductor 37 Touch Panel System using the MC33794/MC34940 E-field Sensor displayData J = verifyKeys() Yes J = 30 J = verifyMuxKeys() No If J > 0 display the preset value according to J into the 7 Seg. displays If J > 0 Make a beep with the buzzer Return Figure 1-34. Display Data Touch Panel System, Rev 1.0 38 Freescale Semiconductor Touch Panel System using the MC33794/MC34940 E-field Sensor display Store left number on MSDI array 1 Verify if LSB of left display is 1 Store right number on MSDI array 2 Set bit 7 of MSDI 2 if LSB of the left number is set Store command 0x0A in MSDI array 0 Yes Right = 255 Set MSDI array 2 value to turn off right display No Yes Left = 255 Set MSDI array 1 and 2 to turn off left display No Send via SPI MSDI array 0..2 Return Figure 1-35. Display Touch Panel System, Rev 1.0 Freescale Semiconductor 39 Touch Panel System using the MC33794/MC34940 E-field Sensor barGraph Load MSDI array with command values MSDI array 0 = 0x09 MSDI array 1 = 0xFF Load MSDI array 2 with value according to LED desired display Return Figure 1-36. Bar Graph Touch Panel System, Rev 1.0 40 Freescale Semiconductor Bill of Materials Appendix A Bill of Materials Table A-1 shows the bill of materials for the Touch Panel System. Table A-1. Bill of Materials Part Value C1, C2, C3, C10 0.1uF C5, C6, C17 10u C7, C8 0.1uF C9, C12, C13, C15, C18, C26, C27, C28, C29, C30, C31, C32, C33, C34, C35 10nF C11 4.7uF C14, C16, C25 1nF C19, C20, C21, C22, C23, C24 1uF Manufacturer Part # 06032R104K7B20D B45197A4106K309 ECS-T1VY104R Package Surface Mount Ceramic ChipCap ANY C-EIA Surface Mount Tantalum Electrolytic Capacitor ANY A-EIA Surface Mount Tantalum Electrolytic Capacitor ANY C0603 06032R102K9B20D ECS-T1CY105R 1N4148WS D1, D2 Manufacturer C0603 06032R103K9B20D ECS-T1AY475R Description Surface Mount Ceramic ChipCap ANY A-EIA Surface Mount Tantalum Electrolytic Capacitor ANY C0603 Surface Mount Ceramic ChipCap ANY A-EIA Surface Mount Tantalum Electrolytic Capacitor ANY SOD323 Surface Mount Switching Diode ANY SOD123 5.1V SMD Diode ANY D3 BZT52C5V1 DIS1, DIS2 LSHD-A103 7 Segment LED Red Display ANY JP1, JP3 TSW-103-23-S-S 1x3 terminal Header ANY JP2 TSW-115-23-S-S 1x15 terminal Header ANY JP4 TSW-108-23-S-D 8x2 terminal Header ANY JP5 TSW-101-23-S-S 1x1 terminal Header ANY LED1, LED2, LED3, LED4, LED5, LED6 LNJ311G8TRU P1 1206 RAPC-722 ERJ-3GEYJ473V Surface Mount Green LED ANY Power Jack ANY R0603 Surface Mount Resistor ANY R0603 Surface Mount Resistor ANY R1 47K R2 680 R3, R9, R10, R11, R12, R15 10K R5 1K ERJ-3GEYJ102V R0603 Surface Mount Resistor ANY R6 39K ERJ-3GEYJ393V R0603 Surface Mount Resistor ANY R7, R8 100k 3266Y-1-104 Trimming Potentiometer ANY R13, R14 2.2K R0603 Surface Mount Resistor ANY R16 10 R0603 Surface Mount Resistor ANY R17 120 R0603 Surface Mount Resistor ANY ERJ-3GEYJ103V ERJ-3GEYJ222V R0603 Surface Mount Resistor ANY Touch Panel System, Rev 1.0 Freescale Semiconductor 41 Bill of Materials S1 EG1218 SPDT Slide Switch E-Switch S2 EG2207 DPDT Switch E-Switch KSR221G SPST Surface Mount Switch SW1_IRQ U1 U2 U3 U4 U5 MC68HC908QB8 LM2767M5 SOIC16W SOT23-5 LM358AD 8-SO MAX232CSE 16-terminal SOICN MC33993DWB 32-SOICW Micro controller Freescale Semiconductor Switching Capacitor Voltage Converter ANY IC Opamp Dual ANY RS-232 Interface Maxim WB MC33993 in SO-32WB Freescale Semiconductor Freescale Semiconductor U6 MC33794/MC34940DW 54-terminal B SOIC Electric Field Imaging Device (ODS) U7 MC7805CDT 5V Voltage Regulator U8 PB-12N23P-05 X1 D-PAK 182-009-212-531 SSM-115-S-SV TPB connector Buzzer D-type Female ANY RS-232 Connector SMD SOCKET STRIP, CENTERLINE: .100" (2,54MM), single row, 15 contacts ANY Projects Unlimited ANY SAMTEC Authors’ Note: Freescale Competitor notation: Freescale does not assume liability, endorse, or warrant components from external manufacturers that are referenced in circuit drawings or tables. While Freescale offers component recommendations in this configuration, it is the customer’s responsibility to validate their application. Touch Panel System, Rev 1.0 42 Freescale Semiconductor Bill of Materials REVISION HISTORY Revision 0.2 Date Sept., 2005 Description of Changes Initial Release Touch Panel System, Rev 1.0 Freescale Semiconductor 43 How to Reach Us: Home Page: www.freescale.com E-mail: [email protected] USA/Europe or Locations Not Listed: Freescale Semiconductor Technical Information Center, CH370 1300 N. Alma School Road Chandler, Arizona 85224 +1-800-521-6274 or +1-480-768-2130 [email protected] Europe, Middle East, and Africa: Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 7 81829 Muenchen, Germany +44 1296 380 456 (English) +46 8 52200080 (English) +49 89 92103 559 (German) +33 1 69 35 48 48 (French) [email protected] Japan: Freescale Semiconductor Japan Ltd. Headquarters ARCO Tower 15F 1-8-1, Shimo-Meguro, Meguro-ku, Tokyo 153-0064 Japan 0120 191014 or +81 3 5437 9125 [email protected] Asia/Pacific: Freescale Semiconductor Hong Kong Ltd. Technical Information Center 2 Dai King Street Tai Po Industrial Estate Tai Po, N.T., Hong Kong +800 2666 8080 [email protected] For Literature Requests Only: Freescale Semiconductor Literature Distribution Center P.O. Box 5405 Denver, Colorado 80217 1-800-441-2447 or 303-675-2140 Fax: 303-675-2150 [email protected] RDTOUCHEFRM Rev 1.0 02/2006 RoHS-compliant and/or Pb-free versions of Freescale products have the functionality and electrical characteristics of their non-RoHS-compliant and/or non-Pb-free counterparts. For further information, see http://www.freescale.com or contact your Freescale sales representative. For information on Freescale’s Environmental Products program, go to http://www.freescale.com/epp. Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale Semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. “Typical” parameters that may be provided in Freescale Semiconductor data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including “Typicals”, must be validated for each customer application by customer’s technical experts. Freescale Semiconductor does not convey any license under its patent rights nor the rights of others. Freescale Semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur. Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc. 2005. All rights reserved.