For applications that require or desire a computer controlled variable current, the use of a digitally controlled potentiometer and a current mirror with degeneration provides a low cost solution.
One of the limitations of a digitally controlled potentiometer is the amount of wiper current allowed. The maximum current is typically about 3-4mA. This is not enough drive for many applications. By using the circuit of Figure 1, the current through the potentiometer is kept within specified limits while providing an output current that can be many hundreds of milliamps (depending on the capability of the transistors).
The basic equation governing the operation of the current mirror circuit of figure 1 is:
This equation makes many assumptions, including that the transistors are matched, that there are no stray resistance values and that transistor base currents can be ignored. It also requires that the voltage on the collector of Q2 remains high enough to keep the transistor operating out of saturation.
Figure 1: Basic degenerative current mirror circuit.
This basic circuit can be used in one of two ways. A variable resistor can adjust the I1 current while keeping the current ratio fixed or the I1 current can be fixed with the ratio changed by a resistor.
First, consider the case where the digitally controlled potentiometer controls the I1 current. Assume R2 is zero and assume the maximum desired current output is to be 50mA for an input current of 3mA (the maximum current through the potentiometer should be limited to about 3mA to avoid exceeding the device specifications). For these conditions, resistor R1 is calculated to be 24.4 ohms (VT=0.026). A calculation for the input current suggests a 1.3K ohm resistor be placed in series with the potentiometer to limit the current. The circuit in Figure 2 indicates the resistors used in the final circuit.
Figure 2. Basic current mirror with digital current control.
The graph in Figure 3 shows the calculated response of this circuit compared with the actual current measurements. The calculated current is based on the measured input current at each tap position. The maximum theoretical output is 50mA with a 3mA input. The maximum output current can be controlled either by the 1.3K ohm current limiting resistor or by R1. The Vout voltage does not need to be 5V. It can be higher if necessary to provide required voltage to the output circuit, however it cannot be so high that heating in Q2 changes the gain of the transistor**.
Since the transfer function is logarithmic, the Xicor X9314 log taper DCP is used to make the response more linear. Each of the sample points on Figure 3 corresponds to one tap position.
Figure 3. Basic current mirror response.
The matching of the calculated current versus the actual current is affected by the base currents in the circuit. That is, the IE current is less than the input current by a small amount. This reduces the output current below the expected values. Adding another transistor, Q3, as shown in Figure 4, reduces the effect of this base current and better matches to calculated performance (see Figure 5.)
Figure 4. Enhanced current controller with digital current control.
Figure 5. Enhanced current mirror response.
In the enhanced circuit, the same value resistors give a lower expected maximum current, because the voltage between the Q1 emitter and collector is approximately 2 diode drops with Q3 in the circuit.
The circuit of figure 4 has a limitation in that it can be affected by heating of the output transistor. This happens when the VCE on Q2 increases due to increased Vout. The heating can cause a mismatch of the gains in the current mirror transistors which changes the actual versus calculated performance of the circuit. Using a dual transistor can reduce this effect, but it will also reduce the maximum current that the circuit provides. Another variation of this circuit can give better performance over a wider Vout range and can increase the current capabilities of the design. This circuit is shown in Figure 6.
Figure 6. Alternate current mirror with digital current control.
The response of this circuit is shown in Figure 7. This circuit has the best theoretical accuracy and should be the least affected by the output voltage supply. Note, Vout for these results was set to 9V. All previous circuits were tested at 5V.
Figure 7. Alternate current mirror response.
Gain control apps
Next, consider the use of a variable resistor in the emitter of Q1. In this case, the current is fixed and the resistor changes the gain of the circuit. Since a digital potentiometer has a relatively large value, a resistor is placed in parallel with the potentiometer as shown in Figure 8 to lower the total emitter resistance. A parallel resistor/potentiometer combination gives a non-linear response. Using a log taper potentiometer does not correct this anomaly, but it changes the curve such that the light output appears more "linear". For non-LED applications, a linear potentiometer might be a better choice in this circuit configuration.
Figure 8. Basic current mirror with digital gain control.
The measured current in this circuit differs significantly from the calculated value (see Figure 9). The reason is the calculated output current is based on the input current of 0.12mA. However, at higher emitter resistance values, a large percentage of the input current goes into the transistor bases.
Figure 9. Basic current mirror with gain control response.
By adding transistor Q3 in Figure 10, the output more closely matches the calculated values. However, the current starts to exceed the calculated value as the R1 resistance increases (see Figure 11.) This can be a result of Q2 heating at higher currents or it can be a side effect of the very high gain that this circuit generates. This high gain turns slight measurement and calculation variances into potentially large output errors.
Figure 10. Enhanced current mirror with digital gain control.
Figure 11. Enhanced current mirror with gain control response.
Finally, look at the alternate connection of the three transistors, with gain control, shown in Figure 12. The response of this circuit closely matches the expected results (see Figure 13.) However, there are some measurement abnormalities in this circuit as well. Most likely these are due to the gain of the circuit where small changes in the R1 current make a big difference in the measured output current.
Figure 12. Alternate current mirror with digital gain control.
Figure 13. Alternate current mirror with gain control response.
With a few low cost components, a digital potentiometer can be used to provide brightness control for LEDs, a variable bias current for sensors, or a programmable reference in other applications. This collection of circuits gives several mechanisms for digital or computer control of a variety of analog circuits.
**The examples in this application note use multiple 2N3904 transistors. Another choice is to replace Q1 and Q2 with a transistor pair, such as the ZDT617CT from Zetex. In this case, there is better matching between the two transistors and any heating will change the characteristics together for better response.