Documentation

Test a Model Component Using Signal Functions

Using the Test Sequence block, you can define a set of input functions to test your component, and conditionally switch the function based on component signals. See Test Sequence for more information.

This example demonstrates building and simulating a test sequence using ramp and square wave signals. The test initializes at constant temperature, ramps down to a limit, and executes a square-wave temperature cycle.

Create a Test Sequence

  1. Access the model. Enter

    cd(fullfile(docroot,'toolbox','sltest','examples'))
  2. Copy this model file and supporting files to a writable location on the MATLAB® path:

    sltestSignalFunctionExample.slx
    sltestHeatpumpBusPostLoadFcn.mat
    PumpDirection.m
  3. Open the model, and open the harness.

    open_system('sltestSignalFunctionExample');
    sltest.harness.open('sltestSignalFunctionExample/Controller',...
    'RampSquareHarness')

  4. Double-click the Test Sequence block to open the test sequence editor.

  5. Rename the first and second steps. Delete the default names and replace them with const_90 and ramp_down.

  6. Add a third step to the table. Right-click the ramp_down line, and select Add step after. Name the third step temp_step.

  7. Add output conditions and transition fields to the steps. Copy and paste the listings from the table.

    StepTransitionNext step
    const_90
    Tset = 75;
    Troom_in = 90;
    after(120,sec)
    ramp_down
    ramp_down
    Tset = 75;
    Troom_in = 90-ramp(et)/8;
    Troom_in <= 60
    temp_step
    temp_step
    Tset = 75;
    Troom_in = 75+15*square(et/90);
      

Simulate the Test Harness

  1. Set the simulation time to 720 sec.

  2. Simulate the Test Harness. Observe the Troom_in signal in the scope.

See Also

Blocks

Was this topic helpful?