SoMachine. Getting & Setting Real Time Clock SysTime Library Guide 04/2012. www.schneider-electric.com EIO0000000667.05. SoMachine

Similar documents
Magelis SCU EIO /2013. Magelis SCU. SoMachine Programming Guide 05/2013 EIO

SCADAPack E ISaGRAF 3 User Manual

Historian SQL Server 2012 Installation Guide

Modicon M340 Peripheral Remote I/O Adapter BMX PRA 0100 User Manual

EIO /2010. SoMachine. Data Logging Functions DataLogging Library Guide 05/2010 EIO

Modicon LMC058 Motion Controller

Modicon M241 Logic Controller Programming Guide

Industrial Process Automation (Exercise)

Job Scheduler User Guide IGSS Version 11.0

Automazione Industriale 3 - I linguaggi di programmazione.

Micro800 Programmable Controllers: Getting Started with CIP Client Messaging

Web Designer for Modicon M340, Premium and Quantum

Technical Training Module ( 30 Days)

Automating witfi STEP7 in LAD and FBD

Automating with STEP7 in LAD and FBD

Backup Recovery User Manual

Variable speed drives for synchronous and asynchronous motors

UPS System Capacity Management Configuration Utility

S and STEP 7 Basic V10.5

SIMATIC. S Getting started with S Preface. Quick review 1. Installation 2. Create a simple latch circuit 3. Complete the user program 4

Ethernet/IP Explicit Messaging Using Unity Software

Straton and Zenon for Advantech ADAM Copalp integrates the straton runtime into the ADAM-5550 device from Advantech

Siemens AG. SIMATIC S7 Ethernet 04/

Programming languagesfor PLC: International Standard IEC (part one)

Automation software Concept V2.6 The flexible IEC development environment to optimize PLC performance

straton Universal control and strong connections. embedded field bus controller soft-plc scada logic

Programmable Logic Controller PLC

Beremiz The Free and Open Source IEC Automation IDE

7TMITETH. IGSS Mitsubishi FX/Q TCP/IP Interface Driver User Manual. Schneider Electric Denmark A/S

Modicon M580 Change Configuration On The Fly User Guide

2011, The McGraw-Hill Companies, Inc. Chapter 5

Achieve benchmark performance while increasing profitability. Modicon logic controllers

PROCESS AUTOMATION PLANNING AND INTEGRATION INFORMATION LB8106* Integration in Siemens SIMATIC PCS 7

Library ModbusRTUlib Modbus RTU master communication. TXV rd Issue February 2010 All rights reserved

SIMATIC. C7-621, C7-621 AS-i Control Systems. Volume 2 Working with C7 A B C D E. Contents. User Information. Introduction. Startup.

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 OUTCOME 3 PART 1

PLC SW and Programming. Nagy István, BMF BGK MEI

StruxureWare Power Monitoring 7.0.1

Configuring PCAN-Explorer to Monitor Data Traffic on a CANopen Network

IEC The Fast Guide to Open Control Software

How to Mimic the PanelMate Readout Template with Vijeo Designer

BECKHOFF. Application Notes. BC9000: Getting Started Guide. For additional documentation, please visit.

IMPORTANT PRODUCT INFORMATION

Programming A PLC. Standard Instructions

Candle Plant process automation based on ABB 800xA Distributed Control Systems

Training Document for Comprehensive Automation Solutions Totally Integrated Automation (T I A) MODULE A5 Programming the CPU 314C-2DP

SIMATIC NET. CP AS-Interface Master B C. Preface Contents. Technical Description and Installation Instructions Interface to the User Program

SECTION 13XXX CONTROL DESCRIPTION (DICP Models NC, 412, 622, 826, 1030)

Optimize your simple machines... Modicon M218 Selection Guide

Modbus Communications for PanelView Terminals

Visual Programming of Logic, Motion, and Robotics

Semaphore T BOX Applications in Data Center Facilities

TSX ETY 110 Module 8

SIMATIC. Structured Control Language (SCL) for S7-300/S7-400 Programming. Preface, Contents. Part 1: Designing Programs

PLCs and SCADA Systems

S7 for Windows S7-300/400

Applications & Tools. Configuration of Messages and Alarms in WinCC (TIA Portal) WinCC (TIA Portal) Application description December 2012

ISaGRAF. Getting Started. Software release 5.2

WA Manager Alarming System Management Software Windows 98, NT, XP, 2000 User Guide

Programmable Logic Controllers Definition. Programmable Logic Controllers History

DATA COMMUNICATION BETWEEN PROGRAMMABLE LOGIC CONTROLLERS IN THE INDUSTRIAL DISTRIBUTION APPLICATIONS

MODBUS. Table Of Contents

SHORT TRAINING COURSES

How To Configure An Iec (Runtu) For A Testnet (Rntu)

Lifecycle Service Tool. Operator's manual

Micro800 Programmable Controllers. Bulletin 2080 Selection Guide

PowerLogic ION Enterprise 5.6

Using Logix5000 Controllers as Masters or Slaves on Modbus

