To introduce the $pV$ work integral, my physics textbook gives me the classic setup of a vertical piston (which has face area $A$) with a gas of pressure $p$ and initial volume $V_i$ (please see the image for the exact setup). On the piston is lead shot which exerts a downward force. The force exerted by the gas is given by $F=PA$. Therefore, the work done by the gas is given by the integral from the initial to final volume of $Fdx=pAdx=pdV$ (please see the image for the full derivation; only the full paragraph is relevant).
This derivation makes sense. However, I have seen formulations of the integral in terms of external pressure rather than internal pressure. Namely, I have seen the differential work written as $dW=-p_{ext}\cdot dV$. I understand that the negative sign comes from the chemistry sign convention, but am confused whether to use the internal or external pressure.
In two different cases, these two integrals seem to produce different results.
Case 1 - Adiabatic Expansion: My book suggests that an adiabatic expansion can be achieved by the following setup: a completely thermally insulated gas piston with lead shot (see image).
As one shot is removed at a time from the piston, the gas expands adiabatically. In this case, the external pressure is constant and the internal pressure varies with volume. I would expect the two integrals (d$W=p\cdot dV$ and $dW=p_{ext}\cdot dV$) to be different, but am not completely sure if this is true.
Case 2 - Free Expansion: In the free-expansion setup, a gas is allowed to expand into a vacuum chamber (see image).
The gas has pressure p, but the external pressure p_ext is zero. Therefore, the first integral, which uses $dW=pdV$ has a non-zero value while the second integral $dW=p_{ext}\cdot dV$ is equal to zero. The second integral produces the correct result while the first does not.
Again, which pressure is correct to use for these integrals.
This is my first post so I apologize for any formatting errors that occurred.
Thank you so much!
Please note that throughout this question, I have used $p$ to refer to internal pressure of the gas and $p_{ext}$ to refer to external pressure.