06-24-2009 07:42 AM
I am implementing a Simulink .dll model (executing with an integration step of 50ms) with SIT in Real-Time and need to talk via UDP sockets to another device bi-directionally such that all packets are sent from one to the other in-sync and within the timing constraints of my base rate loop.
To reiterate: In the designated structure for Reading within the base rate loop vi that is generated with Connection Manager I have UDP blocks that listen on various ports for packets from my other device (non-NI) and feed data into the .dll, and similarly in the structure designated for Writing I will be sending packets out to this device. Think control loop.
I have not yet begun to implement this because I am realizing that when these two asynchronous devices are sending/listening for packets will not be at the same time unless I have a synching mechanism. I don't believe they have to be kept in sync each 50ms interval, but problems with drift I will have to address later on.
For a first cut at this, where can I implement a block that will sit and wait indefinitely until my other non-NI device sends a Sync packet of some kind to then "kick-off" the 50ms iterations of the model with some initial known relative timing.
Or is there a better way to handle this? I would think this would be a common problem for simulations involving control loops. How is it usually implemented in NI Real-Time with SIT?
Solved! Go to Solution.
06-25-2009 06:30 PM
Hi gdubb85,
You should be able to do this by adding a while loop outside of your driver VI with a Wait Until Next ms Multiple set to 50 ms. In this loop, you can listen for packets with a UDP Read, and send the data that you receive using a functional global to your model.
Regards,
Stephen S.
07-16-2009 08:34 AM