Criteria to design good space-time trellis codes (STTCs) have been already developed in previous publications. However, the computation of the best STTCs is time-consuming because a long exhaustive or systematic computing search is required, especially for a high number of states and/or transmit antennas. In order to reduce the search time, an efficient method must be employed to generate the STTCs with the best performance. In this paper, a technique called coset partitioning is proposed to design easily and efficiently optimal 2 n -PSK STTCs with any number of transmit antennas. The coset partitioning is an improved extension to multiple input multiple output (MIMO) systems of the set partitioning proposed by Ungerboeck. This extension is based on the lattice and coset Calderbank's approach. With this method, optimal blocks of the generator matrix are obtained for 4-PSK and 8-PSK codes. These optimal blocks lead to the generation of the STTCs with the best Euclidean distances between the codewords. Thus, new codes are proposed with 3 to 6 transmit antennas for 4-PSK modulation and with 3 and 4 transmit antennas for 8-PSK modulation. These new codes outperform the corresponding best known codes. Besides, the first 4-PSK STTCs with 7 and 8 transmit antennas and the first 8-PSK STTCs with 5 and 6 transmit antennas are given and their performance is evaluated by simulation.