35
Installation Manual PLCSQL link With Siemens TIA SQL Client in a Siemens S7 PLC Revision date: 2014-03-31 / 2016-05-25 Revised by: Anders Jorsal, Henrik Bennedsen and Lenette Brogaard-Larsen, Automatic Syd A/S Version: 1.04

Installation Manual PLCSQL link With Siemens TIA · Installation Manual PLCSQL link With Siemens TIA SQL Client in a ... For PLCSQL link with Siemens TIA Portal ... PLCSQL PLC TIA

  • Upload
    trannhu

  • View
    278

  • Download
    1

Embed Size (px)

Citation preview

Installation Manual

PLCSQL link With Siemens TIA

SQL Client in a Siemens S7 PLC

Revision date: 2014-03-31 / 2016-05-25 Revised by: Anders Jorsal, Henrik Bennedsen and Lenette Brogaard-Larsen, Automatic Syd A/S Version: 1.04

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 2 of 35

Contents

INTRODUCTION 3

SOFTWARE REQUIREMENTS 4

USED BLOCKS IN THIS EXAMPLE PROJECT 4

SETTING UP PLCSQL LINK IN SIEMENS TIA 5

HOW TO COPY TO AN EXISTING OR NEW PLC PROGRAM 6

HOW TO COPY TO AN EXISTING OR NEW HMI PANEL 8

Synchronize HMI Tags 10

SET UP IP ADDRESS FOR HMI PANEL 11

START HMI RUNTIME FOR PLCSQL LINK 12

LOG VALUES 16

SQL CONTROLLER 18

Recipe data 21

CHANGE LOG AND RECIPE DATA ARRAY LENGTHS 23

SQL Server connection settings in PLC 26

Using Watch Table (VAT-table) for Server connection setup 27

Watch table for commands and status 28

DEFINE CONNECTION SETUP FROM PLC PROGRAM 29

SHOW LOGGED DATA IN THE SQL SERVER 32

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 3 of 35

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 “Microsoft SQL Installation Manual”.

Have you chosen to operate the PLCSQL link, together with MySQL server? You also need to follow tutorial “MySQL Installation Manual”.

Both manuals are available for download from www.plcsql-link.com/support

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 4 of 35

Software requirements

This example project is based on following software tools: PLC Program: Siemens Tia Portal V.13 SP1 HMI: Siemens Tia Portal V.13 SP1

If you need another version, please let us know, and we will convert it for you.

Used Blocks in this example project

In the the example project we are using: FC462 SQL_LogValues FC461 SQL_RecipeValues FB3 SQL_Client FB460 SQL_Controller DB1 SQL Make sure these are free, if you copy them into an existing project, or renumber the blocks.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 5 of 35

Setting up PLCSQL Link in Siemens TIA

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:

“PLCSQL_1500_FW1.8_1200_V4.1_V13_SP1_1”.

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, or you can just use this program example project. No matter what you choose to do

- Set up the hardware configuration - Set IP address for the Ethernet port - Compile it - Download the configuration to the PLC.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 6 of 35

How to copy to an existing or new PLC program

I you want to use our example project directly, then just go to Start HMI runtime for PLCSQL Link. If you have created your own PLC station, just follow this description. Copy the program folder PLCSQL-Link, from one of the example programs and paste the program folder in your new station. The CPU family must match. So copy from the PLCSQL1200 for a S7-1200 and from PLCSQL1500 for S7-1500. Open Program bloks Open Program bloks

- Select PLCSQL-Link - Right Click - Right Click - Past - Copy

Copy the 3 network from OB1, from one of the example programs and past the network in your one OB1.

- Compile - Download all blocks to PLC.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 7 of 35

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 8 of 35

How to copy to an existing or new HMI Panel

Setup of the PLC is done through the HMI interface, for this we have created 2 example panels. That can help you getting started.

PLCSQL_HMI1200_large : Is designed for MP 277 10" Touch PLCSQL_HMI1500_small: Is suitable for using the KTP400 Basic color PN

