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_subsystemmodel 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 <subsystem name>. Set test harness properties through the Create Test Harness dialog box.
Open the PLC Coder app. Click the PLC Code tab.
In the Configuration Parameters dialog box, on the PLC Code Generation pane, select a target and click the Generate testbench for subsystem check box.
Test Harness Windowsubsystem, 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.
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
verifykeyword in the test sequence block
Simulink PLC Coder supports the
durationkeyword in the test sequence block but it requires that you run the generated code with the same sample rate as in the Simulink model.