Simulink - External Mode
Hi, I am able to run a Simulink model in PLCnext but I have issues when trying External Mode .
I enabled the External Mode and entered the PLC's IP in the MEX-file arguments box under the Interface Tab in Code Generation , I did a Build for Monitoring from the Hardware Tab ( I can see that the library in PLCNext updates ) ,but then when I hit Connect I get the error :
An error occurred attempting to open an rtIOStream. More detail may be reported in the MATLAB command window
In the Matlab window I get : Attempting to establish connection with hostname '192.168.1.10' through port 17725.
It seems that I'm missing a step here but couldn't figure out how to get this to work . I'm following Rev12 of the UM which is the latest I believe.
Thanks for the help
Comments
Can you confirm that port 17725 is not blocked by a firewall?
yes, the firewall is actually turned off for all public/private/domain profiles
Sorry for the delay.
The configuration on the Simulink page is set correctly.
In order to establish a connection, the port in the Simulink configuration must also be changed in PLCnext Engineer.
Since the model was already built for external mode, we assume that the following steps have already been taken:
1) Model was compiled with "Build for Monitoring".
2) Include the model library in PLCNext.
3) Write project to the controller and start it. PLCnext Engineer should go online to the controller, and into "Debug" mode.
Now comes the missing piece:
Every model that is built for the External Mode contains a
s_Ctrl: Ctrl
port in the GDS Port List. The GDS Port List is visible in PLCnext Engineer, in the "PLCnext" branch of the project tree. By changing the value in this GDS Port variable, the setting for External Mode can be changed.4) In PLCnext Engineer, add the
s_Ctrl:Ctrl
variable into the Watch Window and change the value ofExtModePort
. The value of this variable must be changed to be the same as the port value in Simulink.After doing this, connection should be possible.
Please let us know if this works - if so, I will ask for the documentation to be updated.
hi Martin,
yes, that works. Thank you for the help. I found the note in the manual after doing more digging and searching for this specific ExtModePort