This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Using Simulink Test with Simulink PLC Coder

You can use Simulink® Test™ with Simulink PLC Coder™ to author, manage, and execute simulation-based tests of the generated code.

  1. If you do not have the plcdemo_simple_subsystem model open, open it now.

  2. Create a signal build test harness for the subsystem as shown. To create a test harness for a subsystem, select the subsystem and select Analysis > Test Harness > Create for <subsystem name>. Set test harness properties using the Create Test Harness dialog box.

  3. Right-click the Subsystem block and select PLC Code > Options. The Configuration Parameters dialog box is displayed.

  4. On the PLC Code Generation pane, select a target and enable the Generate testbench for subsystemoption.

  5. Click Apply.

  6. Right-click and select Generate code for the subsystem from the Test Harness Window. 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 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 both the subsystem under test and the testing blocks (for example, say test sequence block) and generate code for this subsystem.

  • Simulink PLC Coder does not yet support verify keyword in the test sequence block

  • Simulink PLC Coder does support duration keyword in the test sequence block but it requires the generate code to be run with the same sample rate as in the Simulink model