Arduino capacitive sensor and the friction drum

I recently cut out a capacitive sensor on my old CNC machine for a friend working at the university. They plan to connect the sensor to Raspberry PI and try to make a virtual friction drum.

CNC machined capacitive sensor pcb

CNC machined capacitive sensor pcb

The sensor is pretty simple – it’s made of several rectangular copper sensing planes which are connected to wires. I drew the cut lines directly in CamBam and used the gcode on the CNC mill to cut it out. The main issue of the home-made capacitive sensors is that you will need to solder some connecting wires to the capacitive sensing plates, which may in some applications interfere with the use of sensor. On a doublesided PCB the connection tracks could be routed on the back side of the sensor and the sensor PCB would have no “soldering bumps”. Another issue is that there is no stop mask which would prevent the user to touch the sensing elements directly, but this can be easily remedied by covering the sensing PCB with some sort of isolating material or by painting it. If you make an actual electric contact with a capacitive sensor (eg. touching the sensing plate directly, with no isolator) it will usually perform badly, especially in sensor with multiple sensing elements.

This version of the sensor will be used for a proof-of-concept work and will probably be replaced by professionally made PCB later. Also the layout of sensing areas will probably be changed to a V / zigzag pattern to increase the linearity of position sensing between two adjacent sensing areas. For some nice capacitive sensor layouts you can check this link – it’s actually a manual for software which generates the layouts, but you can check out the images. If you are interested in these designs you should probably also check the original atmel papers on them.

Altium Atmel Capacitive Sensor Components

Altium Atmel capacitive sensor components (examples)

As I was going to deliver the sensor the next day I didn’t have time to try connecting it to RPi, however I did connect it to arduino to see how it performs.

Before jumping to the arduino code just a quick look at how the capacitive sensing libraries work. Capacitive sensor is basically a variable capacitor. When a conductive object – like a person’s finger comes near sensor, the capacitance gets higher. The libraries used here charge / discharge the capacitor through a large resistor and measure the time it takes to charge / discharge a capacitor to a certain level. The time constant is related to the capacitance – the larger the capacitance, the longer it will take to charge to a certain level.

2015-04-30 16_53_04-LTspice IV - capsense.raw

LTSpice window with capacitive sensor simulation circuit

Here you can see a simulation of a charge / discharge cycle of a few different values of capacitors. Capacitors of 100-300 pF are connected through 10meg resistors. Cyan graph is the input voltage, red (100p), green (200p) and blue (300p) graphs are the voltages on capacitors. It can easily be observed that the bigger the capacitor the longer it takes to charge to a specified value (eg. to 2.5V).

Note that there are also many other ways to measure small capacitances (eg. charge distribution, capacitance to frequency conversion, different bridge implementations), which may be better under some circumstances.

 

There are basically two available capacitive sensing libraries for arduino.

http://playground.arduino.cc/Code/CapacitiveSensor

and

http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense

The first one is “nice” as it uses internal resistors (weak pullup resistors) to do the measuring, which means that there is no external resistors needed for operation – you simply connect the sensing pads to the arduino pins. I quickly edited the code to display multiple inputs.

Sensing pads were connected directly to pins 8-12 on arduino.

IMG_20150418_095804572[1]

Capacitive sensor connected to Arduino UNO

Sensing board was covered with thin transparency film to avoid direct contact with the pins. The resolution however is quite terrible, I only got a few values of change when I pressed against sensing pads.

2015-04-18 10_00_39-COM7

Arduino output

Here you can see the terminal window of arduino showing the measured values. The last five number in each row are displaying the returned value of each capacitive sensor. The middle capacitive sensing pad is touched for the result on the image. You can get a much more pronounced response if you directly touch the sensing pads, but the results are not really usable as also the neighbouring pads will change value…

Next I  modded the capsense example

And breadboarded the resistors needed for the library:

IMG_20150418_101131320[1]

Capacitive sensor with resistors connected to Arduino UNO

Capacitive sensors are connected to arduino pins 8-12, pin 4 is used for excitation. Resistors are connected between pin 4 and each of the sensing pads. 4,7M resistors were used. This library gives much better resolution in terms of value change when an object is near the sensor. You can influence the resolution by substituting resistors with bigger (more resolution) or smaller values (less resolution). It should also be noted that it takes a bit longer to get the result with better resolution.

The next day after testing I delivered the sensor to the lab, so hopefully it will be of some use for them. I will post here if I get some interesting feedback from them, so stay tuned 😉

Tagged with: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*