+ All Categories
Home > Documents > PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG...

PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG...

Date post: 18-Dec-2020
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
20
User Manual PLCSQL SQL Client in a Siemens S7 PLC Revision date: 2011-11-22 Revised by: Anders Jorsal, Automatic Syd A/S Version: 1.00
Transcript
Page 1: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual

PLCSQL

SQL Client in a

Siemens S7 PLC

Revision date: 2011-11-22 Revised by: Anders Jorsal, Automatic Syd A/S Version: 1.00

Page 2: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 2 of 20

Contents

APPLICATION AREAS 3

REASONS FOR USING PLCSQL 4

EXAMPLE SYSTEM DESCRIPTION 5

USING THE PLCSQL MODULE IN SIMATIC MANAGER 6

PARAMETERIZING SQL SERVER CONNECTION 7

SQL STATUS 8

MAIN SCREEN 10

DEFINING VALUES TO LOG TO SQL 11

ESTABLISH CONNECTION TO THE BLACK BOX 12

SEARCH IN LOG DATA 14

SEARCH RESULTS IN WEB PAGE 16

SAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17

BACK UP LOG DATA 18

DELETE OLD LOG DATA 19

SHOW CURRENT / SET TIME AND DATE 20

Page 3: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 3 of 20

Application areas

• Production lines

o Logging of process data for further analyzing / data mining

o Prescription Values and actually produced values. Complete documentation for the production lifecycle of a product.

o Logging of processing time and waiting for time and capacity analysis

o Download of orders (prescriptions) / production data (process values) to / from ERP

• Grains and feed transport and treatment facilities

o Logging of scheduled start / stop. Can be used to document the product's path in the system – tracing.

o Logging of engine parameters, start / stop / manual / warnings. Can be used both as documentation and maintenance. Can also be used as proof to determine if the error happened in the automatic system or operator error.

o Logging of alarms

o Logging of volumes

o Download of orders to / from ERP

• Pumping stations

o Start / stop / error / manual mode

o Flow / power for energy analysis, environmental documentation

• Power plants, solar, etc. o Process Values and alarms

o Start / stop / error / manual mode

o Flow / power for energy analysis, environmental documentation

• Process Industry, for example. dryers, stoves, etc.. o Process Values and alarms

o Energy optimization, documentation, process optimization

Page 4: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 4 of 20

Reasons for using PLCSQL

The conventional way of creating a data flow between a PLC and an SQL server is to invest in a hardware or software gateway that binds the two worlds together. The gateway typically consists of:

1. PLC driver, for example OPC driver/server from the PLC Vendor. 1. OPC Client 2. SQL Client 3. User-written Windows application in VB, VBA, C#, C, .NET, JAVA, Delphi that handles

the logic interfacing between the OPC and SQL Client. In here is written what to do with each tag from the OPC server, and how to generate a SQL query to interact with the SQL server.

The largest problem with the Windows solution, are the ever ongoing issues with continued functionality after a Windows Update, antivirus compatibility. Especially with user-written software can the consequences of a breaking Windows Update be fatal. The customer has to rely on its automation supplier for a very long time. Even with larger automation suppliers like Siemens and Rockwell may it take years before a given automation software component is released for a new Windows release or Service Pack. Another issue with having this gateway is the task of configuring it. Everytime a change in the data flow structure is to be made, the configuration of the gateway has to be changed as well. This can be fatal, if is used for multiple PLC stations, or it may involve several programmers before the configuration is committed. What if we could avoid having these gateways? This question has been asked a lot of times by Automatic Syd. And then we decided to develop a solution that works totally independent of a gateway. -The answer was to develop the SQL Client inside the PLC instead, and the manual for using this SQL Client is what you are reading in right now.

Page 5: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 5 of 20

Example System description

This demonstration project logs between 50 and 100 process values every second to a MySQL server on an embedded PC in the control panel. The data are stored on an external Solid State Disk (SSD), which can be exchanged by a technician on-site. The data logging is thought to be used to log all mission critical data on a portable machine used around the World. The data are then recorded on the SSD disc for investigation of any incidents that might occur with the machine – after the same principle as a Black Box in an aircraft. PLC: ET200S IM151-8 CPU PC: Ebox 3300 Embedded PC Hard disc: Kingston 64GB V100 SSDnow

The example system consists of an embedded Ebox PC 3300 from DMP, hereafter named Blackbox, which is equipped with Debian Linux operating system. On the Blackbox is the MySQL database and Apache web server installed. The SQL server is maintaining the data and the server interface to the PLC, and the web server is used to present the data to the end user in a user friendly way. The Siemens ET200 PLC has a MySQL client program been installed to upload the actual log values from the control system. The MySQL client on the PLC named PLCSQL from Automatic Syd A/S is communicating over the Ethernet with the MySQL database server on the Blackbox.

Page 6: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 6 of 20

Using the PLCSQL module in Simatic Manager

All relevant blocks for the SQL communication (FB,FC and DB) are named with a prefix of SQL_ in the symbol name. All blocks for SQL are placed from 1000 and up, for example FB1001 for the SQL_Controller as shown below. The user may freely place the blocks in another area, as long as changes are made to the entries in the Symbol table, the S7-project is compiled symbolically afterwards, and the parameters for the DB numbers are changed to the new selected areas below. To start a new log, the input bit StartLog is to be set high. Please note, it will take several scans for the PLC to complete the log request. If the log is executed successfully on the SQL server, the output bit LogDone is high for one scan.

Page 7: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 7 of 20

Parameterizing SQL Server connection

