How can I align Simulink Real-Time (SLRT) logging data with the datetime the model was running?

How can I align Simulink Real-Time (SLRT) logging data with the datetime the model was running?
Checking the log, I can only see a time vector, that is counting seconds. I want to change this vector to the datetime that data was logged on.

 Accepted Answer

Simulink Real-Time can only log relative to simulation start, which will be t=0s in the logs.
To align this with the system time the model was running at, please use the following steps:
1) Add an IEEE 1588 Read Parameter block to your model:https://www.mathworks.com/help/slrealtime/io_ref/ieee1588readparameter.html
Because Simulink only supports numeric data types, you won't find the datetime as a direct output of this block.
2) Check the output variants, but the default (nanosecond system time) is likely the best for postprocessing.
Enable logging on the output of this block.
3) When processing the log, you can convert the nanoseconds since Epoch to a datetime type, e.g. with the following:
sys_dt = datetime(ieee_out, 'ConvertFrom', 'epochtime', 'TicksPerSecond', 1e9);
https://www.mathworks.com/help/matlab/ref/datetime.html#d126e365886
4) Use this result in your further postprocessing steps.
This procedure can also be used to synchronize data logged at the same time from different Speedgoat machines.

More Answers (0)

Categories

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!