Installation Manual PLCSQL link

21
Installation Manual PLCSQL link SQL Client in a Siemens S7 PLC Revision date: 2012-09-28 Revised by: Anders Jorsal, Automatic Syd A/S Version: 1.01

Transcript of Installation Manual PLCSQL link

Page 1: Installation Manual PLCSQL link

Installation Manual

PLCSQL link

SQL Client in a

Siemens S7 PLC

Revision date: 2012-09-28 Revised by: Anders Jorsal, Automatic Syd A/S Version: 1.01

Page 2: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 2 of 21

Contents

INTRODUCTION 3

SOFTWARE REQUIREMENTS 4

SETTING UP PLCSQL LINK 5

COLLECT PARAMETERS 13

LOG VALUES 15

SQL CONTROLLER 17

CHANGE LOG DATA ARRAY LENGTH 20

Page 3: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 3 of 21

Introduction

You can operate the PLCSQL link, with different databases. But in order to get it to work, 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 My SQL server? You also need to follow tutorial “MY SQL Installation Manual”.

Page 4: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 4 of 21

Software requirements

This example project is based on following software tools: PLC Program: Simatic Step 7 V5.5 +SP2 HMI: Simatic WinCC Flexible 2008 SP3

Page 5: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 5 of 21

Setting up PLCSQL Link

This chapter takes you through, the process of creating your own PLC station. And interface for setting up PLC link to connect with the SQL database. Start by retrieving the delivered Step 7 Example project “S7-PLCSQL_v2.zip”.

Here you’ll find 2 PLC projects, The program of these two stations are identical, and can be used with f.eks. ET200S, S7-300, S7-400 or RTX soft PLC. Create your own station, with the respecting 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 6: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 6 of 21

Copy the whole program folder, from one of the example programs. And replace the program folder in your new station. Download the blocks to PLC without System data.

Page 7: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 7 of 21

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

HMI Large: Is suitable for using in big screen panels or Runtime applications.

KTP600: Is designed for small screen panels, with smaller layout.

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. In this case I choose to run the application “HMI Large”, in order to setup the PLCSQL Link. Open “Netpro” to setup the IP address for the HMI, to connect the same net as the PLC.

Page 8: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 8 of 21

Open the application “HMI Large” with WinCC Flexible. In here you’ll need to correct, the active connection for the tags, by selecting Your PLC under Partner.

After this click “Start Runtime System”. You can now run the application in demo mode.

Page 9: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 9 of 21

In Runtime You can access the “SQL Setup” page by pressing F11. Here you need to setup the PLCSQL Link to match the Configured SQL database.

CPU Serial number: By clicking Read, the CPUs serial number will be read out.

Memory Card serial number: By clicking read, the MMCs serial

number will be read out. SQL client license key: By informing Automatic Syd, one of

the above mentioned serial numbers. By Mailing Finn C. Nissen: [email protected], or tlf. +45 74449191 A unique License key is being generated, for you to type in. This License key is pared to the given serial number, and cannot be used on another device.

Page 10: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 10 of 21

Integrated PN Controller: Are you using a on-board PN port, click Yes. Are you using external CP cards for

S7-300 and S7-400, that supports AG_SEND / AG_RECIEVE, click No

DeviceID PN Controller: Decide which group of Communication

processor your PLC uses:

B#16#00: CP 443-1EX4x (with S7-400, however, only with connection_type = B#16#12), won't work with SQL B#16#01: IE interface in interface slot 1 (IF1) with WinAC RTX (TCP only) or IM151 PN B#16#02: Integrated IE interface with CPUs 315-2 PN/DP and 317-2 PN/DP B#16#03: Integrated IE interface on the CPU 319-3 PN/DP B#16#05: Integrated IE interface with CPUs 414-3 PN/DP, 416-3 PN/DP and 416-3F PN/DP B#16#06: IE interface in interface slot 2 (IF2) with WinAC RTX (TCP only) B#16#0B. IE interface in interface slot 3 (IF3) with WinAC RTX (TCP only) B#16#0F: IE interface in interface slot 4 (IF4) with WinAC RTX (TCP only)

