Hi Matheus
Thank you for the additional information.
1) Deployment on PLC Itself:
First of all, with most PLC you can generate C code from the model and integrate it into the PLC itself. For instance for Siemens Simatic STEP7:
Usually the code generate is from a controller/state machine, but you can as easily generate code from a physical model of your plant ("digital twin") this would be then run on the PLC itself, with no hassle regarding the communication. A disadvantage would be the reduced possibility to perform optimization of parameters, because of the few computing ressources available on the PLC, depending on your application.
2) Industrial communication - OPC DA
Your idea of using OPC Toolbox and Simulink Desktop Real-Time is a valid one. Simulink Blocks of the OPC toolbox only exist for OPC DA. So you would need to setup the OPC DA, use the block in the model and then run it with Simulink Desktop Real-Time. This is good for simulations that requires a slow time-step such as 1-100 ms.
3) Industrial Communication - MODBUS-TCP/IP
This is particularly good for Siemens PLC. If the PLC suppots MODBUS or TCP/IP, you can use the Instrument Control Toolbox to setup a connection between Simulink and the PLC, and deploy it in near-real-time using Simulink Destop Real-Time. Modbus is supported through MATLAB command, but you may use them in a MATLAB function block in Simulink. see an example here of controlling a PLC using MODBUS Explorer:
4) If hard real-time is a requirement, you may need to go through Simulink Real-Time and a Speedgoat machine
Hope this gives you some inputs and food for thought!
Cheers
Vasco
Best Answer