Creating the program. TIA Portal. SIMATIC Creating the program. Loading the block library. Deleting program block Main [OB1] Copying program blocks

SCADAPack E DNP3 Technical Reference

PROFINET IO Diagnostics 1

Attention: The installation of the ABB Automation Builder software requires administrator rights.

How To Use Safety System Software (S3)

Machine Struxure. Yves Eknadissian Product Manager Automation. 1 februari 2011 N-B-C - Nieuwegein

Understanding the IEC Programming Languages

LADDER LOGIC/ FLOWCHART PROGRAMMING DIFFERENCES AND EXAMPLES

The following shows the symbols used in this Quick start guide with descriptions and examples. Symbol Description Example. Select [Project] [New].

How can I. Develop a time stamping application in PlantStruxure? Develop your project. Time Stamping solutions. System Technical Guide

Industrial IT. Compact Control Builder AC 800M Version 5.0 SP2. Getting Started Introduction and Installation

SIMATIC. WinCC V7.0. Getting started. Getting started. Welcome 2. Icons 3. Creating a project 4. Configure communication 5

System 800xA Control AC 800M Planning

Vijeo Citect Architecture and Redundancy Study Guide

How To Use B&R Automation

S4000TH HART. HART Communication Manual

L5354 ControlNet Communications Interface

Power network telecommunication

Linear Motion and Assembly Technologies Pneumatics Service. Understanding the IEC Programming Languages

Training Document for Comprehensive Automation Solutions Totally Integrated Automation (T I A) MODULE C2. High Level Programming with S7-SCL

Z-TWS4. Multifunction Straton / LINUX Controller.

Programming Manual Catalog Numbers 1756 ControlLogix, 1769 CompactLogix, 1789 SoftLogix, 1794 FlexLogix, PowerFlex 700S with DriveLogix

XSOFT-CODESYS-3 PLC programming

DATA ITEM DESCRIPTION

StruxureWare Power Monitoring Expert 7.2

Programmable set for Ethernet Modbus/TCP in IP67 TI-BL67-PG-EN-2

4511 MODBUS RTU. Configuration Manual. HART transparent driver. No. 9107MCM100(1328)

2 Building Blocks of IEC

UM0272 User manual. Central Unit for Alarm System (CUAS) Evaluation Board. Introduction

TRILOGI 5.3 PLC Ladder Diagram Programmer and Simulator. A tutorial prepared for IE 575 by Dr. T.C. Chang. Use On-Line Help

IT Infrastructure Preparation for StruxureWare Power Monitoring Expert 8.0 Installation

Analog Inputs and Outputs

Transcription:

SoMachine EIO0000000667 04/2012 SoMachine Getting & Setting Real Time Clock SysTime Library Guide 04/2012 EIO0000000667.05 www.schneider-electric.com

The information provided in this documentation contains general descriptions and/or technical characteristics of the performance of the products contained herein. This documentation is not intended as a substitute for and is not to be used for determining suitability or reliability of these products for specific user applications. It is the duty of any such user or integrator to perform the appropriate and complete risk analysis, evaluation and testing of the products with respect to the relevant specific application or use thereof. Neither Schneider Electric nor any of its affiliates or subsidiaries shall be responsible or liable for misuse of the information contained herein. If you have any suggestions for improvements or amendments or have found errors in this publication, please notify us. No part of this document may be reproduced in any form or by any means, electronic or mechanical, including photocopying, without express written permission of Schneider Electric. All pertinent state, regional, and local safety regulations must be observed when installing and using this product. For reasons of safety and to help ensure compliance with documented system data, only the manufacturer should perform repairs to components. When devices are used for applications with technical safety requirements, the relevant instructions must be followed. Failure to use Schneider Electric software or approved software with our hardware products may result in injury, harm, or improper operating results. Failure to observe this information can result in injury or equipment damage. 2012 Schneider Electric. All rights reserved. 2 EIO0000000667 04/2012

Table of Contents Safety Information.............................. 5 About the Book................................. 7 Chapter 1 Getting Started................................. 11 Adding the SysTime Library................................... 12 Get the Controller Date and Time............................... 13 Set the Controller Date and Time............................... 14 Chapter 2 Functions Descriptions.......................... 15 2.1 Time Meter Functions........................................ 16 SysTimeGetMs: Returns Time since Power ON in Milliseconds........ 17 SysTimeGetUs: Returns Time since Power ON in Microseconds....... 18 2.2 Standard Real Time Clock Functions............................ 19 SysTimeRtcGet: Returns Current Controller Real Time Clock......... 20 SysTimeRtcSet: Sets the Controller Real Time Clock............... 21 SysTimeRtcConvertUtcToDate: Converts Timestamp into Date & Time. 22 SysTimeRtcConvertDateToUtc: Converts Date & Time into Timestamp. 23 Chapter 3 SYSTIMEDATE: Date & Time Type................. 25 SYSTIMEDATE: Date & Time Type............................. 25 Chapter 4 Implementation Example......................... 27 Get the Controller Date & Time................................. 28 Set the Controller Date & Time................................. 29 Appendices........................................... 31 Appendix A Function and Function Block Representation....... 33 Differences Between a Function and a Function Block............... 34 How to Use a Function or a Function Block in IL Language........... 35 How to Use a Function or a Function Block in ST Language.......... 38 Glossary........................................... 41 Index........................................... EIO0000000667 04/2012 3

