Implementing a real-time clock
12 views (last 30 days)
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.
Seth Popinchalk on 13 Mar 2011
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.