I you have used the example project, then just go to Start HMI runtime for PLCSQL Link. If you have create your PLC station, you can copy one of the 2 example HMI panels into your project and go to then just go to Set up IP address for HMI panel. If you have created your PLC station, and have made your own HMI, and just want to copy, PLCSQL over in your existing HMI, continue below. Copy the Screen, from one of the example HMI and past in your one HMI. Open Screens Open Screens

- Select the 4 screen - Right Click - Right Click - Past - Copy

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 9 of 35

Copy the Screen management, from one of the example HMI and past in your one HMI. Open Screens management Open Screens management

- Templates - Templates - Select PLCSQL_Background - Right Click - Right Click - Past - Copy

Copy the HMI tags, from one of the example HMI and past in your one HMI. Open HMI tags Open HMI tags

- Select PLCSQL - Right Click - Right Click - Past - Copy

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 10 of 35

Synchronize HMI Tags

Now all tags might be red because synchronization is lost. Right Click on HMI tags

- Click - Synchronize with the PLC tag Click - Synchronize Click - OK Now all tags are gray and connection is made. Compile.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 11 of 35

Set up IP address for HMI panel

Open “Device Configuration” to setup the IP address for the HMI, to connect HMI to the same network as the PLC.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 12 of 35

Start HMI runtime for PLCSQL Link

After configuring the HMI, 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. Go to screen SQL Client

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 13 of 35

Now you need to setup the PLCSQL Link to match the Configured PLC.

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 Anders Jorsal: [email protected], 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 paired to the given serial number, and cannot be used on another device.

Type in the received License Key.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 14 of 35

This data Is the same as in the Microsoft SQL Server for PLCSQL link description SQL Username: Write the username created in the SQL database. (plcsql) SQL Password: Write the Password for the Username. (link) SQL Database: Write name of the generated SQL Database (plcsql) SQL Server IP: Write IP Address of the SQL server.

(Example: 172.20.92.200) SQL Server port: Write 1433. For MySQL use 3306 Time before timeout: Write maximum time before timeout. Maximum retries: Number of retries allowed for the

