Using an Analog Voltage to Control a Digital Potentiometer

By: Hrishikesh Shinde

Abstract: In some applications a digital potentiometer with an I²C interface must be controlled by a continuously varying analog signal. This application note addresses this requirement, and provides a simple design solution. The principle presented here is versatile and can be used in multiple applications.

A similar article appeared in the March 20, 2008 edition of EDN magazine.


This application note describes a simple method that uses an external analog voltage to change the resistance of a digital potentiometer. The Microchip PIC12F683 microcontroller is used to make the conversion from an analog voltage to an I²C stream, which is then used to control the digital potentiometer. The DS1803 digital potentiometer serves as the example device and a minimum number of external components is used in this application. The ideas presented here can be applied to other control inputs and other digital potentiometers/resistors.

Hardware Configuration

Figure 1 shows the schematic for the control circuit that uses the PIC12F683. Four of the microcontroller's six GPIOs are used to control output signals on SDA, SCL, and a single LED, and to accept one analog input.

Output signals on SDA, SCL, and the LED are assigned to GP5, GP4, and GP0, respectively. SDA and SCL have 4.7kΩ pull-up resistors to VDD and connect directly to the DS1803's SDA and SCL pins. The microcontroller's GP1 IO is assigned as the analog input pin. Jumpers are provided for selecting address pins, separating the shared VCC (VDD), and isolating SDA and SCL.

Figure 1. Schematic illustrated analog voltage control of a digital potentiometer.
Figure 1. Schematic illustrated analog voltage control of a digital potentiometer.

Project Firmware

Firmware for this project was written in assembly language using the MPLAB IDE (version 7.40). This tool is currently available from Microchip at no cost. The entire program consists of fewer than 450 bytes in program space (Flash) and 8 bytes in data space (RAM).

The program first initializes the various configuration bits in the PIC, including the ADC and the internal oscillator. The program configures the ADC to accept input from GP1, and sets the conversion clock to use the internal oscillator at 125kHz.

The firmware runs in a loop with the ADC converting the voltage at the analog input continuously. Once a conversion is complete, the 8 MSBs of the 10-bit ADC output are used as the data byte to be sent over the I²C bus. This I²C signal is then used to control the DS1803. The program is set up to control both the potentiometers on the DS1803; by making a change in the firmware, however, the potentiometers can be controlled individually with two different analog inputs on the PIC12F683.

The firmware is available for download.

Versatile Functionality

The program allows the user to control the potentiometer by varying a voltage on the PIC12F683's GP1 input. A continuously varying input on GP1 will cause a corresponding change in the resistances of the potentiometers. The output resistance (ROUT) can be calculated as a function of the input voltage:

End-to-end resistance of the DS1803 used in the design: 50kΩ
VCC range allowable: 2.7V to 5V
Input voltage varies from 0V to VCC

Output resistance observed will be:

ROUT (kΩ) = (50 (kΩ)/VCC) × Input Voltage

While the ADC is running, the LED blinks constantly. The LED remains on in case an I²C error occurs. Once the error is corrected, the LED resumes normal function. The designer can troubleshoot the application by checking that the device address is correct and that the I²C bus is connected.

This design is quite versatile, and a similar approach can be used for a variety of applications. Some examples include:
  1. A nonlinear transfer function (e.g., gamma correction) can be implemented by using the DS3906 variable resistor with the correct transfer function implemented in the embedded lookup tables.
  2. A thermistor can be connected at the input to vary the output of an I²C-controlled current DAC when there are changes in the ambient temperature (DS4402/DS4404).

    Figure 2


This application note describes a simple and cost-effective mechanism for controlling a digital potentiometer by using an analog voltage. The application concept can be extended to use an analog voltage to control any device with an I²C interface.

Questions/comments/suggestions concerning this application note can be sent to: .