Main Content

Author, Manage, and Execute Simulation-Based Tests of Generated Code

Author, manage, and execute simulation-based tests of the generated code, by using金宝app®Test™withSimulink PLC Coder™.

  1. If you do not have theplcdemo_simple_subsystemmodel open, open it.

  2. 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, selectTest Harness>Create for . Set test harness properties through the Create Test Harness dialog box.

  3. Open thePLC Coderapp. Click thePLC Codetab.

  4. ClickSettings.

  5. In the Configuration Parameters dialog box, on thePLC Code Generationpane, select a target and click theGenerate testbench for subsystemcheck box.

  6. ClickOK.

  7. Select theTest Harness Windowsubsystem, click thePLC Codetab and clickGenerate 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 Coderdoes not support theverifykeyword in the test sequence block

  • Simulink PLC Codersupports thedurationkeyword in the test sequence block but it requires that you run the generated code with the same sample rate as in the Simulink model.