One challenge in circuit design is building a good current source, especially when the load is variable or the current must be controlled with a voltage source. The figure shows a simple, low-cost voltage-controlled current source using two op amps that provides a good range of current and maximum load.
The idea is to apply a voltage on a reference resistor (or resistors) having a low thermal coefficient. The current passing through this resistor will be the output current. U1 adds the input voltage with V2, and U2 buffers the load voltage, so we have:
V1 = VIN + V2
Obviously, U1's output current is amplified by Q1.
Applied voltage on the resistor network R is (V1 - V2), which will be equal to:
VR = V1 - V2
= (VIN + V2) - V2
= VIN
So the output current will be:
IOUT = VR/R = VIN/R
If R is a constant value (low thermal coefficient), the output current will be a linear function of the input voltage. Four resistors in series reduce the effect of thermal dependency.
We also have to consider some other constraints. Limited supply voltages cause a limited maximum output current. And if the load is large, transistor Q1 must be able to handle the maximum current.
If U2 is a rail-to-rail amplifier, then the zener diode isn't required. Otherwise, it's needed to prohibit the current source from malfunctioning with low current outputs. (When V2 is very close to -VCC, the buffer's output may not exactly follow input-voltage changes.)
Here is the calculation: Suppose we want to calculate the maximum output current with ±VCC, and R as the resistor value, when the input voltage has a maximum value of VIN(MAX). Then:
IMAX = \\[2 x VCC - (2 x Vz) - VBE - VIN(MAX)\\]/R
For the circuit shown, a maximum current of 20 mA is feasible for a maximum load of 1100 Ohms. Using higher-voltage op amps and larger power transistors can increase these values if cost isn't a concern.