This page provides information on computing sensor capacitance values using the Compensation Capacitor (CC) value. The CC value is also called the CC calibration value as it is computed during the calibration phase. The CC value of each touch button can be obtained as follows:
uint16_t cc_value = ptc_qtlib_node_stat1[SENSOR_NUMBER].node_comp_caps;
The unsigned 16-bit CC values are stored as node_comp_caps in Peripheral Touch Controller (PTC) CC register format.
PTC CC Register Format
Depending on the device, the CC register format changes.
CC Register Bit Values
Computing Sensor Capacitance
SAMD20/SAMD21/SAMDA1/SAMD10/SAMD11, ATmega328PB/ATmega324PB, SAML21/SAML22/SAMC20/SAMC21/SAMHA1 Devices
- Read CC value in decimal: 11639
- Read CC value in hexadecimal: 0x2D77
- Substitute the rough, coarse, fine and accurate values from the table
- Rough: 2*6.75 = 13.5
- Coarse: 13*0.675 = 8.775
- Fine: 7*0.0675 = 0.4725
- Accurate: 7*0.01 = 0.07
Sensor Capacitance (pF) = Rough + Coarse + Fine + Accurate = 22.82 pF (maximum 31 pF)
ATtiny81x/ATtiny161x/ATtiny321x - Self-Capacitance
- Read CC value in decimal: 46967
- Read CC value in hexadecimal: 0xB777
- Substitute the rough, coarse, fine and accurate values from the table
- Rough Addition: 2*6.2 = 12.4
- Rough: 3*6.75 = 20.25
- Coarse: 7*0.675 = 4.725
- Fine: 7*0.0675 = 0.4725
- Accurate: 7*0.01 = 0.07
Sensor Capacitance (pF) = Rough Addition + Rough + Coarse + Fine + Accurate = 37.92 pF (maximum 51 pF)
AVRDA
Self-Capacitance
Sensor Capacitance value = (CC value + 1) * 0.03125 * 2
Mutual Capacitance
Sensor Capacitance value = (CC value + 1) * 0.03125
SAME54/SAME53/SAME51/SAMD51/SAML10/SAML11 - Maximum Sensor Capacitance
Self-Capacitance
Here, the internal compensation capacitance can compensate twice the sensor capacitance.
The maximum supported sensor capacitance is twice the maximum compensation capacitance value (2 * 32 pF).
So, if computed capacitance from CC is 10 pF, then actual sensor capacitance is 20 pF.
Mutual Capacitance
The maximum sensor capacitance is the same as the maximum compensation capacitance value, which is 32 pF.
PIC32CZCA
The compensation capacitance values for PIC32CZCA are calculated as "(((X & 0x1F)+1)*0.075)+(((X » 8) & 0x1F)*1.5)" for mutual capacitance technology and for self-capacitance, the value is multiplied by 2.
Mutual Capacitance
- Read CC value in decimal: 2568
- Read CC value in hexadecimal: 0x0A08
- Calculate the coarse and fine values
- Coarse: A*1.5pF = 15pF
- Fine: (8+1)*75fF = 0.675pF
- Sensor Capacitance (pF) = Coarse + Fine = 15.675 pF (maximum 48.9pF )
Self-Capacitance
- Sensor Capacitance (pF) = (Coarse + Fine) * 2= 31.35 pF (maximum 97.8pF )