Design Article
Basics and implementation of capacitive proximity sensing (Part 2 of 2)
Ganesh Raaja, Cypress Semiconductor Corp.
9/11/2008 12:00 PM EDT
Building a Proximity Sensor
Now that we have discussed the theory about the sigma-delta modulator, let us design a simple proximity sensor that will detect an approaching hand and switch on an LED. A 0.5 mm2 wire, 10 cm long, is chosen as a sensor.
Figure 7 shows the schematic of a proximity sensor circuit built using the CY8C21434 mixed-signal array from Cypress Semiconductor. The resolution of the sigma-delta modulator is set to 14. CINT and Rdis are the only external components required for the sigma-delta modulator.

Figure 7: Proximity-detector circuit
(Click on image to enlarge)
The DEBUG connector is used to read the sensor data through an I2C slave interface and display the data using a PC GUI.
Firmware
Firmware for the proximity detector will depend on the processor and platform. Figure 8 shows the basic flow of the firmware.

Figure 8: Firmware logic
The count value from the sigma-delta modulator is passed through an IIR filter to form a reference count called Baseline. By selecting the filter response of the IIR filter, high-frequency noise on the instantaneous counts are rejected, but slow changes caused by temperature, humidity, and other factors are tracked. If the difference between the instantaneous count and the baseline exceeds a threshold, the firmware reports proximity. Figure 9 is the C code for the above flowchart.

Figure 9: C code example
(Click on image to enlarge)
Following are the functions that are processor-specific.
- ReadCSD: This function reads the instantaneous count from the Sigma Delta Modulator.
- LowPassFilter: This function implements a software IIR filter. It takes an unsigned integer value, passes it through the filter, and returns the result.
- LED_On and LED_Off: These functions turn On or Off the LED.
- Debug_DumpData: This function dumps the sensor data to the external debug port through I2C, RS232, etc.
This is the most important stage of the development. Using the debug port and a PC GUI, display the Instantaneous counts, Baseline and Difference counts from the sensor. Perform the following steps:
1. Adjust Rdis and set the instantaneous counts to 80% of the full scale counts of the converter.
2. Bring the hand to the desired detection range near the sensor.
3. Observe the difference count value.
4. In the firmware, set the THRESHOLD value to about 80% of the observed difference count.
5. The HYSTERISIS value in the firmware should be set in such a way that noise in the system does not create oscillations in the output. A few counts more than the noise level should work fine.
We now have a proximity sensor. Watch the LED being turned ON and OFF as you bring your hand near and away from the sensor. Proximity sensing can be used in a number of interesting ways:
- Switching On an optical mouse when hand approaches
- Switching On the backlight in a control panel when hand approaches
- Switching On the light in a microwave oven when the hand approaches
- Keyless entry in automobiles
- Stopping the window of a car when a hand gets trapped
- Stopping a rolling shutter when someone is standing below it.
About the author
Ganesh Raaja of Cypress Semiconductor Corp. received his degree in Electronics and Communication Engineering from Motilal Nehru Government Polytechnic, Pondicherry. His expertise lies in developing with analog circuits, embedded systems, designing PCBs, and working with Assembly and C.
References
1. Capacitive Sensors, Larry K. Baxter, IEEE Press, ISBN: 0-7803-5351-X (Chapter 2: Equation for capacitance of a Cylinder to a Plane, Chapter 6: Proximity sensor basics)
2. Fundamentals of Physics, J. Walker, E-book (Chapter 26: Capacitance and Dielectrics, Equation for Capacitance of sphere to infinity, Equation for Capacitance of parallel plate capacitance)
3. Engineering Electromagnetics, William Hayt, E-book, McGraw Hill Series (Chapter 5.10: Capacitance Examples)
Related articles of interest
1. Using capacitive sensor user interfaces in next generation mobile and embedded consumer devices,Mariel Van Tatenhove and Andrew Hsu, Synaptics, Inc.
2. Designer's guide to rapid prototyping of capacitive sensors on any surface, Mark Lee, Cypress Semiconductor Corp.
3. Capacitive sensors can replace mechanical switches for touch control, Wayne Palmer, Analog Devices Inc.
4. Building a reliable capacitive-sensor interface, Wayne Palmer, Analog Devices, Inc.
5. The art of capacitive touch sensing, Mark Lee, Cypress Semiconductor Corp.
6. Practical considerations for capacitive touchscreen system design (Part 1 of 2), Yi Hang Wang, Cypress Semiconductor Corp.