4 EIO0000000667 04/2012

Safety Information Important Information NOTICE Read these instructions carefully, and look at the equipment to become familiar with the device before trying to install, operate, or maintain it. The following special messages may appear throughout this documentation or on the equipment to warn of potential hazards or to call attention to information that clarifies or simplifies a procedure. EIO0000000667 04/2012 5

PLEASE NOTE Electrical equipment should be installed, operated, serviced, and maintained only by qualified personnel. No responsibility is assumed by Schneider Electric for any consequences arising out of the use of this material. A qualified person is one who has skills and knowledge related to the construction and operation of electrical equipment and its installation, and has received safety training to recognize and avoid the hazards involved. 6 EIO0000000667 04/2012

About the Book At a Glance Document Scope This documentation describes the SysTime functions used to get and set the real time clock, supported by all SoMachine controllers. The Real time Clock Management is based on functions available in the SysTime library of SoMachine. The following table shows the list of SysTime library functions and the controllers that support them: Function Name M238 M258 LMC058 XBT-GC XBT-GK XBT-GT SysTimeGetMs x x x x SysTimeGetNs - x x x SysTimeGetUs x x x x SysTimeRtcConvertDateToHighRes - x x - SysTimeRtcConvertHighResToDate - x x - SysTimeRtcHighResGet - x x - SysTimeRtcHighResSet - x x - SysTimeRtcControl - x x x SysTimeRtcConvertDateToUtc x x x x SysTimeRtcConvertLocalToUtc - x x x SysTimeRtcConvertUtcToDate x x x x SysTimeRtcConvertUtcToLocal - x x x ATV-IMC EIO0000000667 04/2012 7

Function Name M238 M258 LMC058 XBT-GC XBT-GK XBT-GT SysTimeRtcGet x x x x SysTimeRtcGetTimezone x x x - SysTimeRtcSet x x x x SysTimeRtcSetTimezone x x x - ATV-IMC Legend: x Supported - Not supported To get information about functions not described in this document, refer to the SysTime_V3x_E document. (See Related Documents) Validity Note This document has been updated with the release of SoMachine V3.1. Related Documents Document Name SysTime_V3x_E Location / Part Number On your local SoMachine installation. By default: English version Program Files\Schneider Electric\SoMachine\Documentation\en\CoDeSys German version Program Files\Schneider Electric\SoMachine\Documentation\de\CoDeSys 8 EIO0000000667 04/2012

Product Related Information LOSS OF CONTROL WARNING The designer of any control scheme must consider the potential failure modes of control paths and, for certain critical control functions, provide a means to achieve a safe state during and after a path failure. Examples of critical control functions are emergency stop and overtravel stop, power outage and restart. Separate or redundant control paths must be provided for critical control functions. System control paths may include communication links. Consideration must be given to the implications of unanticipated transmission delays or failures of the link. Observe all accident prevention regulations and local safety guidelines. 1 Each implementation of this equipment must be individually and thoroughly tested for proper operation before being placed into service. Failure to follow these instructions can result in death, serious injury, or equipment damage. 1 For additional information, refer to NEMA ICS 1.1 (latest edition), "Safety Guidelines for the Application, Installation, and Maintenance of Solid State Control" and to NEMA ICS 7.1 (latest edition), "Safety Standards for Construction and Guide for Selection, Installation and Operation of Adjustable-Speed Drive Systems" or their equivalent governing your particular location. UNINTENDED EQUIPMENT OPERATION WARNING Only use software approved by Schneider Electric for use with this equipment. Update your application program every time you change the physical hardware configuration. Failure to follow these instructions can result in death, serious injury, or equipment damage. User Comments We welcome your comments about this document. You can reach us by e-mail at techcomm@schneider-electric.com. EIO0000000667 04/2012 9

10 EIO0000000667 04/2012

SoMachine Getting Started EIO0000000667 04/2012 Getting Started 1 Overview This chapter provides essential information to start using the SysTime functions. What s in this Chapter? This chapter contains the following topics: Topic Page Adding the SysTime Library 12 Get the Controller Date and Time 13 Set the Controller Date and Time 14 EIO0000000667 04/2012 11

Getting Started Adding the SysTime Library Procedure To have access to the SysTime functions, it is necessary to manually add the library: Step Action 1 Double-click the Library Manager node of the controller Application node in the Devices window.. 2 Click Add Library Result: The Add Library dialog box opens. 3 Browse to System SysLibs, visible when the Company filter is set to System or All Company Result: The System libraries list is displayed. 4 Select the SysTime library and press OK Result: The library is added to the Library Manager list. 12 EIO0000000667 04/2012

