Pseudo-differential sampling
Some methods to measure capacitance support a so called pseudo-differential sampling, which can help reduce noise.
The idea behind pseudo-differential sampling is that two samples are taken. The first sample is taken using normal polarity and the second sample is taken with reversed polarity. In the presence of a additive noise source with low bandwidth, the noise can be (partially) cancelled out by subtracting the two samples (low bandwidth in this case means that the instantaneous noise does not change significantly from one sample to the next).
This might be best explained with an example for pseudo-differential resistive sampling. Consider therefore the following schematic, where we want to measure the resistance of resistor by measuring the voltage at node x. The value of the reference resistor and the supply voltage are known.
The voltage at is then:
where is noise from an additive noise source.
From this, we can estimate the value of with
If instead of powering this circuit with a fixed source and a fixed ground, we would power the circuit with 2 GPIO pins from a microcontroller (for eample pins 2 and 3 of an Arduino), we can take 2 measurements and combine them as one which has lower noise than any of the two measurements individually.
Assume a circuit as shown below where the top of is connected to pin 2 and the bottom of is connected to pin 3.
By setting pin 2 as output and high, and pin 3 as output and low, we effectively create the circuit as shown on the top of this page. Hence, the measurement of can be estimated with the formula of as shown above.
However, we can also take a second measurement with the polarity of the pins reversed: pin 2 becomes output and low and pin 3 becomes output and high. In that case, the top of would be connected to ground and the bottom of would be connected to . The measured voltage would then be
and the value of can be estimated with
We can now use the property to rewrite the estimate as
If the noise source now has a limited bandwidth (), the noise term for approximates opposite of the noise term of and thus we can remove the noise by averaging both measurements:
Therefore, if the bandwidth of the noise source is much lower than the sample frequency, taking two measurements with opposite polarities and combining them can significantly reduce the noise.
Note that pseudo-differential measurement is not always possible. At the moment
pseudo-differential measurement (sampleTypeDifferential
) is only implemented
for the CVD method; any other sample methods in TouchLib (including the
resistive sample method) only support normal (sampleTypeNormal
).