Part Number Hot Search : 
FBM0805 09CC0W 1N5943B CYRF6910 230025 1N4051 MAD1103 CY7C4841
Product Description
Full Text Search
 

To Download AN1250 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ? 2009 microchip technology inc. ds01250a-page 1 AN1250 introduction this application note describes the use of microchip?s charge time measurement unit (ctmu) for capacitive touch applications. the ctmu is an excellent periph- eral for use in touch sensing applications. the following are some of the benefits of using the ctmu for touch sensing applications: ? easy hardware setup ? simple to use software algorithms, available free of charge ? high speed allows for greater scan rate of capacitive touch switches and for many other processor tasks ? low cost and low component count; no external hardware other than a connection to the copper sensor pad the purpose of this application note is to inform prospective users of the ctmu for capacitive touch on general usage guidelines, ctmu setup and software algorithms, hardware and layout considerations, and advanced capacitive touch applications, such as matrix keys, sliders and multiple press keys. the ctmu is currently available on selected pic24 and pic18f parts. wherever possible, sample code for both has been included. all hardware examples used in this application note directly pertain to the picdem? touch sense 2 demonstration board (part number dm164128). the picdem touch sense 2 demo board uses a pic24f device-based microcontroller (pic24fj256gb110). this demo board is not necessary for understanding this application note. general features of the ctmu the ctmu is made up of a constant current source and several logic blocks for it to operate: ? the constant current source is connected to the a/d converter of the microcontroller. ? a switch connected to the ctmu constant current source (and the a/d converter) is provided to allow accumulated charge to be drained. ? two external pins are provided to trigger the constant current source. ? an output pin is also available for ctmu use. for the purposes of capacitive touch, the external pins for triggering the ctmu and the ctmu output pin are not used. the connection of the ctmu to the a/d converter is all that is needed for capacitive touch applications. for a more in-depth discussion on the ctmu module and how it is used to measure charge or time, refer to the ctmu chapter of the ?pic24f family reference man- ual? for pic24f microcontrollers, or the appropriate data sheet for pic18f microcontrollers on the microchip web site (http://www.microchip.com). see figure 1 for a block diagram of the ctmu hardware. note that there are a few slight differences in the ctmu module from the pic18f and the pic24f. the pic18f ctmu module does not have an automatic adc conversion trigger. this is of no consequence for capacitive touch applications. for clarity, the automatic adc trigger present on the pic24f has not been used in the sample code so that it more closely matches the pic18f code. also note that the ctmu on the pic18f has different internal trigger sources. (eccp1 and eccp2 for pic18f and timer1 and oc1 for pic24f). this is mentioned purely for reference, and again, makes no difference for capacitive touch applications. the sample code listings in this application note manually set/clear the edg1stat1 and/or edg2stat bits in the ctmu control register for starting and stopping the ctmu current source. author: bruce bohn microchip technology inc. microchip ctmu for capacitive touch applications
AN1250 ds01250a-page 2 ? 2009 microchip technology inc. figure 1: ctmu block diagram ctmucon ctmuicon edge control logic external edge trigger pins ctmu control logic pulse generation logic current source current control a/d conversion trigger comparator 2 pulse output pin comparator 2 input a/d converter timer1 oc1 (ctmuconh and ctmuconl for pic18f) (pic24f only) eccp1/eccp2 (pic18f only) (pic24f only) (pic24f only) output
? 2009 microchip technology inc. ds01250a-page 3 AN1250 overview of capacitive touch applications the ctmu is used in capacitive touch applications by applying the constant current source of the ctmu to the capacitive touch pad using the following equation: where: ? i is the constant current source of the ctmu ? t is a fixed period that the ctmu charges the capacitive touch circuit ? c is the capacitance of the touch circuit ? v is the voltage read by the a/d converter after the capacitive touch circuit is finished charging it is possible to sense a relative shift in capacitance by observing a change in voltage. the above equation can be rearranged to: since the ctmu current source is constant ( i ), the voltage present on the capacitive touch sensor ( v ) relies on two variables: the amount of time the touch circuit is charged ( t ) and the capacitive size of the touch circuit ( c ). if the amount of time the touch circuit is charged is held constant, then changes in the capac- itance of the touch circuit will ultimately affect the voltage that the circuit charges to in the fixed period. the a/d converter is used to read the voltage that the touch circuit is charged to with the ctmu. when the capacitance of a human finger is added to the touch sensor pad, the capacitance increases and the result is a lowering of the voltage seen by the a/d converter (since i and t are held constant). setting up of the ctmu for a capacitive touch application, each sensor must be connected directly to a channel of the a/d converter. see figure 2 for a block diagram of a microchip microcontroller with a ctmu peripheral. this diagram illustrates that the ctmu is internally connected to the a/d converter and allows for selection of any of the a/d channels. with this configuration, a single ctmu unit can measure many capacitive touch sensors. note that the ctmu has been simplified in order to show only the elements required for capacitive touch, namely the cur- rent source, the current source control and the current drain mechanism. these will be explained in detail in later sections. the current source control, labeled ?trigger? in figure 2, is manually controlled in software by manipulating bits in the ctmu control register. figure 2: capacitive touch block diagram i x t = c x v v = (i x t)/c a/d converter current source ctmu sensor 0 c a/d d i s c h a r g e trigger a/d mux
AN1250 ds01250a-page 4 ? 2009 microchip technology inc. the current source of the ctmu is available in three ranges: 0.55 a, 5.5 a and 55 a. the current range selection is made in the ctmuicon register. the cur- rent precision for each of the three ranges is 20%. for many capacitive touch applications, the highest current range setting (55 a) works best. this allows for the quickest charging of the capacitive touch circuit. the ctmuicon register also has bits used to trim the current source in 2% increments up to 62% for each of the three current ranges. the ctmu current source is enabled and disabled using software. two control bits, edg1stat and edg2stat in the ctmu control register, determine if the current source is enabled. these bits are exclu- sively ored. that is, if edg1stat and edg2stat are both set or cleared, the current source is off. if either bit is set while the other is cleared, the current source is enabled and charging the circuit. the idissen bit is enabled to drain charge from the a/d converter to insure the charging process begins at zero potential. if the bit is set, the circuit is connected to v ss (grounded). note that the discharge of the entire circuit is not accomplished with this feature. this is because the a/d converter is not always connected to the external circuitry (i.e., touch sensor pad). the ctmu configuration register (ctmucon) is set up so that the external triggers are not used (these pins may be used for general purpose i/os). the same is true of the ctmu pulse output pin. the ctmu current source is configured using the ctmuicon register. for detailed information on the ctmu registers on the pic24f, refer to section 11. ?charge time measure- ment unit (ctmu)? of the ?pic24f family reference manual? . the registers that control the ctmu on the pic18f parts are identical, with the exception that they are 8-bit registers: ctmuconh and ctmuconl. the ctmu also has different external trigger sources available, namely the eccp1 and eccp2 special event triggers. for detailed information on the ctmu registers for pic18f, refer to the specific product data sheet. see example 1 for a typical setup of the required ctmu and a/d converter registers. note that the ctmu has been configured so that the external pins are not enabled. for the purposes of this application note, all control of the ctmu is handled through software. the a/d converter is set up to do manual conversion. for capacitive touch sensing, a relative change in capacitance due to the presence of a finger is required. the absolute measurement of capacitance is not required. example 1: ctmu and a/d converter setup for pic24f note: all pic18f code examples are written for the pic18f46j11 family. for other pic18f parts with the ctmu module, see the device data sheet for specific ctmu register configurations and ctmu usage. //setup ctmu //ctmucon ctmuconbits.ctmuen = 0; //make sure ctmu is disabled ctmuconbits.ctmusidl = 0; //ctmu continues to run in idle mode ctmuconbits.tgen = 0; //disable edge delay generation mode of the ctmu ctmuconbits.edgen = 0; //edges are blocked ctmuconbits.edgseqen = 0; //edge sequence not needed ctmuconbits.idissen = 0; //do not ground the current source ctmuconbits.cttrig = 0; //trigger output is disabled ctmuconbits.edg2pol = 0; ctmuconbits.edg2sel = 0x3; //edge2 src = oc1 (don?t care) ctmuconbits.edg1pol = 1; ctmuconbits.edg1sel = 0x3; //edge1 src = timer1 (don?t care) //ctmuicon ctmuicon = 0x300; //55ua ctmuicon.itrim = 0; //nominal - no adjustment //setup a/d converter ad1pcfgl = 0x0000; ad1con1 = 0x0000; ad1chs = 0x0000; //select the analog channel 0 ad1cssl=0x0000; ad1con1bits.form = 0x0; //unsigned fractional format ad1con3 = 0x0000; //bits.adrc=0; ad1con2 = 0x0000; ad1con1bits.adon = 1; //turn on a/d ctmuconbits.ctmuen = 1; //enable ctmu
? 2009 microchip technology inc. ds01250a-page 5 AN1250 example 2: ctmu and a/d converter setup for pic18f in the case of the pidem touch sense 2 demo board, all 16 a/d channels are used for capacitive touch. read- ing of each of the sensor channels (a/d channels) is controlled by timer1. timer1 is setup to fire at a 1 ms interval. each time that the timer1 interrupt handler runs, it increments the channel number of the a/d and the capacitive sensor connected to that channel is read. after all 16 touch sensors have been read, the timer1 interrupt handler sets a flag called, ? datareadyctmu ?, and the main routine uses this flag to know when to process the new data just gathered from all 16 capacitive touch sensors. //setup ctmu //ctmucon ctmuconhbits.ctmuen = 0; //make sure ctmu is disabled ctmuconhbits.ctmusidl = 0; //ctmu continues to run in idle mode ctmuconhbits.tgen = 0; //disable edge delay generation mode of the ctmu ctmuconhbits.edgen = 0; //edges are blocked ctmuconhbits.edgseqen = 0; //edge sequence not needed ctmuconhbits.idissen = 0; //do not ground the current source ctmuconhbits.cttrig = 0; //trigger output is disabled ctmuconlbits.edg2pol = 0; ctmuconlbits.edg2sel = 0x0; //edge2 src = eccp2 (don?t care) ctmuconlbits.edg1pol = 1; ctmuconlbits.edg1sel = 0x1; //edge1 src = eccp1 pin (don?t care) //ctmuicon ctmuicon = 0x03; //55ua ctmuicon.itrim = 0; //nominal - no adjustment //setup a/d converter ancon0bits.pcfg = 0x00; ancon1 = 0x0000; adcon0bits.chs = 0x00; //select the analog channel 0 adcon1bits.adfm = 0x00; //right justified result adcon1bits.adon = 1; //turn on a/d ctmuconhbits.ctmuen = 1; //enable ctmu
AN1250 ds01250a-page 6 ? 2009 microchip technology inc. the software routine for reading each of the sensor channels consists of the following 13 steps: 1. set all of the a/d converter channels to digital i/o pins and set them to logic zero (? 0 ?). this has the effect of grounding all of the capacitive touch sensor pads, so they are at zero (0) volts potential. 2. set the a/d channel to be read to an analog input. 3. set the a/d converter to the selected channel. 4. set the discharge bit, idissen, of the ctmucon register. this step insures that the internal capacitance of the a/d converter starts at zero (0) volts potential. 5. wait for charge to drain (a few nop s). 6. clear the discharge bit, idissen. 7. set the sample bit, samp (ad1con1), to begin sampling the selected channel (pic24f only). 8. set either of the edge status bits of the ctmu. for pic24f: edg1stat or edg2stat (ctmucon) bits for pic18f: edg1stat or edg2stat (ctmuconl) bits this step turns on the ctmu current source to the selected a/d channel and begins charging the connected capacitive touch sensor. 9. wait for a fixed period of time. for most capacitive touch applications, this is approximately 2-10 s. in this case, the fixed time period is a loop set up to do nothing until the allotted time has expired. 10. clear the edge status bit that was set above. for pic24f: edg1stat or edg2stat (ctmucon) bits for pic18f: edg1stat or edg2stat (ctmuconl) bits this step turns off the ctmu current source and stops charging the connected capacitive touch sensor. 11. initiate an a/d conversion on the selected channel: a) on pic24f, clear the samp bit (ad1con1). b) on pic18f, set the go/done bit (adcon0). 12. wait for the conversion to complete. 13. store the value read by the a/d converter. figure 3 provides a software flowchart of the ctmu capacitive touch sensor, reading as outlined above. figure 3: ctmu capacitive touch sensor read flowchart start set all of adc as digital outputs (? 0 ?) to insure all sensors at zero potential set selected adc channel to analog set discharge bit, idissen set adc to sample selected channel wait for charge to drain (a few nop s) clear discharge bit, idissen begin sampling by setting the samp bit of the adc set the edge 1 status bit of the ctmu (edg1stat) wait for the capacitive touch circuit to charge clear edge 1 status bit of the ctmu (edg1stat) start adc clearing the samp wait for conversion to to complete: wait for adc interrupt flag (pic24f) move the data from the adc conversion to a temporary variable end (pic24f only) conversion by: bit (pic24f) setting go/done bit (pic18f) wait for go/done = 0 (pic18f) adc operation ctmu operation 1 2 3 4 56 78 9 10 11 12 13
? 2009 microchip technology inc. ds01250a-page 7 AN1250 example 3 provides the equivalent code for reading the capacitive touch sensors using the ctmu on a pic24f device. example 4 has the same algorithm for a pic18f device. note that the channel number being read is referenced by the index variable. the adselect array is setup to have the correct bits set for the corresponding index variable so that the correct channel is set to an analog a/d. the a/d value is temporarily stored in the variable, immediatevalue . the loopcount determines how long the ctmu current source charges the capacitive touch circuit. example 3: reading the capacitive touch sensor circuit software algorithm (pic24f) //read ctmu (get the raw sensor reading) ad1pcfgl= 0xffff; //set all a/d channels to digital i/o pins trisb = 0x0000; latb = 0x0000; portb = 0x0000; //set all channels to logical 0 outputs nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); //wait for charge to drain trisb = adselect[index]; //set selected channel to input ad1pcfgl = ~adselect[index]; //set selected channel to analog a/d input nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); //wait for a/d to connect to channel ad1chs = index; //select a/d channel ctmuconbits.idissen = 1; //drain any charge on the a/d circuit nop(); nop(); nop(); nop(); nop(); //wait for charge to drain ctmuconbits.idissen = 0; //stop discharge of a/d circuit ifs0bits.ad1if = 0; //make sure a/d interrupt flag = 0 ad1con1bits.samp = 1; //manually start sampling ctmuconbits.edg2stat = 0; // make sure edge2 is 0 ctmuconbits.edg1stat = 1; // set edge1 - start charge for (count = 0; count < loopcount; count++); // delay for ctmu charge time ctmuconbits.edg1stat = 0; //clear edge1 - stop charge ifs0bits.ad1if = 0; ad1con1bits.samp = 0; //clear samp bit to begin manual a/d conversion while(!ifs0bits.ad1if); //wait for the a/d conversion to finish immediatevalue = adc1buf0; //read the value from the a/d conversion ad1con1bits.samp = 0; ifs0bits.ad1if = 0; ad1con1bits.done = 0; //make sure a/d bits are cleared //end of ctmu read
AN1250 ds01250a-page 8 ? 2009 microchip technology inc. example 4: reading the capacitive touch sensor circuit software algorithm (pic18f) the main() function contains a while(1) loop (endless) that checks for the datareadyctmu flag (set by the timer1 interrupt handler). if the datareadyctmu flag is not set, other tasks are performed while it waits. in the case of the picdem touch sense 2 demo board, communication of data over the usb is serviced. if the datareadyctmu flag is set, the main() function clears the flag and calls the routines necessary to process the newly acquired data. the main() function temporarily disables timer1 to insure that no new data is introduced in the middle of the routines that are handling data processing. after all processing of the capacitive touch sensor data is complete, and the led display informa- tion is also updated, timer1 is re-enabled, and the whole process begins again. the structuring of the code in this manner is done to make the system deterministic. using a fixed timer to read each capacitive touch sensor channel at a 1 ms rate fixes the update rate to approximately 16 ms (1 ms times 16 channels). the actual update rate is slightly slower, since timer1 is disabled while the new data is processed. //read ctmu (get the raw sensor reading) ancon0bits.pcfg= 0xff; //set all a/d channels to digital i/o pins ancon1bits.pcfg= 0x1f; //set all a/d channels to digital i/o pins trisa = 0x00; trisb = 0x00; trisc = 0x00; trise = 0x00; lata = 0x00; latb = 0x00; latc = 0x00; late = 0x00; portb = 0x00; //set all channels to logical 0 outputs nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); //wait for charge to drain trisa = adpaselect[index]; trisb = adpbselect[index]; trisc = adpcselect[index]; trise = adpeselect[index]; //set selected channel to input ancon0bits.pcfg = ~ad0select[index]; ancon1bits.pcfg = ~ad1select[index]; //set selected channel to analog a/d input nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop(); //wait for a/d to connect to channel adcon0bits.chs = index; //select a/d channel ctmuconhbits.idissen = 1; //drain any charge on the a/d circuit nop(); nop(); nop(); nop(); nop(); //wait for charge to drain ctmuconhbits.idissen = 0; //stop discharge of a/d circuit nop(); nop(); ctmuconlbits.edg2stat = 0; // make sure edge2 is 0 ctmuconlbits.edg1stat = 1; // set edge1 - start charge for (count = 0; count < loopcount; count++); // delay for ctmu charge time ctmuconlbits.edg1stat = 0; //clear edge1 - stop charge ad1con0bits.godone = 1; //set go bit to begin a/d conversion while(ancon0bits.godone); //wait for the a/d conversion to finish immediatevalue = adresh; immediatevalue = immediatevalue << 8; immediatevalue = immediatevalue + adresl; //read the value from the a/d conversion //end of ctmu read
? 2009 microchip technology inc. ds01250a-page 9 AN1250 implementations of special purpose capacitive touch this section describes some of the special handling of the data that is available from reading the capacitive touch sensors using the ctmu. the following topics are covered: ? software algorithms for reliable touch operation ? software algorithms for special purpose capacitive touch sensor implementations ? physical board properties for optimal capacitive touch sensors software algorithms for reliable touch operation there are several software methods used to combat problems with false sensing of capacitive touch sens- ing circuits. the following software algorithms are used not only in the picdem touch sense 2 demo board, but throughout all of the capacitive touch solutions offered by microchip. ? first method ? this is to use a slow averaging routine. this is implemented by simply adding the value read for any capacitive touch sensor circuit into a running average. the key to this method is that a value is only added to the average at a rate much slower than the actual rate that the capacitive touch sensor is being read. on the picdem touch sense 2 demo board, for example, the average is only updated on every 16 th read of the capacitive sensor channel. since the update rate is 16 ms, the slower moving average value is updated at a rate of 256 ms. this slower moving value is then compared to the immediate value. if the immediate value varies by more than what has been established for the trip point for that capacitive sensor, the sensor is determined to be ?pressed?, or touched. for more information on the method of slow averaging, refer to the specific averaging section in an1103, ?software handling for capacitive sensing? . ? second method ? this is a debouncing routine. this algorithm is very similar to that used for debouncing of mechanical switches. in the case of capacitive sensors, the debouncing acts as a noise filtering mechanism. since noise by definition is non-periodic, it should not occur repetitively in multiple sequential scans of a capacitive sensor channel. figure 4 provides the routine setup for both a pressed and unpressed condition. it requires three consecutive values of pressed or unpressed before the actual state of the capacitive touch sensor is ultimately determined. the value can be changed to suit the application. it should be noted that if a higher number is used, a slower response time will be observed. figure 4: debounce algorithm flowchart enter read sensor unpressed no unpressed_count = 0 yes pressed yes no no yes exit sensor reading pressed? pressed_count > = 3? pressed_count ++ unpressed_count ++ pressed_count = 0 unpressed_count > = 3?
AN1250 ds01250a-page 10 ? 2009 microchip technology inc. ? third method ? this is used to improve capacitive touch sensor reliability in oversampling. this method takes advantage of the high-speed capability of the ctmu. using the picdem touch sense 2 demo board as an example, each reading of any of the 16 capacitive touch channels takes approximately 12 s. since the scan rate has been determined by timer1 to be 1 ms, there is sufficient time to reread the capacitive touch sensor channel multiple times. the picdem touch sense 2 demo board reads each channel 64 times. the sum of all 64 readings for the channel is then divided by 64, and this final value is used as the data used by all other software routines in the application. to use this method, a loop is added around the routine that reads the capacitive touch sensor. the sum of the reads is tallied for each iteration through the loop, and at the end of all of the iterations, the sum is divided by the number of times through the loop (64 in this case). this routine has the effect of a low-pass filter. since the average value of multiple readings is taken, a noise source that may cause an incorrect reading is averaged in with multiple correct readings and has a very minimal effect on the overall value. ? fourth method ? this is similar to that used for slow averaging. in this scenario, an array of previously read values is kept, and when a new value is read, it is introduced into the data array and the oldest value is removed. the average value of the array is used as the data value passed to all of the other software routines in the application. this method again causes a spurious incorrect value to have only a slight impact on the final value used. this routine is used on every value read by the capacitive touch routine. note that the picdem touch sense 2 demo board uses all of these methods combined to provide the most reliable sensing solution. capacitive touch sensors can go beyond a simple button that is pressed and released. in this section, we will explore some different capacitive touch topologies, such as multiple key press, paired button press, matrix keyboard implementation and the use of capacitive touch sensors as a slider. multiple keys press using software algorithms, it is possible to detect when two or more buttons are simultaneously pressed. in a multiple press scenario, the buttons are specifically designed to allow for multiple presses. the physical layout of the touch pad sensors is such that an area exists for a single button press, and the button area is extended to an area shared with an adjacent touch pad sensor. the picdem touch sense 2 demo board has an area designated as the ?directional wheel?. this area has four capacitive touch sensors laid out as the four main ordinal compass directions (north, south, east and west). each of these sensors is extended to an area equal to one half (1/2) of the main portion of the sensor. these ?dual? touch sensor areas make up four more directions (northeast, southeast, southwest and northwest). each of the four main sensors also extends to the center of the wheel, with each having one quarter (1/4) of the area of the main portion of the sensor. a ?quad? touch sensor is then formed in the center. see appendix a: ?picdem? touch sense 2 demo board? . note that the cover plate is removed in figure a-2. the software algorithm now looks first for all four sensors being pressed at approximately one quarter (1/4) of the value of a single pressed key. if all four are in range, it is determined that the center button is pressed. next, it looks for two adjacent keys pressed at approximately one half (1/2) of a single pressed key. lastly, single key presses at a full level of the trip value are checked. using this multiple press setup, nine distinct keys are created from only four capacitive touch sensor inputs. the directional wheel works nicely when a finger is moved around the wheel, either clock- wise or counter-clockwise. it provides a smooth fluid-like transition between the keys. capacitances for each of the sensors should be matched as closely as possible, especially when consid- ering that the software algorithm is searching for multiple button presses. the trace lengths to each sensor and adjacent sensors, leds and other board traces become important. the ctmu current trimming capability is a great aid in achieving a ?level playing field? in this respect. the picdem touch sense 2 demo board uses this trimming capability to match up each of the four sensors of the directional wheel. this was done using a manual process, and each of the a/d readings for the sensors was adjusted using the ctmuicon register to slightly alter the ctmu current source up or down so that the unpressed readings matched. the adjusted values required for each channel were then stored in an array, and the ctmuicon regis- ter was written to with a value that was selected from the array to match the selected channel being read. this is done for each channel and is applied to the ctmuicon register at the beginning of the ctmu channel read routine provided in example 3. note: for clarity, the code for ctmu current adjustment is not included in the example code, but may be found in the code listing for the picdem touch sense 2 demo board.
? 2009 microchip technology inc. ds01250a-page 11 AN1250 paired keys press the paired keys press is similar to the multiple key press with the exception that all of the combinations of one half (1/2) are used. in figure 5, it can be seen that each button is made up of either a full circle single touch pad, or two half (1/2) circle touch pads. the soft- ware for the paired press is similar to that used for the multiple key press described above. the ?half? pressed keys are looked for first, and then single keys are scanned for if no paired press keys are found. this implementation has the distinction of generating 10 keys from only four capacitive touch sensor inputs. it should be noted that it is somewhat difficult to differentiate between two single keys being pressed and a single paired press key. figure 5: paired key press capacitive touch sensor keys matrix keys implementation matrix keys use a set of capacitive touch sensors arranged in rows and columns to provide a maximum number of buttons or keys with respect to the number of capacitive touch sensor inputs. the picdem touch sense 2 demo board makes use of a matrix of four rows by five columns (4 x 5) to implement a 20-key calculator type keypad. notice that the number of channels (9) yields a total of 20 distinct keys. the number of possible keys is the multiplication of the number of rows and columns (4 x 5), while the number of channels required is the sum of the number of rows plus the number of columns (4 + 5). appendix a: ?picdem? touch sense 2 demo board? depicts the picdem touch sense 2 demo board with the cover plate removed. the keypad matrix is in the center of the board. each key is a unique combination of a row and a column of the matrix. each key is made up of two touch sensors shaped as half circles, one half circle for the row and one half circle for the column. see figure 6 for a visual example of a keypad matrix. the software algorithm for the keypad matrix looks for a row pressed and a column pressed, and decodes the key pressed. the software for this implementation also looks for the most pressed row and column. this is done since the proximity of the sen- sors can sometimes cause adjacent rows or columns to cross the tripped threshold level. it is important to note that using matrix keys causes the overall capacitance to increase. for example, a matrix with four (4) rows will have approximately two (2) times the capacitance of a single sensor key of equal size. this factor becomes important, since the software is looking for the relative change in capacitance due to a finger on the capacitive touch sensor key. another key factor is that since the rows and columns are very close to each of the actual keys, capacitive coupling also increases the amount of capacitance seen by each of the sensor inputs. it is important to keep the capacitances for each of the rows and each of the columns matched as closely as possible, especially when considering that the software algorithm is searching for the ?most pressed? row and column. the trace lengths to each row/column and adjacent sensors, leds and other board traces become important. the ctmu current trimming capa- bility, mentioned in the ?multiple keys press? section, is applicable to the matrix keypad as well. the difference between paired press and matrix keys is that for the matrix, there is a key for each combination of row and column, and for the paired press, there is a key assigned to each capacitive touch channel and a key assigned to each combination of two capacitive touch channels. 4 1 2 3 ctmu channel:
AN1250 ds01250a-page 12 ? 2009 microchip technology inc. figure 6: matrix key press capacitive touch sensor keys c1 c2 c3 c4 r1 r2 r3 r1 c1 r2 c1 r3 r1 c2 r1 c3 r2 c2 r2 c3 r2 r3 c2 r3 c3 r3 r1 c4 c4 c4 c1
? 2009 microchip technology inc. ds01250a-page 13 AN1250 capacitive touch slider the capacitive touch slider senses the position of a finger along a strip of the circuit board. the area desig- nated as the strip has two capacitive sensor channels, each formed in the shape of a triangle (see figure 7 and figure a-2). the schematic of the picdem touch sense 2 demo board with the cover plate removed shows the slider toward the right hand side of the board. figure 7: slider implementation copper pad shape notice that the trace between the two triangular pads is grounded. this trace provides additional isolation between the two triangular capacitive touch sensors by reducing the effect of capacitive coupling. the slider works by reading the amount of shift in capacitance from a normal untouched sensor. the slow moving average described earlier is used to track the untouched ?base? capacitance of each of the two sensors. when the value is shifted from this base value to a value where the trip point is reached for either of the two slider sensors, the base value is then locked and the slow moving average is no longer used for slider position calculations until the value of both slider sensors is again above the trip threshold. the base values for each of the two sensors is captured and used for the slider position calculations. the software algorithm then looks at the change in the slider value from the captured base value. the position of a finger on the slider is then determined by the following equations. equation 1: since the left triangular sensor has its point at the bottom of the slider, it is expected that the shift in capacitance from a finger on the slider at the bottom will be minimal, and maximum when a finger is positioned at the top. the position of the left sensor (scaled for a value of 0 to 100) is shown in equation 2: equation 2: similarly, the right triangular sensor is large at the bottom of the slider and a finger positioned at the bottom would cause the largest shift in capacitance, while a finger at the top of the slider would produce a minimum amount of capacitance shift. the position of the right sensor (again scaled for a value 0 to 100) is shown in equation 3: equation 3: finally, the two values may be averaged for the final position calculation: equation 4: it should also be noted that when neither the left nor right slider has crossed the tripped value (base or unpressed), the position is not calculated. this prevents jitter between values that are displayed on the slider leds. to achieve maximum linearity and accuracy of the slider, it is important to keep the capacitance for each of the triangular sensors matched as closely as possible since the software algorithm is using and comparing the values for two triangular sensors. the trace lengths to each triangular sensor and adjacent sensors, leds and other board traces become important. the ctmu cur- rent trimming capability, mentioned in the ?multiple keys press? section, is applicable to the slider sensors as well. to input pin b to input pin a note: slider is not to scale. delta left = (captured left base capacitance ? current left value) delta right = (captured right base capacitance ? current right value left position = (delta left * 100)/(delta left + delta right) right position = ((1 ? delta right) * 100)/(delta left + delta right)) position = (left position + right position)/2
AN1250 ds01250a-page 14 ? 2009 microchip technology inc. application-specific considerations every application will have unique needs relative to its capacitive touch features. some of the factors include: environment, response time, number and type of capacitive touch sensors, and the number of other tasks that the microcontroller is ultimately responsible for (such as usb, graphics, i 2 c?, spi, uart, etc). there are typically three common variables that affect overall performance of capacitive touch sensors. these are: ? printed circuit (pc) board layout including sensor pad size, shape and proximity to other sensors ? material and thickness of covering over the capacitive touch sensors ? noise susceptibility, both conducted and radiated pc board layout basic considerations for pc board (pcb) layout include keeping traces as short as possible. traces to capacitive touch sensors should not run for long lengths in parallel due to capacitive coupling effects. the picdem touch sense 2 demo board was laid out so that the most sensitive area (i.e., the matrix keypad) was closest to the microprocessor, so that the traces run to the capacitive sensors were the shortest, and capacitance due to trace length was kept to a minimum. the subject of board layout practice can be quite intri- cate; refer to an1102, ? layout and physical guidelines for capacitive sensing ? for more information. the pad shape, size and proximity to other sensors is also covered in an1102. the picdem touch sense 2 demo board uses a half inch (?") diameter pad with a quarter inch (?") spacing between adjacent sensors. the matrix keypad uses half circle sensor pads that have a ?" diameter. the directional wheel sensors have a total area that is approximately double that of the ?" diameter pads. this was required to allow the double and quad button areas. capacitive touch covering (overlay) considerations the material and thickness of the covering over the capacitive touch sensors is very significant. it deter- mines how much of the capacitance of a human finger is actually transmitted to the capacitive touch sensor. therefore, thinner is better than thicker. if a material is too thin, it may not be mechanically sufficient to support and protect the circuit board. the dielectric constant of the material also is a determining factor. a higher dielectric constant will give better results. two common materials used are plexiglas? and tempered window glass. plexiglas has a dielectric constant of 2.5-3.5, while window glass has a dielectric constant in the range of 4-8. more information on the topic of covering capacitive touch sensors can be found in an1102, ? layout and physical guidelines for capacitive sensing ?. noise susceptibility the existing noise, which affects capacitive touch appli- cations, should always be considered. the factors affecting how to protect against noise are very applica- tion-specific. the picdem touch sense 2 demo board, for example, is open on both the front and back. a hatched ground pattern was added to the back of the board wherever possible to minimize the effects of noise that could be introduced from the bottom of the board. the cross hatched pattern provides a good path to conduct unwanted noise to ground, and at the same time, it does not cause an appreciable increase in the capacitance of the touch sensors due to the coupling effect of the sensor pad through the pc board material to the ground plane. some applications may have a completely shielded enclosure which would allow for less ground plane added to the pc board. another consideration is the proximity of the capacitive touch sensors to other noise producing circuitry on the board, such as communication busses, inverting power supplies for back lighting dis- plays, rf radio transmitters such as those used for wi-fi or other radio based communications, and so on. in the case of a radio transmitter and capacitive touch sensors, it is best to read the buttons only when the rf transmitter is disabled.
? 2009 microchip technology inc. ds01250a-page 15 AN1250 appendix a: picdem? touch sense 2 demo board figure a-2 displays the picdem touch sense 2 demo board schematic with the cover plate removed. figure a-1: picdem? touch sense 2 demo board with cover removed
AN1250 ds01250a-page 16 ? 2009 microchip technology inc. figure a-2: picdem? touch sense 2 de mo board schematic (page 1 of 3) rd10 rd9 rd8 rd5 yel d49 d52 yel d16 orn rd1 yel d51 d53 yel d17 orn 470 r14 rd3 yel d55 470 r15 rd4 red d39 orn d43 d12 red d60 grn red d40 orn d44 d13 red d61 grn red d41 orn d46 grn d57 grn d59 grn d63 r31 47 d50 yel d54 yel yel d56 r17 47 r7 47 d47 orn d45 orn 470 r12 470 r13 rd2 47 r16 d15 red d58 grn d14 red red d42 orn d48 d62 grn grn d64 mc mc 0 4 7 * 5 8 + 6 9 = * / ms 1 2 3 - re7 re6 +/- re8 re5 470 r8 red d10 470 r5 red d7 470 r9 470 r3 re0 red d36 red d29 red d5 re1 red d35 red d30 red d4 re3 re4 47 r10 red d1 red d2 r1 47 470 r4 red d3 red d34 red d37 red d28 red d31 red d8 red d9 r2 47 47 r6 re2 red d33 red d32 red d6 +/- ms mr mc 0 1 4 7 . 2 5 8 btn_3 btn_2 btn_1 btn_0 + 3 6 9 = - * / s7 s1 s9 s3 s25 s26 s11 s4 btn_5 s12 s6 btn_6 s27 s28 s8 s21 s2 s22 s10 s5 s23 s24 btn_7 btn_4 btn_8 btn_9 btn_10 s14 slider
? 2009 microchip technology inc. ds01250a-page 17 AN1250 figure a-3: picdem? touch sense 2 de mo board schematic (page 2 of 3) re4 re3 re1 re0 rd7 rd5 rd4 rd12 rd3 rd1 btn_6 btn_7 btn_8 btn_9 btn_11 btn_12 btn_13 btn_15 btn_0 btn_2 btn_3 btn_5 re9 mclr buzz rg6 rc3 rc2 re7 re6 vbus d- d+ rd8 rd9 btn_1 re8 btn_4 rc1 rc4 re5 re2 .1 m f c13 +3.3v +3.3v +3.3v rd13 rd6 rd2 +3.3v osc2 rd10 btn_10 10 m f c3 btn_14 +3.3v +3.3v +3.3v .1 m f c1 +3.3v .1 m f c4 osc1 osc2 c9 22 pf c10 22 pf 8 mhz y1 .1 m f c2 .1 m f c5 .1 m f c7 .1 m f c6 +3.3v r41 10k 98 re2 31 avss 95 rg14 92 ra7 37 vdd 89 rg1 86 envreg 83 rd6 46 vdd 80 rd13 49 rf4 77 ta4d/rd2 28 vref-/ra9 34 an10/rb10 40 rf12 43 an14/rb14 23 an2/rb2 17 ra0 8 rc3 2 vdd 52 rf2 56 d-/rg3 62 vdd 65 vss 68 rd8 71 rd11 22 an3/rb3 24 an1/rb1 15 vss 16 vdd 18 re8 19 re9 13 mclr 9 rc4 6 rc1 7 rc2 1 rg15 30 avdd 96 rg12 97 rg13 99 re3 36 vss 90 rg0 91 ra6 93 re0 84 tc1/rd7 45 vss 78 ta5/rd3 79 rd12 81 pmpwr/rd4 53 rf8 54 vbus 55 vusb 57 d+/rg2 60 tdi/ra4 61 tdo/ra5 69 rd9 70 rd10 75 vss 27 an7/rb7 29 vref+/ra10 33 an9/rb9 35 an11/rb11 39 rf13 41 an12/rb12 42 an13/rb13 85 vcap/vddcore 87 tc7/vbuss/rf0 47 rd14 48 rd15 20 an5/sck1/rb5 14 pmpa2/rg9 11 pmpa4/rg7 5 sda3/pmpd7/re7 59 sda2/ra3 74 ta0/rc14 21 an4/sdo1/rb4 25 an0/sdi1/rb0 10 pmpa5/rg6 12 pmpa3/rg8 3 pmpd5/re5 4 scl3/pmpd6/re6 88 tc6/rf1 94 re1 100 re4 50 rf5 51 usbid 58 scl2/ra2 63 osc1/clki/rc12 64 osc2/clk0/rc15 66 scl1/ra14 67 sda1/ra15 72 int0/rd0 73 ta1/rc13 76 ta3/rd1 82 pmprd/rd5 26 an6/sck1/rb6 32 an8/rb8 38 tck/ra1 44 an15/rb15 +3.3v r25 nl +5v - + bz1 1k r24 pic24fj256gb110 u1
AN1250 ds01250a-page 18 ? 2009 microchip technology inc. figure a-4: picdem? touch sense 2 de mo board schematic (page 3 of 3) icspdat vss vpp no connect btn_7 btn_6 south rd6 southeast rd7 east rc1 rc2 nort h rc3 rc4 rd12 southwest rd13 vdd icspclk mra4003 d25 +5v pgm1 pgm2 +5v +3.3v 470 r20 nort he ast +3.3v 470 r21 tp4 +3.3v 470 r23 west +3.3v 470 r26 +3.3v 470 r27 +3.3v 470 r30 1 2 3 4 5 6 j1 pickit 2 r18 100 47 m f c14 47 m f c17 tp2 1 m f c26 d20 yel .1 m f c27 d23 grn d26 yel pgm2 gnd mclr optional (unpopulated) r e w o p r e t n e c hwest t r o n re9 rg6 pickit 2 program header for u1 pgm1 tp3 +9v 2 1 3 j4 pj-002b +3.3v +3.3v 470 r22 470 r19 +3.3v d18 mra4003 +3.3v +3.3v 470 r28 470 r32 c16 .1 m f c15 .1 m f 1 gnd 3 in 2 out lm1117imp-5.0ct-nd d21 grn d19 grn d22 yel 33 m f c18 1 gnd 3 in 2 out mcp1702t-3302e/cb d27 grn d65 yel d24 yel d38 red 219-2mst btn_12 btn_14 btn_11 btn_13 d- vbus d+ +5v mbr0520l d11 4 5 6 shield 1 vbus 2 d- 3 d+ j3 mini-b power btn_15 s20 pickit? 2 program header for u1 1 2 4 3
? 2009 microchip technology inc. ds01250a-page 19 AN1250 appendix b: oscilloscope trace figure b-1: oscilloscope trace of charging of cap sensor circuit 1 2 3 4 legend: 1. ctmu current source off. 2. adc conversion takes place. 3. discharge of capacitive sense circuit. 4. ctmu current source on. 1 2 3 4
AN1250 ds01250a-page 20 ? 2009 microchip technology inc. conclusion microchip?s ctmu-based capacitive touch solutions provide a reliable solution for the implementation of capacitive touch and require minimal external hard- ware. the ctmu unit is fast and software needed for operation is easy to set up, configure and integrate into any application requiring capacitive touch. references ? http://www.microchip.com/mtouch ? an1103, ? software handling for capacitive sensing ? ? an1102, ? layout and physical guidelines for capacitive sensing ? ?? picdem? touch sense 2 demo board user's guide? (ds51748) ? ?section 11. charge time measurement unit (ctmu)? in the ?pic24f family reference manual? (ds39724)
? 2009 microchip technology inc. ds01250a-page 21 information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. it is your responsibility to ensure that your application meets with your specifications. microchip makes no representations or warranties of any kind whether express or implied, written or oral, statutory or otherwise, related to the information, including but not limited to its condition, quality, performance, merchantability or fitness for purpose . microchip disclaims all liability arising from this information and its use. use of microchip devices in life support and/or safety applications is entirely at the buyer?s risk, and the buyer agrees to defend, indemnify and hold harmless microchip from any and all damages, claims, suits, or expenses resulting from such use. no licenses are conveyed, implicitly or otherwise, under any microchip intellectual property rights. trademarks the microchip name and logo, the microchip logo, accuron, dspic, k ee l oq , k ee l oq logo, mplab, pic, picmicro, picstart, rfpic, smartshunt and uni/o are registered trademarks of microchip tec hnology incorporated in the u.s.a. and other countries. filterlab, linear active thermistor, mxdev, mxlab, seeval, smartsensor and the embedded control solutions company are registered trademarks of microchip technology incorporated in the u.s.a. analog-for-the-digital age, appl ication maestro, codeguard, dspicdem, dspicdem.net, dspicworks, dsspeak, ecan, economonitor, fansense, in-circuit serial programming, icsp, icepic, mindi, miwi, mpasm, mplab certified logo, mplib, mplink, mtouch, pickit, picdem, picdem.net, pictail, pic 32 logo, powercal, powerinfo, powermate, powertool, real ice, rflab, select mode, total endurance, wiperlock and zena are trademarks of microchip technology incorporated in the u.s.a. and other countries. sqtp is a service mark of microchip technology incorporated in the u.s.a. all other trademarks mentioned herein are property of their respective companies. ? 2009, microchip technology incorporated, printed in the u.s.a., all rights reserved. printed on recycled paper. note the following details of the code protection feature on microchip devices: ? microchip products meet the specification cont ained in their particular microchip data sheet. ? microchip believes that its family of products is one of the most secure families of its kind on the market today, when used i n the intended manner and under normal conditions. ? there are dishonest and possibly illegal methods used to breach the code protection feature. all of these methods, to our knowledge, require using the microchip produc ts in a manner outside the operating specif ications contained in microchip?s data sheets. most likely, the person doing so is engaged in theft of intellectual property. ? microchip is willing to work with the customer who is concerned about the integrity of their code. ? neither microchip nor any other semiconduc tor manufacturer can guarantee the security of their code. code protection does not mean that we are guaranteeing the product as ?unbreakable.? code protection is constantly evolving. we at microchip are co mmitted to continuously improvin g the code protection features of our products. attempts to break microchip?s code protection feature may be a violation of the digital millennium copyright act. if such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that act. microchip received iso/ts-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona; gresham, oregon and design centers in california and india. the company?s quality system processes and procedures are for its pic ? mcus and dspic ? dscs, k ee l oq ? code hopping devices, serial eeproms, microperipherals, nonvolatile memory and analog products. in addition, microchip?s quality system for the design and manufacture of development systems is iso 9001:2000 certified.
ds01250a-page 22 ? 2009 microchip technology inc. americas corporate office 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7200 fax: 480-792-7277 technical support: http://support.microchip.com web address: www.microchip.com atlanta duluth, ga tel: 678-957-9614 fax: 678-957-1455 boston westborough, ma tel: 774-760-0087 fax: 774-760-0088 chicago itasca, il tel: 630-285-0071 fax: 630-285-0075 dallas addison, tx tel: 972-818-7423 fax: 972-818-2924 detroit farmington hills, mi tel: 248-538-2250 fax: 248-538-2260 kokomo kokomo, in tel: 765-864-8360 fax: 765-864-8387 los angeles mission viejo, ca tel: 949-462-9523 fax: 949-462-9608 santa clara santa clara, ca tel: 408-961-6444 fax: 408-961-6445 toronto mississauga, ontario, canada tel: 905-673-0699 fax: 905-673-6509 asia/pacific asia pacific office suites 3707-14, 37th floor tower 6, the gateway harbour city, kowloon hong kong tel: 852-2401-1200 fax: 852-2401-3431 australia - sydney tel: 61-2-9868-6733 fax: 61-2-9868-6755 china - beijing tel: 86-10-8528-2100 fax: 86-10-8528-2104 china - chengdu tel: 86-28-8665-5511 fax: 86-28-8665-7889 china - hong kong sar tel: 852-2401-1200 fax: 852-2401-3431 china - nanjing tel: 86-25-8473-2460 fax: 86-25-8473-2470 china - qingdao tel: 86-532-8502-7355 fax: 86-532-8502-7205 china - shanghai tel: 86-21-5407-5533 fax: 86-21-5407-5066 china - shenyang tel: 86-24-2334-2829 fax: 86-24-2334-2393 china - shenzhen tel: 86-755-8203-2660 fax: 86-755-8203-1760 china - wuhan tel: 86-27-5980-5300 fax: 86-27-5980-5118 china - xiamen tel: 86-592-2388138 fax: 86-592-2388130 china - xian tel: 86-29-8833-7252 fax: 86-29-8833-7256 china - zhuhai tel: 86-756-3210040 fax: 86-756-3210049 asia/pacific india - bangalore tel: 91-80-3090-4444 fax: 91-80-3090-4080 india - new delhi tel: 91-11-4160-8631 fax: 91-11-4160-8632 india - pune tel: 91-20-2566-1512 fax: 91-20-2566-1513 japan - yokohama tel: 81-45-471- 6166 fax: 81-45-471-6122 korea - daegu tel: 82-53-744-4301 fax: 82-53-744-4302 korea - seoul tel: 82-2-554-7200 fax: 82-2-558-5932 or 82-2-558-5934 malaysia - kuala lumpur tel: 60-3-6201-9857 fax: 60-3-6201-9859 malaysia - penang tel: 60-4-227-8870 fax: 60-4-227-4068 philippines - manila tel: 63-2-634-9065 fax: 63-2-634-9069 singapore tel: 65-6334-8870 fax: 65-6334-8850 taiwan - hsin chu tel: 886-3-572-9526 fax: 886-3-572-6459 taiwan - kaohsiung tel: 886-7-536-4818 fax: 886-7-536-4803 taiwan - taipei tel: 886-2-2500-6610 fax: 886-2-2508-0102 thailand - bangkok tel: 66-2-694-1351 fax: 66-2-694-1350 europe austria - wels tel: 43-7242-2244-39 fax: 43-7242-2244-393 denmark - copenhagen tel: 45-4450-2828 fax: 45-4485-2829 france - paris tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany - munich tel: 49-89-627-144-0 fax: 49-89-627-144-44 italy - milan tel: 39-0331-742611 fax: 39-0331-466781 netherlands - drunen tel: 31-416-690399 fax: 31-416-690340 spain - madrid tel: 34-91-708-08-90 fax: 34-91-708-08-91 uk - wokingham tel: 44-118-921-5869 fax: 44-118-921-5820 w orldwide s ales and s ervice 01/16/09


▲Up To Search▲   

 
Price & Availability of AN1250

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X