# Optimal Control Method of Semi-Active Suspension System and Processor-in-the-Loop Verification
## 2 Materials and Methods
### PIL Verification  
Through the utilization of rapid prototyping methods in design and testing procedures, the inherent difficulties faced during the design phase can be efficiently and economically resolved [33]. The classification of these methods from simple to complex is seen in Figure 11. In the MIL, the system model is first obtained. Then, it is tested in a simulation environment. In the software-in-the-loop (SIL), a code is generated in the same way as it is generated in the embedded system. The generated code is run in a simulation environment, and the whole system is tested. In the PIL, the generated code is tested in real-time by running on a processor. In the hardware-in-the-loop (HIL), the generated code is tested together with a real system response.  
Although MIL and SIL methods can produce definite results, the results may differ from MIL and SIL, regarding real-time implementation of the algorithm [52]. For this reason, it is crucial to validate the control algorithm with PIL to obtain results close to the real application. The controller used in the SASS was verified by preparing a PIL simulation in a MATLAB/Simulink environment. Moreover, performance improvements were supplied through PIL simulation.  
In PIL simulation, the code obtained from the designed controller model was run on a real microprocessor. The STM32H743 ZI2 microprocessor was used for this purpose. The used PIL architecture is shown in Figure 12. In general, the PIL comprises a model  
Figure 10: Phase planes of the system (**a**) unsprung mass displacement and velocity, (**b**) sprung mass displacement and velocity.  
of the system where the control algorithm is applied, a two-way communication line that will provide communication between the simulation environment and the processor and a microprocessor where the control algorithm will execute. In PIL simulation, the system model generates a response in accordance with the applied control signal and then transmits this signal to the microprocessor through a communication line. In response to the transmitted signal, the control algorithm is re-executed. While the microprocessor is running, the system model waits in a halt mode, and similarly, when the system model is running, the microprocessor waits in a halt mode. On the other hand, when preparing a PIL simulation, its limitations should be taken into account [52]. Due to the discrete-time behavior of the microprocessor, the simulation environment in which the model is prepared should be suitable for discrete-time operation. The variables to be used both in the simulation and in the microprocessor should be the same type. The simulation speed is affected by the communication line operation speed. Therefore, both the speed of the communication line and the running time of the simulation should be set appropriately. The oscillator frequency of the microprocessor should also be considered as another limitation of a PIL simulation. Consequently, the oscillator frequency of the microprocessor should also be considered when determining how long the simulation will take.  
Figure 11: Prototyping methods: from simple to complex.  
Figure 12: Prepared PIL structure for this study.