Getting Started Get the Controller Date and Time Overview To get the controller Date and Time in SYSTIMEDATE format, it is necessary to use 2 different functions; SysTimeRtcGet (see page 20) and SysTimeRtcConvertUtc- ToDate (see page 22). SysTimeRtcGet: This function returns the controller Real Time Clock (RTC) in a timestamp value (number of seconds since January 1st, 1970 00:00:00). SysTimeRtcConvertUtcToDate: This function converts the Timestamp value into SYSTIMEDATE structure type data providing Year, Month, Day, Hour, Minute, Second values. Principle Diagram An implementation example of this principle is available in this document. (see page 28) Timezone Management Some controllers (see page 7) support time zone information (summer time shift and Universal Time Coordinated (UTC) shift): when this information is not used or set to 0 (default value), the timestamp value returned by SysTimeRtcGet function = RTC. when time zone information is not 0, the function returns UTC = RTC + Time Shift. The Time Shift can be read or set using the Time Zone management functions (SysTimeRtcGetTimezone, SysTimeRtcSetTimezone) UTC timestamp can be converted to local timestamp through SysTimeConvertUtc- ToLocal function. NOTE: These functions are not described in this document, refer to the SysTime_V3x_E document for more information (see Related Documents (see page 8)). EIO0000000667 04/2012 13

Getting Started Set the Controller Date and Time Overview To set the controller RTC from Date and Time in SYSTIMEDATE format, it is necessary to use 2 different functions; SysTimeRtcConvertDateToUtc (see page 23) and SysTimeRtcSet (see page 21): SysTimeRtcConvertDateToUtc: This function converts a SYSTIMEDATE type input into a timestamp value (number of seconds since January 1st, 1970 00:00:00). SysTimeRtcSet: This function sets the controller RTC with the timestamp input. NOTE: Check the SetRTCDrift (See your controller PLCSystem Library Guide to check whether the SetRTCDrift function is supported and to get further information about this function) for a weekly automatic correction of the Real Time Clock, as an alternative to using the SysTimeRtcSet function. Principle Diagram An implementation example of this principle is available in this document. (see page 29) 14 EIO0000000667 04/2012

SoMachine Function Descriptions EIO0000000667 04/2012 Functions Descriptions 2 Overview This chapter describes the SysTime functions used to get and set the controller Real Time Clock. What s in this Chapter? This chapter contains the following sections: Section Topic Page 2.1 Time Meter Functions 16 2.2 Standard Real Time Clock Functions 19 EIO0000000667 04/2012 15

Function Descriptions 2.1 Time Meter Functions Overview This section describes the functions for getting time meters (milliseconds and microseconds). What s in this Section? This section contains the following topics: Topic Page SysTimeGetMs: Returns Time since Power ON in Milliseconds 17 SysTimeGetUs: Returns Time since Power ON in Microseconds 18 16 EIO0000000667 04/2012

Function Descriptions SysTimeGetMs: Returns Time since Power ON in Milliseconds Function Description This function returns the time elapsed since power ON in milliseconds (ms). Graphical Representation I/O Variables Description The following table describes the output variables: Output Type Description SysTimeGetMs UDINT Time elapsed since power ON in milliseconds. EIO0000000667 04/2012 17

Function Descriptions SysTimeGetUs: Returns Time since Power ON in Microseconds Function Description This function returns the time elapsed since power ON in microseconds (µs). Graphical Representation I/O Variables Description The following table describes the output variables: Output Type Description SysTimeGetUs UDINT Function operation diagnostic: 0 = No error detected 2 = Error detected on input variable, the returned value (pustime) is not valid. The following table describes the input/output variables: Input/Output Type Description pustime SYSTIME Time elapsed since power ON in microseconds. NOTE: SYSTIME type is a ULINT. 18 EIO0000000667 04/2012

Function Descriptions 2.2 Standard Real Time Clock Functions Overview This section describes the controller RTC management standard functions. What s in this Section? This section contains the following topics: Topic Page SysTimeRtcGet: Returns Current Controller Real Time Clock 20 SysTimeRtcSet: Sets the Controller Real Time Clock 21 SysTimeRtcConvertUtcToDate: Converts Timestamp into Date & Time 22 SysTimeRtcConvertDateToUtc: Converts Date & Time into Timestamp 23 EIO0000000667 04/2012 19

Function Descriptions SysTimeRtcGet: Returns Current Controller Real Time Clock Function Description This function returns the controller Real Time Clock (RTC) as a Universal Time Coordinated (UTC) timestamp value (number of seconds since 1970, 1st Jan. 00:00:00). Graphical Representation I/O Variables Description The following table describes the output variables: Output Type Description SysTimeRtcGet DWORD Controller RTC as a UTC Timestamp value (number of seconds since January 1st, 1970 00:00:00) The following table describes the input/output variables: Input/Output Type Description presult UDINT Function operation diagnostic: 0 = No error detected 1 = Internal operation error detected, the returned value (SysTimeRtcGet) is not valid (0). NOTE: Note: UTC = RTC + Time Shift (see page 13) NOTE: An example using this function is provided in this document. (see page 28) 20 EIO0000000667 04/2012

