  [ABRIDGED] We examine the velocity structure in the gas associated with
\ion{H}{1} in the damped Ly$\alpha$ absorption system at redshift $z=1.7764$
towards the QSO $1331+170$ using 21cm data, optical and STIS spectra. We find
at least two, and possibly three, components showing \ion{C}{1} lines. One of
these has Doppler parameter $b=0.55${\kms}, corresponding to a kinetic
temperature of 220K if the broadening is thermal. We re-examine the H$_2$
analysis undertaken by \citet{Cui05} using the neutral carbon velocity
structure, and find a model which is, consistent with a mixture of collisional
and background radiation excitation of the observed H$_2$ rotational levels.
  For singly ionized heavy elements we find eight components covering a
velocity range of $\sim 110$ {\kms}. The \ion{H}{1} structure is expected to
follow some combination of the singly ionized and neutral gas, but the 21cm
absorption profile is considerably different. This may be because of the
different extent and brightness distributions of the radio and optical
background sources, and so the spin temperature derived by comparing the
Ly$\alpha$ and 21cm line strengths has little physical meaning. The neutral and
singly ionized heavy element line profiles also show significant differences,
and so the dominant components in each appear to be physically distinct.
Attempts to use the range of atomic masses to separate thermal and turbulent
components of their Doppler widths were not generally successful. The velocity
structure in all ionization stages up to $+3$, apart from the neutral heavy
elements, is sufficiently complex that it is difficult to separate out the
corresponding velocity components for different ionization levels and determine
their column densities.
