How OPA333 withstand 400V bus without burning in this current sensing application?
The OPA333 isn't referenced to ground. It is referenced to the 400V supply bus via the zener diode and Rz. Well, technically the OPA333 is using 400V-5.1V as it's reference, but that reference is always relative to the 400V rail.
Instead of the OPA333 being powered by a potential difference that &quot;sits above&quot; GND by 5.1V, it is a voltage that &quot;hangs below&quot; the 400V bus by 5.1V.
Since the current sense resistor is on the high side and only has a tiny voltage drop across it, it is well within the OPA333's power supply which is 400V for the positive and 400V-5.1V for the negative supply terminals
Therefore, the OPA333's output is basically ~400V above GND and so needs to be re-referenced (shifted) to GND so that the other circuitry (which is GND referenced) can read it. This is done with the P-FET which is rated for 600V since it does have a huge voltage drop across it.
The most interesting part of this circuit is actually the level shifter. I understand why the current through both resistors has to be the same but I don't understand how the negative feedback is able to turn on the PMOS by just the right amount to drop all the excess voltage from the 400V rail.
EDIT: I sort of see how the feedback works now but it's pretty subtle. All the negative feedback does is turn on the PMOS just enough so that the two OPA333 inputs equal each other. This causes the voltage across R1 to match the voltage drop across Rshunt. That's the most direct thing the negative feedback does and the only thing the op-amp is really doing/controlling. Everything else: the current mirroring, the level shifting, and dropping the excess voltage is a byproduct.
The currents through R1 and R2 must be equal, and since their resistances are equal then their voltage drops must also be equal. This achieves the voltage mirroring and level shift. Therefore all the remaining voltage must be dropped across PMOS. It has no choice. It's the most important function of the circuit but is also the most indirect result of the whole operation.
Like a fancy version of how a resistor drops all the excess voltage so the LED doesn't have to. It just has no choice because the LED voltage drop already has its voltage drops defined and fixed.