Modular reconfigurable robots have the potential for great versatility and robustness; however, programming locomotion gaits for hundreds of modules remains a challenge. In this paper we present a formal model for programming locomotion gaits in chain-type modular robots: phase automata. A phase automation is an event-driven state automation with an initial phase delay. The phase delay is normally a real value between 0 and 1. Phase automata are compact representation of locomotion gaits and capable of being embedded and distributed across modules. The concepts of phase automata have been implemented on both PCs and embedded micro-processors. An XML script language and programming interface for phase automata are being built. Locomotion gaits programmed using phase automata have been tested both in simulation with 100+ modules and in hardware with 50+ modules.