2^n programmable gain amplifier

I was trying to design a circuit for conditioning a signal from a photodiode. I needed an amplifier to buffer and amplify the signal before sampling it with an ADC. However, the signal from a photodiode can have a high dynamic range, and I wasn't sure if the ADC can cover that. Instead of using a higher resolution ADC, I read about the programmable gain amplifier.

A programmable gain amplifier can be useful when sampling a signal that has a higher dynamic range than the resolution of the ADC allows. It's similar to setting the exposure of a camera when taking a picture; even though the scene can have a higher dynamic range than the camera can capture, the exposure can be set so that the camera does capture the most interesting part. Essentially, the dynamic range of the ADC is “shifted” to cover the full range of the signal.

There are several PGA ICs available, such as Linear LTC6910, Maxim MAX9939, Microchip MCP6S21, and TI PGA112. I figured I could also build one using an ordinary op-amp. Here's an article I found with two reference designs.

I also came up with an alternative arrangement that is capable of 1x to 128x gain in 2^n steps:

2^n PGA schematic

Unlike the circuits in the article above, this PGA design only requires 3 digital signals for gain control, and it only requires three different resistor values. Also, instead of requiring analog switches, this PGA uses only MOSFETs. On the downside, this circuit has a fairly poor bandwidth when the gain is low, due to MOSFET parasitic capacitances.