Design Idea
Analog voltage controls digital potentiometer
A microcontroller with an internal ADC controls a digital potentiometer via an I2C interface.
Hrishikesh Shinde, Maxim Integrated Products, Dallas, TX; Edited by Charles H Small and Fran Granville -- EDN, 3/20/2008
This Design Idea describes an analog voltage that controls a digital potentiometer through the device’s I2C interface. An ADC in the Microchip PIC12F683 microcontroller converts the analog voltage to the I2C stream that controls the Maxim DS1803 digital potentiometer (Figure 1) and (Reference 1). Of the microcontroller’s six general-purpose I/O pins, two control the SDA (system-data) and SCL (system-clock-line) output signals, one controls an LED, and one accepts the analog input. SDA and SCL connect directly to the digital potentiometer’s SDA and SCL pins with 4.7-kΩ pullup resistors to VDD. By adding or removing jumpers, you can separate the shared VC and VDD and isolate SDA and SCL.
The firmware is in assembly language, which was assembled using Version 7.40 of the MPLab IDE (integrated development environment), which is currently available free from Microchip. The program comprises fewer than 450 bytes in flash memory and 8 bytes in RAM. The program first initializes various configuration bits in the PIC, including the ADC and the internal oscillator. It configures the ADC to accept input from the analog input and sets the conversion clock to use the internal oscillator at 125 kHz.
The firmware runs in a loop, causing the 10-bit ADC to continuously convert the analog-input voltage. When a conversion is complete, the 8 MSBs form a data byte that transmits over the I2C bus, and this I2C-signal stream controls the digital potentiometer. The program controls both potentiometers in this dual device. With a change in firmware, however, you can independently control the potentiometers, using separate analog inputs on the PIC12F683. The program enables you to control the potentiometer by varying a voltage at the GP1 input of the PIC12F683. A change at GP1 causes a corresponding change in the potentiometer’s resistance: ROUT=((Input Voltage)/VCC)×50 kΩ, where the end-to-end resistance of the digital potentiometer is 50 kΩ, the allowable VCC range is 2.7 to 5V, and the input-voltage range is 0 to VCC. You can troubleshoot an application by checking that the device’s address is correct and that the I2C bus is connected. The LED blinks constantly while the ADC is running, but remains on when an I2C error occurs. After you correct the error, the LED resumes its normal function.
You can extend this design approach to other applications for which an analog voltage must control a device with an I2C interface. You can, for example, implement a nonlinear-transfer function, such as gamma correction, using the DS3906 variable resistor, and implement the transfer function in embedded look-up tables (Reference 2). Or, by connecting a thermistor at the input, you can vary the output of an I2C-controlled current DAC in response to changes in the ambient temperature.
| References |
|














