In order to keep pace with the fourth industrial revolution, leading global manufacturers such as DMG MORI, MAZAK and FANUC have been involved in the development of controller and software to improve machine intelligence in order to achieve high-efficiency production, shorten time-to-market, and improve product quality. This paper discusses development of error compensation technique based on the closed loop of RAMI4.0 architecture. An algorithm of the stream of variation analysis (SOVA) is proposed to achieve robust design by identifying sources of error and hence remove the errors. The design focuses on the knowledge-based machining.