## 2 SJB Implementation
### Design of SJB Software  
A flowchart describing the operation of the software program is shown in Figure 8. At a high level, the program operates as follows. The software first initializes the SJB and determines the current status. Then, if no error conditions are detected, the SJB switches to normal operating mode. On the other hand, if errors are detected, the software powers down the SJB by placing it into sleep mode. Detailed descriptions of each step are as follows:  
* SJB status check: determine the status of the SJB by conducting a diagnostic check of the input voltages. If an error is detected, then switch to power down mode by using the algorithm in Appendix A. Normal mode: Monitor the software status and execute any requested load control commands (headlight: duty cycle control, other IPS loads: On/Off control). During IPS operation, monitor the status of the IPS by using the algorithm in Appendix B. Power down mode: When an error is detected, execute sleep mode and provide an error indication to the controller. Then, wait for a wake-up or reset signal to be received through the CAN bus before restarting. The algorithm executed in this step is provided in Appendix C.  
Figure 8: Flow chart of the software.  
Figure 7: Temperature distribution on the SJB PCB module: (**a**) initial temperature, and (**b**) temperature after the wipers were set to high.  
The state switching diagram in Figure 9 illustrates the method used to improve the drive stability by monitoring the load to detect any abnormal states while the vehicle is being driven. The various operating states and switching conditions used in the algorithm are listed in Table 3.  
The timing of the diagnostic routines is depicted in the chart in Figure 10. Because of the stronger current in the transient state in which the headlight is driven, the blind time (\(\mathrm{T_{b}}\)) is placed and excluded from the diagnostic condition. If an abnormal condition (e.g., open, short, overload) is detected after initialization, the load is turned off and then on again using the load control signal. This on/off cycle is then repeated 10 more times. If no abnormal conditions are detected during repeated cycling, the IPS is allowed to resume normal operation. Otherwise, the corresponding IPS is placed into error mode, the error status is stored, and a corresponding message is transmitted to the system controller via the CAN bus. The error state can then be reset by turning off and resetting the corresponding IPS component that caused the error. The system includes a fail/safe function that automatically enables the protection function of the IPS component in the event of short-circuit or over-load conditions during which the MCU malfunctions.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  
Figure 9: State switching diagram.  
The overload protection function is implemented using a programmable current limit (PCL) that monitors the supply current delivered by the IPS to the load. The range of the PCL is shown in Figure 11 and is based on the steady state current delivered to the headlights and the current handling capacity of the wire. In this implementation, the upper and lower limits of the headlights to be controlled are 150% and 50%, respectively, which in the case of the headlight loads (H/LP Low LH) were 6.111 and 2.073 A, respectively. The software program is designed to monitor the current during operation, and if a PCL limit is detected (i.e., an abnormal condition is detected), the IPS is cycled off/on 10 times to ensure the detected error was valid. If an overload or underload is detected after the 10 cycles are complete, the software program displays an error flag and terminates the IPS.