Free Piston Engine linear Generator (FPEG) that is thin and compact and has high efficiency and high fuel flexibility has been developed. The developed FPEG consists of a two-stroke combustion chamber, a linear generator, and a gas spring chamber.This paper focuses on the control logic of the linear generator, where the generator can be changed instantly to act as a driving motor, according to demand. Both the position and velocity of the piston are selected as feedback parameters for the control logic. The proposed feedback method realizes stable and robust control behavior with respect to abnormal combustion conditions, such as pre-ignition.In addition, the control logic must satisfy the following requirements. First, in order to achieve stable two-stroke combustion, the position of the piston is precisely controlled, especially near the top dead center (TDC) and the bottom dead center (BDC). Second, in order to reduce power consumption, it is preferable not to operate the generator as a driving motor during the generating operation. Considering the above requirements, variable feedback gains and a uniquely customized reference waveform are adopted in the logic.As an experimental study, a prototype of FPEG system was constructed. A power generation experiment was carried out, and the results revealed that the system operated stably for a long period of time. Although abnormal combustion occurred several times during the experiment, the operation continued robustly. Moreover, the proposed logic allowed FPEG to operate without using the linear generator as a driving motor, which realized high efficiency generation.