Can I use data from the OPC toolbox to run a real time simulation with Simulink Desktop Real-Time using a model that I created with Simscape?

12 visualizaciones (últimos 30 días)
I'm creating a model using Simscape and I want to use real time data coming from a PLC to run a simulation using the Simulink Desktop Real-Time and the model created with Simscape, is it posible? Is there another way to get this real time data from the PLC?
I'm basically trying to develop a digital twin (using historical and real time data) for optimization purposes.
  2 comentarios
Vasco Lenzi
Vasco Lenzi el 10 de Jul. de 2020
Hi Matheus, great question.
I have a couple of follow-up questions:
1) Which PLC vendor are you using, and which software platform? We have various way to integrate with them.
2) Which release of Simulink are you using? Are you locked-in in a release?
3) Which version of OPC? UA vs DA. Is OPC a "must-have" (because of the machine architecture, maybe other systems using OPC) or would you use it only to connect Simulink to it?
4) How fast does your model runs when you simulate on your computer - is it faster than real-time or slower than real-time?
Matheus Andrade
Matheus Andrade el 10 de Jul. de 2020
Editada: Matheus Andrade el 10 de Jul. de 2020
Hi, Vasco! Thank you for the reply.
I'm actually using Matlab/Simulink for the first time and I'm not working on it yet because my university is not working,.so I might not have some of the answears you want, I'll try my best!
1) It will be probably a Siemens S7 1200 PLC, but it could be the Rockwell Micro850.
2) I don't know for sure, but my university have one of the latest, 2018 or 2019 I guess.
3) It could be OPC UA that is more recent. But it is not a "must-have", I found out that it could be the easiest, but I'm not stuck with it. It would be used just to provide some data from PLC to Simulink.
4) I don't have a model yet, but just for you to have a way to measure it, this will be the digital twin of a steam distilation system, so my variables don't change so fast and my simulation doesn't have to work so fast.
I hope this is enough to make you understand!

Iniciar sesión para comentar.

Respuesta aceptada

Vasco Lenzi
Vasco Lenzi el 13 de Jul. de 2020
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
  3 comentarios
Vasco Lenzi
Vasco Lenzi el 14 de Jul. de 2020
That sounds like a great project! We have an example of machine learning developed in MATLAB and then implemented in a simulink model used as a digital twin:
It can be a great example for you to take a look at.
Cheers
Vasco
Matheus Andrade
Matheus Andrade el 14 de Jul. de 2020
This digital twin you talked about may be somehow like mine.and it can help me a lot! Thank you for all the support!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Install Products en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by