In this study we present a new free tool-chain for model based control design for mechatronic plants applicable to small embedded systems based among other software on the open simulator Scilab-XCos. After a very short introduction of model based design terms this article focuses on the code generator and the other programs of the tool-chain. The design concept is demonstrated by an adaptive self tuning control (STC) of the cart and pendulum system in gantry crane configuration in simulation and on a real laboratory experiment.