This week we learned about electronic input devices. These systems span a broad range of technologies, from cheap and tiny resistance-based temperature sensors to expensive and large gas analyzers. The class focused on the simpler side of sensors we could realistically integrate into our final projects, such as phototransistors, RTDs, and low-resolution cameras. Of particular interest to the class were step response sensors that rely on sensitive capacitance measurements to reflect many different physical phenomena. Our assignment this week was twofold: first, probe an input device's analog levels and digital signals as a group; and second, add a sensor to a microcontroller board we designed, and read its output.
Aubrey and I decided to take a closer look at capacitive touch plates, as he intends to use a number of these sensors for his final project and I am generally fascinated by the method. We started with an STM32F412 Nucleo board since I had a few on hand. The setup is quite simple: an open GPIO line is tied to the touch plate and the pin is periodically flipped from low to high and back again, generating a square wave:
The oscilloscope probe allows one to view the waveform as it changes according to external effects. This clip shows the waveform rise time stretching out when one touches the plate; this happens because the user increases the pin's capacitance to ground, so the circuit's RC time constant goes up:
Using the oscilloscope's measurement functions, we averaged rise time over a number of samples, first with nothing touching the plate:
... and then with a hand on the plate, demonstrating a 27% increase in rise time from 9.87 ns to 12.52 ns:
One may not want to integrate an expensive and bulky oscilloscope into their project; in most touch sensor implementations, the designer uses another GPIO pin to watch the first. An analog comparator tied to a timer can determine the precise moment the pin voltage crosses a given point, or the ADC can be used to directly sample the waveform so the exact cutoff curve can be selected as needed for the application. Choosing which method to use depends on microcontroller speed, program development overhead, and application requirements.