The X9C Digitally Controlled Potentiometer (XDCP™) family of chips from Intersil allows for the digital control of a variable resistor via a three wire digital interface.
This project illustrates a simple circuit where a X9C104 IC is controlled by an Arduino and the resulting variable resistance is used to control the frequency of a square wave generated by a 555 timer running in astable mode.
A simplified block diagram of the circuit shown below:
The basic principle of operation:
- User inputs a variable potentiometer setting via the Arduino serial monitor.
- Arduino accepts input and programs X9C104 to setting
- X9C104 resistance in 555 timer circuit adjusts frequency of oscillation
- The output square wave from 555 timer changes to value set by user in step 1
The X9CXXX integrated circuits are manufactured by Intersil (recently acquired by Renesas corporation) and represent their range of digitally controlled potentiometers. The device includes a resistor array, control section and non-volatile memory. The resistance of the array is controlled by a three wire digital interface.
A block diagram from the Intersil data sheet:
The device can be used as two terminal variable resistor or a three terminal potentiomenter. It includes non-volatile memory that holds the last resistance value on power down and sets the resistor array to this value on subsequent power up.
Control of the wiper position and hence the resistance is determined by the three digital inputs:
- Device is selected by taking CS low
- State of Up/Down (U/D )determines whether the wiper moves closer to Vh/Rh or Vl/Rl
- The wiper moves one step every time INC is taken low and then returned to high.
- The wiper has 100 possible positions (0 – 99), allowing for incremental steps of 1% of the total resistance.
- When the wiper reaches the top or bottom ( Vh/Rh or Vl/Rl), it does not move any further nor does it wrap around to the other extreme.
It is important to remember that the wiper moves a single increment for each INC cycle. The wiper cannot jump across multiple steps. This means that moving from step 10 to step 20 requires 10 INC cycles.
Vh and Vl cannot exceed Vcc and Vss.
Complete specifications for the devices can be found at the Renesas website.
555 Timer CircuitThe 555 Timer circuit used in this project is a standard astable oscillator. There are multiple articles available that document the workings of this circuit and a quick search will allow access to the explanations.
At a high level, operation as follows:
- With pin 7 high and blocking, capacitor C1 charges up through R1 and the variable resistor in the X9C104
- At a certain threshold voltage, the 555 timer internal flip/flop s1witches and Pin 7 goes low
- Capacitor C1 then discharges through the variable resistor in the X9C104
- At the lower threshold voltage, the 555 timer internal flip/flop switches back and the cycle repeats
The equations for frequency and duty cycle as follows:
In the circuit used here, R2 is 100 kΩ (X9C104) and R1 is 1 kΩ. Because of the difference, the frequency and duty cycle of the circuit is effectively set by the value of R2, except at very low values of R2.
Values of R1, R2 and C1 are chosen so that the circuit will generate square waves within the audible frequency range.
Arduino CodeThe code makes use of the Fast X9CXXX library for the Arduino. The library is available on GitHub at:
https://github.com/GitMoDu/FastX9CXXX
Make sure that the code is downloaded and included in your Arduino library folder before compiling the code.
The setup part of the program initiates the X9C104 object using pins 3, 4 and 5 from the Arduino. Potentiomenter is set to 0 step.
The main loop waits for an input from the user via the Serial monitor; this input must be between 0 and 99. For a legitimate input, the potentiomenter step is set to this value and the 555 timer circuit will settle to a square wave frequency determined by the step resistance.
The step input and estimated resistance are printed out to the Serial monitor.
Results and ConclusionFrequency measurements of the circuit were taken at various step values. The results are tabulated in the attached spreadsheet. The first tab shows results using an actual 100 kOhm variable potentiometer. The second tab shows the measured frequency resulting from a XC9104 step compared with a theoretical calculated value.
Of course, there are much easier methods to achieve a variable frequency square wave from an Arduino, but this project moved toward a practical use of the digitally controlled potentiometer.
Comments