Installation Manual PLCSQL link SQL Client in a Siemens S7 PLC Revision date: 2014-03-31 Revised by: Anders Jorsal, Automatic Syd A/S Version: 1.01
Contents INTRODUCTION 3 SOFTWARE REQUIREMENTS 4 SETTING UP PLCSQL LINK 5 LOG VALUES 12 SQL CONTROLLER 14 CHANGE LOG DATA ARRAY LENGTH 16 Page 2 of 18
Introduction You can operate the PLCSQL link with different databases. But in order to get it to work out-of-the-box, it is important to setup the Database, to fit with the design for PLCSQL link. Have you chosen to operate the PLCSQL link, together with Microsoft SQL server? You also need to follow tutorial MS SQL Installation Manual. Have you chosen to operate the PLCSQL link, together with MySQL server? You also need to follow tutorial MySQL Installation Manual. Bot manuals are available for download from www.plcsql-link.com/support Page 3 of 18
Software requirements This example project is based on following software tools: PLC Program: Siemens Tia Portal V.12 HMI: Siemens Tia Portal V.12 Page 4 of 18
Setting up PLCSQL Link This chapter takes you through the process of creating your own PLC station and HMI interface for setting up PLC link to connect with the SQL database. The HMI is optional and not required for operation, but might help during commissioning to see status and test the system. Start by retrieving the delivered TIA Example project PLC_SQL_M2.03_V12_SP1. Here you ll find 2 PLC projects, The program of these two stations are identical, and can be used with e.g. S7-1200 or S7-1500 PLC's. Create your own station, with the respective PLC you are going to work with, you might want to create it in a separate project. Set up the hardware configuration, Set IP address for the Ethernet port. Compile it, and download the configuration to the PLC. Page 5 of 18
Copy the whole program folder, from one of the example programs and replace the program folder in your new station or continue working on one of the sample stations. Download the blocks to PLC. Page 6 of 18
Setup of the PLC is done through the HMI interface, for this we have created 3 example panels. That can help you getting started. PLCSQL_HMI1200: Is suitable for using the KTP 400 Panels PLCSQL_HMI1500: Is suitable for using the KTP 400 Panels HMI_1: Is designed for 10" screen panels, MP277. The pages from these examples can freely be copied into your own user panel. This way, the setup interface for PLCSQL Link, has been created for you. You need to open 2 instances of TIA and copy the PLCSQL-Link under Program Blocks to your own project. The same you need to do under Screens and Tags for HMI, In this case you need to reconnect Tags. In this case we choose to run the application PLCSQL_HMI1200, in order to setup the PLCSQL Link. Open Device Configuration to setup the IP address for the HMI, to connect HMI to the same network as the PLC. Page 7 of 18
After this click Start Simulation. You can now run the application in demo mode for commissioning and test. RT Simulation Start Page: Errors are listed in the Status field. Page 8 of 18
Now you need to setup the PLCSQL Link to match the Configured SQL database. CPU / Memory card Serial number: By clicking Reset, the CPU and MMC card serial number of the actual hardware will be read out. SQL client license key: By informing Automatic Syd, one of the above mentioned serial numbers. By mailing Finn C. Nissen: fcn@automatic-syd.dk, or fill out the form at www.plcsql-link.com/order A unique License key is being generated for you to type into the PLC. This License key is pared to the given serial number, and cannot be used on another device. Type in the received License Key. Page 9 of 18
SQL Username: SQL Password: SQL Database: SQL Server IP: Write the username created in the SQL database. Write the Password for the Username. Write name of the generated SQL Database (PLCSQL). Write IP Address of the SQL server. SQL Server port: Write 1433. Time before timeout: Maximum retries: Recipe SP: Log SP: Write maximum time before timeout. Number of retries allowed for the client before giving up. Query for receiving data from SQL. Query for logging data to SQL. Page 10 of 18
NOTE: After entering the communication setup, you need to click Reset, for the changes to take effect. Access the page Main. On this page status of the connection is displayed. The process can be reset, in order to re-initialize the connection. It is also possible to see if the specific parameter has been updated in this particular recipe, by using the bit SQL.RecipeParm.UpdatedParameters[1..30100], according to the parameter number. NOTE: Following parameters are reserved for system information: 10001: SetCount 15001: SetID 30001: DateTimeStamp. Page 11 of 18
Log values For logging values to SQL, You can link or move the specific parameter numbers from the user program, and into the structured DB1 SQL. This is done in FC 462 SQL_LogValues For this particular value to be logged, you need to set the according bit SQL_LogParm.UpdatedParameters[1..30100] to true, while the log trigger is activated. In this way you can in a flexible way, define what to log, and when. NOTE: Following parameters are reserved for system information: 10001: SetCount 15001: SetID 30001: DateTimeStamp. Page 12 of 18
Page 13 of 18
SQL Controller To set up the triggers for executing the querys from the PLC. You need to edit OB1 Main. If you choose to move the program blocks, in order to fit into your user program. You also need to change the DB pointers on the SQL_Controller, to the new range. Page 14 of 18
To trig a log query, you can replace the SQL. LogStart with your user defined trigger bit. To get new parameters from SQL. You need to define the recipe name, for the dataset, GetData query should refer to. In SQL. Replace SQL"RecipeDone, with your user defined string. Page 15 of 18
Change log data array length The amount of data can be optimized, to fit the needs for your application. This example project is preconfigured to a limited range, in order to reduce unnecessary space obtained in the PLC. But can be expanded according to your needs. For setting up desired length of address arrays, you need to adjust two things. First open FB460146 SQL_Controller, where you can adjust the number of parameters assigned, in each datatype. Note: It is important that you only adjust the last number in the array, and that it doesn t exceed the start number of the next array. This means that you Maximum can assign up to: Real: Integer: Double integer: Bool: String: Updated values: 9.999 parameters 4.999 parameters 4.999 parameters 9.999 parameters 999 parameters Must be able to contain the maximum number of data, you need to handle in one query. Page 16 of 18
Updated parameters: Contains a bit for each parameter, therefore range must cover the maximum number for paramstring. Page 17 of 18
After editing these array lengths, the whole project needs to be saved, compiled and downloaded. In FB460 SQL_Controller, Max and Min ranges for each data type must match the ranges. Page 18 of 18