Microchip offers two capacitive touch Sensing Solutions, one for the edging oscillator mode, that is, by detecting the frequency change of the touch sensing capacitor charge and discharge, to detect if there is a key press, according to the microcontroller integrated hardware resources, the other through Microchip microcontroller integrated on-chip charging time detection unit (CTMU) implementation.
This article refers to address: http://www.eepw.com.cn/article/96101.htm
Simple RC Oscillation Mode
This method is more suitable for a key case, through the integration of analog comparator pic10f204 or pic10f206 to achieve touch sensing function, the use of hardware resources for analog comparators and Timer0 timers. Figure 1 is the circuit diagram, when power on, the touch induction capacitor CP is not charged, the comparator output is high, through the D1 to the capacitor quickly charged to near Vdd, then the comparator flip, output low level, CP through R1 Discharge, Until it is below the internal reference voltage of 0.6V, the comparator flips the output high and enters the next oscillation cycle. The comparator output is sent to Timer0, as the time base, after a fixed delay of the software, read out the value of the TIMER0, you can calculate the comparator output frequency. When the finger touches the key, the capacitance value changes, the comparator output frequency changes, the readout of the value of the TIMER0 changes, thus detecting a touch action.
Comparator mode with SR latch
The pic16f61x, pic16f690, and pic16f88x series of internal analog comparators are available with the SR latch function, with Timer0 and Timer1 for easy touch sensing detection. This type of device can directly support 4-way touch sensing detection without external analog channel expansion.
2, the CS means touch sensing to the ground capacitance, touch sensing directly with the microcontroller on-chip comparator inverting input connection, comparator C1 using internal about 2/3VDD as a reference voltage, C2 using external resistor divider, to obtain 1/4VDD voltage. When power-on, the voltage on CS is 0,c2 output for the 1,C1 output is the 0,SR latch inverting end output of 1, through the resistor to the CS charge, when the CS voltage exceeds the 1/4VDD,C2 output for the 0,SR latch to maintain the original output state. When the CS charge exceeds 2/3VDD, the output of the C1 output for the 1,SR latch inverting end outputs from 1 to 0,cs through the resistor discharge, when the CS discharge voltage is lower than 2/3VDD, the C1 output for the 0,SR latch to maintain the original output state. When the CS discharge voltage is lower than 1/4VDD, the output of the C2 output to the 1,SR latch is 1, and the CS is charged by the resistor to start a new cycle. So the CS repeatedly charge and discharge, the capacitance voltage is Sawtooth wave, the SR latch output is the same frequency square wave.
When there is a touch, CS becomes larger, changes the time constant of the RC circuit, and the square wave frequency of the SR latch output changes. Send the SR latch output square wave signal to the Timer1 as the time base, each time the Timer0 overflow interrupt, interrupt program reads the value of the Timer1 register is the corresponding frequency, whether the frequency change is to indicate whether there is touch action.
Capacitive Sensing module (CSM) mode
The PIC16F72X series integrates the CSM, which has a constant pull-sink current capability to directly drive capacitive loads (PCB pads), a triangular wave that forms a continuous oscillation on the touch-sensitive capacitance, a CSM output with a square wave of the same frequency, and a square wave signal that can be supplied to the TIMER0 or Timer1, The corresponding count value is read by Timer2 interrupt, which means the corresponding frequency. The circuit is simple enough to connect the pads directly to the corresponding pins of the CSM input.
Touch sensing technology based on microchip single chip microcomputer