4. Siemens TIA - banica/metering GitHub Wiki
DISCLAIMER: All of these steps are done on the Virtual Machine, if you chose not to use a VM some things may differ We recommend using the latest TIA version you have available and follow the instructions on the installation wizard for a typical installation. Here is a trial version of TIA that is available for 21 days, we hope this will work, you must also be able to get all of the licenses you might need after the trial ends: https://www.industry-mobile-support.siemens-info.com/en/article/detail/109821411 Follow the instructions from the link as they are the best ones for our scenario of a typical install.
After the install is completed and all of the licenses activated you should open TIA 19. Press on “Create new project”
Give it a name and press “Create” Now press on “Devices & Connections Configure a device”
Select “Add new device > Controllers > Simatic S7-1200 > CPU > Unspecified CPU 1200 > 6ES7-2XX-XXXXX-XXXX” and Add
Now that you are inside of the Project, press on the PLC_1 > Device configuration and the highlighted “detect” button
Now make sure these are the interface connections you have and press Start search:
After the PLC is found press on Detect and it should be now connected to TIA.
Also, if you want to make sure that your PLC is properly connected you could press the “Flash LED” button and the LEDs on the PLC will start to light up Also, if you want to avoid other compatibility errors you could install the Siemens Open Library. To add it you should go inside of your project to “Libraries > Global libraries > New library…” and add your new global library for your version of TIA
Now to be able to create an OPC UA connection you must do the following things: Right click the PLC > Properties > OPC UA > Accessibility of the server > Activate OPC UA server (check this)
Now keep the address below in mind, we will need that later. Still, inside Properties > Runtime licenses > OPC UA and under “Type of purchased license” select “SIMATIC OPC UA S7-1200 basic”
Now go to Access level > Select the level for the PLC > Full access (no protection) You can go on a different route, but this is what was best for us.
Also, under Protection & Security > uncheck “Protect confidential PLC configuration data”
Under Server > Security > Server certificate > Create, and the settings should already be perfect just as is and hit OK:
Now that we set up all of the settings necessary we must go to Program blocks>Add new block > Data block, give it a name and hit OK
Right click the Data block you just created > Properties > uncheck Optimized block access
Now double click the Data block (I will call it Data from now on as this is the name I used) and under “Add new” add your variable, I will make an integer variable called “Value” that holds the value of 45
After this go to OPC Ua communication > Server interfaces > Add new server interface > Server interface, give it a name and select the type “Interface”
This window will open up:
Under OPC UA elements > Data blocks > Data [DB1] and you will see the variable you created earlier. Drag and drop the variable in the “” space inside of OPC UA server interface:
This is all for the setup that needs to be made inside of TIA. Now just go to “Download to device”, follow the process and you should be done with TIA!
After doing all of these you must follow these images and replicate them using the Modbus (standard/old, not RTU) library to be able to read the values outputted from the PLC:
Instead of “data sent”.data use what you used for your own data block and array type (we used int), also, for DATA_LEN use the number of variables you have in your array, we used 12 for other testing purposes.
Now on the OPC UA server change the variable you initially added to your newly created array and you should be golden!
For more information you can also download our project from this link: https://drive.google.com/file/d/1vHVTSb-LCX54WYxTodSOi63PtxeqbnO0/view?usp=sharing
Also, if you use the same RS232 module we used make sure to change this setting into this, if you do not it will definitely not work:
UNSOLVED PROBLEM ENCOUNTERED In our testing we never managed to get the PLC to ever read any values, even though the settings were properly dialed in. We believe this issue could either come from our Waveshare module, or our PLC itself. We did manage to write from it though, which is the same as reading in terms of setup (except that in the MODE section of the MB_MASTER it is 0 for reading and 1 for writing) We were not able to fix it as of yet. Everything else should work if you do it all as it is done in this documentation.