Hostname: Write the name of your machine. SQL Username: Write the username created in the SQL database. SQL Password: Write the Password for the Username. SQL Database: Write name of the generated SQL Database (PLCSQL). Server type: You can work with 2 different Databases: MS SQL (this tutorial), og MySQL. SQL Server IP: Write IP Address of the SQL server. SQL Server port: Write 1433. Time before timeout: Write maximum time before timeout. Maximum retries: Number of retries allowed for the

system. ParamID1…5: Is the Parameter ID numbers you

want to include, to filter the SQL database.

in order to find the right request data.

You can choose to enter them as fixed Values on the setup screen, or

dynamic by the user program. ParamValue 1…5: Is the values you want to search for.

Page 11: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 11 of 21

You can choose to enter them as fixed Values on the setup screen, or

dynamic by the user program. Query 1 (Init): Query for initialization of connection to SQL. Query 2 (Request data): Query for receiving data from SQL. Query 3 (Log data): Query for logging data to SQL. NOTE: If you are using “My SQL”, the expression EXEC must be replaced with

CALL. NOTE: After entering the communication setup, you need to click “Restart SQL

Client”, for the changes to take effect.

Page 12: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 12 of 21

Access the page “SQL Status” by pressing F10. On this page status of the connection is displayed, if Controller Step Nr. Indicates 150, the connection was established successfully. The process can be reset, in order to re-initialize the connection.

For detailed information, a number of information’s are listed. TCP Network communication: Status of the last query executed. SQL Query: Displays the actual Query string being

Send to SQL.

Query Length: Displays length of the generated Query. Updated test parameters from SQL: Displays the last updated parameters, Send from SQL. Values to log from PLC: Displays te values being logged from

the PLC.

Page 13: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 13 of 21

Collect Parameters

For collecting values / parameters from SQL, You can link or move the specific parameter numbers out in the user program, sorted to fit your needs. This is done in FC 157 “MoveTestValues”, where the values are pinned out from DB147 “SQL_TestParm”. It is also possible to see if the specific parameter has been updated in this particular recipe, by using the bit “SQL_TestParm”.UpdatedParameters[1..30100], according to the parameter number. NOTE: Following parameters are reserved for system information: 10001: SetCount 15001: SetID 30001: DateTimeStamp.

Page 14: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 14 of 21

Page 15: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 15 of 21

Log values

For logging values to SQL, You can link or move the specific parameter numbers from the user program, and into the structured DB148 “SQL_LogParm”. This is done in FC 158 “MoveLogValues” 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 an flexible way, define what to log, and when. NOTE: Following parameters are reserved for system information: 10001: SetCount 15001: SetID 30001: DateTimeStamp.

Page 16: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 16 of 21

Page 17: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 17 of 21

SQL Controller

To set up the triggers for executing the querys from the PLC. You need to edit FB140 “SQL_Call”. 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 18: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 18 of 21

To trig a log query, you can replace the “OP_db.”LogTrigger” 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 “OP_db”.NewReceiptName”, with your user defined string.

Page 19: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 19 of 21

To trig a GetData query, you can replace the “OP_db.”GetData” with your user defined trigger bit.

Besides the 3 previously mentioned Function blocks:

FC 157 “MoveTestValues” FC 158 “MoveLogValues” FB140 “SQL_Call”.

You do not have to edit the other blocks, they are predefined from Automatic Syd.

Page 20: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 20 of 21

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 UDT146 “SQL_DataTypes”, 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: 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.

Page 21: Installation Manual PLCSQL link

Installation Manual: For PLCSQL link

Subj. PLC prog. For PLCSQL Document: PLCSQL PLC Installation

Manual_V1_1.docx

Ref. 158397AJO Version 1.01 Revision: 2012-09-28 by HBE

Page 21 of 21

After editing these array lengths, the whole project needs to be compiled and downloaded.

In DB142 “SQL_Setup”, Max and Min ranges for each data type must match the ranges edited in UDT146 “SQL_DataTypes”.