Function Descriptions SysTimeRtcSet: Sets the Controller Real Time Clock Function Description This function sets the controller Real Time Clock by a provided Timestamp value (number of seconds since January 1st, 1970 00:00:00). Graphical Representation I/O Variables Description The following table describes the input variables: Input Type Description ultimestamp DWORD Timestamp value (number of seconds since January 1st, 1970 00:00:00) The following table describes the output variables: Output Type Description SysTimeRtcSet UDINT Function operation diagnostic: 0 = No error detected 1 = Internal operation error detected NOTE: An example using this function is provided in this document. (see page 29) EIO0000000667 04/2012 21

Function Descriptions SysTimeRtcConvertUtcToDate: Converts Timestamp into Date & Time Function Description This function converts a timestamp value (number of seconds since 1970, 1st Jan. 00:00:00) into the corresponding Date & Time in SYSTIMEDATE format (see page 25). Graphical Representation I/O Variables Description The following table describes the input variables: Input Type Description dwtimestamputc DWORD Timestamp to be converted (number of seconds since January 1st, 1970 00:00:00) The following table describes the output variables: Output Type Description SysTimeRtcConvertUtcToDate UDINT Function operation diagnostic: 0 = No error detected 2 = Error detected on input variable, the returned value (pdate) is not valid. The following table describes the input/output variables: Input/Output Type Description pdate SYSTIMEDATE Date & Time calculated from input value (see page 25) NOTE: An example using this function is provided in this document. (see page 28) 22 EIO0000000667 04/2012

Function Descriptions SysTimeRtcConvertDateToUtc: Converts Date & Time into Timestamp Function Description This function converts a Date & Time in SYSTIMEDATE format (see page 25) into the corresponding Timestamp value (number of seconds since January 1st, 1970 00:00:00). Graphical Representation I/O Variables Description The following table describes the output variables: Output Type Description SysTimeRtcConvertDateToUtc UDINT Function operation diagnostic: 0 = No error detected 2 = Error detected on input variable, the returned value (pdwtimestamputc) is not valid. The following table describes the input/output variables: Input/Output Type Description pdate SYSTIMEDATE Date & Time to be converted (see page 25) pdwtimestamputc DWORD Timestamp calculated from entered Date & Time value = number of seconds since January 1st, 1970 00:00:00 or FFFF FFFF hex in case of unsuccessfull conversion. NOTE: An example using this function is provided in this document. (see page 29) EIO0000000667 04/2012 23

Function Descriptions 24 EIO0000000667 04/2012

SoMachine SYSTIMEDATE: Date & Time Type EIO0000000667 04/2012 SYSTIMEDATE: Date & Time Type 3 SYSTIMEDATE: Date & Time Type Data Type Description This structure contains detailed information on the Date & Time, presented in a readable format (in contrast to the timestamp). Name Type Description wyear UINT Year wmonth UINT Month, values 1..12 (Jan=1..Dec=12) wday UINT Day of month, values 1..31 whour UINT Hours of current day, values 0..23 wminute UINT Minutes of current hour, values 0..59 wsecond UINT Seconds of current minute, values 0..59 wmilliseconds UINT Milliseconds of current second, values 0..999 wdayofweek UINT Day of the week, values 1..7 (Monday = 1..Sunday=7) wyday UINT Day of the year, values 1..366 (01.Jan=1..31.Dec=365 resp. 366) EIO0000000667 04/2012 25

SYSTIMEDATE: Date & Time Type 26 EIO0000000667 04/2012

SoMachine Implementation Example EIO0000000667 04/2012 Implementation Example 4 Overview This chapter provides implementation examples showing how to get or set the Real Time Clock. What s in this Chapter? This chapter contains the following topics: Topic Page Get the Controller Date & Time 28 Set the Controller Date & Time 29 EIO0000000667 04/2012 27

Implementation Example Get the Controller Date & Time Overview This program example can be used to get the controller Date & Time. Variable Declaration VAR // controller current Date & Time Ctrl_DateTime: SYSTIMEDATE; CtrlYear: UINT; CtrlMonth: UINT; CtrlDay: UINT; CtrlHour: UINT; CtrlMinute: UINT; CtrlSecond: UINT; CtrlMSecond: UINT; CtrlDayOfWeek: UINT; CtrlYday: UINT; // SysTimeRtcGet operation diag GetTimeResult: UDINT; // SysTimeRtcConvertUtcToDate operation diag UTCtoDate_diag: UDINT; END_VAR POU Program 28 EIO0000000667 04/2012

Implementation Example Set the Controller Date & Time Overview This program example can be used to set the controller Real Time Clock with a user Date & Time. Variable Declaration VAR // Date & Time to set controller RTC MyDateTime: SYSTIMEDATE; MyYear: UINT; MyMonth: UINT; MyDay: UINT; MyHour: UINT; MyMinute: UINT; MySecond: UINT; // SysTimeRtcConvertDateToUtc operation diag DatetoUTC_diag: UDINT; // Date & Time in timestamp format My_UTC: DWORD; // Controller RTC setting command Set_DateTime: BOOL; // SysTimeRtcSet operation diag RtcSet_diag: UDINT; END_VAR EIO0000000667 04/2012 29

