Q:

Thermodynamics Work Done At constant pressure and charles law

If we fix a piston in the mouth of a cylindrical container in such a way that the piston settles when the pressure from outside the piston is equal to that of the gas within the container, and increase the temperature, the molecules of the gas will collide more frequently with the wall of the container and also with the bottom surface of the piston, and the pressure will increase due to larger force from inside the container, and the pressure does not remain constant.
So how can volume change by keeping pressure constant ,pressure has to change. When gas stops to expand then of course pressure is same as it was initially but in the process it has to be greater than initial pressure so that it moves the piston up. Now my doubt is then how is Charles law correct and how is work done at constant pressure..? 
I am really confused about this and I have my exam really soon, I have to get grip on thermodynamics.

A:

Charle's Law:
$\frac{V}{T}=k$
The idea is that, given an ideal gas, as the temperature rises the system instantly responds by balancing the potential increase in pressure with an actual increase in volume. 
In the case of the piston, you can easily measure the work done by measuring how much the piston moved. But in a general case:
$dW = Fdx$
$Fdx$ or force times movement interval could be written as pressure (force over area) times interval of area times area interval times movement interval or $dW = pdAdx$. You can represent that better with $dW = pdV$ or volume interval.
So for a general case, with constant pressure, the work done by the gas is $W = p(V_f - V_i)$.
Nevertheless, depending on what they ask, you might need to use:
$pV = nRT$
In that case, you need to solve the integral:
$W = nRT\int_{V_i}^{V_f} \frac{dV}{V}$
Which solves to:
$W=nRT(\ln{V_f} - \ln{V_i})$
Or
$W=nRT \ln{\frac{V_f}{V_i}}$

