Multiwavelength campaign on Mrk 509. XIV. Chandra HETGS spectra