If you only heat the cylinder, the ammonia boils, during which time
- The whole apparatus remains at saturation temperature,
- The vapor phase expands simply because more ammonia is being added to it, and
- Some of the heat-energy goes into pushing up the piston to accommodate more gas.
After all the liquid has boiled off, the vapor heats up and expands as suggested by the ideal gas law.
If you pull on the piston, the pressure drops and more liquid boils to restore the vapor pressure. But this takes energy out of the system and lowers its temperature, which makes a new equilibrium pressure and temperature lower than what you started with. If you pull on the piston after all the liquid has boiled, the vapor cools down further.
Because what you are doing is a flow process, with mass inflow and no mass outflow, you need to use the thermodynamic equation:
$dU_{cv}={m_{in}d}{H}_{in}-{m_{out}d}H_{out}+\delta Q-\delta W_{shaft}$
If you insulate your air cylinder well enough, $\delta Q = 0$.
Assuming that your air cylinder does not deform, $\delta W = 0$.
Since you are filling your cylinder with air and assuming no air escapes, ${m_{out}d}H_{out} = 0$
Therefore, the enthalpy of the gas which you are filling adds to the internal energy of the gas in the cylinder, and because the internal energy is positively correlated to temperature, the temperature in of the gas in the cylinder rises.
$\Delta{U_{cv}}={H_{in}}>0$, so
$\Delta{T} >0$
You may apply the reverse for the release of air from the cylinder. In this case:
$\Delta{U_{cv}}={-H_{out}}<0$, so
$\Delta{T} <0$
http://en.wikipedia.org/wiki/Thermodynamic_system#Flow_process
Best Answer
Realize that the problem statement says, "Heat is now slowly transferred to the steam..." after the piston begins to lift.
This means that the gas is in mechanical equilibrium (i.e., matching pressures) with the piston at every instant in time. In thermodynamics we call this a quasistatic process; the gas is in "quasi-equilibrium" with the surroundings at every point in the process. If the pressures are unequal at any time, then the process is not in equilibrium during that time.