Implementation Example POU Program 30 EIO0000000667 04/2012

SoMachine EIO0000000667 04/2012 Appendices EIO0000000667 04/2012 31

32 EIO0000000667 04/2012

SoMachine Function and Function Block Representation EIO0000000667 04/2012 Function and Function Block Representation A Overview Each function can be represented in the following languages: IL: Instruction List ST: Structured Text LD: Ladder Diagram FBD: Function Block Diagram CFC: Continuous Function Chart This chapter provides functions and function blocks representation examples and explains how to use them for IL and ST languages. What s in this Chapter? This chapter contains the following topics: Topic Page Differences Between a Function and a Function Block 34 How to Use a Function or a Function Block in IL Language 35 How to Use a Function or a Function Block in ST Language 38 EIO0000000667 04/2012 33

Function and Function Block Representation Differences Between a Function and a Function Block Function A function: is a POU (Program Organization Unit) that returns one immediate result is directly called with its name (not through an Instance) has no persistent state from one call to the other can be used as an operand in other expressions Examples: boolean operators (AND), calculations, conversion (BYTE_TO_INT) Function Block A function block: is a POU (Program Organization Unit) that returns one or more outputs is always called through an Instance (function block copy with dedicated name and variables) each Instance has a persistent state (outputs and internal variables) from one call to the other Examples: timers, counters In the example below, Timer_ON is an instance of the Function Block TON: 34 EIO0000000667 04/2012

Function and Function Block Representation How to Use a Function or a Function Block in IL Language General Information This part explains how to implement a Function and a Function Block in IL language. Functions IsFirstMastCycle and SetRTCDrift and Function Block TON are used as examples to show implementations. Using a Function in IL Language The following procedure describes how to insert a function in IL language: Step Action 1 Open or create a new POU in Instruction List language. NOTE: The procedure to create a POU is not detailed here. For more information, refer to the SoMachine global help. 2 Create the variables that the function requires. 3 If the function has 1 or more inputs, start loading the first input using LD instruction. 4 Insert a new line below and: type the name of the function in the operator column (left field), or use the Input Assistant to select the function (select Insert Box in context menu). 5 If the function has more than 1 input and when Input Assistant is used, the necessary number of lines is automatically created with??? in the fields on the right. Replace the??? with the appropriate value or variable that corresponds to the order of inputs. 6 Insert a new line to store the result of the function into the appropriate variable: type ST instruction in the operator column (left field) and the variable name in the field on the right. To illustrate the procedure, consider the Functions IsFirstMastCycle (without input parameter) and SetRTCDrift (with input parameters) graphically presented below: Function without input parameter: IsFirstMastCycle Graphical Representation with input parameters: SetRTCDrift EIO0000000667 04/2012 35

Function and Function Block Representation In IL language, the function name is used directly in the Operator Column: Function IL example of a function without input parameter: IsFirstMastCycle Representation in SoMachine POU IL Editor IL example of a function with input parameters: SetRTCDrift Using a Function Block in IL language The following procedure describes how to insert a function block in IL language: Step Action 1 Open or create a new POU in Instruction List language. NOTE: The procedure to create a POU is not detailed here. For more information, refer to the SoMachine global help. 2 Create the variables that the function block requires, including the instance name. 36 EIO0000000667 04/2012

Function and Function Block Representation Step Action 3 Function Blocks are called using a CAL instruction: Use the Input Assistant to select the FB (right-click and select Insert Box in context menu). Automatically, the CAL instruction and the necessary I/O are created. Each parameter (I/O) is an instruction: Value to inputs are set by ":=". Values to outputs are set by "=>". 4 In the CAL right-side field, replace??? with the instance name. 5 Replace other??? with an appropriate variable or immediate value. To illustrate the procedure, consider this example with the TON Function Block graphically presented below: Function Block TON Graphical Representation In IL language, the function block name is used directly in the Operator Column: Function Block TON Representation in SoMachine POU IL Editor EIO0000000667 04/2012 37

Function and Function Block Representation How to Use a Function or a Function Block in ST Language General Information This part explains how to implement a Function and a Function Block in ST language. Function SetRTCDrift and Function Block TON are used as examples to show implementations. Using a Function in ST Language The following procedure describes how to insert a function in ST language: Step Action 1 Open or create a new POU in Structured Text language. NOTE: The procedure to create a POU is not detailed here. For more information, refer to the SoMachine global help. 2 Create the variables that the function requires. 3 Use the general syntax in the POU ST Editor for the ST language of a function. The general syntax is: FunctionResult:= FunctionName(VarInput1, VarInput2,.. VarInputx); To illustrate the procedure, consider the function SetRTCDrift graphically presented below: Function SetRTCDrift Graphical Representation The ST language of this function is the following: Function SetRTCDrift Representation in SoMachine POU ST Editor PROGRAM MyProgram_ST VAR mydrift: SINT(-29..29) := 5; myday: DAY_OF_WEEK := SUNDAY; myhour: HOUR := 12; myminute: MINUTE; myrtcadjust: RTCDRIFT_ERROR; END_VAR myrtcadjust:= SetRTCDrift(myDrift, myday, myhour, myminute); 38 EIO0000000667 04/2012

