The framework is designed to output a synchronous signal on another pin to help maximize the sensitivity of the mTouch sensors. A guard ring is most effective when it encloses a sensor and shields it from any nearby communication traces, power planes (including ground), antennas, or other noise sources. The theory is that we want to decrease the voltage differential between the capacitive sensor and its environment.
Guard rings (or shields) are driven by an I/O or the DACOUT pin to minimize the amount of parasitic capacitance on the sensor. Parasitic capacitance will cause the field lines of the sensor to be distorted - pulling them down and decreasing the amount of sensitivity. With the guard ring, however, the sensor will be shielded from this effect.
Sensor Field Lines with and without a Guard Ring
There are two possible ways to implement the guard ring.
Two Guard Options and Their Behaviors
To implement the blue line (maximum sensitivity gain), the DACOUT pin must be connected to the guard ring on your board. This is the easiest and most fine-tunable of the two options.
#define CVD_GUARD_DACOUT_ENABLED #define CVD_GUARD_DACCON0_A PIC_DACOUT_DACCON0_HALF_VDD // Pre-defined value to set '1/2 VDD' #define CVD_GUARD_DACCON1_A PIC_DACOUT_DACCON1_HALF_VDD // Pre-defined value to set '1/2 VDD' #define CVD_GUARD_DACCON0_B PIC_DACOUT_DACCON0_HALF_VDD // Pre-defined value to set '1/2 VDD' #define CVD_GUARD_DACCON1_B PIC_DACOUT_DACCON1_HALF_VDD // Pre-defined value to set '1/2 VDD'
To implement the red line, any I/O pin may be used. A large amount of series resistance should be added to the pin to lower the rise/fall time of the pin. The closer the rise/fall time of the I/O is able to match the rise/fall of the mTouch sensor, the better the result. Good typical starting value: 100K-200K ohms.
#define CVD_GUARD_IO_ENABLED #define CVD_GUARD_PORT LATA // <-- Guard ring is connected to RA2 / LATA2 #define CVD_GUARD_PIN 2