A weighing matrix W of order $$n=\frac{p^{m+1}-1}{p-1}$$ and weight $$p^m$$ is constructed shown that the rows $$-W$$ together form optimal constant ternary codes length n, minimum distance $$p^{m-1}(\frac{p+3}{2})$$ for each odd prime power p integer $$m\ge 1$$ thus $$\begin{aligned} A_3\left( \frac{p^{m+1}-1}{p-1},p^{m-1}\big (\frac{p+3}{2}\big ),p^{m}\right) =2\big (\frac{p^{m+1}-1}{p-1}\big...