Configure a project in TIA Portal for emulation
Start by launching Siemens TIA Portal and creating a new project (or opening an existing one).
In this example, we choose a 1212C AC/DC/Rly.
Start by right-clicking on the project and going into Properties.
Then select the Protection tab, and fill in the checkbox next to Support simulation during block compilation. Click OK to accept the change.
Then right-click on the PLC and go to Properties and select Protection & Security. Make sure Full access is selected to allow the Gateway application to read and write.
Further down the same page, there is a check box for Permit access with PUT / GET communication from remote partner. Make sure it is filled.
Select the settings for Ethernet addresses in the list on the left and enter the IP address of the PLC to be connected.
Then click the Add new subnet button.
Navigate to I/O addresses under DI 8/DQ 6. Ensure that the Organization block has the value None under both inputs and outputs. The model can then read and write in memory without conflicts. This must be done under all addresses that will be used, for the analog signals the same setting is under AI 2 / I/O addresses in this case.
Click OK to accept the changes.
Simple test program
To test the connection, we write a simple program. Start by assigning a name to each input/output that will be used. Simumatik will read and write directly to the addresses, therefore any name can be used for any time.
Now we can create a simple network in OB1. In the example below, the address of the green button is directly linked to the red light.
Now all settings are configured, and we have a simple program to test the connection. The next step is to download the changes to the PLC.
Connect to a PLCSIM instance
This chapter goes through the steps required to connect Simumatik to PLCSIM. If a real PLC will be used to execute the program, this chapter can be skipped (instructions for this can be found in the next chapter).
To connect PLCSIM to a digital twin, the NetToPLCsim program is used. Start by going to http://nettoplcsim.sourceforge.net/ and download the latest version (DOWNLOAD).
NetToPLCsim will be downloaded in a compressed (.zip) folder. Start by unpacking it, then go into the subfolder bin, right-click on the NetToPLCsim application and choose to run as administrator.
If a warning box now appears with the message “Port 102 is in use!”, Then click Yes to continue.
Now the text “Port 102 OK” should be at the bottom left.
In TIA Portal, it is now time to start PLCSIM, click on the Start simulation button.
A “Download to device” box will appear. Click Start search first, and then Load.
The next step is to go back to NetToPLCsim and click Add.
In the “Station” window, we start by selecting the correct “Network IP Address” by pressing the top three-point button and selecting the card from the list. Then click on the lower button with three dots. The PLCSIM instance should appear.
Click OK in the right pane and then select 0 / 1 in the drop-down menus (according to the instructions at the bottom of the pane).
The result should look like the image below. Click Start Server.
The IP address in the column “Network address” is to be entered in the PLC component of the digital twin. Then click on Play in Simumatik to start the emulation, if everything works as it should, the PLC component will update its “status” to “RUNNING”.
Connect to a real PLC
This chapter shows how a real PLC on the same local network can be used to execute the code and connect to the digital twin in Simumatik. First click on the PLC in the project and then on the Download to device button in the toolbar.
This will open a window with communication settings. Select the Ethernet card to be used in the list for PG/PC interface.
Click Start search and wait for the PLC to be added to the list. Continue by clicking Load at the bottom right, then Load without synchronization and select Stop all in the following boxes.
Click on the PLC component in Simumatik and make sure that the IP address matches the IP address previously configured in TIA Portal.
Now the emulation can be started. Again, make sure the gateway is connected, as described in Chapter 4. Then click the Play button on the toolbar to start the emulation.