I have used both pull-up resistors and transimpedance amplifiers to read light signals from phototransistors and photodiodes (see Colorimeter design—weird behavior and Optical pulse monitor with little electronics, for example, though any of the posts tagged phototransistor or transimpedance amplifier may be relevant), so I decided to do a post about what the difference is in terms of performance.
Test setup for comparing pullup resistor and transimpedance amplifier. The Arduino board outputs a pulse train with two different pulse widths (approx 65µs and 125µs).
Obviously, a pull-up resistor is simpler and cheaper—it is hard to get much simpler or cheaper than a single resistor—so why ever use a transimpedance amplifier with a phototransistor?
I believe that the answer comes down to speed.
With a pullup resistor, you have a common-emitter amplifier—the photocurrent generated at the base-collector junction becomes the base-emitter current, which controls the collector-emitter current, and the voltage swing at the output is the change in the collector current times the resistance of the load resistor. As you increase the load resistor, you get more voltage swing. But there is a fly in the ointment—the Miller capacitance between the base and the collector, which serves as a negative feedback loop limiting the slew rate of the output. I’ve looked at that feedback loop before in More on nFET Miller plateau, for example, but the analysis here is slightly different.
Phototransistor with pullup resistor, showing the Miller capacitance (collector-base capacitance) that provides a negative feedback loop.
The current through the capacitor from the collector to the base is , assuming that the base voltage is roughly constant. We end up with a differential equation:
In response to a step change in the photocurrent, the voltage does an exponential decay towards the endpoint with a time constant of . If we choose a large R to get a large voltage swing, then we end up with a slow rise and fall time. At high frequencies, we end up with a considerable loss of signal—we have a low-pass filter with corner frequency .
We can speed up the transitions by using a transimpedance amplifier, which eliminates the change in voltage of the collector, holding it at the same voltage as the positive reference input. The photocurrent still has to charge and discharge the base-collector capacitor C, but there is no longer the pesky multiplication by , the current gain of the transistor, so our bandwidth is theoretically times higher than with the pullup resistor.
Of course, the slew rate of the output of the transimpedance amplifier is also limited by the amplifier characteristics. Using an MCP6004 op amp (which has a 600mV/µs slew rate, and 1MHz gain-bandwidth product) and feedback resistor of 3kΩ to get the same low-frequency gain as with a 3kΩ pull-up resistor, we get much faster rise and fall times than with the pullup resistor:
The top, green trace is using the transimpedance amplifier, while the bottom, yellow trace is from the pullup resistor. Both are at 100mV/division and 50µs/division, but the DC offsets are different.
I see about 5 times faster edges with the transimpedance amplifier, but I expected a bigger improvement than that—the current gain on NPN transistors is usually in the hundreds. I have a fairly large VCE (2.5V for the transimpedance amplifier and 4.5V—4.7V for the pullup), so the transistor should be well into the saturation region.
If I have a stronger input signal (by lining up the LED and phototransistor better), I get much sharper edges from the transimpedance amplifier:
Again with 3kΩ pullup or transimpedance amplifier, but with a stronger light input. The vertical scale is now 1V/div, but the horizontal is still 50µS/div.
The fast edges for the large signal may be an illusion—the op amp output is hitting the 5V rail and clipping. That saturation also explains why the low-going pulses are shorter than they should be. So maybe the rise and fall for the larger pulses is still slow. I changed the resistors to 1kΩ, which should speed up the rise and fall and avoid clipping for the strong signals:
With 1kΩ pull-up and transimpedance resistors and a strong input signal, the ratio of the transition times looks about how I expected with a 1V/div, 50µs/div trace.
I think that the ringing on the rising edge is due to the slew rate of op amp not being fast enough to keep up with the phototransistor and the negative input of the op amp dropping a bit below the positive one. There is such a triangular blip, about 50mV and lasting about 10µs. There is a similar upward blip on the downward transitions of the op-amp output, but those don’t seem to cause any any overshoot.
So I think I understand most of what is going on here, but why is the rise/fall time so slow for small inputs?