Baseline getting stuck

Question: Why does the CapSense button always remain in ON state ?

 

Answer:

 

One of the reason for CapSense buttons to always remain in ON state is the sticking of baseline to a particular value (observed with the CSD_waSnsBaseline array which contains the baseline value for each sensor).

 The baseline is basically equivalent to the average raw counts value when there is no finger present and acts as a reference for detecting finger presses. In PSoC devices, it is calculated using the “Bucket Algorithm” for every sensor. The algorithm used to calculate the same is as explained below:

  1.   On power up, baseline is initialized to the current raw count value (Assuming that the finger is not present).
  2.   If the raw counts are lesser than the baseline value but within the negative noise threshold, the baseline immediately updates to the current raw count value.
  3.   If the raw counts are lesser than the baseline and the difference is greater than the negative noise threshold, the baseline is updated only if the same behavior is observed for a no. of times equal to the low baseline reset parameter.
  4.   If the raw counts are greater than the baseline but within the positive noise threshold, the baseline immediately updates.
  5.   If the raw counts are greater than the baseline by an amount greater than the positive noise threshold, the baseline does not update.

Thus, the algorithm used to calculate the baseline value is such that the baseline always follows the raw counts if they are lesser than the baseline but if the raw counts are greater than the baseline, the baseline is updated only if the difference is lesser than the positive noise threshold (sensor auto-reset disabled). Hence, if there is a sudden change in the raw counts due to any supply transients or sudden change in temperature or noise etc. and makes the difference between the baseline value and raw counts to be greater than the positive noise threshold, the baseline may get stuck at a particular count. This condition can be addressed in following ways:

  1.   Proper selection of the “NegativeNoiseThreshold” and “LowBaselineReset” parameters such that frequent transients do not alter the baseline.
  2.   Enabling auto reset. However, this setting limits the maximum ON time duration of the sensor.
  3.   Addressing the cause of transients such as power supply variations or switching noise in nearby traces.
  4.   Re-initializing the baseline in the firmware using CSD_InitializeSensorBaseline() API.

Also, large rise time of the power supply may be another reason of the baseline to get stuck during power up. This happens if Vdd has not reached its required value when the baseline is first initialized, since in this case, due to lesser Vdd, the raw counts value is low. However, when the same sensor is scanned again after scanning all other sensors, the Vdd may have reached its required value. This time, the raw counts will be higher (even higher than the noise threshold). In this case, the baseline will get stuck. This can be addressed by giving a certain delay in the firmware (at power up) before initializing the baseline.