The parameters for the connection to the SQL server can be administrated from the WinCC Flexible interface. Here you setup the network card type, IP address, TCP port, username and password and also the text string of the different SQL queries, eg. the name of the SQL Stored Procedures to be used. If you prefer to rather make this setup programmatically in the PLC program, you are free to do this as well, as all setup parameters are stored in the DB named SQL_Setup. An example to benefit from this, is to make a program to swap between multiple SQL servers. It is also on this page that you enter the SQL client license key supplied by Automatic Syd. Please note, that you need a license key for each unique CPU or memory card where you want to run the client on. The PLCSQL client will not start up without a valid license key for the current hardware serial number. You can decide between requesting a license key for either the CPU serial number or the MMC memory card.

Page 8: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 8 of 20

SQL Status

The actual status for the SQL Client can be monitored on the SQL status page. It is possible to monitor and debug almost all possible errors from this page.

In the example below the network connection to the SQL Server has been lost, for example by disconnecting the network cable. The Connection Status will switch to red, and the SQL info text reports: Waiting for response from SQL server… An alarm will be shown in the standard WinCC Flexible Alarm list with the text above included in the alarm text.

Page 9: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 9 of 20

The alarm is also shown on the main screen for the application, as it is a general alarm.

Page 10: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 10 of 20

Main screen

The main screen for this example project shows an input field on the top, where the operator inputs an order number with a barcode scanner. This order number is then used in a request to the SQL server for retrieving parameter values for the current order. Basic information about the order is shown on the top to the right, which includes the current article number, article name, timestamp when this order specification was created, and username of the author. Below is shown the actual parameter values for the current order. As the product is being processed, the log values are written to the screen.

When the product test is done, a request to log the data to the SQL server is activated. A popup is shown on the user interface when the log request is done, showing the id of the record inserted into the database.

Page 11: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL

Subj. PLCSQL – SQL Client in a PLC

Ref. 12342AJO Version 1.00

Defining values to log to SQL

To define a parameter to be logged only require a minimum of programming. Simply move the value you want to log into the DB nameUpdatedParameters bit high for the chosen ID number. As standard the structure for the parameter ID range and corresponding data types are as follows: 1-9999 REA10001-14999 INT15001-19999 DINT20000-29999 BOOL30001-39999 STRING To log a REAL value we select an available number in the REAL range, for example 82. We move the actual value to the SQL_LogParm DB into the array named ParamREAL and on the index 82. To tell the SQL Client to include this Parameter ID in the SQL Query, we set the UpdatedParameters ID to true.

PLCSQL – SQL Client in a Siemens S7 PLC

SQL Client in a PLC Document: PLCSQL User Manual.docx

Revision: 2011-11-22 by AJO

Defining values to log to SQL

To define a parameter to be logged only require a minimum of programming. Simply move the value you want to log into the DB named SQL_LogParm, and set the UpdatedParameters bit high for the chosen ID number. As standard the structure for the parameter ID range and corresponding data types are as follows:

REA 32-bit floating point values INT 16-bit signed integers (-32768 to 32767)DINT 32-bit signed integers (-2147 mil to 2147 mil)BOOL 1 bit, Boolean value, true or falseSTRING ASCII text string up to 256 bytes.

To log a REAL value we select an available number in the REAL range, for example 82. actual value to the SQL_LogParm DB into the array named ParamREAL

and on the index 82. To tell the SQL Client to include this Parameter ID in the SQL set the UpdatedParameters ID to true. See below.

SQL Client in a Siemens S7 PLC

Page 11 of 20

To define a parameter to be logged only require a minimum of programming. Simply d SQL_LogParm, and set the

UpdatedParameters bit high for the chosen ID number. As standard the structure for the

32768 to 32767) 2147 mil to 2147 mil)

1 bit, Boolean value, true or false ASCII text string up to 256 bytes.

To log a REAL value we select an available number in the REAL range, for example 82. actual value to the SQL_LogParm DB into the array named ParamREAL

and on the index 82. To tell the SQL Client to include this Parameter ID in the SQL

Page 12: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 12 of 20

Establish connection to the Black box

The Black Box has a web interface, that enables easy access to the log data with a powerfull search environment for filtering the log data.

o Connect your laptop to the Ethernet Network with a network cable to the switch on the ET200S CPU module.

o Give you network card the following settings: IP address: 172.20.71.98 Subnet mask: 255.255.255.0

o Select Properties for you network card, and double click on TCP IP network protocol:

Page 13: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 13 of 20

Page 14: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 14 of 20

Search in log data

• Start a web browser like Internet Explorer, Google Chrome, Firefox or Opera

• Input the IP address of the Blackbox in the address line, e.g. : http://172.20.71.100

• You will then see the page below:

Page 15: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 15 of 20

Page 16: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 16 of 20

Search results in web page

Page 17: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 17 of 20

Save search results as CSV file for Excel

Page 18: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 18 of 20

Back up log data

The backup process may take more than an hour with a lot of data! Please don’t cancel it or do anything else on the Blackbox system during the backup, as it is requiring a lot of resources from the Blackbox system.

Page 19: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 19 of 20

Delete old log data

As default is the date field entered with one month ago.

Confirm delete

Page 20: PLCSQL User ManualSAVE SEARCH RESULTS AS CSV FILE FOR EXCEL 17 BACK UP LOG DATA 18 DELETE OLD LOG DATA 19 SHOW CURRENT / SET TIME AND DATE 20 User Manual: PLCSQL – SQL Client in

User Manual: PLCSQL – SQL Client in a Siemens S7 PLC

Subj. PLCSQL – SQL Client in a PLC Document: PLCSQL User Manual.docx

Ref. 12342AJO Version 1.00 Revision: 2011-11-22 by AJO

Page 20 of 20

Show current / set time and date


Recommended