MATLAB Answers

How can I verify if an output signal changed within a given time slot after a trigger (input) signal was set using Simulink Test R2019b?

3 views (last 30 days)
I have a signal out which has to be set by the system under test within a certain time slot. This is what I have to verify if e.g. signal out is set within 5 to 10 ms after the trigger signal in was set. Assuming that the signal out is set by SuT at 7.6ms (sample time is 0.5 ms) and I verify with a "hasChangedTo"-request, I get the just sample this sample with the result PASS. All other samples within the defined time slot (5-10 ms) will FAIL. 
If I use this test within Simulink Test Manager, the whole test will fail and this is what I want to avoid because the signal changed within the specified time slot and therefore the result has to be PASSED. How can I realize this?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Oct 2021 at 4:00
Edited: MathWorks Support Team on 18 Oct 2021 at 15:11
There are several possibilities:
1)
The most convenient way to accomplish this is using Trigger Response of Temporal Assessments in Test Manager:https://www.mathworks.com/help/releases/R2021a/sltest/ug/temporal-assessments.html#mw_5b12980d-9bbe-4b5e-b5d2-dc4a633d9078
This could be set up like this:
2) 
One other thing you can do is to use a local variable (local data) as a flag to indicate whether the change has happened and do something like below (a very rough sketch but shows the idea):\n
initialize the flag as false
when before 10ms
  verify(signal != 1);
when between 10ms and 15ms
  if flag == false && hasChangedTo(signal, 1)
    flag = true;
  end
when after 15ms
  verify(flag == true)
end
So that it never fails between 10 ~15 ms and will only fail before 10 ms or after 15 ms.
For more information about how to use local data see: https://www.mathworks.com/help/releases/R2021a/sltest/ug/test-sequence-editor.html#mw_a309f004-f9ff-42eb-a935-961e789845c0
This is a possible solution when having the test steps and verify statements define in one and the same Test Sequence block.
3) 
In case you are using separate Test Sequence and Assessment blocks you'd need to use a Data Store as a flag instead of local data. Please find an example attached that gives an idea of how to set this up.
The main things are:
Test Sequence Block:
Here you can see the implementation of the flag and the 15 ms as the latest time for switching the output signal.
Assessment Block:
The "flag" can be seen here again as well as 3 assessments. The latter two are used to check whether the switching of the output signal took place within the specified time frame of 5-15ms.
The Data Store Memory Block itself is placed directly in the Harness.
A test file that simulates the harness and evaluates the assessment results is also attached.
There is also another way to realize option (3) - please see LocalData_example_v2.slx for reference:
Basically, this is to record the simulation time at which "input" changes in Test Sequence and pass it to the Test Assessment. I/O is used to pass it but Data Store Memory would also work. And then in the Test Assessment block, when it detects the change of "out", verify the time difference is between 5 and 15.
Here, "t" is a reserved keyword that returns the current simulation time. "latch" returns the value of an expression when it first enters the step. For details, see below.
https://www.mathworks.com/help/releases/R2021a/sltest/ref/t.htmlhttps://www.mathworks.com/help/releases/R2021a/sltest/ref/latch.html
Test Sequence Block:
Assessment Block:

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!