How to Construct a Pushbutton Controller for the DS1803/DS1805 Digital Potentiometers
Abstract: This application note describes a simple method that uses pushbuttons and a microcontroller to change the resistance of a DS1803 or DS1805 digital potentiometer.
Introduction
This application note describes a simple method for changing the resistance of a DS1803 or DS1805 digital potentiometer. The Microchip PIC12F509 microcontroller is used to interface four switches with the digital potentiometer. A minimal number of other components is required.
Hardware
The hardware schematics for this application note are shown in Figures 1 and 2. The PIC12F509 has six I/Os that can be used to output control signals on SDA, SCL, and a single LED, and to accept inputs from four switches.
Figure 1 illustrates the schematic for a pluggable or built-in control circuit with the PIC12F509. R1, R2, and R3 are optional pullup resistors that do not need to be populated when the PIC12F509 is used. Figure 2 illustrates how the DS1803 can be connected for evaluation. Jumpers are provided for selecting address pins, separating the shared VCC (VDD), and isolating SDA and SCL.
Three of the switches are momentary pushbutton type and used to increment (UP), decrement (DWN), and program a middle pot value (MID). When depressed, the switches force a low on three of the microcontroller's general-purposeI/Os (GP0, GP1, and GP3). These I/Os were explicitly chosen because they have internal (optional) pullup resistors and can generate a wake-up interrupt if the low-current SLEEP mode is enabled. The other input switch is a DPDT toggle assigned to GP2 that can be used to select either POT0 or POT1 for programming.
Output signals on SDA, SCL, and the LED are assigned to GP5, GP4, and GP0, respectively. SDA and SCL have 4.7kΩ pullup resistors and connect directly to the communication pins of the digital pot. The LED and the MID momentary switch both use the GP0 pin as a resource. The GP0 pin functions as an input most of the time, polling for a LOW caused by the MID pushbutton. However, if one or both of the other momentary pushbuttons are depressed, then the PIC outputs a LOW and causes the LED to be driven. In this way the LED is driven whenever the MID button is pressed and by the PIC whenever another pushbutton switch is depressed.
Figure 1. PIC12F509 interface circuitry.
Figure 2. DS1803 digital potentiometer connected to PIC controller.
Firmware
Firmware for this project was written in assembly language complied in MPLAB IDE (version 7.31). This tool is currently available from Microchip at no cost. The entire program consists of fewer than 512 instructions in program space (flash) and 11 locations in data space (RAM).
The instructions are divided among five blocks: Initialize, Read, UP, DWN, and MID. Since this PIC does not feature any interrupts, the firmware simply runs in a loop that continuously polls the input pins. Switch debouching is automatically incorporated in software due to the intrinsic delays and logical flow of the program.
The Initialize block runs once on PIC power-up or after waking-up (if SLEEP is enabled). After the instructions in the Initialize block have run, the operating registers, flags, and variables are loaded to known states. After these instructions have been executed, the remaining blocks serially form an infinite loop to poll the switches, read, or write new Pot values through I²C interface.
An I²C READ of the potentiometer values only occurs when the RD_FLAG is set. This flag is set once during initialization, then whenever a pushbutton calls for a potentiometer register to be written to a new value. By performing an I²C READ only during a potentiometer value change and at startup, there are no superfluous communication bursts occurring on the bus when the UP, DWN or MID buttons have not been depressed. For example, if the potentiometer is already in service controlling a power-supply trim parameter, then the pushbutton controller is connected to perform in-circuit programming. The current potentiometer value will be read before an I²C WRITE of the potentiometer value is performed. Once the I²C WRITE has completed, the RD_FLAG is set again to generate one final I²C READ of the new potentiometer value.
The UP, DWN, and MID blocks run sequentially after the Read block. In each of these blocks the respective pins are polled for a LOW state. If a HIGH state is found, then the program exits the block quickly and without causing any I²C communication to occur. If a LOW is detected, then the program flows as described in the logical block diagram.
Please refer to the firmware flowchart (PDF) and source code (ASM) for a complete description of this project's design.
Functional Description
This project's firmware and hardware allow several different operations to be conducted while programming the potentiometer values on the DS1803/DS1805. The switch and LED functions are as follows:
POT0/1 (selection toggle switch)
This switch chooses which Pot (if necessary) will be controlled in the next loop iteration. A change of state on this switch selects Pot 0 or 1, causes an I²C read, and has no effect on LED.
Tap the MID, UP, or DWN button (< 400ms)
By tapping one of these switches, the selected Pot will either increment (UP), decrement (DWN), or be loaded with the middle position of 0x80 directly (MID). The LED will illuminate briefly while the I²C write is carried out; an I²C read will occur in the next loop iteration.
Press and hold UP or DWN button (> 400ms)
By pressing and holding the UP or DWN button, the selected Pot will enter a fast increment or decrement mode. In this mode the Pot value will continue to change until the button is either released or the max/min position is reached. The LED will illuminate as I²C writes are carried out; it will remain illuminated until the button is released. After button release, an I²C read will occur in the next loop iteration.
Press and hold UP, then tap DWN button
By pressing and holding the UP button, the selected Pot will begin incrementing. Then (while the UP button is still depressed) the DWN button is tapped, causing the selected Pot to directly be loaded with the maximum position of 0xFF. The LED will illuminate until the switches are released. After the buttons are released, an I²C read will occur in the next loop iteration.
Press and hold DWN, then tap UP button
By pressing and holding the DWN button, the selected Pot will begin decrementing. Then (while the DWN button is still depressed) the UP button is tapped, causing the selected Pot to directly be loaded with the minimum position of 0x00. The LED will illuminate until the switches are released. After the buttons are released, an I²C read will occur in the next loop iteration.
LED blinks three times
The LED will blink three times whenever the PIC controller is initialized during power-up or whenever the watchdog timer causes a system reset (if enabled).
LED continuously blinks quickly
The LED will continually blink quickly whenever an I²C error occurs. Once the error is corrected, the LED will resume normal functionality. Troubleshoot by checking that the device address is correct and that the I²C bus is connected.
Conclusion
This application note describes how to use and construct a simple and cost-effective controller for the DS1803/DS1805 nonvolatile digital potentiometers. Button inputs are converted to I²C commands to increment, decrement, or set a middle position. The design does not require a host computer. This project also requires a minimal number of external components to realize potentiometer control.
Questions/comments/suggestions concerning this application note can be sent to: .
의견을 보내주세요! 위 내용이 도움이 되셨나요? 여러분의 의견을 기다립니다 — Maxim은 보내주신 정정이나 제안사항을 반영하고 있습니다.
이 페이지를 평가하고 의견을 보내주십시오.