Device PLCSIM Advanced¶
In the following example, a system is created and used to test a PLC program for a Siemens S7-1500. The PLC program is to be edited by an instance in the Siemens PLCSIM Advanced.
Note: PLCSIM Advanced is not the integrated PLCSIM of the TIA Portal. PLCSIM Advanced offers extended simulation options for PLC programs using the S7-1500. The PLCSIM Advanced software must be purchased in addition to the TIA Portal. Information about PLCSIM Advanced: https://support.industry.siemens.com/cs/document/109739660/simatic-s7-plcsim-advanced%3A-co-simulation-via-api?dti=0&lc=de-WW
As of version 18.104.22.168, PLC-Lab supports the PLCSIM Advanced device. The PLCSIM Advanced version 2.0 SP1 or higher must be used.
Starting the PLCSIM Advanced and creating an instance¶
In the first step, start the PLCSIM Advanced control panel.
Now you have to specify the name of an instance. In the example we use "Instance1".
Click the "Start" button to start the instance. Shortly afterwards the instance can be viewed.
The instance represents a CPU. It cannot be switched to Run at the moment because it has not yet been configured. You will do this in the next step using the TIA Portal.
Starting the TIA Portal and creating a new project¶
After starting the TIA Portal, a new project is created.
Then you have to configure the device.
Within the PLC family S7-1500, select an S7-1513 for our example. It does not matter which CPU is selected. It must be an S7-1500 with a version that is higher than V1.8 so that the PLCSIM Advanced can simulate it. The CPUs that are supported can be found in the manual or in the help section of PLCSIM Advanced.
Switch to the project view in the TIA and call up the device configuration of the station.
You can find this entry within the task card "Project Navigation". Double click to display the station with the modules; currently only the CPU is displayed. In the example we will configure the inputs I0.0 to I1.7 and Q0.0 to Q1.7 as modules. This means that you can insert a DI16 and a DQ16 from the module catalog into the rack of the PLC. Set the start address of each module to 0.
Make sure that the input and output modules for the inputs and outputs used in PLC-Lab are available in the hardware configuration of the S7-1500. Otherwise PLCSIM Advanced will not synchronize them correctly with the process image.
After these actions, the PLC will look as follows:
Simulating the blocks in the TIA project¶
Before we can create the PLC program, we must set the simulatability of the blocks in the TIA project.
The PLC program cannot be simulated in PLCSIM Advanced without setting the simulability of the blocks in the TIA project.
For this purpose, call up the context menu of the project and its properties within the Task Card "Project Navigation".
As a result, the dialog with the properties of the project is displayed. You will find the necessary setting in the "Protection" tab.
After selection you can confirm the dialog with OK.
Creating the OB1 in the TIA Portal¶
The PLC program requires only three operands, which are provided with symbols in the variable table.
The actual PLC program is programmed in OB1 and has the following appearance.
It consists of an S/R element. Indicate the I0.0 "Start" at the S input and the negated I0.1 "Stop" at the R input. The memory is assigned to Q0.0 "LampeStart".
Transferring the settings and the PLC program to PLCSIM Advanced¶
This completes the configuration and the PLC program. The hardware and software can be translated and transferred to the instance of PLCSIM Advanced. To do this, select "Translate->Hardware and Software" in the context menu of the station.
Then select the menu item "Load to device->Hardware and software" in the context menu.
After that you can see the dialog "Preview Load" ...
... and then the dialog "Results of the loading process".
In the latter case, you have to set the start of the module.
After these actions, the state of the instance on the PLCSIM Advanced Control Panel has changed. The CPU is now displayed in RUN mode.
After starting PLC-Lab a new project is selected.
Creating a new PLCSIM Advanced Device¶
In the first step, a new device of the type "PLCSIM Advanced" is created. To do this, click the "Create a new Device" button in the symbol table.
In the dialog that appears, select "PLCSIM Advanced" as the device type. In the example, we use "Advanced01" as the name for the device. You can choose this name as you like.
Click OK to confirm the dialog. The "PLCSIM Advanced Settings" dialog appears. Enter the name of the PLCSIM Advanced instance to be addressed. In the example, the instance has the name "Instance1", which can be viewed on the PLCSIM Advanced Control Panel. If you do not enter the correct name, there will be no connection. Below you can see the dialog filled out for the example.
You can also confirm this via OK.
Creating operands and symbols¶
Now you have to enter the operands and symbols in the symbol table. You can also import the symbols from the TIA variable table (as XML), but you should create the three operands required for the example manually.
It is important that the operands are assigned to the device "Advanced01". Therefore, you have to select this device in the device selection.
Once finished, you can insert the first operand into the table. To do this, click the insert button in the symbol table.
As a result, the first operand with the address I0.0 is now available in the symbol table. The operand has a standard symbol, which you have to change to "Start".
The tab key takes you to the line of the operand. Here the address I0.0 is indicated, which stands for input 0.0. You can now change the address to E0.0 if you want to use German syntax. Or you leave the address as it is. Enter "Start-Taster" as comment.
You can now use the insert button to insert the other two operands and specify their symbols. You have to change the operand for the lamp to A0.0 or Q0.0. Below you find the completed symbol table.
Placing push-buttons and lamps¶
In the next step, we will place the two push-buttons and the lamp for our example.
Start with the start push-button "Start-Taster". Select a green switch in the category "Switches->Switches not illuminated".
Then move the mouse to the position within the drawing board where you want to place the switch. The mouse pointer now resembles a cross. Use the left mouse button to drag the switch object onto the drawing board. When you let go of the mouse button, the process is completed.
After the switch has been placed, its properties are displayed in the object properties table. In the example, the operand to which the switch object is connected should be specified first. It will be affected when the switch is actuated. Several options are available for specifying the operand:
First option "Autocompletion": In the first option, in the cell for the operand, the device name followed by a period is specified first; in the example, this is "Advanced01.". Then use the key combination Ctrl + Space. As a result, all symbols of this device are now displayed in a list. Select the symbol you want to use with the cursor keys (../up or down) and confirm with the return key. The selected symbol is then entered as an operand. These steps are shown below:
Second option "drag & drop": With the second option, you select the line of the operand in the symbol table and then drop it on the description of the operand property or the properties editor using drag & drop.
Third option "drag & drop" to the switch object: Now for the third option. In this case, you also select the operand from the symbol table and then drag and drop it. But here the target is the switch. This means that the operand is dropped directly on the object. For switch objects, the operand you have inserted is automatically inserted as the operand that is affected by the switch.
The advantage of the options 2 and 3 is that the symbol of the operand is automatically used to label the switch object.
When you have used one of the options, the switch is connected to the symbol "Start" and thus to the I0.0. Now the switch object must be defined as a push-button. Furthermore, "Start" should appear as text with a font size of "12" in the switch object. The properties required for this are shown below:
Drawing the second push-button¶
Now we move on to the second switch object that we need. We want to create this switch from a copy of the first switch. Select the first switch and press Ctrl + D. A copy of the selected switch is then placed next to the source object.
To display the properties of the new switch in the table, click on a free space in the draw-window and then select the new switch with the mouse. Now the properties are displayed and can be changed.
In the first step you have to adjust the operand of the switch. This is supposed to be the "Stop" push-button. We will do this using the third option described above. The operand with the symbol "Stop" in the symbol table is dropped over the switch object using drag & drop.
This action also changes the label because the symbol of the new operand is used as the label of the switch object. Thus only the property of the switch as opener has to be set in the properties of the switch object.
Drawing a lamp¶
Finally, we need a lamp object to signal the "Start" state. For this purpose, select a green indicator light in the object selection "Lamps->Indicator lights".
The lamp can then be placed on the drawing board.
In the next step, assign the operand with the symbol "Lamp" to the object. This is also done via drag & drop on the object.
Now you have set the operand as a lamp operand. You can remove the caption from the lamp.
This means that no more text is displayed in the object.
After these actions, the drawing board looks as follows:
The PLC-Lab project is now complete.
Starting the simulation¶
Because PLCSIM Advanced has already been started with the instance and the configuration, you can now also start the simulation in PLC-Lab. To do this, click the following button in PLC-Lab:
PLC-Lab then tries to establish the connection to PLCSIM Advanced. Once the connection has been established, the display in the lower area of PLC-Lab changes as follows:
Testing the PLC program¶
Now you can switch to the TIA and enable OB1 observation by pressing the mouse button shown below:
Then the display of OB1 changes and the status data of the block is displayed. You can now switch the push-buttons to PLC-Lab and observe the effects in OB1.
You can see that when the "Start" push-button is activated, output Q0.0 is set to status '1' and the lamp is illuminated as a result. When you activate the "Stop" push-button, Q0.0 is reset and the lamp turns dark again.
Conclusion: The example shows how a virtual system can be created in PLC-Lab to test a PLC program that is processed in PLCSIM Advanced. In the example we established the connection to an instance named "Instance1". This name of the instance is specified in the properties when the PLCSIM Advanced Device is created in PLC-Lab.
You can change this name at any time by selecting the device and clicking the "Change the settings of the Device" button.
In the dialog "Settings PLCSIM Advanced" you can enter a new name for the instance.
If another instance of PLCSIM Advanced is to be addressed in the same project, an additional Device of type PLCSIM Advanced can be created and its instance name specified. In the symbol table, you can then create operands for this new device and assign them to the objects.