Sunday, March 1, 2015

How to exchange data with a running SIMULINK model from MATLAB workspace

I have a SIMULINK model to filter and process sensor data. I wanted to access some of model data from MATLAB workspace while the model was running.

How-i-fixed-it:

In my simulink model i added a non-blocking UDP receive block, a triggered subsystem ad a UDP send block.
The Status output of the UDP receive block triggers the subsystem which contains the UDP send block and received as Input the model data i want to send to the workspace.

In the workspace i create a UDP object to communicate with the UDP blocks in the SIMULINK model.
When the model is running, i send just a single byte on UDP from Workspace to the UDP Receive to Trigger the send. Next step is to read the desired number of bytes from the udp port in the workspace.

I found out, that the timing of this solution is not very performant. When the model is very busy (or at least the CPU is), then there can be significant delays in the model sending out the data on UDP. I think this does not work for real-time Systems, but its a simple solution to get it working.

for details click below

No comments:

Post a Comment