# Application of the MiL and HiL Simulation Techniques in Stewart Platform Control Development
## 1 Introduction  
The V-Cycle (Figure 1) as defined in the VDI 2206 guideline is a systematic approach for the development of a mechatronic system [1]. The V-Cycle or V-Model is represented by a seamlessly following development stages and gradual verification and validation. The initial stage is a precise definition of the system requirements. The next step involves an analysis of the requirements and development of the general design of the system, with the support of system engineering tools and languages such as SysML or System Composer [2, 3]. The general solution concept of the system is then split into specific domains of mechanical, electrical, and software engineering to be further concretized and then integrated to form an overall system. At this point, the interaction between the domains needs to be investigated. The design process is continuously verified and validated. The result of this cycle is a verified and validated product. The entire development cycle is also supported with modelling and simulation tools and follows the model-based design methodology [4, 5, 6]. If the development cycle has been strongly supported with modelling and simulation tools, after the domain-specific design, we have designed a simulation model of the mechatronic system and its control strategy. In case we decide to proceed with this design to the system integration phase, we need to check whether the designed control algorithm could be performed on a desired hardware in real-time [7, 8]. Since testing the control algorithm on the real prototype can be dangerous in many scenarios, it is efficient to use Model-in-the-Loop (MiL), Software-in-the-Loop (SiL), Processor-in-the-Loop (PiL) or Hardware-in-the-Loop (HiL) techniques. MiL is often used in the early phase of development to verify the design [9], and the rest of the techniques are used later in the system integration phase [10, 11]. MiL is performed in the simulation environment (i.e., Matlab/Simulink) where both the controller and the plant are mathematical models. SiL is performed in the simulation environment as well, but the controller is implemented as a code (i.e., C/C++) that is going to be implemented in the controller. PiL performs a simulation where the controller code is implemented on a development prototyping board and is connected through the I/O interface with the computer that simulates the plant. The last technique to be mentioned is HiL (Figure 2), which works on a similar principle to PiL, with the difference that the controller is run in real-time on the intended hardware and the plant simulation model runs on the real-time target. The HiL tests can also include safety functions. One of the most significant advantages of the model-based design approach is the automatic code generation [12; 13]. Therefore, we had to choose a controller that is powerful enough to perform our code in real-time and supports the conversion of our controller model from the Matlab/Simulink environment, to the form that is compatible with the selected controller. For this purpose, we have chosen the PLCnext controller, which meets the defined requirements [14]. The programming code can also be created in classical PLC  
Figure 1: V-Cycle defined in VDI 2206. Figure 2: Hardware-in-the-Loop general scheme. languages according to the IEC 61131-3 or in C#, C/C++, etc. The code created by both approaches can be combined and merged into the complete control system. PLCnext can also run an HMI application for visualisation and control. Since PLCnext can run as a web server, the HMI application can be accessed through the standard web browser. In this article, we are concerned with the transition from the design phase to the system integration phase and verification of the designed control strategy for the Stewart platform. In the first part, we describe the Stewart platform parallel mechanism. Then we present the multibody simulation model of the Stewart platform, the designed feedback control loop and the results of the MiL simulation.