Implementing a real-time clock

7 visualizaciones (últimos 30 días)
Francis
Francis el 9 de Mzo. de 2011
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 comentarios
MarkB
MarkB el 10 de Mzo. de 2011
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.
Francis
Francis el 13 de Mzo. de 2011
Hi Mark.
As what you have mentioned, does that mean that only Real-Time Window Target can simulate a real-time clock? What are the blocks that I can use from RTWT, so that I can simulate a clock which synchronise data transfer. Thank you.

Iniciar sesión para comentar.

Respuestas (1)

Seth Popinchalk
Seth Popinchalk el 13 de Mzo. de 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.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by