Simulink Equivalent to 'now'?
이전 댓글 표시
I have been declaring 'now' an extrinsic function in an embedded MATLAB function in Simulink. The trouble is, you can't use extrinsic functions in real time applications using Real Time Windows Target. There doesn't seem to be a Simulink block to access the system time.
I feel the need to write a C/C++ S-Function to try and give the same result. I've never written anything in C/C++ and I don't really think I'm going to be able to figure it out soon enough.
Can anybody help me out here? I kind of figured there would be something in the File Exchange, but searches like 'simulink system time' return huge applications that seem to have nothing to do with what I want.
Thanks in advance,
Zack
답변 (1개)
Walter Roberson
2011년 11월 30일
0 개 추천
I would not really expect Simulink to have a block for that, unless it was a target-specific block, as there are a lot of embedded systems that do not have any time-of-day device.
Time-of-day devices need to have a battery backup, as they must keep counting while the system is otherwise turned off. Those batteries run out, making time-of-day devices unsuitable for situations where there is no interface for the user to input the time.
There is not just one way to interface time-of-day devices: some are port-mapped and some are memory-mapped and some involve running special instruction sequences.
댓글 수: 4
Zachary Santer
2011년 11월 30일
Walter Roberson
2011년 11월 30일
http://www.beaglesoft.com/mainfaqclock.htm#clocks%20in%20pc has some useful information. The software clock it mentions is a function of the operating system; I do not know if it would exist on RTWT. The hardware clock it mentions is standard PC hardware, but as indicated on that site, the readable time resolution is limited to 1 second.
Putting together some information I found, it appears that the standard Real Time Clock (RTC) on MS Windows is accessed via OUT instructions to port 70 and IN instructions from port 71, with the CMOS index being OUT and the response being IN'd. The list of offsets needed is shown at http://www.codepedia.com/1/CMOS_C which makes the very good point that interrupts should be disabled during the reading, as otherwise an interrupt might gain control and OUT something else before you can do the IN, so you would get the wrong value back from the IN.
Walter Roberson
2011년 11월 30일
The 70 and 71 are hex port numbers -- i.e., 112 and 113 decimal.
Zachary Santer
2011년 12월 1일
카테고리
도움말 센터 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!