author, manage, and execute simulation-based tests of generated code
author, manage, and execute simulation-based tests of the generated code, by using simulink® test™ with simulink plc coder™.
if you do not have the
plcdemo_simple_subsystem
model open, open it.create a signal build test harness for the subsystem. to create a test harness for a subsystem, select the subsystem, right-click, and from the context menu, select test harness > create for
. set test harness properties through the create test harness dialog box. open the plc coder app. click the plc code tab.
click settings.
in the configuration parameters dialog box, on the plc code generation pane, select a target and click the generate testbench for subsystem check box.
click ok.
select the
test harness window
subsystem, click the plc code tab and click generate plc code. the generated code contains multiple test benches from the signal builder. you can run this code in the plc emulator to make sure it matches your model simulation.
limitations
if you use anything other than a signal builder block in the test harness, you must create a top-level atomic subsystem in the test harness that contains the subsystem under test and the testing blocks (for example, test sequence block) and generate code for this subsystem.
simulink plc coder does not support the
verify
keyword in the test sequence blocksimulink plc coder supports the
duration
keyword in the test sequence block but it requires that you run the generated code with the same sample rate as in the simulink model.