Hi @Djordje ,
After reviewing your comments, I will suggest create a top-level model named controller_overall. It should contain four subsystems, each representing a phase controller (ctrl_phase0, ctrl_phase1, ctrl_phase2, ctrl_phase3). In this case, each subsystem will be responsible for controlling its respective phase of the DC-DC converter. Instead of using triggered subsystems, I would recommend utilizing pulse generators to create the phase-shifted signals. Set the frequency of all pulse generators to match the desired switching frequency of the converter. For example, if the switching frequency is f, the period T is 1/f. Each pulse generator should be configured to output a pulse with a duration that corresponds to the desired duty cycle.The phase offsets for each generator can be set as follows:
ctrl_phase0: 0 seconds ctrl_phase1: T/4 seconds ctrl_phase2: T/2 seconds ctrl_phase3: 3T/4 seconds
Also, instead of using triggered subsystems, convert each ctrl_phaseN subsystem into a function-call subsystem. This allows you to call the subsystems directly from the main model without generating additional triggered subsystem code. Connect the output of each pulse generator to the corresponding function-call subsystem. This way, the function-call subsystem will execute when the pulse generator outputs a signal. In the Simulink model, navigate to the Configuration Parameters and ensure that the code generation settings are optimized for your target microcontroller.
- Set the "System target file" to match your microcontroller's requirements (e.g., ert.tlc for Embedded Coder).
- Under "Code Generation", ensure that "Generate function calls" is selected to facilitate the function-call subsystem execution.
In your microcontroller code, implement an ISR that will call each of the function-call subsystems based on the timing dictated by the phase shifts. This can be done using a timer interrupt that triggers at the frequency of the pulse generators. Using this approach avoids any additional generated code associated with triggered subsystems and allows you to implement precise timing control based on the microcontroller's clock. Example Implementation:
void ISR_Handler() { if (check_time_for_phase(0)) { ctrl_phase0(); } if (check_time_for_phase(1)) { ctrl_phase1(); } if (check_time_for_phase(2)) { ctrl_phase2(); } if (check_time_for_phase(3)) { ctrl_phase3(); } }
Hope this helps.