We propose high spectral resolution observations of high level CO emission lines in a sample of evolved stars, in order to study the evolution of the winds and circumstellar envelopes from the AGB to the Planetary Nebula phases. We will determine the thermal structure of the circumstellar gas shells, as well as the mass-loss rates during the superwind phase. The sample of objects chosen for the study includes AGB stars with low, intermediate and very high mass-loss rates, post-AGB stars with low, intermediate and high central star temperatures, and low- and high-excitation PN. Both O-rich and C-rich examples of each type are included. The CO observations will be modelled using a full radiative transfer code in the comoving frame in the case of AGB stars and the coolest post-AGB stars, whilst for the post-AGB stars and PN we will use modified codes originally written for the study of photodissociation regions which we have already used succesfully to model KAO observations of CO in a few of the brightest of such sources. The results will allow us to follow the evolution of physical conditions (gas temperature and density) in the hottest, densest parts of the circumstellar envelopes, close to the central stars.