client before giving up. Recipe SP: Query for receiving data from SQL. (For MySQL you will need to write CALL in front of the SP and end the input with a start parenthesis: (

Log SP: Query for logging data to SQL. NOTE: After entering the communication setup, you need to click “Reset, for the

changes to take effect.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 15 of 35

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.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 16 of 35

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”. How to do this is shown in FC 462 “SQL_LogValues” For a 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. You may put logic in front of the bit coil, to only log certain values at a specific condition. For example to only log a motor speed when the motor is started. NOTE: Following log parameter IDs are reserved for system information: 10001: SetCount (Number of parameters sent to SQL) 15001: SetID (Auto-incremented database key of inserted data) 30001: DateTimeStamp

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 17 of 35

To log some extra data, you simply copy a network, and change the parameter number on the MOVE instruction and the UpdatedParameters bit. No change is necessary in the SQL Server, when using our default, flexible database structure. The same procedure to log data by moving them to the LogParm array as shown above in network 2 and 3 can be used for the datatypes REAL, INT and DINT. For STRING you need to use the instruction S_MOVE, however the procedure is exactly the same:

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 18 of 35

SQL Controller

In the example project SQL_Controller is called from OB1 Main, but could be called from anywhere in your PLC Program. You might also have multiple instances of the SQL_Controller Call to allow multiple parallel connections to your SQL Server. If you want multiple connections, you need to define a unique Connection ID for each instance by setting the tag “SQL”.SQL_Client.SQL_Setup.ConnectionID. For multiple calls, you will need a separate instance DB for each call of SQL_Controller. Multi Instance DB call is also possible (not covered in this manual).

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 19 of 35

In the example project we have not set the LogStart or RecipeStart bits from the PLC program, but the can be set from the corresponding buttons on the HMI to trigger a request.

Examples on how to set the log request bit. To save log the log data you have defined in the FC462 SQL_LogValues to the SQL Server, you set the input bit ”LogStart” on the SQL_Controller block. You may either attach a memory bit on the block or set the SQL.LogStart bit from somewhere else. It could for example be a timer, that sets the bit high for every X seconds, or whenever a specific situation occurs.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 20 of 35

As described earlier, you could also attach your own command and status bits to the input/output tags on the SQL_Controller:

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 21 of 35

Here the Input and output of the function blocks has been attached to various tags. Please note that the LogDone and RecipeDone bits comes as one-shot pulses (only high for one scan when the request has been completed in the SQL Server), and only when the LogStart or RecipeStart respectively is on. The LogStart and RecipeStart bits will be set to false by the SQL_Controller internally when the request is completed.

Recipe data

To get new parameters from SQL, You need to define the recipe name, for the dataset, GetData query should refer to. In SQL.SQL_Client.SQL_Setup.ParamValue[1] this value may also be changed from our example HMI. It is possible to see if a 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 (Number of parameters received from SQL) 15001: SetID (Auto-incremented database key) 30001: DateTimeStamp.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 22 of 35

To use the received recipe data, you might simply move them to your existing tags by a MOVE instruction – like we did with Log parameters, now just in the opposite direction:

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 23 of 35

Change log and recipe data array lengths

The size of the data arrays can be changed 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. It 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, for each datatype, and for each direction (Log and Recipe) 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: 9.999 parameters Integer: 4.999 parameters Double integer: 4.999 parameters Bool: 9.999 parameters String: 999 parameters Updated values: Must be able to contain the maximum number of

data, you need to handle in one query. Updated parameters: Contains a bit for each parameter, therefore range

must cover the maximum number for paramstring.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 24 of 35

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 25 of 35

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.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 26 of 35

SQL Server connection settings in PLC

If you prefer not to use a HMI for commissioning of PLCSQL Link, you may define the settings in the Instance DB called SQL, under SQL_Client.SQL_Setup. You have several options to define the connection settings. Either by manipulating directly in the DB:

You may want to look at the chapter: Applying monitored values on page 102 in the manual (PDF page 147): SIMATIC S7-1500 /ET 200MP Manual Collection https://support.industry.siemens.com Entry ID: 86140384

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 27 of 35

Using Watch Table (VAT-table) for Server connection setup

You may also use a Watch Table to alter the SQL Server connection:

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 28 of 35

Watch table for commands and status

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 29 of 35

Define connection setup from PLC Program

You may also define the server connection settings from the PLC program. You may use whichever language you may prefer.

Above is an example on how to set the SQL Server IP address using the LAD language. Below you will find an example on how to set most of the PLCSQL Link setup parameters using SCL logic.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 30 of 35

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 31 of 35

Using the technique of setting the connection parameters from PLC code, you could also create a function to switch between multiple connection parameters, for example for failover applications or conditional changes. You may also change which Stored Procedure call to run on a SQL server, for example based on a condition bit. In the example below we swap between saving the data to the Log_DATETIME, Log_REAL, LOG_INT, etc. tables and the Recipe_DATETIME, Recipe_REAL, etc. tables. In this way we can create a really simple SQL based recipe handling system with full traceability in the SQL server on all recipe changes. When M12.0 is high, data is saved from the PLC in the Recipe SQL tables making a later retrieval by RecipeStart possible. When M12.0 changes to the low state, data is saved in the Log SQL tables.

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 32 of 35

Show Logged data in the SQL Server

The data is stored in a normalized database, and each datatype is stored in its own table for optimal performance and flexibility.

To see that data sets are logged from the PLC, the following SQL Query can be executed in SQL Management Studio: SELECT TOP 1000 * FROM [PLCSQL].[dbo].[Log_DATETIME] ORDER BY SetID DESC

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 33 of 35

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 34 of 35

The values for the different parameters can be found in the datatype tables:

Installation Manual: For PLCSQL link with Siemens TIA Portal

Subj. PLCSQL Link in TIA Document: PLCSQL PLC TIA Installation

Manual_V1_04.docx

Ref. 158397AJO Version 1.04 Revision: 2016-05-25 by AJO

Page 35 of 35

To view the data in one large table like in a conventional table, have a look at our SQL View generator, that can be found in our PLCSQL Link forum. With the simple tool, you define what each column should be named, and which parameter ID it should pull data from. The forum can be found at www.plcsql-link.com/support