I have been working with some capacitive strain sensors and would like to adjust the touch.c file to get higher sensitivity in my ranges of interest. In some previous posts, adjusting parameters in touch.c in accordance with the parameters given in the k20 reference documentation, at: https://www.nxp.com/docs/en/reference-manual/K20P64M72SF1RM.pdf is recommended as an option. However I am somewhat going in circles with exactly how changing specific values will effect sensitivity output as the numbers I have plugged in are not matching up to the notes in touch.c file.
In touch.c comments, it is mentioned that default settings give approx 0.02 pF sensitivity and 1200 pF range, and that time to measure 33 pF is approx 0.25 ms and time to measure 1000 pF is approx 4.5 ms, and output is about 50*C_elec pF.
Looking at the spec sheet for k20, I understand the following values to be 'fixed':
deltaV=500mV
cRef=1pF
The following values can be adjusted in touch.c in order to change speed, sensitivity and range:
#define CURRENT 2 // 0 to 15 - current to use, value is 2*(current+1)
#define NSCAN 9 // number of times to scan, 0 to 31, value is nscan+1
#define PRESCALE 2 // prescaler, 0 to 7 - value is 2^(prescaler+1)
I noticed that Iref could also be modified by changing value in TSI0_SCANC = TSI_SCANC_REFCHRG(3) , but I assume you hard coded it for a reason.
When I plug the default values into the formula from the K20 reference documents, I am not getting the values you list in touch.c comments:
Time=2*PRESCALE*NSCN*C_electrode*deltaV/CURRENT=2*2^(2+1)*C_electrode*1*500/(2*(2+1)
Time(33pF)= .33 ms, time(1000 pF)=13.3 ms
Sensitivity=cRef*CURRENT/(Iref*PRESCALE*NSCAN)=1*2*(2+1)/(8*2^(2+1)*10)=0.0125pF
Output = Iref*PRESCALE*NSCN*C_elec/(cRef*Ielec)=C_elec*8*2^(2+1)*10/(1*2^(3+1))=80*C_elec pF
Given how far these numbers are from the ones listed in comments, I wanted to make sure I actually understand how these formula work before I start modifying the touch.c file.
In touch.c comments, it is mentioned that default settings give approx 0.02 pF sensitivity and 1200 pF range, and that time to measure 33 pF is approx 0.25 ms and time to measure 1000 pF is approx 4.5 ms, and output is about 50*C_elec pF.
Looking at the spec sheet for k20, I understand the following values to be 'fixed':
deltaV=500mV
cRef=1pF
The following values can be adjusted in touch.c in order to change speed, sensitivity and range:
#define CURRENT 2 // 0 to 15 - current to use, value is 2*(current+1)
#define NSCAN 9 // number of times to scan, 0 to 31, value is nscan+1
#define PRESCALE 2 // prescaler, 0 to 7 - value is 2^(prescaler+1)
I noticed that Iref could also be modified by changing value in TSI0_SCANC = TSI_SCANC_REFCHRG(3) , but I assume you hard coded it for a reason.
When I plug the default values into the formula from the K20 reference documents, I am not getting the values you list in touch.c comments:
Time=2*PRESCALE*NSCN*C_electrode*deltaV/CURRENT=2*2^(2+1)*C_electrode*1*500/(2*(2+1)
Time(33pF)= .33 ms, time(1000 pF)=13.3 ms
Sensitivity=cRef*CURRENT/(Iref*PRESCALE*NSCAN)=1*2*(2+1)/(8*2^(2+1)*10)=0.0125pF
Output = Iref*PRESCALE*NSCN*C_elec/(cRef*Ielec)=C_elec*8*2^(2+1)*10/(1*2^(3+1))=80*C_elec pF
Given how far these numbers are from the ones listed in comments, I wanted to make sure I actually understand how these formula work before I start modifying the touch.c file.