Function and Function Block Representation Using a Function Block in ST Language The following procedure describes how to insert a function block in ST language: Step Action 1 Open or create a new POU in Structured Text language. NOTE: The procedure to create a POU is not detailed here. For more information, refer to the SoMachine global help. 2 Create the input and output variables and the instance required for the function block: Input variables are the input parameters required by the function block Output variables receive the value returned by the function block 3 Use the general syntax in the POU ST Editor for the ST language of a Function Block. The general syntax is: FunctionBlock_InstanceName(Input1:=VarInput1, Input2:=VarInput2,... Ouput1=>VarOutput1, Ouput2=>VarOutput2,...); To illustrate the procedure, consider this example with the TON function block graphically presented below: Function Block TON Graphical Representation The following table shows examples of a function block call in ST language: Function Block TON Representation in SoMachine POU ST Editor EIO0000000667 04/2012 39

Function and Function Block Representation 40 EIO0000000667 04/2012

SoMachine Glossary EIO0000000667 04/2012 Glossary 0-9 % Prefix that identifies internal memory addresses in the controller that are used to store the value of program variables, constants, I/O, and so on. A application A SoMachine application consists of a program, configuration data, symbols, and documentation. ASCII American Standard Code for Information Interchange is a communication protocol for representing alphanumeric characters, notably letters, figures and certain graphic and control characters. ASIC Application Specific Integrated Circuit. Integrated Circuit designed especially for an application. This Integrated Circuit can be analog, digital or both. EIO0000000667 04/2012 41

Glossary C CANopen CANopen is a communication protocol and device profile specification used by Modicon Logic Controllers. continuous function chart language (CFC) Continuous Function Chart, in extension to the IEC61131-3 standard, is a graphical programming language based on the Function Block Diagram (FBD) language. However, no networks are used but free positioning of graphic elements, which allows feedback loops. controller A controller, or programmable logic controller (PLC), or else programmable controller is used for automation of industrial processes. E EEPROM Electrically Erasable Programmable Read-Only Memory is a type of non-volatile memory used to store data that must be saved when power is removed. expansion bus Expansion I/O Modules connect to the Modicon Logic Controller using the expansion bus. expansion I/O modules Optional Expansion I/O Modules are available to add I/O points to a Modicon Logic Controller. (Not all controller models allow expansion). 42 EIO0000000667 04/2012

Glossary F FG Frequency Generator firmware The firmware is the program embedded in the Modicon Logic Controller. FreqGen See FG. function A function: is a POU (Program Organization Unit) that returns one immediate result is directly called with its name (not through an Instance) has no persistent state from one call to the other can be used as operand in expressions Examples: boolean operators (AND), calculations, conversion (BYTE_TO_INT) function block A function block: is a POU (Program Organization Unit) that returns one or more outputs is always called through an Instance (function block copy with dedicated name and variables) each Instance has a persistent state (outputs and internal variables) from one call to the other Examples: timers, counters function block diagram language (FBD) A function block diagram describes a function between input variables and output variables. A function is described as a set of elementary blocks. Input and output variables are connected to blocks by connection lines. An output of a block may also be connected to an input of another block. EIO0000000667 04/2012 43

Glossary G GRAFCET GRAFCET is used to represent the functioning of a sequential operation in a structured and graphic form. This is an analytical method that divides any sequential control system into a series of steps, with which actions, transitions, and conditions are associated. GVL global variable list in SoMachine managing global variables that are available in all the POUs of the application H HSC High-Speed Counter I IEC 61131-3 IEC for International Electrotechnical Commission, is a not-for-profit, nongovernmental international standards organization that prepares and publishes International Standards for all electrical, electronic and related technologies. IEC 61131 is a standard for Programmable Logic Controllers (PLCs). IEC 61131-3 deals with PLC programming languages and defines two graphical and two textual programming language standards: Ladder Diagram (LD), graphical Function Block Diagram (FBD), graphical Structured Text (ST), textual Instruction List (IL), textual Sequential Function Chart (SFC), has elements to organize programs for sequential and parallel control processing. 44 EIO0000000667 04/2012

