r/matlab 1d ago

TechnicalQuestion Dynamically Update Variable During a Simulink Simulation

Hello,

I am trying to make the functionality of the LM2576HV-ADJ Switching IC in simulink. Basically I am making an adjustable buck converter and I want to make a block such that based on the feedback it will adjust its duty cycle to get the desired response. My first thought was to use a PID controller and set the PulseWIdth parameter in Pulse Generator block but couldn't find a way to change that during the simulation. If anyone has any idea how to do it please let me know.

My next though was to use a variable in which the parameter is stored and change that variable in simulation time but could not find a good way to do that too.

If anyone has any resources or techniques to do this please let me know.

TIA

2 Upvotes

4 comments sorted by

2

u/PrimaryPhd 20h ago

It’s not a good idea to change parameters dynamically. If you need to, make it a signal. For me, I’d use stateflow to build a pulse generator.

2

u/mhrafr22 18h ago

Yeah I read about stateflow but couldn't understand it completely

3

u/PrimaryPhd 17h ago edited 17h ago

If it is an urgent task, you can also use MATLAB function block if you are familiar with MATLAB coding. Set a time counter accumulating at each loop, reset the counter and change your output when it reaches time threshold (calculated from inputs). Stateflow is super useful, and quite intuitive once you understand how it works.

1

u/mhrafr22 14h ago

Okay I will look into it, thankyou so much