During the HIL phase, HIL systems will contain high power, which is a serious safety concern. State charts are especially suited to implement control flow logic, including fault detection and fail-safe modes to address faults with respect to both human and machine safety. For example, consider the model below, of an HIL application that starts with a high voltage power supply and applies it to a motor to achieve a setpoint speed.
A state chart is used to sequentially turn on the power supply, turn on the PWM’s, and supply the power to the motor. Once the motor is powered, a block diagram controller algorithm maintains its speed. The host model (shown in the blue outlined boxes) is used to control the state machine and plot data collection. The target model (shown in the red outlined box) executes the C code that was automatically generated by the state machine and control algorithm sections of the model.