MATLAB: What is a “LibIsSampleHit” function and why can’t PLC Coder generate code for it

libissamplehitplc codersimulinkSimulink PLC Coder

Hi!
I'm working with the PLC Coder demo "Cruise Control" (plcdemo_cruise_control.mdl) and when I run the "Check Subsystem Compatibility" of the PLC Coder menu on the "Controller" module using the default configuration parameters (Ode5 and fixed step size of 0.05) the subsystem passes the check.
But! if I change the step size to 0.01 I get the following error message after running the "Check Subsystem Compatibility":
"Block 'plcdemo_cruise_control/Controller/PID Controller' is configured to operate as function LibIsSampleHit. PLC Coder does not support this function."
I guess this is because the "PID Controller" module has a Discrete Time integrator with a sample time of 0.05.
What is a "LibIsSampleHit" function and why can't the PLC Coder generate code for it??
Thanks, Ferchots.

Best Answer

LibIsSampleHit is used to determine if the block executes on a given step. This is run when the model has multiple rates. Listed under the Current Limitations of the Simulink PLC Coder for R2010b is multi-rate models.
If you want to generate code for this model with the PLC Coder, you will need to change the Discrete Time Integrator in the PID Controller to have a sample time of 0.01.