How to get system time into simulink (under Real-time windows target)?
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
For the purpose of time stamping, I would like to read system time, i.e., PC clock, in Simulink under 'Real-time windows target'. Any ideas how to do this?
0 Kommentare
Antworten (1)
Jan Houska
am 28 Nov. 2014
In Normal mode, you can use any method you would use in Simulink. For example, a MATLAB Function block that returns the output of the clock function.
However, this wouldn't work in External Mode. Although there are ways to achieve the goal in External Mode, their usability depends on what you are trying to timestamp, what accuracy you need, etc. For example, I think I would be able to suggest a setup that would generate timestamps that would be highly accurate relative to each other but their absolute accuracy would be limited (the whole timestamp series may be somewhat shifted in time). Please let me know if you are interested.
2 Kommentare
Jan Houska
am 1 Dez. 2014
Getting an absolute accuracy in order of milliseconds will be a real challenge. This would require to have your PC clock running exactly to a millisecond which is rarely the case and is itself difficult to achieve.
Anyway, I'm attaching a model that attempts to do what you need. It uses simulation time to get relative offset for timestamps and then reads the system time in a callback to Initial time offset block and adds it to the relative time. Because there is some delay between the execution of the callback and actual start of the model, additional offset is added by the Time offset tuning that can be fine-tuned to compensate for that.
Using this model, you should be able to get sub-millisecond relative accuracy of the timestamps (one vs. another), and absolute accuracy to hundreds or maybe even tens of milliseconds.
Siehe auch
Kategorien
Mehr zu Target Computer Setup finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!