Check if Connected in External Mode in Simulink

2 views (last 30 days)
I'm using Simulink in combination with TwinCAT (but this question is, I think, not only applicable to TwinCAT). In order for it to work, I build my Simulink model to 'TwinCAT.tlc' target, 'run' it in TwinCAT and use Simulink External Mode to connect to it and control it.
My problem now is that the model controls a robot, and, for safety, I want the robot to be turned off as soon as the connection between Simulink and TwinCAT is broken (and I also want to enable/disable logging based on the connection state).
Hence the question: Is there any way to get into Simulink the current state of connection between Simulink and TwinCAT (or any other target)? I think that it must be a Simulink block that directly outputs it in the model; a Matlab callback function could probably check it, but as soon as the connection is broken it is not able to send any information to the running Simulink executable (since the connection is broken), so that's not good enough.

Answers (0)

Community Treasure Hunt

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

Start Hunting!