Implementing a real-time clock
10 次查看(过去 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 中查找有关 Sources 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!