Real-Time Simulation | Virtual Commissioning with Siemens SIMATIC Target 1500S for Simulink, Part 2
From the series: Virtual Commissioning with Siemens SIMATIC Target 1500S for Simulink
Felipe Ravazzi Iaconis, Siemens AG
Due to the increasing share of software in modern production machines and systems, the risk of not being able to keep costs, project duration, and quality during on-site commissioning is increasing. The late availability of the physical machine or plant makes testing the machine software more difficult.
Virtual commissioning enables early testing and verification of the software using a digital model of the machine. In the simulation model, the interaction between mechanics, machine software, and the product to be manufactured can be tested, optimized, and verified in various scenarios before the physical machine is available. This approach reduces costs, ensures high product quality, and speeds up commissioning.
Learn how to use a digital twin of your machine to test the control algorithm on your PLC in real time. You'll follow the necessary steps to create a real-time application from a Simulink® model and run it on a Speedgoat® target computer hardware, then establish the connection between the Speedgoat target computer and a PLC via PROFINET Fieldbus. Finally, you'll see how the virtual commissioning takes place with the help of a Siemens® S7 PLC.
Published: 23 Mar 2021
Hello, and welcome to the webinar virtual commissioning of a hill application with SIMATIC Target 1500S for Simulink. My name is Conrado Ramirez Garcia, and I am an application engineer at MathWorks. In this webinar, I will be accompanied by a colleague from Siemens, Felipe, would you please introduce yourself? Thank you, Conrado, and hello also from my side.
My name is Felipe Ravazzi, I work at Siemens as a technical consultant and pre-sale support, supporting topics around the SIMATIC Target 1500S on our PC based controllers, and also virtual commissioning with MATLAB Simulink.
This is the agenda for today's webinar. We will start by providing an overview of the integration workflow, where we are going to give more specific information about the system and their testing, as well as the hardware setup. In the second chapter, Simulation in Real-Time Hardware, we will focus on the steps needed to convert the plant model on their design into a Real-Time application, so that we can run it on a SpeakWith hardware.
The next part will cover the steps needed to deploy a control algorithm on a PLC. This will describe the settings required in TIA Portal to configure appropriate interface. Once both algorithms have been deployed for the speedgoat and the PLC, we will conclude the webinar by showing the cost of simulation between both hardware, using PROFINET communication. At the end, we will summarize by showing the products used to build the application.
In the last webinar, it was shown the virtual model of a robotic arm controlled by an algorithm and Stateflow. The control algorithm was deployed on the battlefield scene and using PLC advanced, it was simulated. The robotic arm model was entirely created and simulated in Simulink, and the communication, which involved both models, was enabled through shared memory. As you see on the upper diagram, this is summarized under Desktop Simulation block. In other words, the whole simulation is happening on one single computer.
Today's webinar is focused on the Real-Time Simulation block. The control algorithm will be deployed on a real field scene, using the SIMATIC Target 1500s for Simulink, and for the plant model, we are using Simulink Real-Time, in order to deploy it into the speedgoat Real-Time hardware. As you can see, those blocks represent different systems and they are independent from each other. So the only way to communicate and exchange data is through PROFINET link. And that's what we're going to see in this webinar. So, how to achieve the cost of simulation, in real time for both hardware.
This is the mother representing the robotic arm that we will use for the Real-Time simulation. But before we start, there is a couple of settings that we need to modify in order to convert a desktop model into a Real-Time application.
In the model settings, we need to make sure that we are using the right solver. It should run with a fixed size, and the solver should be able to run physical models. In this case, we select ode14x solver. Another important thing to configure is code generation settings. So we navigate to the code generation part, and
on their system target file, we browse the available options. We need to look for Simulink Real-Time so that we are able to deploy the model on the speedgoat.
Now that the changes has been applied, we see that another tab appears called Real-Time. This includes the options needed to configure the speedgoat. So at this point, the model is configured to run on Real-Time time on the speedgoat however, we are still missing the interface to be able to communicate with the Siemens PLC. So if we navigate to the library browser, and we look for the Speedgoat library, we find the IO75X. So in this port, we need to configure a PROFINET device, a slave, and in there we find the send and receive ports responsible for the profit communication, as well as the setup block. All of these blocks are included in the model by drag and drop.
So in the model, we receive for inputs from the PLC. And those input signals are read by the receive port. If we check this block, we see that we are receiving 32 bytes, so that means that we are reading for inputs from double data type. And here is also configure the sample time, so that means execution. And is configured to 10 milliseconds.
In a similar way, the same port is also sending 8 invites, so it's according to the outputs that we have in the model. And execution time is 10 milliseconds, as well. In the setup lock, the configuration is done by a configuration file externally. So, up to this point, we saw the Model Configuration for Simulink in Real-Time. Now Felipe is going to provide an overview of the setup in TIA Portal.
As Conrado already mentioned, we want to have the logic of the robot arm being executed on a Siemens Open Controller. And we want to have the model of the robot itself running on the Real-Time hardware, which is in this case, our speedgoat. So what I will be talking about is, firstly, the configuration in TIA Portal that we have to do.
So, when we remember the last webinar, we have been using the Target 1500S to compile the models and run them onto the Siemens's PLCs. Now, we are using the Open Controller as a real hardware for Real-Time simulation. So the Target 1500S, well here export all the function blocks that we need inside of our user program. What we want to do now is the connection between the Open Controller and the speedgoat hardware.
So the first thing we need to do is install the GSD file. This is the file that is used to describe the hardware that we're using to connect over PROFINET IO. So here, the first thing we need to do is specify the source path where our GSD file is located. Select the package and install. After the installation is done, we can go back to our device overview.
Go to our hardware catalog, and then go to other fuel devices, PROFINET IO, and then we select the PROFINET device that we are using, which is in this case, this one. Now, we can establish a connection by drag and dropping it to the correct interface. Next step, would be adding our IOs that we have within this PROFINET device. So here, for our model, we are using 4 outputs that are all real variables, or long real variables, which means we need at least 32 bytes of memory for the inputs and for the outputs. So in this case, we can select the device, enlarge this window a little bit, and then here, we can select input and output modules.
So, firstly, we drag and drop the inputs, then the outputs. Perfect. And here, I can already see my IO addresses. So I have, for my inputs, I have the addresses from 0 to 31, and for the outputs, the exact same thing. Perfect. So now what we can do, is specify our text in the PLC tag table. This I have already done beforehand. So here, I have the inputs and the outputs for my model already connected to the respective input and output addresses that I have on my hardware.
Now let's have a look at the PLC program. Here on the left-hand side, I have one organization block which is responsible for the PLC cycle, which I have set to a fixed 10 milliseconds. Here in the first step, what we are doing is we are reading the values from the PLC tag table, and writing them to a local data block. So this means we are collecting the current status of our robot arm.
Then here, in the second network, I am running them through the robot arm state machine, which I have previously generated with the Target 1500S, and then I'm writing these new states here back to my data block. And then the final step, of course, I am writing the new states of my robot back to my speedgoat hardware. So now, I would like to hand over to Conrado, to show us the full simulation in action.
Thank you, Felipe. Now, I will explain the set up for the cost of simulation. In the previous chapters, we have seen the steps required to prepare a model to run as a Real-Time application. The control algorithm was deployed on the PLC, and the robotic arm model was prepared to run on the speedgoat. As you'll see in the diagram below, Real-Time simulation, the PLC and the speedgoat run independently in different platforms and exchange data through a PROFINET connection.
With the current configuration, we are able to lock and visualize data for further analysis. However, we are missing the animation of the robotic arm. In the desktop simulation diagram, on top, there is some other responsible for the robotic arm animation. This model will run in parallel to the Real-Time simulation in closed loop and will retrieve data from the speedgoat through UDP communication. This data will provide information about the position of every articulation and component of the robotic arm. I will switch to the animation model in Simulink, so that we see how this is done.
This is the model we will use for the animation, and on the right hand side, in the mechanics explorer, we see the 3D model of the robotic arm. In the Simulink model, we see that there are no input signals connected, and if we open the model, we see each component. These components are reading or are receiving all the information from go-to blocks. If we go back in the model, we see that there is a receive block. This is the UDP receive block that is reading all the information from the speedgoat, and this information and data is provided to the go-to blocks, so that they are provided to the model. Now, I am going to switch to the Real-Time model that we saw in the previous chapter.
In the Real-Time model, we also have the UDP Send block, so that we can communicate with animation model. Now, the first step is to establish the connection with a speedgoat, so we click the Connect button. And then, we build the application, so that we'll start the code generation process. Once the code has been generated, we deploy it to the target. And then, we connect to the model. The application is ready to run, but we first need to prepare the control algorithm into TIA Portal, so we will switch to the TIA Portal environment.
Here, in TIA Portal, we have the block representing the control algorithm, which will be deployed on the PLC. So now, I will proceed to deploy it on the hardware. Now that it has been deployed to the hardware, I will start the monitoring process, so that we can watch all of the signals in Real-time.
So at this point, we're ready to start the application on the speedgoat side and see the closed loop simulation. Now that the PLC is up and running, I will first start the animation model, followed by starting the application on the speedgoat. So we click on the Run button, and we see that the model is getting compiled.
So now, we can see that the animation already started, and we can now start application of the speedgoat, so we click on the Start application button. So we can immediately see that the robotic arm is being moved and controlled, so once again, this model is being controlled in Real-Time or is reading all
the values from the speedgoat from the Real-Time simulation. So we can also see that the values are being updated in TIA Portal, so now the simulation is finished. So, we saw that the PLC was controlling the virtual model, and animation was the representation of the robotic arm. So what's next, I will talk about the products we use in order to build the virtual commissioning application.
Here, we're listing to products used to build the virtual commissioning application. From the MathWorks side, we use MATLAB and Simulink, a simulation platform. Simscape and Simscape Multibody were used to build the robotic arm model used in the animation. And with the Stateflow, we were able to model the State Machine responsible for the control algorithm. MATLAB Coder and Simulink Coder were used for this C/C++ code generation, and this code was exported into the TIA Portal by means of the SIMATIC Target 1500S. Simulink Real Time was used to deploy the robotic arm model in the speedgoat hardware and also to enable the Real-Time simulation. So that's all for today's webinar, and thanks for watching.
Related Products
Learn More
Featured Product
Simulink Real-Time
Related Videos:
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia-Pacífico
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)