Experiment #8: Comparison of different sensor pin capacitors

The Capacitive Sensing Library article on the Arduino Playground suggests placing a capacitor of around 100pF between the sensor pin and “ground” to improve stability and repeatablity. This experiment tests various capacitor values, connected as recommended in the article.

I've placed “ground” in quotes because I'm, unsure whether this means the capacitor should be connected to the circuit's 0V ground or to the physical earth. In my test circuits I've taken the former approach. Connecting to earth isn't straightforward using the breadboard rig I have been using.

Methodology

Four capacitor values were chosen for testing: 10pF, 56pF, 100pF and 1nF. The grounded sensor from experiment #7 was reused. A circuit without a capacitor was used as a control.

For each capacitor, and the control circuit, the right hand index finger was tapped on the sensor in a pattern of three long taps followed by three short taps. The resulting sensor readings were written to an Arduino Uno’s serial port and captured to text files using CoolTerm.

The experiment was performed using the CapacitiveSensor library at both 25 and 50 samples per reading.

Circuit

The control circuit was the same as that used with the grounded sensor in experiment #7. The circuit was adapted to test capacitors by connecting the required capacitor between the Uno’s sensor pin (pin 3) and ground. Each capacitor being tested was swapped into the circuit as required. All capacitors were ceramic.

The following circuit diagram gives a representation of how the capacitors were connected. It also represents how the circuit with no capacitor was configured:

Circuit diagram for experiment #8

The next two images are photos of the circuit as built on a breadboard, coupled to an Elegoo Uno and grounded sensor 9G. The 1st photo shows the circuit with one of the capacitors in situ, while the second photo shows the control circuit with no capacitor connected.

Photo of breadboard circuit, with capacitor

Photo of breadboard circuit, without capacitor

Code

Again the GuidedSensorTouchDataLogger Arduino sketch was used. The code takes repeated sensor readings using the CapacitiveSensor library and reports the results over the Arduino’s serial port. The sketch also indicates when the user should touch the sensor, by means of tones emitted though a speaker or buzzer.

This sketch requires that the SAMPLES define is set to the number of samples per reading required. The default value is 25.

Results

The contents of the text files containing results for all readings were analysed in a Libre Office Calc spreadsheet. Results were tabulated in two different ways. Firstly, the sensor readings for all capacitors (and none) were grouped by sample rate, analysed and graphed. Secondly, the results for each sample rate were grouped by capacitor (or none) and again analysed and graphed.

As in several earlier experiments, the following statistics were calculated:

  1. The maximum reading
  2. The average of all readings
  3. The lower average, i.e. the average of the lower readings, where “lower” is taken to be values between 0 and the average of all readings, inclusive.
  4. The upper average, i.e. the average of the higher readings, where “upper” is taken to be values greater than the average of all readings.

To see all the data, the analysis and the graphs you can download the spreadsheet (zipped).

Comparison of capacitors to each other

The following image carousel shows two graphs, one for each sample rate, that show the performance of each capacitor and for the control circuit. The y-axis shows the sensor readings while the x-axis is the number of readings taken:

The next image carousel also contains an image for each sample rate, but this time plots the maximum, average, lower average and upper average readings for each capacitor value and for the control circuit. The y-axis is the sensor reading while the different capacitors and the control are represented on the x-axis:

Comparison of samples per reading for each capacitor

The following image carousel shows five graphs, one graph for each of the four capacitor values and one for the control circuit. The graphs compare the readings at the two different sample rates. The y-axis shows the sensor readings while the x-axis is the number of readings taken:

Conclusions

  1. All circuits with capacitors responded more slowly than the control, with responsiveness reducing with increasing capacitance. The circuit with the 1nF capacitor responded so slowly as to be useless.
  2. At 50 samples per reading, no capacitors showed results that were smoother than those of the control circuit. Results were less smooth the higher the capacitance.
  3. At 25 samples per reading, only the 20pF and 56pF capacitors appeared to give smoother results than the control, while the 100pF and 1nF capacitors gave less smooth results.
  4. All capacitors, with the exception of the 1nF capacitor, had similar maximum, minimum, lower average and upper average readings to the control. The 1nF capacitor had much higher readings all round, with even the lower average reading being higher than the control’s maximum reading.
  5. Other than the 1nF capacitor all capacitors had comparible minimum readings to the control. The 1nF capacitor had very unstable lower readings, some of which were higher than the control’s maximum readings.

Overall, the improved stability noted in the article referenced above was not observed, except in the case of the 10pF and 56pF capacitors at 25 samples per reading. Perhaps the results described in the article were based on a smaller number of samples per reading? Or perhaps the capacitor was connected to earth?

If a sample rate of 50 samples per second is chosen for the instrument then there seems to be no benefit in connecting a capacitor between the sensor pins and ground.

However, should 25 samples per reading be adopted then there may be some benefit in using a 10pF capacitor, or a 56pF capacitor if the slow down in sampling rate is acceptable.