Implementing a real-time clock
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi, I am new to matlab. Currently, I am doing this as a school project and need help urgently.
I have two workstations with a lan cable connected. Both are running matlab concurrently with one side as the sending end, while the other is the receiving end. I am using udp simulink blocks to transmitting the data. (SimUdpClient block and SimUdpServer block)
I am suppose to implement a real-time clock to synchronize between the transmitting end and the receiving end. The objective is to get the receiving end and the transmitting end on the same clock. What are the simulink blocks that are relevant? Need some help here. Thank you in advance.
댓글 수: 2
MarkB
2011년 3월 10일
This might be a lot more complicated than it initially seems. The primary issue is that, outside of our Real-Time Windows Target product, there's really no way to make Simulink run in real-time.
The primary obstacles are the fact that there's no way to control how many other programs and OS services are running on the computer and as a result, there's no way to ensure when Simulink gets its "share" of computing resources. In addition to this, depending on the size of the model, it can always be too big and require more than a real-world second to calculate a simulated second.
There are some blocks on MATLAB Central that put in "wait" behavior to slow models down to roughly real-time, but these only work in the cases where the model would have otherwise run too quickly. Furthermore, they are only as accurate as the operating system utilities used for monitoring time.
답변 (1개)
Seth Popinchalk
2011년 3월 13일
You will not be able to achieve "hard real-time" with a configuration using two PCs running MATLAB without some kind of real-time kernel controlling the system.
However, simulating real-time clock synchronization is still possible. You will need to implement some kind of mechanism to slow down the simulation clock (like implementing a pause) if you are faster than the other computer. This can be done with crude methods like a while loop that checks for a certain amount of wall time to pass, or more elaborate scheduling techniques that rely on the OS to schedule a wait condition.
The Aerospace Blockset includes a Pace block to control simulation speed. You may also want to use any discrete time block with a known step size to control execution of a subsystem that eats cycles. Stateflow would also be a very natural way to implement such a system.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Development Computer Setup에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!