MATLAB DISCUSSION

What changes when a Simulink controller moves from variable-step simulation to an MCU?

Started by dattakakade Simulink deploymentfixed-step simulationMCU timingcontrol loopssample time
3 replies 248 views 4 participants
Latest activity · 27 Sep 2026

What changes when a Simulink controller moves from variable-step simulation to an MCU?

dattakakade MATLAB Forum
#1

A controller can look satisfactory in a desktop simulation while behaving differently after deployment. What should be checked when moving from a variable-step simulation to a periodically executed microcontroller implementation?

Suppose the target control task is intended to run every 1 ms. How do solver settings, discretization, execution time and sensor delays contribute different errors?

Community replies 3

Re: What changes when a Simulink controller moves from variable-step simulation to an MCU?

#2

Distinguish the numerical solver step from the controller's sample interval. A variable-step plant simulation can take smaller steps around rapid changes, while the deployed controller sees measurements only at scheduled instants. Model the intended discrete controller, sampling and holds explicitly, and use solver settings that resolve the plant dynamics. A smaller desktop solver step does not make the physical ADC sample faster.

Re: What changes when a Simulink controller moves from variable-step simulation to an MCU?

#3

Budget the entire 1 ms interval: acquisition, conversion, control calculation, output update and scheduling overhead. Measure worst observed execution time under representative load and include an engineering margin; an average below 1 ms is insufficient. Define what happens if an update misses its deadline. Logging every sample over a slow serial link can itself create the overrun being investigated.

Re: What changes when a Simulink controller moves from variable-step simulation to an MCU?

#4

Add realistic delays and limits to the model before comparing with hardware. ADC conversion, filtering, communication and actuator response all affect phase and timing. Compare the same input sequence and initial conditions on both systems. If they disagree, investigate one source at a time, including numeric precision and saturation, instead of changing gains until the plots happen to resemble each other.

TEP COMMUNITY