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
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 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
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.
PLC Coder does not support the
verify keyword in the test
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.