CURRENT ISSUE

Contests

bottom corner

FROM THE BENCH



Issue #213 April 2008

Digital Touch
A Potentiometer with No Moving Parts
by Jeff Bachiochi

Start | Touch Slider IC | Digital Potentiometers | Control and Feedback | Value to Digits | Linear Segmentation | Worth It | Sources & PDF

CONTROL AND FEEDBACK

One advantage of using a mechanical potentiometer is that the knob or slider position gives you feedback about the present position of the control. Once you remove your finger from the touch control, you have no feedback about where the control is set. This could be presented in a number of ways with LEDs. You can put a row of LEDs along the touch area to give some kind of feedback or present the user with a number representing the potentiometer’s position. I chose the latter, because I can make this value represent various data. For instance, I might want to show a percentage (0 to 100%) or the actual binary data from the QSlide.

I have an inexpensive four-digit seven-segment display that will give three digits with a spare that I might use to present a minus sign (more on that later). The display requires eight row and four column connections. With a Microchip Technology PIC16F882 microcontroller, I can source eight segments (rows) directly, as long as I multiplex the digits using a (column) transistor that will support the current of eight (potential) segments. My prototype has the display mounted on the touch side of the PCB. I now realize that the cool factor would be increased if the display was on its own PCB and mounted on the component side of the PCB, flush with the top (component-less) touch side. Although it is a bit more expensive, the cost of an extra PCB, it would enable the graphic label to cover the top side of the PCB, with a transparent window for the display.

The timing for multiplexing the digits is based on persistence of vision. Note that 60-Hz AC lighting is continuously going off and on but it happens faster than your eye can respond. If it happens too slowly, you begin to see a very distracting flicker. To prevent this with the seven-segment display, each digit is enabled at a rate above this minimum. Many video gamers consider 30 frames per second (fps) to be an absolute minimum. This project uses an internal 2-MHz oscillator giving a 2-µs instruction cycle. Configuring Timer0 to use a divide-by-eight prescaler, the 8-bit timer will overflow about every 4 ms or 4,096 µs (i.e., 2 µs × 8 × 256). Therefore, Timer0 will cause an interrupt every 4 ms. The interrupt deselects the present digit, gets the next digit’s data, and enables the new digit. Because there are four digits in this system, each digit is flashed for 4 ms out of every 16 ms. That’s a refresh rate of 62.5 Hz (0.0625 ms = 62.5 Hz). Take a look at the flowchart for this application in Figure 4.

The main routine of this application waits for a 64-ms flag to be set (by the display routine). It then looks for an indication of touch from the QT411. If no touch is sensed (QT411Reply.7 = 0), the application checks the configuration jumper settings for auto-zero. Auto-zero initializes the P0Value to “zero” (or 0x40, mid-scale for zero-centered output) whenever the touch detection is removed. Otherwise, the P0Value equals the actual touch value (0x00–0x7F).

The Percentage routine checks the configuration jumper settings to determine which of the three modes to use, Actual Value (0x00–0x7F), Percentage (0–100), or Zero-Centered (±0–100). The Actual Value mode requires no conversion and the percentage is equal to the P0Value. Percentage mode uses two integer math routines (multiplication and division) to calculate a percentage of the full-scale value (P0Value × 100/127). The zero-centered value is similar to the percentage calculations except P0Values less than 0x60 are considered negative and must be subtracted from 0x60 prior to determining the percentage. Other P0Values are considered positive and must have 0x60 subtracted from them prior to determining the percentage. When a P0Value is determined to be negative, a flag bit is set to indicate this. The zero-centered value (not to be confused with the auto-zero) treats the linear potentiometer as a balance adjustment (left/right or plus/minus).

The QT411 can correct for temperature and environmental influences if you give it a compensation (DriftComp) command every so often. When and if to use this command is up to you and it is based on how the potentiometer will be used. In an application where the control is used for more than intermittent use, drift compensation during lingering contact will attempt to cancel what it sees, so perform drift compensation less often.

The MPC41010 can only be spoken to. Its 10-kW potentiometer is set based on the second 8 bits of a 16-bit command. The 0x00–0xFF value for the digital potentiometer is twice the resolution of the QT411. Therefore, a translation must be made between the value read from the touch slider and the value written to the digital potentiometer. In this case, a simple shift (times 2) does a nice job.

A note here on SPI use is in order. Not all SPI communication uses the same configuration. To use a SPI device, you need to know if it requires an idle high or idle low clock level. In addition, you need to know how the device reads and writes data or when data is clocked in and out (rising or falling edge of the clock). When multiple devices are used, each must have a separate CS (chip enable). This enables a single device to be active while all the others lay idle on the SPI bus. For devices that require different parameters, you can initialize the SPI bus differently for each device prior to enabling (*CS) communication with it. Once the digital potentiometer is set, the main loop is finished and the application loops back, awaiting the next 16-ms flag.

Previous | Next


bottom corner