Siemens S7 db file
generation
To use the Siemens S7-1200 PLC device and Siemens S7-1500 PLC device, it is necessary to generate a DB file as part of the setup.
The screenshots presented bellow are images captured using TIA Portal in a simulated environment. Editing a PLC program can have devastating consequences, any change to a PLC program should be verified by an authority.
As a requirement for the tutorial bellow, the machine needs to have a Siemens S7 Project installed on the TIA Portal in order to generate the DB File. Once this requirement is met, do the following:
-
On the TIA Portal, select Project at the top left corner;
-
When the project opens, expand "Program Blocks";
-
From there, it is possible to see the Program Blocks. The Data Blocks listed are the ones involved on the DB Generation, the other elements are code;
-
To create a new Data Block, double click on the "Add new block" option. A pop up will appear;
-
To generate a new datablock, some specific offsets are needed. When clicking on DB and OK, a new entry will be generated and can be viewed in a table similar to an Excel table, where it is possible to add items of various types;
-
To add a new row, fill out the Name, the Data Type and the other columns as needed. Click enter to go to the following row until finished;
-
Once finished, right click on the new DB, or any previously filled DB, select Properties in the attributes and make sure that the option "Optimized block Access" isn't selected. Press OK once finished;
-
Compile the DB, for efficiency select Software (only changes).
-
To generate the DB File, right click the DB and select "Generate source from blocks", under the options, select "Including all dependent blocks";
-
Save the DB file on the desired folder;
-
The Data Blocks generated need to be placed in staging/siemens folder using the Staging Browser of deviceWISE Node before Device Start.
Connecting the Workbench to Siemens PLC S7-1200 PLC or S7-1500 PLC
With the Data Blocks generated correctly inserted in staging/siemens, follow these steps:
-
Create a new device, in this case, following the tutorial above, it is going to be a S7-1200 PLC, but the steps are also applied to S7-1500 PLC. Observe that under the Data Blocks field, the naming is DB10/Data_block.db. Click here and go to the Using the Workbench to define a Siemens Device to better understand the rules behind the naming conventions for the device definition.
-
Validate the device and Save it.
-
The device will now appear under the Devices tab;
-
Under the Variables Tab, it is also possible to interact with the variables and see the ones created on the TIA Portal;
-
Right click on any variable and click Write to test the connection, altering the value of it and seeing if it also changes on the TIA Portal;
-
Check it on the TIA Portal;