Glossary instruction list language (IL) A program written in instruction list language is composed of a series of instructions executed sequentially by the controller. Each instruction is composed of a line number, an instruction code, and an operand. IEC 61131-3 compliant. IP 20 (Ingress Protection) The protection classification offered by an enclosure is shown by the letter IP and two digits. The first digit indicates two factors: the protection for persons and for equipment. The second digit the protection against water. For more information see refer to the norm NF EN 60.529 L ladder diagram language (LD) A program written in ladder language is composed of graphical representation of instructions of a controller program with symbols for contacts, coils, and blocks in a series of rungs executed sequentially by a controller. IEC 61131-3 compliant. latching input Incoming pulses are captured and recorded for later examination by the application. located variable A located variable has an address. (An unlocated variable does not.) M MAST A master (MAST) task is a processor task that is run through its programming software. The MAST task has two sections: IN: Inputs are copied to the IN section before execution of the MAST task. OUT: Outputs are copied to the OUT section after execution of the MAST task. EIO0000000667 04/2012 45

Glossary master/slave Master/slave is a model for a communication protocol where one device or process has unidirectional control over one or more other devices. Modbus Communication protocol allowing communication between many devices connected to the same network. N NEMA National Electrical Manufacturers Association publishes standards for the performance of various classes of electrical enclosures. The NEMA standards cover corrosion resistance, ability to protect from rain and submersion, etc. For IEC member countries, standard IEC 60529 is classifying the ingress protection rating (IP Codes) of enclosures. network Interconnected devices sharing a common data path and protocol for communication. node An addressable device on a communications network. O OS Firmware that can be uploaded/downloaded by the user 46 EIO0000000667 04/2012

Glossary P PC Personal Computer. PLCopen The PLCopen standard brings efficiency, flexibility, and manufacturerindependence to the automation and control industry through the standardization of tools, libraries, and modular approaches to software programming. Post configuration Files that contain machine dependent parameters: machine name device name or IP address Modbus SL address Routing table POU A program organization unit includes a variable declaration in source code and the corresponding instruction set. POUs facilitate the modular reuse of software programs, functions, and function blocks. Once declared, POUs are available to one another. SoMachine programming requires the utilization of POUs. protocol A protocol is a convention or standard that controls or enables the connection, communication, and data transfer between two computing endpoints. PTO Pulse Train Output PWM Pulse Width Modulation EIO0000000667 04/2012 47

Glossary R real-time clock An option that keeps the time for a limited amount of time even when the controller is not powered. reflex output In HSC mode, the HSC counter current value is measured against its configured thresholds to determine the state of these dedicated outputs. RFID Radio-Frequency Identification is an automatic identification method, relying on storing and remotely retrieving data using devices called RFID tags or transponders. RPDO Process Data Object Reception RTC See Real-Time Clock. RUN A command that causes the controller to run an application program. S scan A controller scans a program and essentially performs three basic functions. First, it reads inputs and places these values in memory. Next, it executes the application program one instruction at a time and stores results in memory. Finally, it uses the results to update outputs. sequential function chart language (SFC) A program written in sequential function chart can be used for processes that can be split into steps. SFC is composed of steps with associated actions, transitions with associated logic condition and directed links between steps and transitions. The SFC standard is defined in IEC 848. IEC 61131-3 compliant. 48 EIO0000000667 04/2012

Glossary SMS The Short Message Service is a standard communication service for telephones (or other devices) that send short text messages over the GSM mobile communications system. SoMachine SoMachine is a comprehensive Controller Development System software tool for configuring and programming the Modicon Logic Controller and devices compliant with IEC 61131-3. STOP A command that causes the controller to stop running an application program. structured text language (ST) A program written in structured text is composed of complex statements and nested instructions such as: iteration loops, conditional executions, or functions. IEC 61131-3 compliant. symbol a symbol is an elementary controller variable published for HMI terminals System time Time which is provided in a device by an internal clock system variable Unlocated structure that give information on controller data and diagnostic and allow sending commands to controller. EIO0000000667 04/2012 49

Glossary T task A group of sections and subroutines, executed cyclically or periodically for the MAST task, or periodically for the FAST task. A task possesses a level of priority and is linked to inputs and outputs of the controller. These I/O are refreshed in consequence. threshold output Coils that are controlled directly by the HSC according to the settings established during configuration. TPDO Process Data Object Transmission U UTC Coordinated Universal Time V Variable Memory unit that can be addressed and modified by a program. 50 EIO0000000667 04/2012

SoMachine Index EIO0000000667 04/2012 Index CBA D Data Types SYSTIMEDATE, 25 F Functions Differences Between a Function and a Function Block, 34 How to Use a Function or a Function Block in IL Language, 35 How to Use a Function or a Function Block in ST Language, 38 SysTimeGetMs, 17 SysTimeGetUs, 18 SysTimeRtcConvertDateToUtc, 23 SysTimeRtcConvertUtcToDate, 22 SysTimeRtcGet, 20 SysTimeRtcSet, 21 SysTimeRtcConvertUtcToDate Functions, 22 SysTimeRtcGet Functions, 20 SysTimeRtcSet Functions, 21 S SYSTIMEDATE Data Types, 25 SysTimeGetMs Functions, 17 SysTimeGetUs Functions, 18 SysTimeRtcConvertDateToUtc Functions, 23 EIO0000000667 04/2012 51

Index 52 EIO0000000667 04/2012