Simulink Test Sequence, Time Tolerance
17 views (last 30 days)
Show older comments
Hi,
I've been using Simulink Test Sequences to run some time sensitive testing: validation that something is True for 1 second, False for 0.5 seconds, True for 5 seconds, etc.
I am having issues with this, since I am generating these "time till next transition" in my model, but validating that my calculations are correct inside of the Test Sequence (running a calculation in transition steps to find the 'same' time based of inputs). However, my "verify" statements are failing, due to failing for 0.1/0.2/0.3 seconds (the verify is starting too early/ending too late). This isnt due to a malfunction, but timing issues with inputs/state machine transitions/components reacting.
In my test cases, I'd like to set a tolerance for when these tests pass, and was wondering if there was a mechanism to do so. Ive only seen tolerances in terms of values, not in terms of time.
Thanks for the help! Zach
0 Comments
Answers (1)
Khoo Yit Phang
on 5 Feb 2018
Hi,
There isn't any explicit mechanism for time tolerance in Test Sequence, however, you can use the following pattern to achieve something similar (transition conditions omitted):
step_TrueFor1Second
if elapsed == 0
measured = 0;
end
measured = max(measured, duration(input1));
step_FalseForHalfSecond
if elapsed == 0
verify(abs(measured - 1.0) < 0.1, 'TrueFor1Second within 0.1 second tolerance')
measured = 0;
end
measured = max(measured, duration(input2));
step_TrueFor5Seconds
if elapsed == 0
verify(abs(measured - 0.5) < 0.1, 'TrueForHalfSecond within 0.1 second tolerance')
measured = 0;
end
measured = max(measured, duration(input3));
moreSteps
if elapsed == 0
verify(abs(measured - 5) < 0.1, 'TrueFor5Seconds within 0.1 second tolerance')
measured = 0;
end
...
The basic idea is to perform the time measurement in a step (using an auxiliary local "measured" and the "max" and "duration" functions), and verify it with tolerance at the beginning of the next step (if "elapsed == 0").
Let me know if you need further clarification of the above pattern.
Yit
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!