You are on page 1of 296

Unity Pro

33002539 07/2012

Unity Pro
System
Block Library
07/2012
33002539.11

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 33002539 07/2012
Table of Contents

Safety Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
About the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Part I General information . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Chapter 1 Block Types and their Applications . . . . . . . . . . . . . . . . 13
Block Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
FFB Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
EN and ENO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Chapter 2 Availability of the function block on different hardware
platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Block Availability on the Various Hardware Platforms. . . . . . . . . . . . . . . . 23
Part II File Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Chapter 3 Implementing File Management . . . . . . . . . . . . . . . . . . . 29
File Management on Memory Cards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Function Block Operating Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
File Descriptor knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Chapter 4 Formatting a Memory Card . . . . . . . . . . . . . . . . . . . . . . . 37
Formatting the Memory Card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Chapter 5 CREATE_FILE: Create a Data Storage File . . . . . . . . . . 39
CREATE_FILE: Create a Data Storage File . . . . . . . . . . . . . . . . . . . . . . . 39
Chapter 6 OPEN_FILE: Open a File . . . . . . . . . . . . . . . . . . . . . . . . . 43
OPEN_FILE: Open a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Chapter 7 SET_FILE_ATTRIBUTES: Set File Attributes . . . . . . . . . 47
SET_FILE_ATTRIBUTES: Sets the File Attributes . . . . . . . . . . . . . . . . . . 47
Chapter 8 GET_FILE_INFO: Retrieve File Attributes . . . . . . . . . . . 49
GET_FILE_INFO: Retrieves the File Attributes . . . . . . . . . . . . . . . . . . . . 49
Chapter 9 GET_FREESIZE: View Available Space on Memory Card 53
GET_FREESIZE: View Available Space of the File Partition on the
Memory Card. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Chapter 10 SEEK_FILE: Position in a File . . . . . . . . . . . . . . . . . . . . . 57
SEEK_FILE: Position in the File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

33002539 07/2012 3
Chapter 11 WR_DATA_TO_FILE: Write Data to a File . . . . . . . . . . . . 61
WR_DATA_TO_FILE: Writes Data to a File . . . . . . . . . . . . . . . . . . . . . . 61
Chapter 12 RD_FILE_TO_DATA: Read Data in a File . . . . . . . . . . . . . 65
RD_FILE_TO_DATA: Read Data from a File . . . . . . . . . . . . . . . . . . . . . 65
Chapter 13 CLOSE_FILE: Close a File. . . . . . . . . . . . . . . . . . . . . . . . . 69
CLOSE_FILE: Close the File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Chapter 14 DELETE_FILE: Delete a File . . . . . . . . . . . . . . . . . . . . . . . 71
DELETE_FILE: Delete a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Chapter 15 Memory Card File Management EFB Error Codes . . . . . 75
Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Chapter 16 Memory Card File Management EF Examples . . . . . . . . 77
Definition of the Example and Declaration of Variables. . . . . . . . . . . . . . 78
Offline Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Online Example: Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Example written in ST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Chapter 17 WRITE_U_PCMCIA: Writing data to the memory card . . 89
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Chapter 18 READ_U_PCMCIA: Reading data in the memory card . . 93
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Chapter 19 WRITE_U_PCMCIA and READ_U_PCMCIA Functions
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
WRITE_U_PCMCIA and READ_U_PCMCIA Example . . . . . . . . . . . . . . 97
Chapter 20 WRITE_V_PCMCIA: Write Variable to PCMCIA Card . . . 99
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Chapter 21 READ_V_PCMCIA: Read Variable from PCMCIA Card . . 103
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Chapter 22 PRJ_VERS: Project Version . . . . . . . . . . . . . . . . . . . . . . . 107
PRJ_VERS: Project Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Part III Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Chapter 23 HALT: Stopping the program . . . . . . . . . . . . . . . . . . . . . . 113
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Chapter 24 ITCNTRL : Triggering of TIMER type event processing . 115
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Chapter 25 MASKEVT: Global masking of events . . . . . . . . . . . . . . . 119
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Chapter 26 UNMASKEVT: Global unmasking of events . . . . . . . . . . 121
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Part IV Hot Stand By . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Chapter 27 HSBY_RD: Reading the Hot Standby command register 125
HSBY_RD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

4 33002539 07/2012
Chapter 28 HSBY_ST: Reading the Hot Standby status register . . 129
HSBY_ST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Chapter 29 HSBY_WR: Writing to the Hot Standby command
register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
HSBY_WR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Chapter 30 REV_XFER: Writing and reading the two Reverse-
Transfer-Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
REV_XFER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Part V SFC Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Chapter 31 CLEARCHART: Reset all active steps . . . . . . . . . . . . . . 143
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Chapter 32 FREEZECHART: Freeze sequence . . . . . . . . . . . . . . . . . 147
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Chapter 33 INITCHART: Reset all active steps and start sequence
normally . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Chapter 34 RESETSTEP: Reset a specific step in the sequence . . 155
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Chapter 35 SETSTEP: Set a specific step in the sequence . . . . . . . 159
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Chapter 36 SFCCNTRL: SFC Control . . . . . . . . . . . . . . . . . . . . . . . . . 163
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Parameter description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Chapter 37 SFC_RESTORE: SFC Save and Restore. . . . . . . . . . . . . 175
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Requirements and Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Save and Restore Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Saving the Active Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Restoring the Steps for Activation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Resuming the SFC Sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Interaction with SFCCNTRL Function Block . . . . . . . . . . . . . . . . . . . . . . . 191
STATUS Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Part VI SysClock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Chapter 38 FREERUN: Free-running timer . . . . . . . . . . . . . . . . . . . . 197
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Chapter 39 GET_TS_EVT_M: Reading the Modicon M340 Time
Stamped Event Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Chapter 40 GET_TS_EVT_Q: Reading the Quantum Time Stamped
Event Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

33002539 07/2012 5
Chapter 41 PTC: Reading the stop date and code . . . . . . . . . . . . . . . 211
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Chapter 42 RRTC_DT: Reading the system date . . . . . . . . . . . . . . . . 213
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Chapter 43 RRTC_DT_MS: Network real-time clock function . . . . . . 215
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Chapter 44 R_NTPC: Network real-time clock function . . . . . . . . . . . 219
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Chapter 45 SCHEDULE: Real-time clock function . . . . . . . . . . . . . . . 223
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Chapter 46 WRTC_DT: Updating the system date . . . . . . . . . . . . . . . 227
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Part VII System Specials . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Chapter 47 IS_PAR_CON: Is Parameter Connected. . . . . . . . . . . . . . 231
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
How to Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Chapter 48 IS_BIT_FORCED:Function Block . . . . . . . . . . . . . . . . . . . 235
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Chapter 49 UNFORCE_BIT: Function Block . . . . . . . . . . . . . . . . . . . 237
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Chapter 50 FORCE_BIT : Function Block . . . . . . . . . . . . . . . . . . . . . . 239
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Chapter 51 SIG_WRITE: Write a Signature . . . . . . . . . . . . . . . . . . . . . 241
SIG_WRITE: Write a Signature in Memory Card. . . . . . . . . . . . . . . . . . . 241
Chapter 52 SIG_CHECK: Check a Signature . . . . . . . . . . . . . . . . . . . 245
SIG_CHECK: Check Signature in Memory Card . . . . . . . . . . . . . . . . . . . 245
Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Appendix A System objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
System Bit Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Description of System Bits %S0 to %S7 . . . . . . . . . . . . . . . . . . . . . . . . . 253
Description of System Bits %S15 to %S21 . . . . . . . . . . . . . . . . . . . . . . . 255
Description of System Bits %S30 to %S59 . . . . . . . . . . . . . . . . . . . . . . . 258
Description of System Words %SW12 to %SW29. . . . . . . . . . . . . . . . . . 261
Description of System Words %SW48 to %SW59. . . . . . . . . . . . . . . . . . 266
Description of Quantum System Words %SW60 to %SW66. . . . . . . . . . 268
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293

6 33002539 07/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.

33002539 07/2012 7
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.

8 33002539 07/2012
About the Book

At a Glance

Document Scope
This document describes the functions and function blocks of the System library.

Validity Note
This document is valid from Unity Pro Version 7.0.

User Comments
We welcome your comments about this document. You can reach us by e-mail at
techcomm@schneider-electric.com.

33002539 07/2012 9
10 33002539 07/2012
Unity Pro
General information
33002539 07/2012

General information

I
Overview
This section provides general information on the System library

What Is in This Part?


This part contains the following chapters:
Chapter Chapter Name Page
1 Block Types and their Applications 13
2 Availability of the function block on different hardware 23
platforms

33002539 07/2012 11
General information

12 33002539 07/2012
Unity Pro
Block Types and their Applications
33002539 07/2012

Block Types and their


Applications
1
Overview
This chapter describes the different block types and their applications.

What Is in This Chapter?


This chapter contains the following topics:
Topic Page
Block Types 14
FFB Structure 16
EN and ENO 19

33002539 07/2012 13
Block Types and their Applications

Block Types

Block Types
Different block types are used in Unity Pro. The general term for the block types is
FFB.
There are the following types of block:
z Elementary Function (EF)
z Elementary Function Block (EFB)
z Derived Function Block (DFB)
z Procedure

NOTE: Motion Function Blocks are not available on the Quantum platform.

Elementary Function
Elementary functions (EF) have no internal status and one output only. If the input
values are the same, the output value is the same for the executions of the function,
for example the addition of two values gives the same result at every execution.
An elementary function is represented in the graphical languages (FBD and LD) as
a block frame with inputs and an output. The inputs are represented on the left and
the outputs on the right of the block frame. The name of the function, that is the
function type, is shown in the center of the block frame.
The number of inputs can be increased with some elementary functions.

CAUTION
UNEXPECTED BEHAVIOR OF EQUIPMENT
For Unity Pro V4.0 and earlier versions, do not use links to connect function blocks
outputs, when your application relies on persistent output data of an EF.
Failure to follow these instructions can result in injury or equipment damage.

NOTE: With Unity Pro V4.0 and earlier versions the deactivation of an EF (EN=0)
causes links connected to its Input/Output to be reset. To transfer the state of the
signal do not use a link. A variable must be connected to the EFs output and must
be used to connect the input of the element. With Unity Pro V4.1 and later versions
you can maintain the output links even if an EF is deactivated by activating the
option Maintain output links on disabled EF (EN=0) via the menu Tools
Program Languages Common.

14 33002539 07/2012
Block Types and their Applications

Elementary Function Block


Elementary function blocks (EFB) have an internal status. If the inputs have the
same values, the value on the outputs can have another value during the individual
executions. For example, with a counter, the value on the output is incremented.
An elementary function block is represented in the graphical languages (FBD and
LD) as a block frame with inputs and outputs. The inputs are represented on the left
and the outputs on the right of the block frame. The name of the function block, that
is the function block type, is shown in the center of the block frame. The instance
name is displayed above the block frame.

Derived Function Block


Derived function blocks (DFBs) have the same properties as elementary function
blocks. They are created by the user in the programming languages FBD, LD, IL
and/or ST.

Procedure
Procedures are functions with several outputs. They have no internal state.
The only difference from elementary functions is that procedures can have more
than one output and they support variables of the VAR_IN_OUT data type.
Procedures do not return a value.
Procedures are a supplement to IEC 61131-3 and must be enabled explicitly.
There is no visual difference between procedures and elementary functions.

CAUTION
UNEXPECTED BEHAVIOR OF EQUIPMENT
For Unity Pro V4.0 and earlier versions, do not use links to connect function blocks
outputs, when your application relies on persistent output data of an EF.
Failure to follow these instructions can result in injury or equipment damage.

NOTE: With Unity Pro V4.0 and earlier versions the deactivation of an EF (EN=0)
causes links connected to its Input/Output to be reset. To transfer the state of the
signal do not use a link. A variable must be connected to the EFs output and must
be used to connect the input of the element. With Unity Pro V4.1 and later versions
you can maintain the output links even if an EF is deactivated by activating the
option Maintain output links on disabled EF (EN=0) via the menu Tools
Program Languages Common.

33002539 07/2012 15
Block Types and their Applications

FFB Structure

Structure
Each FFB is made up of an operation (name of the FFB), the operands are required
for the operation (formal and actual parameters) and an instance name for
elementary/derived function blocks.
Call of a function block in the FBD programming language:

CAUTION
UNEXPECTED APPLICATION BEHAVIOR
Do not call several times the same block instance within a PLC cycle
Failure to follow these instructions can result in injury or equipment damage.

16 33002539 07/2012
Block Types and their Applications

Formal call of a function block in the ST programming language:

Operation
The operation determines which function is to be executed with the FFB, e.g. shift
register, conversion operations.

Operand
The operand specifies what the operation is to be executed with. With FFBs, this
consists of formal and actual parameters.

Formal/actual parameters
Inputs and outputs are required to transfer values to or from an FFB. These are
called formal parameters.
Objects are linked to formal parameters; these objects contain the current process
states. They are called actual parameters.
At program runtime, the values from the process are transferred to the FFB via the
actual parameters and then output again after processing.
The data type of the actual parameters must match the data type of the input/output
(formal parameters). The only exceptions are generic inputs/outputs whose data
type is determined by the actual parameter. If the actual parameters consist of
literals, a suitable data type is selected for the function block.

33002539 07/2012 17
Block Types and their Applications

FFB Call in IL/ST


In text languages IL and ST, FFBs can be called in formal and in informal form.
Details can be found in the Reference manual.
Example of a formal function call:
out:=LIMIT (MN:=0, IN:=var1, MX:=5);
Example of an informal function call:
out:=LIMIT (0, var1, 5);
NOTE: The use of EN and ENO is only possible for formal calls.

VAR_IN_OUT variable
FFBs are often used to read a variable at an input (input variables), to process it and
to output the altered values of the same variable (output variables).
This special type of input/output variable is also called a VAR_IN_OUT variable.
The input and output variable are linked in the graphic languages (FBD and LD)
using a line showing that they belong together.
Function block with VAR_IN_OUT variable in FBD:

Function block with VAR_IN_OUT variable in ST:


MY_EXAMP1 (IN1:=Input1, IN2:=Input2, IO1:=Comb_IN_OUT,
OUT1=>Output1, OUT2=>Output2);
The following points must be considered when using FFBs with VAR_IN_OUT
variables:
z The VAR_IN_OUT inputs must be assigned a variable.
z Literals or constants cannot be assigned to VAR_IN_OUT inputs/outputs.

The following additional limitations apply to the graphic languages (FBD and LD):
z When using graphic connections, VAR_IN_OUT outputs can only be connected
with VAR_IN_OUT inputs.
z Only one graphical link can be connected to a VAR_IN_OUT input/output.
z Different variables/variable components can be connected to the VAR_IN_OUT
input and the VAR_IN_OUT output. In this case the value of the variables/variable
component on the input is copied to the output variables/variable component.
z No negations can be used on VAR_IN_OUT inputs/outputs.
z A combination of variable/address and graphic connections is not possible for
VAR_IN_OUT outputs.

18 33002539 07/2012
Block Types and their Applications

EN and ENO

Description
An EN input and an ENO output can be configured for the FFBs.
If the value of EN is equal to "0" when the FFB is invoked, the algorithms defined by
the FFB are not executed and ENO is set to "0".
If the value of EN is equal to "1" when the FFB is invoked, the algorithms defined by
the FFB will be executed. After the algorithms have been executed successfully, the
value of ENO is set to "1". If certain error conditions are detected when executing
these algorithms, ENO is set to "0".
If the EN pin is not assigned a value, when the FFB is invoked, the algorithm defined
by the FFB is executed (same as if EN equals to "1"), Please refer to Maintain output
links on disabled EF (see Unity Pro, Operating Modes).
If the algorithms are executed successfully, then value of ENO is set to "1", else ENO
is set to "0".
If ENO is set to "0" (caused by EN=0 or a detected error condition during execution
or unsuccessful algorithm execution):
z Function blocks
z EN/ENO handling with function blocks that (only) have one link as an output
parameter:

If EN from FunctionBlock_1 is set to "0", the output connection OUT from


FunctionBlock_1 retains the status it had in the last correctly executed
cycle.
z EN/ENO handling with function blocks that have one variable and one link as
output parameters:

If EN from FunctionBlock_1 is set to "0", the output connection OUT from


FunctionBlock_1 retains the status it had in the last correctly executed
cycle. The variable OUT1 on the same pin, either retains its previous status or
can be changed externally without influencing the connection. The variable
and the link are saved independently of each other.

33002539 07/2012 19
Block Types and their Applications

z Functions/Procedures

CAUTION
UNEXPECTED BEHAVIOR OF EQUIPMENT
For Unity Pro V4.0 and earlier versions, do not use links to connect function
blocks outputs, when your application relies on persistent output data of an EF.
Failure to follow these instructions can result in injury or equipment dam-
age.

NOTE: With Unity Pro V4.0 and earlier versions the deactivation of an EF (EN=0)
causes links connected to its Input/Output to be reset. To transfer the state of the
signal do not use a link. A variable must be connected to the EFs output and must
be used to connect the input of the element. With Unity Pro V4.1 and later versions
you can maintain the output links even if an EF is deactivated by activating the
option Maintain output links on disabled EF (EN=0) via the menu Tools
Program Languages Common.
As defined in IEC61131-3, the outputs from deactivated functions (EN-input set
to "0") is undefined. (The same applies to procedures.)
Here is an explanation of the output status in this case:
z EN/ENO handling with functions/procedures that (only) have one link as an
output parameter:

If EN from Function/Procedure_1 is set to "0", the output connection OUT


from Function/Procedure_1 is also set to "0".
z EN/ENO handling with function blocks that have one variable and one link as
output parameters:

If EN from Function/Procedure_1 is set to "0", the output connection OUT


from Function/Procedure_1 is also set to "0". The variable OUT1 on the
same pin, either retains its previous status or can be changed externally
without influencing the connection. The variable and the link are saved
independently of each other.

20 33002539 07/2012
Block Types and their Applications

The output behavior of the FFBs does not depend on whether the FFBs are called
up without EN/ENO or with EN=1.

Conditional/Unconditional FFB Call


"Unconditional" or "conditional" calls are possible with each FFB. The condition is
realized by pre-linking the input EN.
z EN connected
conditional calls (the FFB is only processed if EN = 1)
z EN shown, hidden, and marked TRUE, or shown and not occupied
unconditional calls (FFB is processed independent from EN)
NOTE: For disabled function blocks (EN = 0) with an internal time function (e.g.
DELAY), time seems to keep running, since it is calculated with the help of a system
clock and is therefore independent of the program cycle and the release of the block.

CAUTION
UNEXPECTED APPLICATION EQUIPMENT
Do not disable function blocks with internal time function during their operation.
Failure to follow these instructions can result in injury or equipment damage.

Note for IL and ST


The use of EN and ENO is only possible in the text languages for a formal FFB call,
e.g.
MY_BLOCK (EN:=enable, IN1:=var1, IN2:=var2,
ENO=>error, OUT1=>result1, OUT2=>result2);
Assigning the variables to ENO must be done with the operator =>.
With an informal call, EN and ENO cannot be used.

33002539 07/2012 21
Block Types and their Applications

22 33002539 07/2012
Unity Pro
Availability of the function block
33002539 07/2012

Availability of the function block


on different hardware platforms
2
Block Availability on the Various Hardware Platforms

Introduction
Not all blocks are available on all hardware platforms. The blocks available on your
hardware platform can be found in the following tables.
NOTE: The functions and function blocks in this library are not defined in IEC 61131-
3.

Events
Availability of the blocks:

Block name Block type M340 Premium Quantum


HALT Procedure + + +
ITCNTRL Procedure + + +
MASKEVT Procedure + + +
UNMASKEVT Procedure + + +

Legend:
+ Yes
- No

33002539 07/2012 23
Availability of the function block

Hot Standby
Availability of the blocks:

Block name Block type M340 Premium Quantum


HSBY_RD EFB - - 140 CPU 671 60/1
40 CPU 672 61
HSBY_ST EFB - - 140 CPU 671 60/1
40 CPU 672 61
HSBY_WR EFB - - 140 CPU 671 60/1
40 CPU 672 61
REV_XFER EFB - - 140 CPU 671 60/1
40 CPU 672 61

Legend:
+ Yes
- No

SFC Management
Availability of the blocks:

Block name Block type M340 Premium Quantum


CLEARCHART EF + + +
FREEZECHART EF + + +
INITCHART EF + + +
RESETSTEP Procedure + + +
SETSTEP Procedure + + +
SFCCNTRL EFB + + +
SFC_RESTORE EFB - + +

Legend:
+ Yes
- No

24 33002539 07/2012
Availability of the function block

System Clock
Availability of the blocks:

Block name Block type M340 Premium Quantum


FREERUN EF + TSX P 57 5 +
GET_TS_EVT_M EFB + - -
GET_TS_EVT_Q EFB - - +(2)
PTC Procedure + + +
RRTC_DT Procedure + + +
R_NTPC Procedure + + +
RRTC_DT_MS Procedure + + +(1)
SCHEDULE Procedure + + +
WRTC_DT Procedure + + +

Legend:
+ Yes
- No
(1) Not available for Legacy Quantum
(2) M340 Ethernet remote I/O drop addressed from a Quantum
platform

System Specials
Availability of the blocks:

Block name Block type M340 Premium Quantum


IS_PAR_CON EF + + +

Legend:
+ Yes
- No

33002539 07/2012 25
Availability of the function block

Memory Card File Management


Availability of the blocks:

Block name Block type M340 Premium Quantum


CREATE_FILE EF + - -
OPEN_FILE EF + - -
SET_FILE_ATTRIBUTES EF + - -
GET_FILE_INFO EF + - -
GET_FREESIZE EF + - -
SEEK_FILE EF + - -
WR_DATA_TO_FILE EF + - -
RD_FILE_TO_DATA EF + - -
CLOSE_FILE EF + - -
DELETE_FILE EF + - -
WRITE_U_PCMCIA Procedure - + +
READ_U_PCMCIA Procedure - + +

Legend:
+ Yes
- No

26 33002539 07/2012
Unity Pro
Memory Card File Management
33002539 07/2012

File Management

II
Overview
This section describes the elementary functions and elementary function blocks of
the File Management family.

What Is in This Part?


This part contains the following chapters:
Chapter Chapter Name Page
3 Implementing File Management 29
4 Formatting a Memory Card 37
5 CREATE_FILE: Create a Data Storage File 39
6 OPEN_FILE: Open a File 43
7 SET_FILE_ATTRIBUTES: Set File Attributes 47
8 GET_FILE_INFO: Retrieve File Attributes 49
9 GET_FREESIZE: View Available Space on Memory Card 53
10 SEEK_FILE: Position in a File 57
11 WR_DATA_TO_FILE: Write Data to a File 61
12 RD_FILE_TO_DATA: Read Data in a File 65
13 CLOSE_FILE: Close a File 69
14 DELETE_FILE: Delete a File 71
15 Memory Card File Management EFB Error Codes 75
16 Memory Card File Management EF Examples 77
17 WRITE_U_PCMCIA: Writing data to the memory card 89
18 READ_U_PCMCIA: Reading data in the memory card 93
19 WRITE_U_PCMCIA and READ_U_PCMCIA Functions Example 97
20 WRITE_V_PCMCIA: Write Variable to PCMCIA Card 99
21 READ_V_PCMCIA: Read Variable from PCMCIA Card 103
22 PRJ_VERS: Project Version 107

33002539 07/2012 27
Memory Card File Management

28 33002539 07/2012
Unity Pro
Implementing File Management
33002539 07/2012

Implementing File Management

3
Introduction
This chapter describes implementation of file management on memory cards.

What Is in This Chapter?


This chapter contains the following topics:
Topic Page
File Management on Memory Cards 30
Function Block Operating Modes 32
File Descriptor knowledge 34

33002539 07/2012 29
Implementing File Management

File Management on Memory Cards

At a Glance
The tables below set out the methods for using the memory card once it has been
formatted.
NOTE: The operations presented below only concern the Modicon M340 range.

Creating a File
The table below sets out the method for creating a file and adding information to it.

Step Action Related function Comment


1 Create the file CREATE_FILE Returns the identifier (file
(see page 39) descriptor) which will be used
by the other functions.
2 Set the file attributes SET_FILE_ATTRIBUTES Optional
(see page 47)
3 Display available GET_FREESIZE Optional
space (see page 53) This function can be called at
any time.
4 Positioning in the file SEEK_FILE (see page 57)
5 Write data into the file WR_DATA_TO_FILE
(see page 61)
6 Close the file CLOSE_FILE
(see page 69)

Opening a File for Reading/Writing


The table below sets out the methods for opening a file to read it or write data into it.

Step Action Related function Comment


1 Open the file OPEN_FILE Returns the identifier (file
(see page 43) descriptor) which will be used
by the other functions.
2 Retrieve the file GET_FILE_INFO Optional
attributes (see page 49)
3 Position in the file SEEK_FILE Optional
(see page 57)
4 Display available GET_FREESIZE Optional
space (see page 53) This function can be called at
any time.
5 Write data WR_DATA_TO_FILE
(see page 61)

30 33002539 07/2012
Implementing File Management

Step Action Related function Comment


6 Position in the file SEEK_FILE
(see page 57)
7 Read data RD_FILE_TO_DATA
(see page 65)
8 Close the file CLOSE_FILE
(see page 69)

Deleting a File
The table below sets out the method for deleting a file

Step Action Related function


1 Delete the file DELETE_FILE (see page 71)

Function Limitations
The number of files that may be open at the same time is limited to 16.
The number of files that can be created depends on the storage capacity of the
memory card.
The functions can only be used in the MAST task.
The memory card must have DATA-STORAGE rights to be able to use these
functions.

33002539 07/2012 31
Implementing File Management

Function Block Operating Modes

At a Glance
The various operating modes of the function blocks depend on the following
parameters:
z REQ
z DONE
z ERROR
z STATUS

Parameter Description
Execution of all EFBs of this family is asynchronous without exception
towards application execution (the service can be executed over several cycles).
Before starting a new operation, the DONE and ERROR bits of the previous
operation must be tested, and the STATUS word must be consulted if the ERROR
bit is at 1.
All of the file management EFs are configured with the following parameters:

Parameter Type Description


REQ EBOOL Starts a full operation on rising edge.
DONE BOOL Sets to 1 when the operation is finished.
This output is reset to zero when the block is enabled by a rising
edge on the REQ input.
ERROR BOOL Sets to 1 in case of error during execution of the operation.
This output is reset to zero when the block is enabled by a rising
edge on the REQ input.
STATUS WORD Error code. (see page 75)
This word is only representative when an error has occurred
(ERROR = 1).

The file system EFs can only be used in the MAST task. They are all executed
asynchronously to the task without exception. If the EFs are called by another
task, the following error code is immediately returned:
SDCARD_WRONG_USER_TASK.

32 33002539 07/2012
Implementing File Management

Illustration
The figure below illustrates how the block parameters operate:

33002539 07/2012 33
Implementing File Management

File Descriptor knowledge

At a glance
A file descriptor is an abstract value, that contains all the necessary information for
the handle of a file:
z A pointer to the file,
z the access rights to this file,
z the access conditions to the file (read, write or read/write),
z the current position in the file, etc.

Operation
It is possible to use one or more descriptors simultaneously or sequentially on one
file in order to create multiple accesses (read, write or read/write) at the same
position or at different positions (beginning, end, middle etc...).
A file descriptor is:
z Allocated (via OPEN_FILE, CREATE_FILE),
z used (via RD_FILE_TO_DATA, WR_DATA_TO_FILE, SEEK_FILE,
GET_FILE_INFO),
z realesed (via CLOSE_FILE).

It is used to identify a transaction to a file and it is possible to have many transactions


on the same file.

EFB instance
The EFB instance is considered as a tool that realize an action on a file in a given
context. The instance is represented by the file descriptor.
With the same EFB instance, it is possible to work on many transactions sequentially
through one or many file descriptors.
Via these file descriptors, it is posssible to work on the same file or on different files.
NOTE: The file descriptor will be lost and then you wont be able to close the file. In
this case you could reach the maximum number of files opened, as you cant close
the files already open, and for each new opening you will get an error.

34 33002539 07/2012
Implementing File Management

CAUTION
UNEXPECTED APPLICATION BEHAVIOR
Do not open a file with the same variable as file descriptor when the file is not
closed.
Failure to follow these instructions can result in injury or equipment damage.

NOTE: In case of FILE_DELETED error code (error code 17) you must close the
corresponding file to release the associated file descriptor

33002539 07/2012 35
Implementing File Management

36 33002539 07/2012
Unity Pro
Formatting a Memory Card
33002539 07/2012

Formatting a Memory Card

4
Formatting the Memory Card

Formatting
Formatting the memory card is possible by using the %SW93 word via the Unity Pro
animation table but normally has not to be used. Formatting the card on a PC using
Windows commands may render the card unusable.
When the memory card is formatted, the default directory \DataStorage\ is created.
Before formatting with Unity Pro, the user must download an application by default.
Otherwise, the %SW93 system word does not exist.
NOTE: Formatting is only possible when the PLC is in STOP mode.

%SW93 Operating Mode


The formatting command and status of the memory card are provided by the %SW93
system word.
SW93.0: a rising edge starts the formatting.
SW93.1: gives the status of the system file partition:
z 0: invalid system file partition (incorrect format, formatting in progress, etc.),
z 1: Valid system file partition.
The figure below displays the statuses of the %SW93.0 and %SW93.1 bits.

33002539 07/2012 37
Formatting a Memory Card

Save
It is recommended that users save the file partition (data stored, manufacturer or
user Web pages) with the FTP client, which can be launched from Unity Pro.
Users can save Web pages with FactoryCast or WAD (Web Application Designer).
They can therefore restore pages in case of problems.
Unity Loader also allows files to be saved on the memory card.

38 33002539 07/2012
Unity Pro
CREATE_FILE
33002539 07/2012

CREATE_FILE: Create a Data


Storage File
5
CREATE_FILE: Create a Data Storage File

Function Description
The CREATE_FILE function enables creation of a file called FILENAME, if it doesnt
exist, and allows it to be opened with the specified ModeFlag flag:
z O_RDONLY: opening in read-only mode (value 0),
z O_WRONLY: opening in write-only mode (value 1),
z O_RDWR: opening in read and write mode (value 2),
This flag is reset to 0 once the file is closed.
The file is created in the \DataStorage\. sub-directory
If you use the simulator mode the file is created in the temporary user folder.
To access the file by FTP refer to this page (see Unity Pro, Operating Modes).
NOTE: Each time a file is opened, a random value is returned by the FileDescriptor
parameter.
This will be used when you close the file. If you open a new file without closing the
previous one, a new FileDescriptor parameter value is returned, and you will not be
able to close the previous file.Therefore you should save the FileDescriptor
parameter after opening a file.
When the maximum number of opened files is reached, an error is returned if you
try to open any further files.
NOTE: If the file already exists, the behavior of CREATE_FILE is similar to that of
OPEN_FILE.
The additional parameters EN and ENO can be configured.

33002539 07/2012 39
CREATE_FILE

FBD Representation
The representation in FBD of the CREATE_FILE function is as follows:

Ladder Representation
The representation in Ladder of the CREATE_FILE function is as follows:

IL Representation
The representation in IL of the CREATE_FILE function is as follows:
LD REQ
ST CREATE_FILE.REQ
LD SL0
ST CREATE_FILE.Slot
LD FN
ST CREATE_FILE.FileName
LD MF
ST CREATE_FILE.ModeFlag
CAL CREATE_FILE
LD CREATE_FILE.Error
ST ERR
LD CREATE_FILE.Done

40 33002539 07/2012
CREATE_FILE

ST DO
LD CREATE_FILE.Status
ST STS
LD CREATE_FILE.FileDesc
ST FD

ST Representation
The representation in ST of the CREATE_FILE function is as follows:
CREATE_FILE(REQ,SL0,FN,MF,DO,ERR,STS,FD);

Parameter Description
The following table describes the input parameters:

Parameter Type Comment


SL0 Slot DINT This parameter specifies the slot address of the
memory card (always has address 0).
FN FileName STRING This parameter specifies the name of the file to create.
Maximum number of characters : 64
Characters like ? or * are not allowed.
MF ModeFlag INT This parameter specifies the opening mode.
z O_RDONLY (0): opened in read-only mode,
z O_WRONLY (1): opened in write-only mode,
z O_RDWR (2): opened in read and write mode.

The following table describes the output parameters:

Parameter Type Comment


FD DINT This parameter allows the DATA_STORAGE function
FileDescriptor to access the file.

Description of common parameters (see page 32).

33002539 07/2012 41
CREATE_FILE

42 33002539 07/2012
Unity Pro
OPEN_FILE
33002539 07/2012

OPEN_FILE: Open a File

6
OPEN_FILE: Open a File

Function Description
The OPEN_FILE function enables a file named FileName to be opened (in the
\DataStorage\ directory). The file must already exist. The argument mode has one
of the following values: O_RDONLY, O_WRONLY, O_RDRW.
The file is opened in binary mode. This means that there is no translation of specific
characters like CTRL-Z (EOF marker) or carriage return/line break.
A maximum number of 16 files can be opened simultaneously.
If you use the simulator mode the file is opened in the temporary user folder.
To access the file by FTP refer to this page (see Unity Pro, Operating Modes).
NOTE: Each time a file is opened, a random value is returned by the FileDescriptor
parameter.
This will be used when you close the file. If you open a new file without closing the
previous one, a new FileDescriptor parameter value is returned, and you will not be
able to close the previous file.Therefore you should save the FileDescriptor
parameter after opening a file.
When the maximum number of opened files is reached, an error is returned if you
try to open any further files.
NOTE: It is still possible to modify the status of a file in the file system although the
file is already open.The status of a file (Read Only, Read/Write) is not evaluated
when the file is opened, but only when data are written into. (For example it is
possible to open a Read Only file in R/W mode without any error). Thus, as long as
the file is in read only mode in the file system, any writing request will lead to an error
(error 14) although the file has been opened successful in R/W mode. As soon as
the file is in R/W mode again, the writing requests will work again without the
obligation to close and reopen the file.
The additional parameters EN and ENO can be configured.

33002539 07/2012 43
OPEN_FILE

FBD Representation
The representation in FBD of the OPEN_FILE function is as follows:

Ladder Representation
The representation in Ladder of the OPEN_FILE function is as follows:

IL Representation
The representation in IL of the OPEN_FILE function is as follows:
LD REQ
ST OPEN_FILE.REQ
LD SL0
ST OPEN_FILE.Slot
LD FN
ST OPEN_FILE.FileName
LD MF
ST OPEN_FILE.ModeFlag
CAL OPEN_FILE
LD OPEN_FILE.Error
ST ERR
LD OPEN_FILE.Done

44 33002539 07/2012
OPEN_FILE

ST DO
LD OPEN_FILE.Status
ST STS
LD OPEN_FILE.FileDesc
ST FD

ST Representation
The representation in ST of the OPEN_FILE function is as follows:
OPEN_FILE(REQ,SL0,FN,MF,DO,ERR,STS,FD);

Parameter Description
The following table describes the input parameters:

Parameter Type Comment


FN FileName STRING This parameter specifies the name of the file to open.
MF ModeFlag INT This parameter specifies the opening mode.
z O_RDONLY (0): opened in read-only mode,
z O_WRONLY (1): opened in write-only mode,
z O_RDWR (2): opened in read and write mode.

The following table describes the output parameters:

Parameter Type Comment


FD DINT This parameter allows the DATA_STORAGE function
FileDescriptor to access the file.

Description of common parameters (see page 32).

33002539 07/2012 45
OPEN_FILE

46 33002539 07/2012
Unity Pro
SET_FILE_ATTRIBUTES
33002539 07/2012

SET_FILE_ATTRIBUTES: Set File


Attributes
7
SET_FILE_ATTRIBUTES: Sets the File Attributes

Function Description
The SET_FILE_ATTRIBUTES function enables the file attributes to be set.
The additional parameters EN and ENO can be configured.

FBD Representation
The representation in FBD of the SET_FILE_ATTRIBUTES function is as follows:

Ladder Representation
The representation in Ladder of the SET_FILE_ATTRIBUTES function is as follows:

33002539 07/2012 47
SET_FILE_ATTRIBUTES

IL Representation
The representation in IL of the SET_FILE_ATTRIBUTES function is as follows:
LD REQ
ST SET_FILE_ATTRIBUTES.REQ
LD FD
ST SET_FILE_ATTRIBUTES.FileDesc
LD ATT
ST SET_FILE_ATTRIBUTES.Attributes
CAL SET_FILE_ATTRIBUTES
LD SET_FILE_ATTRIBUTES.Error
ST ERR
LD SET_FILE_ATTRIBUTES.Done
ST DO
LD SET_FILE_ATTRIBUTES.Status
ST STS

ST Representation
The representation in ST of the SET_FILE_ATTRIBUTES function is as follows:
SET_FILE_ATTRIBUTES(REQ,FD,ATT,DO,ERR,STS);

Parameter Description
The following table describes the input parameters:

Parameter Type Comment


FD DINT This parameter specifies the file descriptor returned
FileDescriptor by the CREATE_FILE or OPEN_FILE functions.
ATT Attributes WORD This parameter specifies the attributes to set. Only
two attributes are accepted by the system:
z SET_RDONLY (1): the file is write protected,
z CLR_RDONLY (0): Clears the read-only
attribute.

Description of common parameters (see page 32).

48 33002539 07/2012
Unity Pro
GET_FILE_INFO
33002539 07/2012

GET_FILE_INFO: Retrieve File


Attributes
8
GET_FILE_INFO: Retrieves the File Attributes

Function Description
The GET_FILE_INFO function enables information on the file to be obtained.
The OPEN_FILE (see page 43) function must be enabled before the
GET_FILE_INFO block because the value of FileDescriptor (see page 45) comes
from the output parameter of the OPEN_FILE or CREATE_FILE block.
The additional parameters EN and ENO can be configured.

FBD Representation
The representation in FBD of the GET_FILE_INFO function is as follows:

33002539 07/2012 49
GET_FILE_INFO

Ladder Representation
The representation in Ladder of the GET_FILE_INFO function is as follows:

IL Representation
The representation in IL of the GET_FILE_INFO function is as follows:
LD REQ
ST GET_FILE_INFO.REQ
LD FD
ST GET_FILE_INFO.FileDesc
CAL GET_FILE_INFO
LD GET_FILE_INFO.Done
ST DO
LD GET_FILE_INFO.Error
ST ERR
LD GET_FILE_INFO.Status
ST STS
LD GET_FILE_INFO.Attributes
ST ATT
LD GET_FILE_INFO.Length
ST LT
LD GET_FILE_INFO.AccessTime
ST AT
LD GET_FILE_INFO.ModTime
ST MT
LD GET_FILE_INFO.ChangeStatTime
ST CST

50 33002539 07/2012
GET_FILE_INFO

ST Representation
The representation in ST of the GET_FILE_INFO function is as follows:
GET_FILE_INFO(REQ,FD,DO,ERR,STS,ATT,LT,AT,MT,CST);

Parameter Description
The following table describes the input parameter:

Parameter Type Comment


FileDescriptor DINT This parameter specifies the file descriptor returned by
the OPEN_FILE functions.

The following table describes the output parameters:

Parameter Type Comment


ATT Attributes WORD This bit field specifies the file attributes:
z Bit 0: read-only file
z Bit 1: hidden file
z Bit 2: system file
z Bit 3: volume label (not a file)
z Bit 4: sub-directory
z Bit 5: subject to archival
LT Length UDINT This parameter specifies the size of the file in
bytes.
AT AccesTime DATEANDTIME This parameter specifies the date and time
when the file was last accessed.
MT ModTime DATEANDTIME This parameter specifies the date and time
when the file was last modified.
CST DATEANDTIME This parameter specifies the date and time
ChangeStatTime when the last file status change took place.

Description of common parameters (see page 32).

33002539 07/2012 51
GET_FILE_INFO

52 33002539 07/2012
Unity Pro
GET_FREESIZE
33002539 07/2012

GET_FREESIZE: View Available


Space on Memory Card
9
GET_FREESIZE: View Available Space of the File Partition on the Memory Card

Function Description
The GET_FREESIZE function displays the amount of available space on the
memory card.
This available space is linked to the system file partition, which contains both
storage data and Web pages.
The additional parameters EN and ENO can be configured.

FBD Representation
The representation in FBD of the GET_FREESIZE function is as follows:

33002539 07/2012 53
GET_FREESIZE

Ladder Representation
The representation in Ladder of the GET_FREESIZE function is as follows:

IL Representation
The representation in IL of the GET_FREESIZE function is as follows:
LD REQ
ST GET_FREESIZE.Req
LD SL0
ST GET_FREESIZE.Slot
CAL GET_FREESIZE
LD GET_FREESIZE.Error
ST ERR
LD GET_FREESIZE.Done
ST DO
LD GET_FREESIZE.Status
ST STS
LD GET_FREESIZE.Size
ST SZ

ST Representation
The representation in ST of the GET_FREESIZE function is as follows:
GET_FREESIZE(REQ,SL0,DO,ERR,STS,SZ);

54 33002539 07/2012
GET_FREESIZE

Parameter Description
The following table describes the input parameter:

Parameter Type Comment


SL0 Slot BYTE This parameter specifies the slot address of the
memory card (always has address 0).

The following table describes the output parameter:

Parameter Type Comment


SZ Size UDINT This parameter specifies the size in bytes of the
available space on the memory card.

Description of common parameters (see page 32).

33002539 07/2012 55
GET_FREESIZE

56 33002539 07/2012
Unity Pro
SEEK_FILE
33002539 07/2012

SEEK_FILE: Position in a File

10
SEEK_FILE: Position in the File

Function Description
The SEEK_FILE function sets the current position in the file at the position specified
by the Offset argument.
The Whence argument assigns the file position pointer. It has three values:
z SEEK_SET (value 0): this places the pointer at the position corresponding to the
offset (default value : to overwrite the file),
z SEEK_CUR (value 1): places the pointer at the current position + offset,
z SEEK_END (value 2): places the pointer at the position corresponding to the file
size + offset. Useful if you want to overwrite last variables of the file (negative
offset) or to write in the file from the end in order to not overwrite data.

33002539 07/2012 57
SEEK_FILE

The following figure illustrates the positioning of the pointer according to the offset:
(differents values of offset in this diagram).

The additional parameters EN and ENO can be configured.

FBD Representation
The representation in FBD of the SEEK_FILE function is as follows:

58 33002539 07/2012
SEEK_FILE

Ladder Representation
The representation in Ladder of the SEEK_FILE function is as follows:

IL Representation
The representation in IL of the SEEK_FILE function is as follows:
LD REQ
ST SEEK_FILE.REQ
LD FD
ST SEEK_FILE.FileDesc
LD OFF
ST SEEK_FILE.Offset
LD WH
ST SEEK_FILE.Whence
CAL SEEK_FILE
LD SEEK_FILE.Done
ST DO
LD SEEK_FILE.Error
ST ERR
LD SEEK_FILE.Status
ST STS

ST Representation
The representation in ST of the SEEK_FILE function is as follows:
SEEK_FILE(REQ,FD,OFF,WH,DO,ERR,STS);

33002539 07/2012 59
SEEK_FILE

Parameter Description
The following table describes the input parameters:

Parameter Type Comment


FD FileDescriptor DINT This parameter specifies the file descriptor returned by the
CREATE_FILE or OPEN_FILE functions.
OFF Offset DINT This parameter specifies the offset of the movement.
WH Whence INT Seek Mode:
z SEEK_SET (0) - set to Offset,
z SEEK_CUR (1) - set to the current position plus Offset,
z SEEK_END (2) - set to the file size plus Offset.

Description of common parameters (see page 32).

60 33002539 07/2012
Unity Pro
WR_DATA_TO_FILE
33002539 07/2012

WR_DATA_TO_FILE: Write Data


to a File
11
WR_DATA_TO_FILE: Writes Data to a File

Function Description
The WR_DATA_TO_FILE function enables a direct address variable (%MW1000), a
located variable (VAR0 @ %MW1000), or an unlocated variable to be written to a file.
The value written is added after the current position in the file. After writing, the
current position of the file is updated.
NOTE: When you use the WR_DATA_TO_FILE function with string data type, It
creates in the file an array of bytes whose size is the maximum size declared (for
instance if you declare a STRING[100] it writes 100 bytes in the file).If you read it
with an EFB of Unity Pro the function read the 100 bytes but it sees only the first
characters before the first NULL character. if you use a third party software or tool
and if youve got many null characters in the 100 bytes, it could see many string
instead of one.
NOTE: It is still possible to modify the status of a file in the file system although the
file is already open. The status of a file (Read Only, Read/Write) is not evaluated
when the file is opened, but only when data.
The additional parameters EN and ENO can be configured.

FBD Representation
The representation in FBD of the WR_DATA_TO_FILE function is as follows:

33002539 07/2012 61
WR_DATA_TO_FILE

Ladder Representation
The representation in Ladder of the WR_DATA_TO_FILE function is as follows:

IL Representation
The representation in IL of the WR_DATA_TO_FILE function is as follows:
LD REQ
ST WR_DATA_TO_FILE.REQ
LD FD
ST WR_DATA_TO_FILE.FileDesc
LD VAR0
ST WR_DATA_TO_FILE.Variable
CAL WR_DATA_TO_FILE
LD WR_DATA_TO_FILE.Done
ST DO
LD WR_DATA_TO_FILE.Error
ST ERR
LD WR_DATA_TO_FILE.Status
ST STS

ST Representation
The representation in ST of the WR_DATA_TO_FILE function is as follows:
WR_DATA_TO_FILE(REQ,FD,VAR0,DO,ERR,STS);

62 33002539 07/2012
WR_DATA_TO_FILE

Parameter Description
The following table describes the input parameters:

Parameter Type Comment


FD FileDescriptor DINT This parameter specifies the file descriptor returned by the
CREATE_FILE or OPEN_FILE functions.
VAR0 Variable ANY This parameter specifies the variable to write to the file.
Any direct address variable (%MW1000), located variable (VAR0 @
%MW1000), or unlocated variable (single type, table, structure) can be
written.
To write a table of %MW or direct variables, the syntax used is
%MW1000:10 (10 words from %MW1000).

Description of common parameters (see page 32).

33002539 07/2012 63
WR_DATA_TO_FILE

64 33002539 07/2012
Unity Pro
RD_FILE_TO_DATA
33002539 07/2012

RD_FILE_TO_DATA: Read Data in


a File
12
RD_FILE_TO_DATA: Read Data from a File

Function Description
The RD_FILE_TO_DATA function allows data to be read from a file, at the current
position of the file, and enables it to be copied into a direct address variable
(%MW1000), a located variable (VAR0 @ %MW1000), or an unlocated variable. After
reading, the current position in the file is updated.
This elementary function reads a number of bytes that correspond to the size of the
variable in the specified file.
The additional parameters EN and ENO can be configured.

FBD Representation
The representation in FBD of the RD_FILE_TO_DATA function is as follows:

33002539 07/2012 65
RD_FILE_TO_DATA

Ladder Representation
The representation in Ladder of the RD_FILE_TO_DATA function is as follows:

IL Representation
The representation in IL of the RD_FILE_TO_DATA function is as follows:
LD REQ
ST RD_FILE_TO_DATA.REQ
LD FD
ST RD_FILE_TO_DATA.FileDesc
CAL RD_FILE_TO_DATA
LD RD_FILE_TO_DATA.Done
ST DO
LD RD_FILE_TO_DATA.Error
ST ERR
LD RD_FILE_TO_DATA.Status
ST STS
LD RD_FILE_TO_DATA.Variable
ST VAR0
LD RD_FILE_TO_DATA.NbBytesRd
ST NBBYTESRD

ST Representation
The representation in ST of the RD_FILE_TO_DATA function is as follows:
RD_FILE_TO_DATA(REQ,FD,DO,ERR,STS,VAR0,NBBYTESRD);

66 33002539 07/2012
RD_FILE_TO_DATA

Parameter Description
The following table describes the input parameters:

Parameter Type Comment


FD FileDescriptor DINT This parameter specifies the file descriptor
returned by the CREATE_FILE or OPEN_FILE
functions.

The following table describes the output parameters:

Parameter Type Comment


VAR0 Variable ANY This parameter specifies the variable or table which will
receive the data.
Any direct address variable (%MW1000), located
variable (VAR0 @ %MW1000), or unlocated variable
(single type, table, structure) can be used as a
destination.
To copy to a table or direct variables, the syntax used is
%MW1000:10 (10 words starting at %MW1000).
NBBYTESRD UDINT This parameter specifies the size effectively read. It
NbBytesRd may be smaller than the size of the variable.The main
reason why the NBBYTESRD can be smaller than the
Variable size is that:
File size- read start position < Variable
size
Then the read variable is only updated with the number
of bytes read and the other bytes of data come from the
last reading.

Description of common parameters (see page 32).

33002539 07/2012 67
RD_FILE_TO_DATA

68 33002539 07/2012
Unity Pro
CLOSE_FILE
33002539 07/2012

CLOSE_FILE: Close a File

13
CLOSE_FILE: Close the File

Function Description
The CLOSE_FILE function enables the specified file to be closed and the file
descriptor to be freed.
NOTE: If the user want to disable access to the card in order to extract it for
example, he will set to 1 the bit %S65. In this case all current accesses are finished,
consequently all open files will be automatically closed. (To enable again the access
to the card %S65 must be reset to 0.)
NOTE: Each time a file is opened, a random value is returned by the FileDescriptor
parameter.
This will be used when you close the file. If you open a new file without closing the
previous one, a new FileDescriptor parameter value is returned, and you will not be
able to close the previous file.Therefore you should save the FileDescriptor
parameter after opening a file.
When the maximum number of opened files is reached, an error is returned if you
try to open any further files.
The additional parameters EN and ENO can be configured.

FBD Representation
The representation in FBD of the CLOSE_FILE function is as follows:

33002539 07/2012 69
CLOSE_FILE

Ladder Representation
The representation in Ladder of the CLOSE_FILE function is as follows:

IL Representation
The representation in IL of the CLOSE_FILE function is as follows:
LD REQ
ST CLOSE_FILE.REQ
LD FD
ST CLOSE_FILE.FileDesc
CAL CLOSE_FILE
LD CLOSE_FILE.Error
ST ERR
LD CLOSE_FILE.Done
ST DO
LD CLOSE_FILE.Status
ST STS

ST Representation
The representation in ST of the CLOSE_FILE function is as follows:
CLOSE_FILE(REQ,FD,DO,ERR,STS);

Parameter Description
The following table describes the input parameter:

Parameter Type Comment


FD DINT This parameter specifies the file descriptor returned
FileDescriptor by CREATE_FILE or OPEN_FILE.

Description of common parameters (see page 32).

70 33002539 07/2012
Unity Pro
DELETE_FILE
33002539 07/2012

DELETE_FILE: Delete a File

14
DELETE_FILE: Delete a File

Function Description
The DELETE_FILE function enables deletion of the file named FileName.
NOTE:
When using the DELETE_FILE function, always close an opened file before deleting
it using the CLOSE_FILE function. Otherwise:
z The opened file counter is not updated, opened files limitations (see page 31).
z The FileDescriptor (FD) output parameter is not released.

WARNING
HAZARD OF OVERFLOW OF FILE DESCRIPTORS
Always close an opened file before deleting it with the DELETE_FILE function.
Deleting an open file can be done without user information message and can lead
to the increment of the number of file descriptors up to an overflow.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

The additional parameters EN and ENO can be configured.

FBD Representation
The representation in FBD of the DELETE_FILE function is as follows:

33002539 07/2012 71
DELETE_FILE

Ladder Representation
The representation in Ladder of the DELETE_FILE function is as follows:

IL Representation
The representation in IL of the DELETE_FILE function is as follows:
LD REQ
ST DELETE_FILE.REQ
LD FN
ST DELETE_FILE.FileName
LD SL0
ST DELETE_FILE.Slot
CAL DELETE_FILE
LD DELETE_FILE.Done
ST DO
LD DELETE_FILE.Error
ST ERR
LD DELETE_FILE.Status
ST STS

ST Representation
The representation in ST of the DELETE_FILE function is as follows:
DELETE_FILE(REQ,SL0,FN,DO,ERR,STS);

72 33002539 07/2012
DELETE_FILE

Parameter Description
The following table describes the input parameters:

Parameter Type Comment


SL0 Slot BYTE This parameter specifies the memory card slot (always at zero).
FN FileName STRING This parameter specifies the name of the file to delete.
Maximum number of characters : 64

Description of common parameters (see page 32).

33002539 07/2012 73
DELETE_FILE

74 33002539 07/2012
Unity Pro
File Management EFB Error Codes
33002539 07/2012

Memory Card File Management


EFB Error Codes
15
Error Codes

At a Glance
An error code is valid until the next time the EF that generated it is initialized.

Table of Error Codes


The following table describes the error codes that can be generated for EFB
functions:

Value Description
1 The memory card is missing in the slot.
2 The memory card doesnt support data storage (wrong part number) Or the file
system structure has been deleted on the memory card (probably the memory
card has been reformatted on a PC).
3 The slot number is incorrect (has to be 0).
4 Attempt to write in a memory card write-protected by the switch.
5 Attempt to open more than 16 files at the same time.
6 Attempt to write when there is no more space available in the memory card for
data storage.
7 Attempt to open a file that doesnt exist on the memory card.
11 The file name size exceed 64 characters.
13 The file name is incorrect or empty.
14 Attempt to write a file opened in read only mode.
17 The file has been deleted (occurs when a file descriptor exist and the file has
been deleted by DELETE_FILE EFB or by FTP command).
21 The file descriptor is incorrect.
23 Attempt to execute a data storage function block in a task different than the
MAST.
-1 Other errors than the previous ones.

33002539 07/2012 75
File Management EFB Error Codes

76 33002539 07/2012
Unity Pro
File Management EF Examples
33002539 07/2012

Memory Card File Management EF


Examples
16
Overview
This chapter gives usage examples for memory card file management EFBs.

What Is in This Chapter?


This chapter contains the following topics:
Topic Page
Definition of the Example and Declaration of Variables 78
Offline Example 79
Online Example: Procedure 80
Example written in ST 83

33002539 07/2012 77
File Management EF Examples

Definition of the Example and Declaration of Variables

Definition
The EFB WR_DATA_TO_FILE and RD_FILE_TO_DATA allow variables to be written
into a file and data in a file to be read. These elementary functions make up part of
the basis of file management and can therefore be used to build whatever type of
application that requires these functions.
The example only uses the following four functions:
z OPEN_FILE, to open an already created file (see page 39),
z WR_DATA_TO_FILE, to write data,
z RD_FILE_TO_DATA, to read data,
z CLOSE_FILE to close the file.

Declaration of Variables
The table below shows the details of the variables to be declared for the parameters
used:

Name of the Type Comment


variable.
cmd_open EBOOL File opening bit.
cmd_write EBOOL Write data to file bit.
cmd_read EBOOL Read file data bit.
cmd_close EBOOL Close file bit.
FileName STRING File name. By default the value is test:
FileDesc INT FileDesc is the number automatically assigned when a file is
opened. This unique and temporary identification number will
be assigned by the OPEN_FILE function.

NOTE: The temporary identification number FileDesc enables, amongst other


things, several people to open the same file at the same time to work on it. The
number used for FileDesc is freed once the file is closed using the CLOSE_FILE
function. FileDesc is managed automatically by the system.

78 33002539 07/2012
File Management EF Examples

Offline Example

At a Glance
The figure below describes the elementary blocks with the variables declared
beforehand, offline:

33002539 07/2012 79
File Management EF Examples

Online Example: Procedure

Procedure
In this example, the data is to be written into a file, which is then to be closed, after
which it is re-opened to read the data from the same file. The table below describes
the procedure to follow for this example:

Step Action
1 Execute the OPEN_FILE function by enabling the cmd_open bit, by right-
clicking on the Req input parameter.
Result: A unique and temporary identification number is assigned to the
opening instance as a FileDesc output. (In this case, we have assigned value
5 to this output. Use this value to declare the FileDesc input variable for the
WR_DATA_TO_FILE and CLOSE_FILE functions.)
The graphic below is a representation of the function after execution:

Disable cmd_open by right-clicking on the Req input parameter.


2 In the WR_DATA_TO_FILE block, force the %MW10 variable to the value 100 by
right-clicking on the variable input parameter.
3 Execute the WR_DATA_TO_FILE function by enabling the cmd_write bit by
right-clicking on the Req input parameter.
Result: the value of the variable is written into the test file.
The graphic below is a representation of the function after execution:

Disable cmd_write by right-clicking on the Req input parameter.

80 33002539 07/2012
File Management EF Examples

Step Action
4 Execute the CLOSE_FILE function by enabling the cmd_close bit by right-
clicking on the Req input parameter.
Result: The file is closed and the FileDesc identification number is freed for
use at a later date.
The graphic below is a representation of the function after execution:

Disable cmd_close by right-clicking on the Req input parameter.


5 Execute the OPEN_FILE function again by enabling the cmd_open bit by right-
clicking on the Req input parameter.
Result: It is a new opening instance, so a new FileDesc number is assigned,
in this case 6. Use these values to declare the FileDesc input variable for the
RD_FILE_TO_DATA and CLOSE_FILE functions.
The graphic below is a representation of the function after execution:

Disable cmd_open by right-clicking on the Req input parameter.


6 In the RD_FILE_TO_DATA block, force the %MW10 variable to the value 120 by
right-clicking on the variable input parameter. By doing this, it is possible to
check that the value retrieved by the RD_FILE_TO_DATA function is correct.
The graphic below is a representation of the function before execution:

33002539 07/2012 81
File Management EF Examples

Step Action
7 Execute the RD_FILE_TO_DATA function by enabling the cmd_read bit, by
right-clicking on the Req input parameter.
Result: The function reads the file data, i.e., the value of the variable written
beforehand with the WR_DATA_TO_FILE function. This value can be found in
the Variable output parameter.
The graphic below is a representation of the function after execution:

Disable cmd_read by right-clicking on the Req input parameter.


8 Execute the CLOSE_FILE function by enabling the cmd_close bit by right-
clicking on the Req input parameter.
Result: The file is closed and the FileDesc identification number is freed for
use at a later date.
The graphic below is a representation of the function after execution:

Disable cmd_close by right-clicking on the Req input parameter.

82 33002539 07/2012
File Management EF Examples

Example written in ST

At a glance
In this example we use the following EFBs in order to perform some actions on a file:
z CREATE_FILE,
z OPEN_FILE,
z SEEK_FILE
z WR_DATA_TO_FILE
z RD_FILE_TO_DATA
z CLOSE_FILE

Declaration of variables
The table below shows the details of the variables to be declared for the parameters
used:

Variable name Type Comment


close_req EBOOL Enable CLOSE_FILE function bit
create_req EBOOL Enable CREATE_FILE function bit
fileDesc DINT FileDesc is the number automatically assigned
when a file is opened. This unique and
temporary identification number will be assigned
by the OPEN_FILE function.
NbBytesRd UDINT Specify the size effectively read of the variable.
read_req EBOOL Enable RD_FILE_TO_DATA function bit
variable INT variable read in the file
seek_req EBOOL Enable SEEK_FILE function bit
write_req EBOOL Enable WR_DATA_TO_FILE function bit
variable_tab ARRAY[0..9] OF INT Array for the different values of the variables
written in the file
cmd_write EBOOL write file bit
GO_STORE EBOOL Bit used to start the creation of the file
cmd_seek EBOOL seek file bit
Error_WR BOOL Error during execution of WR_DATA_TO_FILE
function bit
cmd_close EBOOL close file bit
GO_RESTORE EBOOL Bit used to start the re-opening of the file
open_req EBOOL Enable OPEN_FILE function bit
cmd_read EBOOL read file to data bit
Done_WR BOOL Writing in the file operation completed bit

33002539 07/2012 83
File Management EF Examples

Variable name Type Comment


Done_OPEN BOOL Opening the file operation completed bit
Status_WR WORD Error code (useful when Error_WR:=1)
Done_SEEK BOOL Seeking the file operation completed bit
Error_SEEK BOOL Error during execution of SEEK_FILE function
bit
Status_SEEK WORD Error code (useful when Error_SEEK:=1)
Done_CREATE BOOL Creating the file operation completed bit
Error_CREATE BOOL Error during execution of CREATE_FILE
function bit
Status_CREATE WORD Error code (useful when Error_CREATE:=1)
Done_CLOSE BOOL Closing the file operation completed bit
Error_CLOSE BOOL Error bit for CLOSE_FILE function
Status_CLOSE WORD Error code (useful when Error_CLOSE:=1)
Error_OPEN BOOL Error during execution of OPEN_FILE function
bit
Status_OPEN WORD Error code (useful when Error_OPEN:=1)
Done_RD BOOL Reading the file operation completed bit
Error_RD BOOL Error during execution of RD_FILE_TO_DATA
function bit
Status_RD WORD Error code (useful when Error_RD:=1)

Code
This code perform the following actions :
z Create the file or seek it if it is already created,
z Write data in the file,
z Close the file,
z Open the closed file,
z Read the data written in the file,
z Close the file.
(*********************************************************
Create a file TEST.bin if doesnt exist and open it in
append mode(SEEK).
Write a data and close the file
*********************************************************)
(******* Begin CREATE part *******)
if RE(GO_STORE) then (* Set GO_STORE to start *)

84 33002539 07/2012
File Management EF Examples

create_req := 1;
end_if;
CREATE (REQ := create_req,(* Rising edge on REQ input to start
the CREATE *)
SLOT := 0,
FILENAME := TEST.bin,
MODEFLAG := 2,(* Read/Write mode *)
DONE => Done_CREATE,
ERROR => Error_CREATE,
STATUS => Status_CREATE,
FILEDESC => fileDesc);
create_req := 0;
if GO_STORE then
if (Done_CREATE and not Error_CREATE) then
GO_STORE := 0 ;
seek_req := 1;
cmd_seek := 1;
end_if;
end_if;
(******* End CREATE part *******)
(******* Begin SEEK part *******)
SEEK (REQ := seek_req;(* Rising edge on REQ input to
start the SEEK *)
FILEDESC := fileDesc
OFFSET := 0,
WHENCE := 2;
(* SEEK_END *)
DONE => Done_SEEK,
ERROR => Error_SEEK,
STATUS => Status_SEEK);
seek_req := 0;
if cmd_seek then
if (Done_SEEK and not Error_SEEK) then
cmd_seek := 0;

33002539 07/2012 85
File Management EF Examples

write_req := 1;
cmd_write := 1;
end_if;
end_if;
(******* End SEEK part *******)
(******* Begin WRITE part *******)
variable_tab[0] := variable_tab[0] + 1;
WRITE (REQ := write_req,(* Rising edge on REQ input to
start the WRITE *)
FILEDESC := fileDesc,
VARIABLE := variable_tab,
DONE => Done_WR,
ERROR => Error_WR,
STATUS => Status_WR);
write_req := 0;
if cmd_write then
if (Done_WR and not Error_WR) then
cmd_write := 0;
close_req := 1;
cmd_close := 1;
end_if;
end_if;
(******* End WRITE part *******)
(******* Begin CLOSE part *******)
CLOSE (REQ := close_req,(* Rising edge on REQ input to
start the CLOSE *)
FILEDESC := fileDesc,
DONE => Done_CLOSE,
ERROR => Error_CLOSE,
STATUS => Status_CLOSE);
close_req := 0;
if cmd_close then
if (Done_CLOSE and not Error_CLOSE) then
cmd_close := 0;

86 33002539 07/2012
File Management EF Examples

end_if;
end_if;
(******* End CLOSE part *******)
(*********************************************************
Open the file TEST.bin,
read the first data and close the file
**********************************************************
(******* Begin OPEN part *******)
if RE(GO_RESTORE) then(* Set GO_RESTORE to start *)
open_req := 1;
end_if;
OPEN (REQ := open_req,(* Rising edge on REQ input to start the
OPEN *)
SLOT := 0,
FILENAME := TEST.bin,
MODEFLAG := 0,
DONE => Done_OPEN,
ERROR => Error_OPEN,
STATUS => Status_OPEN,
FILEDESC => fileDesc);
open_req := 0;
if GO_RESTORE then
if (Done_OPEN and not Error_OPEN) then
GO_RESTORE := 0 ;
read_req := 1;
cmd_read := 1;
end_if;
end_if;
(******* End OPEN part *******)
(******* Begin READ part *******)
READ (REQ := read_req,(* Rising edge on REQ input to
start the READ *)
FILEDESC := fileDesc,
DONE => Done_RD,

33002539 07/2012 87
File Management EF Examples

ERROR => Error_RD,


STATUS => Status_RD,
VARIABLE => variable,
NBBYTESRD => NbBytesRd);
read_req := 0;
if cmd_read then
if (Done_RD and not Error_RD) then
cmd_read := 0;
close_req := 1;(* Same CLOSE part than the
CREATE/SEEK/WRITE/CLOSE *)
cmd_close := 1;
end_if;
end_if;
(******* End READ part *******)

88 33002539 07/2012
Unity Pro
WRITE_U_PCMCIA
33002539 07/2012

WRITE_U_PCMCIA: Writing data


to the memory card
17
Description

Function description
The WRITE_U_PCMCIA function transfers data from the PLCs RAM memory to the
user memory card archiving zone. The function WRITE_U_PCMCIA enables to
address the PLC zones beginning to be copied to the PCMCIA card up to 65 535
(instead of 32 767 for WRITE_PCMCIA function) and is therefore recommended to
be used instead of WRITE_PCMCIA function.
The additional parameters EN and ENO can be configured.
An example using the function WRITE_U_PCMCIA is available, WRITE_U_PCMCIA
and READ_U_PCMCIA Example (see page 97).

Representation in FBD
Representation:

33002539 07/2012 89
WRITE_U_PCMCIA

Representation in LD
Representation:

Representation in IL
Representation:
LD Slot_Number
WRITE_U_PCMCIA Dest_Address, Words_Number, Source_Address,
Write_State

Representation in ST
Representation:
WRITE_U_PCMCIA(Slot_Number, Dest_Address, Words_Number,
Source_Address, Write_State);

Description of the parameters


The following table describes the input parameters:

Parameter Type Comment


Slot_Number INT PCMCIA card slot:
z 0 = upper slot,
z 1 = lower slot

Dest_Address DINT First address where the data is written in the memory
card.
Words_Number INT Number of words to write.
Source_Address UINT First address where the data is read from the PLC
(%MW). The upper limit of the address is: 65 535.

90 33002539 07/2012
WRITE_U_PCMCIA

The following table describes the output parameters:

Parameter Type Comment


Write_State INT Code providing the result of the write commands
execution:
z 16#0000: write performed correctly,
z 16#0102: Source_Address + Words_Number -
1 is greater than the maximum number of declared
words in the PLC,
z 16#0104: no valid application or no word in the PLC,
z 16#0201: no file zone in the memory card,
z 16#0202: memory card error,
z 16#0204: memory card write-protected,
z 16#0241: Dest_Address < 0,
z 16#0242: Dest_Address + Words_Number-1 is
greater than the highest address of the memory
card,
z 16#0401: Words_Number = 0,
z 16#0402: Slot_Number is different from 0 and 1,
z 16#0501: unsupported service.

33002539 07/2012 91
WRITE_U_PCMCIA

92 33002539 07/2012
Unity Pro
READ_U_PCMCIA
33002539 07/2012

READ_U_PCMCIA: Reading data


in the memory card
18
Description

Function description
The READ_U_PCMCIA function transfers data from the user memory card archiving
zone to the PLC RAM memory. The function READ_U_PCMCIA enables to address
the PLC zones beginning to be copied to the PCMCIA card up to 65 535 (instead of
32 767 for READ_PCMCIA function) and is therefore recommended to be used
instead of READ_PCMCIA function.
The additional parameters EN and ENO can be configured.
An example using the function READ_U_PCMCIA is available, WRITE_U_PCMCIA
and READ_U_PCMCIA Example (see page 97).

Representation in FBD
Representation:

33002539 07/2012 93
READ_U_PCMCIA

Representation in LD
Representation:

Representation in IL
Representation:
LD Slot_Number
READ_U_PCMCIA Source_Address, Words_Number, Dest_Address,
Read_State

Representation in ST
Representation:
READ_U_PCMCIA(Slot_Number, Source_Address, Words_Number,
Dest_Address, Read_State);

Description of the parameters


The following table describes the input parameters:

Parameter Type Comment


Slot_Number INT PCMCIA card slot:
z 0 = upper slot,
z 1 = lower slot

Source_Address DINT First address where the data is read from the memory
card (0...).
Words_Number INT Number of words to be read.
Dest_Address UINT First address where the data is written in the PLC
(%MW). The upper limit of the address is: 65 535.

94 33002539 07/2012
READ_U_PCMCIA

The following table describes the output parameters:

Parameter Type Comment


Read_State INT Code providing the result of the read commands
execution:
z 16#0000: read performed correctly,
z 16#0102: Dest_Address + Words_Number -1
is greater than the maximum number of declared
words in the PLC.
z 16#0104: no valid application or no word in the
PLC,
z 16#0201: no file zone in the memory card,
z 16#0202: memory card error,
z 16#0204: memory card write-protected,
z 16#0241: Source_Address < 0,
z 16#0242: Dest_Address + Words_Number-1
is greater than the highest address of the memory
card,
z 16#0401: Words_Number = 0,
z 16#0402: Slot_Number is different from 0 and 1,
z 16#0501: Words_Number = unsupported service.

33002539 07/2012 95
READ_U_PCMCIA

96 33002539 07/2012
Unity Pro
WRITE_U_PCMCIA and READ_U_PCMCIA Example
33002539 07/2012

WRITE_U_PCMCIA and
READ_U_PCMCIA Functions
Example 19
WRITE_U_PCMCIA and READ_U_PCMCIA Example

Objectives
This example shows how to use the READ_U_PCMCIA and WRITE_U_PCMCIA
function blocks by:
z Writing values from words (%MW100 to %MW109) to a memory card.
z Reading values from the memory card to words (%MW110 and %MW119).
NOTE: In this example, to use those function blocks, a memory card must be
connected into the PLC.

Configuration of the CPU


In this example, the TSX MRP C007M SRAM memory card is connected into the
upper slot A of the CPU (parameter SLOT = 0 for the functions blocks). In addition,
for data storage purposes, the CPU is configured with 2000 kB of memory.
NOTE: The data storage is used for READ_U_PCMCIA and WRITE_U_PCMCIA
function blocks. The 2000 kB of data storage represents:

The READ_U_PCMCIA and WRITE_U_PCMCIA functions are working with word


addresses:

Addresses from 0 to 1024000 for the memory card can be used.

33002539 07/2012 97
WRITE_U_PCMCIA and READ_U_PCMCIA Example

Programming the MAST section


In the MAST section of the program, program as follows:
z The memory card is connected into slot 0.
z The WRITE_U_PCMCIA function writes 10 words to address 10000 on the
memory card from %MW100.
z The READ_U_PCMCIA reads 10 words from address 10000 on the memory card
to %MW110.
Representation of WRITE_U_PCMCIA and READ_U_PCMCIA in FBD language:

Representation of WRITE_U_PCMCIA and READ_U_PCMCIA in ST language:


WRITE_U_PCMCIA (0,10000,10,100,Status_write);
READ_U_PCMCIA (0,10000,10,110,Status_read);

Testing the Example


By using animation tables with words: %MW100 to %MW119, the values from
%MW100 to %MW109 are copied to %MW110 to %MW119 via the memory card.

98 33002539 07/2012
Unity Pro
WRITE_V_PCMCIA
33002539 07/2012

WRITE_V_PCMCIA: Write Variable


to PCMCIA Card
20
Description

Function description
The WRITE_V_PCMCIA function transfers variables from the PLC RAM memory to
a given location in the user memory card.

Representation in FBD
The representation in FBD of the WRITE_V_PCMCIA function is as follows:

1 Slot number
2 Memory card address
3 Number of BYTEs to be write
4 Source variable address
5 Write status

Representation in LD
The additional parameters EN and ENO can be configured.

33002539 07/2012 99
WRITE_V_PCMCIA

The representation in LD of the WRITE_V_PCMCIA function is as follows:

1 Slot number
2 Memory card address
3 Number of BYTEs to be write
4 Source variable address
5 Write status

Representation in IL
The representation in IL of the WRITE_V_PCMCIA function is as follows:
LD SLOT
WRITE_V_PCMCIA SLOT, DEST, NUM, EMIS, CR

Representation in ST
The representation in ST of the WRITE_V_PCMCIA function is as follows:
WRITE_V_PCMCIA(SLOT, DEST, NUM, EMIS, CR);

Description of the parameters


The following table describes the Input parameters:

Parameter Type Comment


SLOT INT PCMCIA card slot:
z 0 = upper slot,
z 1 = lower slot

DEST DINT First address where the variable is written in the


memory card.
NUM UDINT Number of BYTEs to write.
EMIS ANY First address of the variable in the PLC.

100 33002539 07/2012


WRITE_V_PCMCIA

The following table describes the Output parameters:

Parameter Type Comment


CR INT Code providing the result of the write commands
execution:
z 0000 hex: write performed correctly
z 0201 hex: no file zone in the memory card
z 0202 hex: memory card error
z 0204 hex: memory card write-protected
z 0241 hex: DEST < 0
z 0401 hex: NUM = 0
z 0402 hex: SLOT is different from 0 and 1
z 0501 hex: unsupported service

33002539 07/2012 101


WRITE_V_PCMCIA

102 33002539 07/2012


Unity Pro
READ_V_PCMCIA
33002539 07/2012

READ_V_PCMCIA: Read Variable


from PCMCIA Card
21
Description

Function description
The READ_V_PCMCIA function transfers variables from the user memory card to the
PLCs RAM.

Representation in FBD
The representation in FBD of the READ_V_PCMCIA function is as follows:

1 Slot number
2 Memory card address
3 Number of BYTEs to be read
4 Destination variable address
5 Read status

Representation in LD
The additional parameters EN and ENO can be configured.

33002539 07/2012 103


READ_V_PCMCIA

The representation in LD of the READ_V_PCMCIA function is as follows:

1 Slot number
2 Memory card address
3 Number of BYTEs to be read
4 Destination variable address
5 Read status

Representation in IL
The representation in IL of the READ_V_PCMCIA function is as follows:
LD SLOT
READ_V_PCMCIA SRC, NUM

Representation in ST
The representation in ST of the READ_V_PCMCIA function is as follows:
READ_V_PCMCIA(SLOT, SRC, NUM);

Description of the parameters


The following table describes the READ_V_PCMCIA Input parameters:

Parameter Type Comment


SLOT INT PCMCIA card slot:
z 0 = upper slot,
z 1 = lower slot

SRC DINT Source address where the variable is read from


the memory card (0...).
NUM UDINT Number of BYTEs to be read. Use the SIZEOF
(see Unity Pro, Standard, Block Library)
function to find this number.

104 33002539 07/2012


READ_V_PCMCIA

The following table describes the READ_V_PCMCIA Output parameters:

Parameter Type Comment


RCPT ANY Destination address of every located or
unlocated variable (DDT).
CR INT Code providing the result of the read
commands execution:
z 0000 hex: read performed correctly
z 0201 hex: no file zone in the memory card
z 0202 hex: detected memory card error
z 0204 hex: memory card write-protected
z 0241 hex: SRC < 0
z 0401 hex: NUM = 0
z 0402 hex: SLOT is different from 0 and 1
z 0501 hex: NUM = unsupported service

33002539 07/2012 105


READ_V_PCMCIA

106 33002539 07/2012


Unity Pro
PRJ_VERS
33002539 07/2012

PRJ_VERS: Project Version

22
PRJ_VERS: Project Version

Function Description
The PRJ_VERS function allows you to obtain information about the current project
open in Unity Pro.
To access this information in Unity Pro:

Step Action
1 On the Tools menu, click PLCScreen.
Results: The PLCScreen opens.
2 Click on the Information tab.
3 On the left side of the PLCScreen, click SYSTEM INFORMATION
APPLICATION INFORMATION.
Results: Information about the application is displayed on the right side of the
PLCScreen.

33002539 07/2012 107


PRJ_VERS

FBD Representation
The representation in FBD of the PRJ_VERS function (with example data) is as
follows:

NOTE: For an explanation of these parameters, refer to Parameter Descriptions


(see page 110).

108 33002539 07/2012


PRJ_VERS

Ladder Representation
The representation in LD of the PRJ_VERS function is (with example data) as
follows:

IL Representation
The representation in IL of the PRJ_VERS function is as follows:
CAL FBI_PRJ_VERS (
OS_VERSION :=> OS_VERSION,
UNITY_VERSION := > UNITY_VERSION,
LIB_VERSION := > LIB_VERSION,
PRJ_NAME := > PRJ_NAME,
PRJ_VERSION := > PRJ_VERSION,
MAJOR_VERSION :=> MAJOR_VERSION,
MINOR_VERSION :=> MINOR_VERSION,
BUILD_VERSION :=> BUILD_VERSION,
SIGNATURE :=> SIGNATURE,
LAST_MODIFIED :=> LAST_MODIFIED,
SECOND :=> SECOND,
MINUTE :=> MINUTE,

33002539 07/2012 109


PRJ_VERS

HOUR :=> HOUR,


DAY :=> DAY,
MONTH :=> MONTH,
YEAR :=> YEAR
)

ST Representation
The representation in ST of the PRJ_VERS function is as follows:
FBI_PRJ_VERS(OS_VERSION, UNITY_VERSION, LIB_VERSION,
PRJ_NAME, PRJ_VERSION, MAJOR_VERSION, MINOR_VERSION,
BUILD_VERSION, SIGNATURE, LAST_MODIFIED, SECOND, MINUTE, HOUR,
DAY, MONTH, YEAR);

Parameter Descriptions
The following table describes the PRJ_VERS output parameters:

Parameter Type Comment


OS_VERSION INT*100 Processor version
UNITY_VERSION INT*100 Unity Pro version
LIB_VERSION INT*100 LibSet Version
PRJ_NAME String[68] Project name
PRJ_VERSION UDINT Project version
MAJOR_VERSION INT Project version (major)
MINOR_VERSION INT Project version (minor)
BUILD_VERSION INT Build version
SIGNATURE UDINT Build signature
LAST_MODIFIED DT Build last
SECOND INT Build version modified (secod)
MINUTE INT Build version modified (minute)
HOUR INT Build version modified (hour)
DAY INT Build version modified (day)
MONTH INT Build version modified (month)
YEAR INT Build version modified (year)

110 33002539 07/2012


Unity Pro
Events
33002539 07/2012

Events

III
Overview
This section describes the elementary functions and elementary function blocks of
the Events family.

What Is in This Part?


This part contains the following chapters:
Chapter Chapter Name Page
23 HALT: Stopping the program 113
24 ITCNTRL : Triggering of TIMER type event processing 115
25 MASKEVT: Global masking of events 119
26 UNMASKEVT: Global unmasking of events 121

33002539 07/2012 111


Events

112 33002539 07/2012


Unity Pro
HALT
33002539 07/2012

HALT: Stopping the program

23
Description

Description of the function


The HALT function in an application program can be used to halt its execution (stop
all tasks), which effectively freezes the variable objects of this program.
In order for execution to resume, a program halted in this way must be initialized
(using the INIT command). The instructions that follow the HALT instruction are
therefore not executed.
NOTE: When the PLC is in HALT, tasks are stopped (see Unity Pro, Operating
Modes). Check the behavior of the associated I/Os.
The additional parameters EN and ENO can be configured.

FBD representation
Representation:

LD representation
Representation:

33002539 07/2012 113


HALT

IL representation
Representation:
HALT

ST representation
Representation:
HALT();

114 33002539 07/2012


Unity Pro
ITCNTRL
33002539 07/2012

ITCNTRL : Triggering of TIMER


type event processing
24
Description

Description of the function


The ITCNTRL function is a timer that triggers the TIMER type event processing
(see Unity Pro, Program Languages and Structure, Reference Manual ) selected by
the EVENT input, when the current value reaches the preset value.
The preset and time base values are selected in the event processing properties
dialog box (see Unity Pro, Operating Modes).
Additional parameters EN and ENO can be configured.

Representation in FBD
Representation:

33002539 07/2012 115


ITCNTRL

Representation in LD
Representation:

Representation in IL
Representation:
LD Enable
ITCNTRL Reset_Timer, Hold_Timer, Nb_task_Event , Status_Timer,
Current_Value

Representation in ST
Representation:
ITCNTRL(ENABLE := Enable_Timer, RESET := Reset_Timer, HOLD :=
Hold_Timer, EVENT := Nb_Task_Event, STATUS => Status_Timer,
VALUE => Current_Value);

Description of the parameters


The following table describes the input parameters:

Parameter Type Comment


Enable BOOL Enable input selected,.
on state 1: the event processing is triggered
when the timer has elapsed.
on state 0: no event is emitted
Reset_Timer BOOL On state 1 reset the timer
Hold_Timer BOOL On state 1 freeze the timer incrementation.
Nb_Task_Event BYTE Input word which determines the TIMER event
processing number to be triggered.

116 33002539 07/2012


ITCNTRL

The following table describes the output parameters:

Parameter Type Comment


Status_Timer WORD Status word:
z bit0 = 1 execution delayed by a masking of
the interruption.
z bit 1 =1 event processing number not valid
z bit 2 = 1 validated timer (Enable input
image).
z bit 3 = 1 "frozen" timer (Hold_Timer input
image).
z bit 4 =1 as soon as ITCNTRL is called the
first time with the input Reset_Timer or
Hold_Timer at 1 (out-of-phase mode). It is
reset to 0 on a cold start.
z bit 5 = 1 FIFO memory stack of the saturated
interruptions.
Current_Value TIME Current timer value.
This value is increased by 0 to the preset value.
When the preset value is reached, it is reset to
0.
If the associated TIMER type event processing
is confirmed, it is executed.

33002539 07/2012 117


ITCNTRL

118 33002539 07/2012


Unity Pro
MASKEVT
33002539 07/2012

MASKEVT: Global masking of


events
25
Description

Description of the function


The MASKEVT function performs global masking of events (1).
Events are stored in the PLCs memory, but any associated event processing tasks
remain inactive, as long as the masking operation is valid, until the next UNMASKEVT
instruction.
NOTE: It is recommended to use this instruction only for short masking sequence,
in the same task cycle. In other cases, %S38 should be used. Events are
automatically unmasked by the system on change of mode (stop -> run, ...). It is not
recommended to execute masking sequences when event timers are active,
because they will be reset to 0.
The additional parameters EN and ENO can be configured.
(1) except for interruptions generated by FIPWAY telegrams.

FBD representation
Representation:

33002539 07/2012 119


MASKEVT

LD representation
Representation:

IL representation
Representation:
MASKEVT

ST representation
Representation:
MASKEVT();

120 33002539 07/2012


Unity Pro
UNMASKEVT
33002539 07/2012

UNMASKEVT: Global unmasking


of events
26
Description

Description of the function


The UNMASKEVT function performs global unmasking of events.
The events that were stored during the masking period are processed. The event
processing mechanism is operational until the next MASKEVT instruction.
NOTE: It is recommended to use this instruction only for short masking sequence,
in the same task cycle. In other cases, %S38 should be used. Events are
automatically unmasked by the system on change of mode (stop -> run, ...). It is not
recommended to execute masking sequences when event timers are active,
because they will be reset to 0.
The additional parameters EN and ENO can be configured.

FBD representation
Representation:

LD representation
Representation:

33002539 07/2012 121


UNMASKEVT

IL representation
Representation:
UNMASKEVT

ST representation
Representation:
UNMASKEVT();

122 33002539 07/2012


Unity Pro
Hot Stand By
33002539 07/2012

Hot Stand By

IV
Overview
This section describes the elementary functions and elementary function blocks of
the Hot Stand By family.

What Is in This Part?


This part contains the following chapters:
Chapter Chapter Name Page
27 HSBY_RD: Reading the Hot Standby command register 125
28 HSBY_ST: Reading the Hot Standby status register 129
29 HSBY_WR: Writing to the Hot Standby command register 133
30 REV_XFER: Writing and reading the two Reverse-Transfer- 137
Registers

33002539 07/2012 123


Hot Stand By

124 33002539 07/2012


Unity Pro
HSBY_RD
33002539 07/2012

HSBY_RD: Reading the Hot


Standby command register
27
HSBY_RD

Function Description
This EFB allows you to use the Hot Standby function. It searches (together with the
other Hot Standby EFBs) the configuration of the respective Quantum PLC for the
required components.
These components refer to hardware that is actually connected. Therefore, the
correct behavior of this EFB on the simulators cannot be guaranteed.
The HSBY_RD EFB checks System Word (see page 268) %SW60 to see if a Hot
Standby configuration exists:
z If a Hot Standby configuration is present the contents of the command register
are returned and the HSBY_ConfigurationFound output parameter is set to 1.
z If a Hot Standby configuration is not present the contents of the command
register are returned and the HSBY_ConfigurationFound output parameter is
set to 0.
EN and ENO can be configured as additional parameters.

Representation in FBD
Representation:

33002539 07/2012 125


HSBY_RD

Representation in LD
Representation:

Representation in IL
Representation:
CAL HSBY_RD_Instance (HSBY=>HSBY_ConfigurationFound,
INV_KEY=>InvalidateKeypad, PCA_RUN=>PLC_A_Running,
PCB_RUN=>PLC_B_Running, SBY_OFF=>StandbyOff,
EXC_UPD=>ExecUpdate, SWP_MB1=>SwapAddressModbusPort1)

Representation in ST
Representation:
HSBY_RD_Instance (HSBY=>HSBY_ConfigurationFound,
INV_KEY=>InvalidateKeypad, PCA_RUN=>PLC_A_Running,
PCB_RUN=>PLC_B_Running, SBY_OFF=>StandbyOff,
EXC_UPD=>ExecUpdate,
SWP_MB1=>SwapAddressModbusPort1);

126 33002539 07/2012


HSBY_RD

Parameter Descriptions
Description of the output parameters:

Parameter Data type Meaning


HSBY BOOL 1 = Hot Standby configuration found
0 = Hot Standby configuration not found
INV_KEY BOOL 1 = The submenu for the Hot Standby PLC button is
disabled.
0 = The submenu for the Hot Standby PLC button is
not disabled.
PCA_RUN BOOL For the local rack PLC with the Hot Standby CPU A:
1 = Command Register is selected for RUN
0 = Command Register is selected for OFFLINE
PCB_RUN BOOL For the local rack PLC with the Hot Standby CPU B:
1 = Command Register is selected for RUN
0 = Command Register is selected for OFFLINE
SBY_OFF BOOL 1 = ???
0 = The Standby PLC switches to the OFFLINE
mode as soon as both PLCs receive a different
program.
EXC_UPD BOOL 1 = Operating System update in the Standby-PLC is
possible with the primary CPU PLC still running.
0 = ???
(After Operating System Update, the Standby CPU
PLC changes back to the ONLINE mode.)
SWP_MB1 BOOL If a switchover has occurred, for Modbus ports 1:
1 = There is no swapping of addresses
0 = There is swapping of address
SWP_MB2 BOOL Not used. Reserved
SWP_MB3 BOOL Not used. Reserved

33002539 07/2012 127


HSBY_RD

128 33002539 07/2012


Unity Pro
HSBY_ST
33002539 07/2012

HSBY_ST: Reading the Hot


Standby status register
28
HSBY_ST

Function Description
This EFB allows you to use the Hot Standby function. It searches (together with the
other Hot Standby EFBs) the configuration of the respective Quantum PLC for the
required components.
These components refer to hardware that is actually connected. Therefore, the
correct behavior of this EFB on the simulators cannot be guaranteed.
This EFB is used to read the IEC Hot Standby status register (%SW61
(see page 268)). If there is no Hot Standby configuration present, the HSBY
output is set to 0.
EN and ENO can be configured as additional parameters.

Representation in FBD
Representation:

33002539 07/2012 129


HSBY_ST

Representation in LD
Representation:

Representation in IL
Representation:
CAL HSBY_ST_Instance (HSBY=>HSBY_ConfigurationFound,
THIS_OFF=>PLC_Offline, THIS_PRY=>Primary_PLC,
THIS_SBY=>Standby_PLC,
REMT_OFF=>Remote_PLC_Offline,
REMT_PRY=>PrimaryRemote_PLC,
REMT_SBY=>StandbyRemote_PLC,
LOGIC_OK=>IdenticalPrograms,
THIS_ISA=>HSBY_ModuleSwitchA,
THIS_ISB=>HSBY_ModuleSwitchB)

130 33002539 07/2012


HSBY_ST

Representation in ST
Representation:
HSBY_ST_Instance (HSBY=>HSBY_ConfigurationFound,
THIS_OFF=>PLC_Offline, THIS_PRY=>Primary_PLC,
THIS_SBY=>Standby_PLC,
REMT_OFF=>Remote_PLC_Offline,
REMT_PRY=>PrimaryRemote_PLC,
REMT_SBY=>StandbyRemote_PLC,
LOGIC_OK=>IdenticalPrograms,
THIS_ISA=>HSBY_ModuleSwitchA,
THIS_ISB=>HSBY_ModuleSwitchB);

Parameter Descriptions
Description of output parameters:

Parameter Data type Meaning


HSBY BOOL 1 = Hot Standby configuration found
0 = Hot Standby configuration not found
THIS_OFF BOOL 1 = This PLC is offline
0 = This PLC is not offline
THIS_PRY BOOL 1 = This PLC is the Primary CPU PLC
0 = This PLC is not the Primary CPU PLC
THIS_SBY BOOL 1 = This PLC is the Standby CPU PLC
0 = This PLC is not the Standby CPU PLC
REMT_OFF BOOL 1 = The other (remote) PLC is OFFLINE
0 = The other (remote) PLC is not OFFLINE
REMT_PRY BOOL 1 = The other PLC is the Primary CPU PLC
0 = The other PLC is not the Primary CPU PLC
REMT_SBY BOOL 1 = The other PLC is the Standby CPU PLC
0 = The other PLC is not the Standby CPU PLC
LOGIC_OK BOOL 1 = The programs for both PLCs are identical and
application mismatch is active.
0 = The programs are not the identical.
THIS_ISA BOOL 1 = This PLC chose the CPU with the lower IP
address between both Hot Standby CPUs. This is
the Hot Standby CPU A.
0 = This is not CPU A.
THIS_ISB BOOL 1 = This PLC chose the CPU with the higher IP
address between both Hot Standby CPUs. This is
the Hot Standby CPU B.
0 = This is not CPU B.

33002539 07/2012 131


HSBY_ST

132 33002539 07/2012


Unity Pro
HSBY_WR
33002539 07/2012

HSBY_WR: Writing to the Hot


Standby command register
29
HSBY_WR

Function Description
This EFB allows you to use the Hot Standby function. It searches (together with the
other Hot Standby Fibs) the configuration of the respective Quantum PLC for the
required components.
These components refer to hardware that is actually connected. Therefore, the
correct behavior of this EFB on the simulators cannot be guaranteed.
HSBY_WR is used to set different Hot Standby Modes for the Primary CPU. Setting
the respective modes means changing the Hot Standby Command register (%SW60
(see page 268)), which is carried out automatically by the function block. If there
is no Hot Standby configuration, the HSBY_ConfigurationFound output is set to
0, otherwise it is set to 1.
EN and ENO can be configured as additional parameters.

Representation in FBD
Representation:

33002539 07/2012 133


HSBY_WR

Representation in LD
Representation:

Representation in IL
Representation:
CAL HSBY_WR_Instance (INV_KEY:=InvalidateKeypad,
PCA_RUN:=PLC_A_Running, PCB_RUN:=PLC_B_Running,
SWP_MB1:=SwapAddressModbusPort1,
HSBY=>HSBY_ConfigurationFound)

Representation in ST
Representation:
HSBY_WR_Instance (INV_KEY:=InvalidateKeypad,
PCA_RUN:=PLC_A_Running, PCB_RUN:=PLC_B_Running,
SWP_MB1:=SwapAddressModbusPort1,
HSBY=>HSBY_ConfigurationFound);

134 33002539 07/2012


HSBY_WR

Parameter Description
Description of the input parameters:

Parameter Data type Meaning


INV_KEY BOOL In the submenu for the Hot Standby PLC button:
1 = Changes are not allowed.
0 = Changes are allowed.
PCA_RUN BOOL If 1 -> 0, then the Hot Standby A CPU on the local
rack is forced into OFFLINE mode.
If 0 -> 1 and its button mode is in RUN mode, then
the Hot Standby A CPU is forced into the RUN
mode.
PCB_RUN BOOL If 1 -> 0, then the Hot Standby B CPU on the local
rack is forced into OFFLINE mode.
If 0 -> 1 and its button mode is in RUN mode, then
the Hot Standby B CPU is forced into the RUN
mode.
SWP MB1 BOOL If 0 and there is a Switchover, then the Modbus
address on port 1 of the NEW Primary CPU PLC
changes:
z New Primary CPU PLC address = old Primary
CPU address
z New Standby CPU PLC address = new Primary
CPU address + 128.
If 1 and there is a Switchover, then the Modbus
address on Port 1 of the PLC does not change:
z New Primary CPU PLC address = old Standby
CPU address
z New Standby CPU PLC address = old Primary
CPU address
SWP_MB2 BOOL Not used. Reserved
SWP MB3 BOOL Not used. Reserved

Description of the output parameters:

Parameter Data type Meaning


HSBY BOOL 1 = Hot Standby configuration found.
0 = Hot Standby configuration not found.

33002539 07/2012 135


HSBY_WR

136 33002539 07/2012


Unity Pro
REV_XFER
33002539 07/2012

REV_XFER: Writing and reading


the two Reverse-Transfer-
Registers 30
REV_XFER

Function Description
This EFB allows you to use the Hot Standby function. It searches (together with the
other Hot Standby EFBs) the configuration of the respective Quantum PLCs for the
required components. These components refer to hardware that is actually
connected.
REV_XFER provides the ability to transmit 2 registers (%SW62/63) from the Standby
PLC to the Primary PLC. The two registers EFB are used by the application program
(in the first section) to register diagnostic information.
REV_XFER can only be used in the first executable section of the project. The
parameter addresses TO_REV1 and TO_REV2 have to be in the Non-Transfer Area
to prevent being overwritten by the Primary CPU.
As additional parameters, EN and ENO are projected.

Appearance in FBD
Appearance:

33002539 07/2012 137


REV_XFER

Appearance in LD
Appearance:

Appearance in IL
Appearance:
CAL REV_XFER_Instance (TO_REV1:=Standby_PLC_FirstReg,
TO_REV2:=Standby_PLC_SecondReg, HSBY=>HSBY_ConfFlag,
PRY=>Primary_PLC_Flag, SBY=>Standby_PLC_Flag,
FR_REV1=>FirstRevTransReg,
FR_REV2=>SecondtRevTransReg)

Appearance in ST
Appearance:
REV_XFER_Instance (TO_REV1:=Standby_PLC_FirstReg,
TO_REV2:=Standby_PLC_SecondReg, HSBY=>HSBY_ConfFlag,
PRY=>Primary_PLC_Flag, SBY=>Standby_PLC_Flag,
FR_REV1=>FirstRevTransReg,
FR_REV2=>SecondtRevTransReg);

138 33002539 07/2012


REV_XFER

Parameter Description
Description of input parameters:

Parameter Data type Description


TO_REV1 INT Describes the first reverse transfer register if this
PLC is the Standby PLC. Data in this register are
transferred from the Standby CPU to the Primary
CPU at each scan.
TO_REV2 INT Describes the second reverse transfer register if this
PLC is the Standby CPU. Data in this register are
transferred from the Standby CPU to the Primary
CPU at each scan.

Description of the output parameters:

Parameter Data type Description


HSBY BOOL 1 = This is a Hot Standby configuration.
0 = This is not a Hot Standby configuration.
PRY BOOL 1 = This PLC is the Primary CPU PLC.
0 = This PLC is not the Primary CPU PLC.
SBY BOOL 1 = This PLC is the Standby CPU PLC.
1 = This PLC is not the Standby CPU PLC.
FR_REV1 INT Content of first reverse transfer register (%SW62
(see page 268)). Output only if HSBY is 1.
FR_REV2 INT Content of second reverse transfer register (%SW63
(see page 268)). Output only if HSBY is 1.

33002539 07/2012 139


REV_XFER

140 33002539 07/2012


Unity Pro
SFC Management
33002539 07/2012

SFC Management

V
Overview
This section describes the elementary functions and elementary function blocks of
the SFC Management family.

What Is in This Part?


This part contains the following chapters:
Chapter Chapter Name Page
31 CLEARCHART: Reset all active steps 143
32 FREEZECHART: Freeze sequence 147
33 INITCHART: Reset all active steps and start sequence 151
normally
34 RESETSTEP: Reset a specific step in the sequence 155
35 SETSTEP: Set a specific step in the sequence 159
36 SFCCNTRL: SFC Control 163
37 SFC_RESTORE: SFC Save and Restore 175

33002539 07/2012 141


SFC Management

142 33002539 07/2012


Unity Pro
CLEARCHART
33002539 07/2012

CLEARCHART: Reset all active


steps
31
Description

Function description
This function is to reset sequences.

WARNING
UNEXPECTED SYSTEM BEHAVIOR
Do not use CLEARCHART to find error on controllers of machine tools, process or
material management system if they are running.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

WARNING
UNINTENDED EQUIPMENT OPERATION
Avoid using SFCCNTRL command with CLEARCHART, FREEZCHART, INITCHART,
SETSTEP and RESETSTEP commands altogether.
Carefully check the interactions between these function blocks and analyze the
resulting impact on SFC.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

With a 1 signal at the input ClearSequence, the sequence is stopped and all steps
are reset. As long as the 1 signal is at the input, the sequence stays in this mode,
i.e. it cannot be started.
This state remains even if input ClearSequence reverts back to 0.
The status (sequence reset) is shown with a 1 signal at the output ClearState.

33002539 07/2012 143


CLEARCHART

Only when there is a 0 signal at the input ClearSequence, the sequence can be
started with the function block SFCCNTRL (see page 164) (Input INIT), the
function INITCHART (see page 151) or another external step activation
command.
Since the sequence is permanently reset as long as there is a 1 signal at the input
ClearSequence, you should take the following measures to prevent a permanent
blocking of the sequence:
z Conditional call of the function CLEARCHART via the input EN.
z Conditional call of the function CLEARCHART via e.g. IF statement in the
programming language ST.
z Use edge recognition (R_TRIG) at the input ClearSequence.

NOTE: The output ClearState shows the current state of the sequence, i.e. the
sequence can also be reset with the function block SFCCNTRL (see page 164)
(Input CLEAR), the function INITCHART (see page 151), the procedure
RESETSTEP (see page 155) (reset the last/only active step) or and other control
command (external).
EN and ENO can be configured as additional parameters.

Representation in FBD
Representation:

Representation in LD
Representation:

144 33002539 07/2012


CLEARCHART

Representation in IL
Representation:
LD SectionName
CLEARCHART ClearChart
ST ClearState

Representation in ST
Representation:
ClearState := CLEARCHART (SectionName, ClearChart) ;

Parameter description
Description of input parameters:

Parameter Data type Description


CHARTREF SFCCHART_STATE Association with the SFC section to be controlled is
done via the name of the section.
If an SFC section is created then it is automatically
assigned with a variable of data type
SFCCHART_STATE. The variable that is created
always has the name of the respective SFC
section.)
CLEAR_I BOOL 0->1: Reset all active steps in the sequence.

Description of output parameters:

Parameter Data type Description


CLEAR_O BOOL 1: Sequence was reset, i.e. the sequence has no
active step

33002539 07/2012 145


CLEARCHART

146 33002539 07/2012


Unity Pro
FREEZECHART
33002539 07/2012

FREEZECHART: Freeze sequence

32
Description

Function description
The function is to "freeze" the sequence (evaluation of transitions is turned off).

WARNING
UNEXPECTED SYSTEM BEHAVIOR
Do not use FREEZECHART to find error on controllers of machine tools, process or
material management system if they are running.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

WARNING
UNINTENDED EQUIPMENT OPERATION
Avoid using SFCCNTRL command with CLEARCHART, FREEZCHART, INITCHART,
SETSTEP and RESETSTEP commands altogether.
Carefully check the interactions between these function blocks and analyze the
resulting impact on SFC.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

The current state of the sequence is frozen by a 1 signal at the input FreezeSe-
quence. The status of the transitions is no longer evaluated. Therefore, it is no
longer possible to move on in the sequence, even if the transition condition of the
"active" transition is true.
This function can be used in conjunction with the functions for step-by-step
processing (function block SFCCNTRL (see page 164) (Inputs STEPUN and
STEPDEP) or external SFC control command) for error correction.

33002539 07/2012 147


FREEZECHART

The output SequenceFreezed is 1 when the sequence is frozen.


NOTE: The output shows the current status of the sequence, i.e. the sequence can
also be frozen with the function block SFCCNTRL or another external SFC control
command.
EN and ENO can be configured as additional parameters.

Representation in FBD
Representation:

Representation in LD
Representation:

Representation in IL
Representation:
LD SectionName
FREEZECHART SectionName
ST SequenceFreezed

Representation in ST
Representation:
SequenceFreezed := FREEZECHART (SectionName,
FreezeSequence) ;

148 33002539 07/2012


FREEZECHART

Parameter description
Description of the input parameter:

Parameter Data type Meaning


SectionName SFCCHART_STATE Association with the SFC section to be controlled
is done via the name of the section.
If an SFC section is created then it is automatically
assigned with a variable of data type
SFCCHART_STATE. The variable that is created
always has the name of the respective SFC
section.)
FreezeSequence BOOL 1: Freeze sequence (turn off evaluation of
transitions)

Description of the output parameter:

Parameter Data type Meaning


SequenceFreezed BOOL 1: Sequence was frozen (evaluation of transitions
was turned off)

33002539 07/2012 149


FREEZECHART

150 33002539 07/2012


Unity Pro
INITCHART
33002539 07/2012

INITCHART: Reset all active steps


and start sequence normally
33
Description

Function description
This function is to reset and normally start sequences.

WARNING
UNEXPECTED SYSTEM BEHAVIOR
Do not use INITCHART to find error on controllers of machine tools, process or
material management system if they are running.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

WARNING
UNINTENDED EQUIPMENT OPERATION
Avoid using SFCCNTRL command with CLEARCHART, FREEZCHART, INITCHART,
SETSTEP and RESETSTEP commands altogether.
Carefully check the interactions between these function blocks and analyze the
resulting impact on SFC.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

33002539 07/2012 151


INITCHART

In relation to all functions and function blocks for sequence control, INITCHART has
the highest priority.
z Reset sequence
With a 1 signal at the input InitSequence, the sequence is stopped and all
steps are reset. As long as the 1 signal is at the input, the sequence stays in this
mode, i.e. it cannot be started.
Since the sequence is permanently reset as long as there is a 1 signal at the input
InitSequence, you should take the following measures to prevent a permanent
blocking of the sequence:
z Conditional call of the function INITCHART via the input EN.
z Conditional call of the function INITCHART via e.g. IF statement in the
programming language ST.
z Use edge recognition (R_TRIG) at the input InitSequence.

z Start sequence normally


With a 1->0 edge at the input InitSequence, the sequence is started normally,
i.e. the initial step is activated. This is shown for one cycle with a 1 signal at the
output InitState.
NOTE: The output InitState shows the current status of the sequence, i.e. the
sequence can also be normally started with the function block SFCCNTRL
(see page 164) (input INIT) or another external control command.
EN and ENO can be configured as additional parameters.

Representation in FBD
Representation:

Representation in LD
Representation:

152 33002539 07/2012


INITCHART

Representation in IL
Representation:
LD SectionName
INITCHART InitializeChart
ST InitState

Representation in ST
Representation:
InitState := INITCHART (SectionName, InitializeChart) ;

Parameter description
Description of input parameters:

Parameter Data type Description


CHARTREF SFCCHART_STATE Association with the SFC section to be controlled is
done via the name of the section.
If an SFC section is created then it is automatically
assigned with a variable of data type
SFCCHART_STATE. The variable that is created
always has the name of the respective SFC
section.)
INIT_I BOOL 0->1: Reset all active steps in the sequence.
1->0: Start standard sequence (set initial step)

Description of output parameters:

Parameter Data type Description


INIT_O BOOL 1: Sequence was started normally (on for only one
cycle)

33002539 07/2012 153


INITCHART

154 33002539 07/2012


Unity Pro
RESETSTEP
33002539 07/2012

RESETSTEP: Reset a specific step


in the sequence
34
Description

Function description
This procedure is to reset a step in a sequence.
NOTE: The procedure can only be used in the operation mode "Multi-Token".
This procedure resets the specified step.
Since the step stays reset as long as this procedure (RESETSTEP) is running (the
procedure is run cyclically), you should take one of the following measures to
prevent a permanent resetting of the step:
z Conditional call of the procedure RESETSTEP via the input EN.
z Conditional call of the procedure RESETSTEP via e.g. IF statement in the
programming language ST.
z Use edge recognition (R_TRIG) at the input.

When the last/only active step of the sequence is reset, the sequence can only be
restarted with the function block SFCCNTRL (see page 164) (input INIT), the
function INITCHART (see page 151) or the procedure SETSTEP
(see page 159) or another external step activation command.

WARNING
UNEXPECTED SYSTEM BEHAVIOR
Do not use RESETSTEP to find error on controllers of machine tools, process or
material management system if they are running.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

33002539 07/2012 155


RESETSTEP

WARNING
UNINTENDED EQUIPMENT OPERATION
Avoid using SFCCNTRL command with CLEARCHART, FREEZCHART, INITCHART,
SETSTEP and RESETSTEP commands altogether.
Carefully check the interactions between these function blocks and analyze the
resulting impact on SFC.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

EN and ENO can be configured as additional parameters.

Representation in FBD
Representation:

Representation in LD
Representation:

Representation in IL
Representation:
LD StepName
RESETSTEP

Representation in ST
Representation:
RESETSTEP (StepName);

156 33002539 07/2012


RESETSTEP

Parameter description
Description of the input parameter:

Parameter Data type Meaning


StepName SFCSTEP_STATE Assignment of the step to be reset via the name of
the step.
(If an SFC step is created then it is automatically
assigned with a variable of data type
SFCSTEP_STATE. The variable that is created
always has the name of the respective SFC step.)

33002539 07/2012 157


RESETSTEP

158 33002539 07/2012


Unity Pro
SETSTEP
33002539 07/2012

SETSTEP: Set a specific step in


the sequence
35
Description

Function description
This procedure is to set a step in a sequence.
NOTE: The procedure can only be used in the operation mode "Multi-Token".
This procedure sets the specified step, in addition to the already active step(s).
Already active steps are not affected by this procedure.
Since the step stays set as long as this procedure (SETSTEP) is running (the
procedure is run cyclically), you should take one of the following measures to
prevent a permanent setting of the step:
z Conditional call of the procedure SETSTEP via the input EN.
z Conditional call of the procedure SETSTEP via e.g. IF statement in the
programming language ST.
z Use edge recognition (R_TRIG) at the input.

WARNING
UNEXPECTED SYSTEM BEHAVIOR
Do not useSETSTEP to find error on controllers of machine tools, process or
material management system if they are running.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

33002539 07/2012 159


SETSTEP

WARNING
UNINTENDED EQUIPMENT OPERATION
Avoid using SFCCNTRL command with CLEARCHART, FREEZCHART, INITCHART,
SETSTEP and RESETSTEP commands altogether.
Carefully check the interactions between these function blocks and analyze the
resulting impact on SFC.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

EN and ENO can be configured as additional parameters.

Representation in FBD
Representation:

Representation in LD
Representation:

Representation in IL
Representation:
LD StepName
SETSTEP

Representation in ST
Representation:
SETSTEP (StepName);

160 33002539 07/2012


SETSTEP

Parameter description
Description of the input parameter:

Parameter Data type Meaning


StepName SFCSTEP_STATE Assignment of the step to be set via the name of the
step.
(If an SFC step is created then it is automatically
assigned with a variable of data type
SFCSTEP_STATE. The variable that is created
always has the name of the respective SFC step.)

33002539 07/2012 161


SETSTEP

162 33002539 07/2012


Unity Pro
SFCCNTRL
33002539 07/2012

SFCCNTRL: SFC Control

36
Introduction
This chapter describes the SFCCNTRL block.

What Is in This Chapter?


This chapter contains the following topics:
Topic Page
Description 164
Parameter description 168

33002539 07/2012 163


SFCCNTRL

Description

Function description
This function block is to control the execution sequences.
For example, you can go through step by step, processing transition conditions can
be turned on or off or the sequence can be reset to its initialization state.

WARNING
UNEXPECTED SYSTEM BEHAVIOR
Do not use INIT, CLEAR, DISTRANS, DISACT, STEPUN and STEPDEP to find
errors when controlling machine tools, processes or material management
systems, if they are running.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

WARNING
UNINTENDED EQUIPMENT OPERATION
Avoid using SFCCNTRL command with CLEARCHART, FREEZCHART, INITCHART,
SETSTEP and RESETSTEP commands altogether.
Carefully check the interactions between these function blocks and analyze the
resulting impact on SFC.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

EN and ENO can be configured as additional parameters.

164 33002539 07/2012


SFCCNTRL

Representation in FBD
Representation:

Representation in LD
Representation:

33002539 07/2012 165


SFCCNTRL

Representation in IL
Representation:
CAL SFCCNTRL_Instance (CHARTREF:=SectionName,
INIT:=InitializeChart, CLEAR:=ClearChart,
DISTIME:=DisableTimeCheck, DISTRANS:=DisableTransitions,
DISACT:=DisableActions, STEPUN:=StepUnconditional,
STEPDEP:=StepTransDependent, RESETERR:=ResetTimeErrors,
DISRMOTE:=DisableRemoteControl,
ALLTRANS:=CalcAllTransitions, RESSTEPT:=ResetStepTimes,
INITST=>InitState, CLEARST=>ClearState,
TIMEDIS=>TimeCheckDisabled, TRANSDIS=>TransitionsDisabled,
ACTDIS=>ActionsDisabled, MODECHG=>OperatingModeChanged,
STATECHG=>StatusChanged, TIMEERR=>TimeError,
TERRACT=>PendingTimeError)

Representation in ST
Representation:
SFCCNTRL_Instance (CHARTREF:=SectionName,
INIT:=InitializeChart, CLEAR:=ClearChart,
DISTIME:=DisableTimeCheck, DISTRANS:=DisableTransitions,
DISACT:=DisableActions, STEPUN:=StepUnconditional,
STEPDEP:=StepTransDependent, RESETERR:=ResetTimeErrors,
DISRMOTE:=DisableRemoteControl,
ALLTRANS:=CalcAllTransitions, RESSTEPT:=ResetStepTimes,
INITST=>InitState, CLEARST=>ClearState,
TIMEDIS=>TimeCheckDisabled, TRANSDIS=>TransitionsDisabled,
ACTDIS=>ActionsDisabled, MODECHG=>OperatingModeChanged,
STATECHG=>StatusChanged, TIMEERR=>TimeError,
TERRACT=>PendingTimeError) ;

Parameter description
Description of input parameters:

Parameter Data type Description


CHARTREF SFCCHART_STATE Association with the SFC section to be controlled is
done via the name of the section
If an SFC section is created then it is automatically
assigned with a variable of data type
SFCCHART_STATE. The variable that is created
always has the name of the respective SFC
section.)
INIT BOOL 0->1: Reset all active steps in the sequence.
1->0: Start standard sequence (set initial step)

166 33002539 07/2012


SFCCNTRL

Parameter Data type Description


CLEAR BOOL 0->1: Reset all active steps in the sequence.
DISTIME BOOL 1: Turn off time monitoring
DISTRANS BOOL 1: Turn of evaluation of the transitions (freeze
sequence)
DISACT BOOL 1: Turn off processing of the actions and reset all
actions in the sequence
STEPUN BOOL 0->1: Activate the next step, independent of the
transition condition
STEPDEP BOOL 0->1: Activate the next step, dependent on the
transition condition
RESETERR BOOL 0->1: Reset the time monitoring error.
DISRMOTE BOOL 1: Prevent control of the sequence using processing
parameters of the Online Animation Panel
ALLTRANS BOOL 1: Calculate all transition sections
RESSTEPT BOOL 0->1: Deactivate and reset time calculation
1->0: Restart time calculation
Reminder: If the RESSTEPT function is active,
steps with a defined delay time are never activated
(With RESSTEPT, the current step time is reset
continually and so the defined delay time can never
be achieved.)

Description of output parameters:

Parameter Data type Description


INITST BOOL 1: Sequence was started normally (on for only one
cycle)
CLEARST BOOL 1: Sequence was reset, i.e. the sequence has no
active step
TIMEDIS BOOL 1: Time monitoring was turned off
TRANSDIS BOOL 1: Evaluation of the transitions was turned off
ACTDIS BOOL 1: Processing of the actions was turned off and all
actions in the sequence were reset
MODECHG BOOL 1: Operation mode of the sequence was changed
(on for only one cycle)
STATECHG BOOL 1: Status of the sequence was changed (on for only
one cycle)
TIMEERR BOOL 1: Error in the time monitoring has occurred (on for
only one cycle)
TERRACT BOOL 1: There is currently an error in the time monitoring

33002539 07/2012 167


SFCCNTRL

Parameter description

General

WARNING
UNEXPECTED SYSTEM BEHAVIOR
Do not use INIT, CLEAR, DISTRANS, DISACT, STEPUN and STEPDEP to find
errors when controlling machine tools, processes or material management
systems, if they are running.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

CHARTREF
Association with the SFC to be controlled.
If an SFC section is created then it is automatically assigned with a variable of data
type SFCCHART_STATE. The variable that is created always has the name of the
respective SFC section.
This variable is used for assigning the function block SFCCNTRL to the SFC section
to be controlled.
NOTE: The data type SFCCHART_STATE cant be created by the user, and the value
cannot be modified; so in the animation table this variable cannot be modified and
the value field stay empty.

INIT
Reset sequence and start normally.
This input to the function block has the highest priority, above all other inputs.
z Reset sequence
With a 0->1 Edge at the input, the sequence is stopped and all steps are reset.
No operator access is possible.
This status remains as long as the input is 1. The status (sequence reset) is
shown with a 1 signal at the output CLEARST.
z Start sequence normally
With a 1->0 edge at the input and 0 at CLEAR, the sequence is started normally,
i.e. the initial step is activated. This is shown for one cycle with a 1 signal at the
output INITST.

168 33002539 07/2012


SFCCNTRL

Interaction of INIT, CLEAR, INITST and CLEARST:

Interaction of INIT, CLEAR, INITST and CLEARST:

Phase Description
1 If there is a 0->1 edge at input INIT, all steps in the sequence are reset and the
output CLEARST is set to 1.
2 If there is a 1->0 edge at input INIT, the initial step in the sequence is set, the
output INITST is set to 1 for one cycle and the output CLEARST is set to 0.
3 If there is a 0->1 edge at input INIT, all steps in the sequence are reset and the
output CLEARST is set to 1.
4 A 1->0 edge at input CLEAR, has no influence on the state of the sequence or the
outputs of the function block.
5 If the sequence is already in the status "reset", a 0->1 edge at input INIT, has no
influence on the state of the sequence or the outputs of the function block.
6 If the sequence is already in the status "reset", a 0->1 edge at input CLEAR, has
no influence on the state of the sequence or the outputs of the function block.
7 When CLEAR is 1, a 1->0 edge at input INIT, has no influence on the state of the
sequence (CLEARST) or the outputs of the function block.

CLEAR
Reset sequence
With a 0->1 Edge at the input, the sequence is stopped and all steps are reset. No
operator access is possible.
The status (sequence reset) is shown with a 1 signal at the output CLEARST.
This state remains even if input reverts back to 0.
The sequence can only be started by a 1->0 edge on the input INIT, of the function
INITCHART (see page 151) or another step activation command (external),
while CLEAR is 0.

33002539 07/2012 169


SFCCNTRL

DISTIME
Turn off time monitoring
The time monitoring of the active step is suppressed by a 1 signal at the input. The
execution time will continue to be calculated, but no error will be reported if the time
is outside the upper and lower limits.
Already existing errors are not affected by this function (Animation or Output
TERRACT).

DISTRANS
Turn off transition evaluation
The current state of the sequence is frozen by a 1 signal at the input. The status of
the transitions is no longer evaluated. Therefore, it is no longer possible to move on
in the sequence, even if the transition condition of the "active" transition is true.
This function can be used in conjunction with STEPUN and STEPDEP for error
correction.

DISACT
Turn off processing of the actions
All active actions are reset with a 1 signal at the input.

STEPUN
Activate the next step, independent of the transition condition
With a 0->1 edge at the input, independent of the status of the transition condition,
the current active step(s) are deactivated and the next step(s) is activated. However,
this occurs first after the delay time (step time) of the active step has run out.
Using this command with simultaneous branching, all branches are activated and for
alternative branching, the left branch is always activated.
The input STEPDEP is used for process dependent activation of branches.

STEPDEP
Activate the next step, dependent on the transition condition
With a 0->1 edge at the input and a successful transition condition, the next step(s)
is activated. However, this occurs first after the delay time (step time) of the active
step has run out.

170 33002539 07/2012


SFCCNTRL

The control command is only sensible when there is a 1 signal at the input
DISTRANS.
By freezing the transitions(DISTRANS = 1), it is possible to manually process the
sequence, step by step, with this control command. In this way, the transitions are
dependent on the transition conditions.

RESETERR
Reset the time monitoring error.
With a 0->1 edge at the input, display of all time monitoring errors with the animation
of the SCF section are turned off. Currently displayed time monitoring errors are
updated. Existing time monitoring errors are reported anew. If there are no time
monitoring errors, the output TERRACT is reset.

DISRMOTE
Prevent control of the chart using processing parameters of the SFC Animation
Panel.
A 1 signal at the input prevents control of the SFC chart with the processing
parameters of the SFC Animation Panel (initialize, turn off time monitoring, turn off
evaluation of the transitions, turn off processing of the actions). Despite this, the
SFC chart continues to be controlled by the SFCCNTRL function block.
Setting DISRMOTE to 1 means that SFCNTRL is dominant. If DISRMOTE is not set or
is set to 0, the inputs DISTRANS, DISACT, DISTIME and INIT of the SFCNTRL
function block and the corresponding inputs in the SFC Animation Panel are treated
as a logical OR combination.
Setting DISRMOTE to 1 causes that the controls of the SFC Animation Panel are
disabled.
Setting DISRMOTE to 0 causes that the controls of the SFC Animation Panel are
enabled and all other components of the SFC section variable (SFCCHART_STATE)
stay unchanged.
When setting DISRMOTE to 1 or 0 the value is assigned to the SFC section variable
of the controlled SFC chart.
This causes a problem, if the SFCCNTRL function block sets the variable to 1 (and
blocks the SFC Animation Panel) and then the SFCCNTRL function block instance is
deleted. In this case, the blocking value stays till next Rebuild all in offline mode.
This problem could happen when
z the SFC section variable assigned to the CHARTREF input is replaced in online
mode (meaning that the SFCCNTRL function block instance is assigned to
another SFC section),
z the SFCNTRL function block instance is deleted or
z the section with the SFCNTRL function block instance is deleted.

33002539 07/2012 171


SFCCNTRL

Work around for online mode: Create a new SFCCNTRL function block instance,
assign the correct SFC section name to the CHARTREF input and set DISRMOTE to
0. This will unblock the SFC Animation Panel. Now you can delete this SFCCNTRL
function block instance again.
Preventing the problem: To prevent to described problem, always make sure that
DISRMOTE is set to 0 before deleting a SFCCNTRL function block instance.
NOTE: Please also refer to the SFC_RESTORE function block (Interaction with
SFCCNTRL Function Block, page 191).

ALLTRANS
Calculate all transition sections
With a 1 signal at the input, all transition sections are calculated (even if the
corresponding step is not active). For processing of the sequence, only the active
transitions continue to be evaluated. This function only serves to display the
animation of all transition statuses simultaneously.
NOTE: Due to the additional processing of all transition sections whose step is
inactive, the cycle time of the program may be considerably increased.

RESSTEPT
Deactivate time calculation
With a 0->1 signal, all time monitoring errors (minimum and maximum monitoring
time), the elapsed time since activation of the step and the output TERRACT are all
reset. As well, all time errors in the diagnosis are cancelled and the time monitoring
of the step is stopped. This status is valid as long as the 1 signal is present.
With a 1->0 edge, all times (starting with 0) are recalculated and the time monitoring
is activated.
NOTE: If the RESSTEPT function is active, steps with a defined delay time are never
activated. (With RESSTEPT, the current step time is reset continually and so the
defined delay time can never be achieved.)

INITST
Sequence started normally
With a 1->0 edge at the input INIT, the sequence is started normally, i.e. the initial
step is activated. This is shown for one cycle with a 1 signal at the output INITST.
see also INIT, page 168
NOTE: The output shows the current status of the sequence, i.e. the sequence can
also be normally started with the function INITCHART (see page 151) or
another external control command.

172 33002539 07/2012


SFCCNTRL

CLEARST
Sequence was reset
With a 0->1 Edge at the input INIT or CLEAR, the sequence is stopped and all steps
are reset.
This state is maintained until a 1->0 edge at the input INIT occurs.
see also INIT, page 168
NOTE: The output shows the current status of the sequence, i.e. the sequence can
also be reset with the function INITCHART (see page 151), CLEARCHART
(see page 143) or RESETSTEP (see page 155) (reset the last/only active
step) or another external control command.

TIMEDIS
Time monitoring was turned off
The output is 1 if the display of the time error was turned off, independent of if the
display was turned off with the function block itself (input DISTIME) or via SFC
control commands.

TRANSDIS
Evaluation of the transitions was turned off
The output is 1 if the evaluation of the transitions was stopped.
NOTE: The output shows the current status of the sequence, i.e. the sequence can
also be frozen with the function FREEZECHART (see page 147) or another
external SFC control command.

ACTDIS
Processing of the actions was turned off and all actions in the sequence were reset
The output is 1 if the display of the actions was stopped, independent of if the display
was stopped with the function block itself (input DISACT) or via SFC control
commands.

MODECHG
Operation mode of the sequence was changed
The output is 1 for a cycle, if one or more operation modes of the sequence was
changed, independent of if the change was done with the function block itself
(setting or resetting the inputs INIT, CLEAR (see page 169), DISTIME,
DISACT or DISTRANS) or via external SFC control commands.

33002539 07/2012 173


SFCCNTRL

STATECHG
Status of the sequence was changed
The output is 1 for a cycle, if the status of the sequence was changed, independent
of if the change was caused by processing the sequence, done with the function
block itself or via external SFC control commands.

TIMEERR
An error in the time monitoring has occurred
The output is 1 for a cycle if one or more time monitoring errors have occurred.

TERRACT
There is currently an error in the time monitoring
The output remains 1 when one or more time monitoring errors exist.

174 33002539 07/2012


Unity Pro
SFC_RESTORE
33002539 07/2012

SFC_RESTORE: SFC Save and


Restore
37
Introduction
This chapter describes the SFC_RESTORE block.

What Is in This Chapter?


This chapter contains the following topics:
Topic Page
Description 176
Requirements and Restrictions 180
Save and Restore Strategy 184
Saving the Active Steps 185
Restoring the Steps for Activation 187
Resuming the SFC Sections 189
Interaction with SFCCNTRL Function Block 191
STATUS Error Messages 192

33002539 07/2012 175


SFC_RESTORE

Description

Function Description
This function block is used to restart all SFC charts of an application with a given set
of active steps at a state, saved before a CPU failure.
In a recovery situation it is possible to set a group of steps that represent a given
state in the process and to continue at that point.
The behavior of the charts will be like using INITCHART and SETSTEP, i.e. the step
time is reset to 0 and P/P1 actions are executed.
For more information please refer to Save and Restore Strategy, page 184.

WARNING
UNINTENDED EQUIPMENT OPERATION
Check the state of all SCF charts before re-starting your process application.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

EN and ENO can be configured as additional parameters.

Representation in FBD
Representation

176 33002539 07/2012


SFC_RESTORE

Representation in LD
Representation

Representation in IL
Representation:
CAL SFC_RESTORE_Instance (SLOT:=Slot_Number,
ADR_W:=Dest_Address, SPACE_KW:=Words_Number,
SAVE:=Save_In, RESTORE:=Restore_In, RESUME:=Resume_In,
STATUS=>Save_Restore_State, NUMSAVED=>saved_charts,
NUMFAILED=>failed_charts, NUMPOSBL=>possible_charts)

Representation in ST
Representation:
SFC_RESTORE_Instance (SLOT:=Slot_Number,
ADR_W:=Dest_Address, SPACE_KW:=Words_Number,
SAVE:=Save_In, RESTORE:=Restore_In,
RESUME:=Resume_In,
STATUS=>Save_Restore_State, NUMSAVED=>saved_charts,
NUMFAILED=>failed_charts, NUMPOSBL=>possible_charts);

33002539 07/2012 177


SFC_RESTORE

Parameter Description
The SFC_RESTORE function block is used to access memory (SLOT, ADR_W,
SPACE_KW) and to select the possible modes (SAVE, RESTORE, RESUME).
It also gives the status of operation (STATUS).
The amount of memory as an input parameter (SPACE_KW) determines the space
that could be used by SFC Interpreter.
This memory area starts at the given address (ADR_W) and exclusive use by SFC
system is supposed.
Description of input parameters

Parameter Data Type Description


SLOT INT PCMCIA card slot
z 0: upper slot (default)
z 1: lower slot

ADR_W DINT address of the archiving zone where SFC data is


stored in memory card (word offset)
SPACE_KW INT This number determines the size of the memory in
kilo words that the SFC interpreter is allowed to use.
SAVE BOOL z 0: save mode not selected
z 1: save mode selected
active only if
z RESTORE = 0 and
z RESUME = 0

z 1->0
falling edge = saving is stopped
This event is reported to diagnostic buffer.
RESTORE BOOL z 0: restore mode not selected
z 0->1
rising edge = saved steps from storage area are
restored in each SFC section
This event is reported to diagnostic buffer. All
SFC sections enter mode disable
transitions and disable actions.
z 1: no SAVE / no RESTORE / no RESUME
z 1->0
falling edge = no activity
RESUME BOOL z 0: resume mode not selected
z 0->1
rising edge = resume all SFC charts to normal
mode if RESTORE = 0
This event is reported to diagnostic buffer.
z 1: no activity, but prevents SAVE
z 1->0
falling edge = no activity

178 33002539 07/2012


SFC_RESTORE

Description of output parameters

Parameter Data type Description


STATUS INT 0 = OK
STATUS error message (see STATUS Error
Messages, page 192)
NUMSAVED INT number of SFC sections on which the save was
performed during the last scan
NUMFAILED INT number of SFC sections that could not be saved
during the last scan
NUMPOSBL INT number of SFC sections that fits into the given
memory space

33002539 07/2012 179


SFC_RESTORE

Requirements and Restrictions

General
The analyzer will check the following rules and errors will be reported if not matched
in the application:
z The EFB must not be used more than once in the whole application.
z A PCMCIA card of type DATA must be present in right slot.
z Data size must match the memory borders.

Only 1 SFC_RESTORE
Only 1 SFC_RESTORE function block is used to control SFC save and restore.
NOTE: SFC_RESTORE can only be used once in an application (single control
instance).

Location of SFC_RESTORE
It is recommended to locate the usage of SFC_RESTORE in a section executed
before the first SFC section.
A change at input(s) will then affect all SFC sections in the same scan.
It is also strongly recommended to not disable this EFB or the section, in which this
EFB is located, because otherwise the saved data will be inconsistent to the SFC
charts.

SFC_RESTORE Disabled or Deleted


If the SFC_RESTORE function block is disabled or deleted, the SFC interpreter is no
more notified.
This will be detected after some scans and the SFC save and restore feature will be
shut off. No more saves are done.
The data in the PCMCIA memory card is kept and a warning is registered to the
diagnostic buffer.

Currently Active Mode


The currently active mode/action is calculated according to the following table.

Mode/Action Save Value Restore Value Resume Value


idle 0 0 0
save 1 0 0
restore 0 or 1 0 -> 1 (rising edge) 0 or 1
resume 0 or 1 0 0 -> 1 (rising edge)

180 33002539 07/2012


SFC_RESTORE

PCMCIA Memory Card


The SFC_RESTORE function block can only be used in CPUs with a PCMCIA
memory card slot.
The presence of a suitable PCMCIA memory card is checked at analyze time in the
configuration data.
An error is reported if missing or wrong slot is selected.
If given as constant value, it is checked additionally that the memory area fits into
the card memory starting from the given address.
Nevertheless, a run-time error will be shown at the STATUS output if the card is not
present (like WRITE_PCMCIA, e.g. 16#0201: no file zone in the memory
card).

Estimation of Memory
To estimate the amount of memory needed to save your SFC sections, you can use
the following formula:
bytes = 570 + n*210
570 bytes needed for data management
n number of SFC sections
210 bytes needed per SFC section
NOTE: Values may change in case of OS update.

Memory Area
Starting at the address given by the ADR_W input, the SFC interpreter assumes a
memory area of SPACE_KW * 2 Kbytes usable by SFC save and restore feature.
The integrity of this memory is verified by a checksum per block.
If an error is detected (e.g. checksum error), the related block is marked as
invalid and an error is reported.
As in the next scan SFC will try to save active steps again, the lack of restore-
possibility could be temporary.

33002539 07/2012 181


SFC_RESTORE

WARNING
UNINTENDED EQUIPMENT OPERATION
Provide enough memory in the PCMCIA memory card for the SFC save and
restore feature.
Use this memory area is exclusively used by the SFC save and restore feature and
there will be no overlapping with other parts of your application.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

NOTE: Take into account that even the READ_PCMCIA and WRITE_PCMCIA blocks
can manage the PCMCIA memory card.

Number of Saved SFC Sections


According to the SPACE_KW input, a certain amount of memory is used. There is no
check at build time whether this amount of memory is suitable.
If more SFC sections are detected at run time than fit into memory, an error will be
reported.
It is still possible to restore SFC charts that have been saved.
If the number of active SFC sections increases (enable sections, add with online
modification), this type of error could be detected spontaneously at run time.
To give help on the number of SFC sections in the application, 3 outputs are
available:
z NUMSAVED: number of saved SFC sections
z NUMFAILED: number of not saved SFC sections
z NUMPOSBL: maximum number of SFC sections that could be saved in the current
scenario
NOTE: If there is no need to economize memory, it is recommended to add some
memory space for future expansion.

Memory Not Cleared


New parameters at the EFB, according to an online build/change, will be taken into
account.
In case of an address change, the new memory will be used.
NOTE: The old memory will not be cleared.
A change at SPACE_KW will result in an increase or decrease of the used memory.
The presence and exclusive availability of that memory is assumed.

182 33002539 07/2012


SFC_RESTORE

New Save in Case of Build


In case of a build/change of any modified part of the application, the saved data is
invalidated.
That is because the application signature, which is used to identify good pairs of
application and storage, is changed in any case.
NOTE: To be able to perform a restore again, it is mandatory to save again after a
build/change.

33002539 07/2012 183


SFC_RESTORE

Save and Restore Strategy

Save Strategy
The save strategy is based on a save of the active steps to a CPU-external memory
area (PCMCIA memory card).
In the environment of individual sections, it is known, whether active steps have
changed. Only in this case (or to recover from an error), the save will be performed.
NOTE: If the state of a chart does not change, there is no update of data in the
cartridge.
Only the StepIDs (internal identifiers) of the active steps are saved due to memory
consumption and needed time to save.
The save is done individually for each SFC section in its context.

Restore Strategy
In case of restore, the StepIDs are read from the PCMCIA memory card area and
activated in the charts.
Those StepIDs must be consistent, i.e. all steps must be present and they must
identify the same objects in the SFC sections as at the save-time.
NOTE: To ensure this, there must not be a change/build of the application between
saving and restoring of steps.

184 33002539 07/2012


SFC_RESTORE

Saving the Active Steps

Overview
In case of Save mode, save will be done at the end of the processing of every chart.
If a change of the active steps of a chart occurs, the new StepIDs (internal identifier)
are stored to the memory and a status is memorized.
This is repeated for all SFC sections following in the scan.
At next execution of the EFB, the cumulated status of save operation is retrieved and
shown at the output.
If more than 1 error is detected, the most significant one (see STATUS Error
Messages, page 192) will be displayed.

Effects of Modifying the Application


If the application is modified (adding, deleting, moving or disabling SFC sections),
this will influence the saved data.

Modification Effect
adding an SFC section Active steps are immediately saved when section is
executed.
deleting an SFC section No more save, data in memory is removed.
moving an SFC section Data will be stored in different order.
disabling an SFC section No more save, but data is still valid.
Saved again if enabled.

Checksum
It will be checked whether the data fits into memory space according to user settings
(number of SFC sections and number of active steps per SFC section).
A checksum is created for each section and will provide a certain security, that
content is not damaged.
NOTE: If a check fails, the related data is marked as invalid.

33002539 07/2012 185


SFC_RESTORE

Update of Stored Data


z If SFC sections are not executed because execution condition is false, the
StepIDs (internal identifier) of the last execution are still available.
z If executed again, the StepIDs will be updated.
z Newly added SFC sections will store their StepIDs as soon as they are executed.
z Stored data of deleted SFC sections will be immediately deleted.
In general after a build/change all data are invalidated as they are not usable
because of changed application signature. This avoids memory shortage due to
obsolete data.
In this environment, a restore after a CPU failure is probably a mix of chart data of
2 scans, as the CPU failure most likely will occur somewhere within the scan.
NOTE: In such a scenario it might be possible to have inconsistent states between
charts.

186 33002539 07/2012


SFC_RESTORE

Restoring the Steps for Activation

Overview
If a rising edge (0->1) of RESTORE is detected, then the first executed SFC section
will perform the restore operation for all sections.
The all-at-once recovery is necessary to ensure that every SFC section gets back
the stored StepIDs (internal identifier), even the disabled ones.
If a high signal is active at the RESTORE input, no SAVE and no RESUME will be
performed, even if those inputs are active.
This is necessary to prevent overwriting the save area and to provide a clear
separation of operating modes.

CLEARCHART / SETSTEP
To perform a RESTORE operation, a CLEARCHART will be executed.
This resets all steps and actions and also de-registers all SFC errors from diagnostic
buffer.
After that, for each StepID taken from the storage area, a SETSTEP operation will be
performed.

General Check
Before starting the RESTORE operation, a general check is performed to ensure
integrity of the memory card data.
The application build ID must be equal and the version must be in valid range.
If not all of the checks succeed, the restore operation is aborted.
An error (An INIT was done due to restore error) is notified to EFB and diagnostic
buffer.
NOTE: The PLC will not enter the HALT state. All SFC charts will start with INIT
steps.

33002539 07/2012 187


SFC_RESTORE

Individual Checks
There are also checks within individual sections:
z save operation must be completed
z the checksum must fit
z StepID must be valid

If an error occurs during recovery of individual sections, then the SFC section
currently in progress is forced to the initial state.
A warning (Not all SFC charts could be restored / resumed / initialized) is notified.
Detecting such failures will not prevent the complete restore mechanism to restore
as much steps as possible.

188 33002539 07/2012


SFC_RESTORE

Resuming the SFC Sections

Overview
After having checked that SFC sections are in correct state, it is possible to use
RESUME input to set all SFC charts to enabled action and transition mode.
For behavior in case of interaction with SFCCNTRL function block please refer to
Interaction with SFCCNTRL Function Block, page 191.

Check SFC Charts

WARNING
UNINTENDED EQUIPMENT OPERATION
Check the state of all SFC charts before re-starting your process application.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

Performing a Complete Restore Cycle


To perform a complete restore cycle of SFC charts, you must perform the following
steps:

Step Action Comment


1 Load application. Must be the same application that did the save of the
steps.
This action may be optional, depends on the situation.
2 Reset SAVE input. This prevents overwriting of saved data.
3 Reset RESUME input. -
4 Perform a PLC Init. Already done if application is newly loaded.
This action may be optional.
5 Set RESTORE input. The rising edge will initiate the restore of all charts in the
next executed SFC section.
Should be set before RUN to bring SFC into disabled
mode.
6 Run application. -
7 Reset RESTORE input. -
8 Check SFC charts. The rising edge of RESTORE input will disable actions
and transitions for all SFC charts.
Note:
Be careful to ensure that no harm can occur before
activating SFC charts. See safety message Check SFC
Charts, page 189 above.

33002539 07/2012 189


SFC_RESTORE

Step Action Comment


9 Individually enable the This action may be optional, depends on the situation.
charts using the SFC
Animation Panel.
10 Set RESUME input. Rising edge of RESUME input will enable all SFC
transitions and actions.
Note:
This will remove DisableTransitions and
DisableActions flags from all SFC sections.
11 Reset RESUME input. -
12 Set SAVE input. After system works well again, probably enable again to
save the active steps.

Timing Diagram

1 Normal operation.
2 CPU failure.
3 Reset SAVE input.
4 Perform a PLC -> Init.
5 Set RESTORE input and PLC -> Run.
6 Reset RESTORE input.
7 As a result of (5) all SFC actions/transitions are disable. It is now possible to enable SFC
actions/transitions using the SFC Animation Panel.
8 Set and reset RESUME input.
9 Set SAVE input.
10 Normal operation.

190 33002539 07/2012


SFC_RESTORE

Interaction with SFCCNTRL Function Block

Overview
Some SFC section(s) might also be controlled by SFCCNTRL function block(s).
If inputs DISTRANS and/or DISACT of the SFCCNTRL function block are used, this
will influence the behavior of RESTORE and RESUME inputs of the SFC_RESTORE
function block as described below.

DISRMOTE = 1
In case the DISRMOTE input is 1 the SFCCNTRL function block has the mastership.
After performing a RESTORE or a RESUME with the SFC_RESTORE function block the
value that is present at the inputs DISTRANS / DISACT of the SFCCNTRL function
block will be active.

DISRMOTE = 0
In case the DISRMOTE input is 0 the SFCCNTRL function block and remote control
(SFC Animation Panel or SFC_RESTORE function block) have same level of
priority.
It works as a "wired or": a TRUE from any source will disable transition / action.
To achieve a FALSE value, any source that activates it to TRUE must remove it.
In this case, control coming from the SFC_RESTORE function block has the same
result as SFC Animation Panel, i.e. it is taken as the same source.
After performing a RESTORE, the chart will be in the disabled mode, nevertheless
what value is active at SFCCNTRL function block.
The SFCCNTRL function block could hold it on disabled, but to enable it, SFC
Animation Panel or RESUME input of the SFC_RESTORE function block must be
used.

33002539 07/2012 191


SFC_RESTORE

STATUS Error Messages

Error Handling
The PLC will not enter the HALT state due to storage failure, but a warning is given
in 2 stages:
z Error message is provided at EFB output STATUS.
z Error message is send to diagnostic buffer.

Memory Access Messages


PCMCIA card memory access messages

Code Description
16#0000 action performed correctly
16#0102 ADR_W + SPACE_KW - 1 is greater than the maximum number of
declared words in the PLC
16#0104 no valid application or no word in the PLC
16#0201 no file zone in the memory card
16#0202 memory card error
16#0204 memory card write-protected
16#0241 ADR_W < 0
16#0242 ADR_W + SPACE_KW -1 is greater than the highest address of the memory
card
16#0401 SPACE_KW = 0
16#0402 Slot_Number is different from 0 and 1
16#0501 unsupported service

SFC Specific Messages


New SFC specific messages/warnings have been defined additionally to the
PCMCIA card memory access messages.

Code Description
16#a4F4 End of SAVE model
16#a5F4 RESTORE initiated
16#a6F4 RESUME initiated
16#a7F4 Nothing saved
16#a8F4 Communication lost with SFC_RESTORE EFB
16#a9F4 too much SFC sections for SFC_Restore
16#aaF4 saved data not valid

192 33002539 07/2012


SFC_RESTORE

Code Description
16#abF4 not all charts could be restored / resumed / initialized
16#acF4 memory space too small
16#adF4 application has changed
16#aeF4 an INIT was done due to restore error

NOTE: If more than 1 status has to be reported, only the most significant is shown
at the STATUS output of the EFB. Significance increases with higher numbers (in
hexadecimal or unsigned notification). INIT warning (16#aeF4) is most significant.
NOTE: If error 16#a0F4 (SFC command undefined) is shown at the EFB STATUS,
the OS in the PLC does not support SFC_Restore feature (e.g. wrong version of
OS).

Reports to Diagnostic Buffer


The following events are reported to diagnostic buffer, but not to EFB.

Code Description
16#a4F4 End of SAVE mode
16#a5F4 RESTORE initiated
16#a6F4 RESUME initiated
16#a9F4 too much SFC sections for SFC_Restore

33002539 07/2012 193


SFC_RESTORE

194 33002539 07/2012


Unity Pro
SysClock
33002539 07/2012

SysClock

VI
Overview
This section describes the elementary functions and elementary function blocks of
the SysClock family.

What Is in This Part?


This part contains the following chapters:
Chapter Chapter Name Page
38 FREERUN: Free-running timer 197
39 GET_TS_EVT_M: Reading the Modicon M340 Time Stamped 199
Event Buffer
40 GET_TS_EVT_Q: Reading the Quantum Time Stamped 205
Event Buffer
41 PTC: Reading the stop date and code 211
42 RRTC_DT: Reading the system date 213
43 RRTC_DT_MS: Network real-time clock function 215
44 R_NTPC: Network real-time clock function 219
45 SCHEDULE: Real-time clock function 223
46 WRTC_DT: Updating the system date 227

33002539 07/2012 195


SysClock

196 33002539 07/2012


Unity Pro
FREERUN
33002539 07/2012

FREERUN: Free-running timer

38
Description

Function description
This function enables a free-running counter, which can be used for run time
measurement of sections and application programs.
EN and ENO can be configured as additional parameters.

Run time determination of a section


Determine the run time of a section:

Step Action
1 Place one FREERUN function at the start of the section and one at the end.
2 Use the execution sequence to ensure that the FREERUN function at the start of
the section is executed first and the one at the end of the section is executed last.
3 Calculate the delta of the two values obtained.
Delta displays the run time of the section in microseconds.

Run time determination of a program


Determine the run time of a program:

Step Action
1 Place a FREERUN function at the start of the first section of the program and one
at the end of the last section.
2 Use the execution sequence to ensure that the FREERUN function at the start of
the first section is executed first and the one at the end of the section is executed
last.
3 Calculate the delta of the two values obtained.
This delta displays the run time of the program in microseconds.

33002539 07/2012 197


FREERUN

Representation in FBD
Representation:

Representation in LD
Representation:

Representation in IL
Representation:
FREERUN
ST MeasuredTime

Representation in ST
Representation:
MeasuredTime := FREERUN () ;

Parameter description
Description of the output parameter:

Parameter Data type Meaning


MeasuredTime DINT Shows the time measured since the program started
in microseconds.

198 33002539 07/2012


Unity Pro
GET_TS_EVT_M
33002539 07/2012

GET_TS_EVT_M: Reading the


Modicon M340 Time Stamped
Event Buffer 39
Description

Description of the function


The GET_TS_EVT_M function block gets the time stamped data in a Modicon M340
BMX ERT 1604T module in a local drop. This function allows to read the event
buffer in the source time stamped IO module (BMX ERT 1604T) and to make it
available for the Modicon M340 PLC application.
The additional parameters EN and ENO can be configured.

FBD representation
Representation:

33002539 07/2012 199


GET_TS_EVT_M

LD representation
Representation:

IL representation
Representation:
CAL GET_TS_EVT_M_Instance (ENABLE:=GetTsEnable,
ADR:=ModuleAddress, ABORT:=GetTsAbort,
NUMBER:=NbEventsToRead, TIMEOUT:=TimeToWait, CMD:=ModuleCmd,
DONE=>GetTsSuccessfull, ACTIVE=>GetTsActive,
ERROR=>GetTsFaulty, STATUS=>ErrorCode, DIAG_BUFF=>DiagBuffer,
BUFFER=>TimeStamp, NB_EVT=>NbNewEvents)

ST representation
Representation:
GET_TS_EVT_M_Instance (ENABLE:=GetTsEnable,
ADR:=ModuleAddress, ABORT:=GetTsAbort,
NUMBER:=NbEventsToRead, TIMEOUT:=TimeToWait, CMD:=ModuleCmd,
DONE=>GetTsSuccessfull, ACTIVE=>GetTsActive,
ERROR=>GetTsFaulty, STATUS=>ErrorCode, DIAG_BUFF=>DiagBuffer,
BUFFER=>TimeStamp, NB_EVT=>NbNewEvents)

200 33002539 07/2012


GET_TS_EVT_M

Description of the parameters


The following table describes the input parameters:

Parameter Type Comment


ENABLE BOOL Set to 1 to send the request to the concerned module.
ADR ANY_ARRAY_INT Array containing the Modbus slave address, result of
ADDM (see Unity Pro, Communication, Block
Library) function.
ABORT BOOL Set to 1 to abort the current operation.
NUMBER INT Maximum number of events to be read in the module
local buffer.
TIMEOUT INT Maximum time to wait for the drop reply.
CMD INT Set to:
z 0: read the module buffer
z 1: reset the module buffer

The following table describes the output parameters:

Parameter Type Comment


DONE BOOL Function block completed indication. Set to 1 when the
execution of the function block is completed
successfully.
ACTIVE BOOL Function block in progress indication. Set to 1 when the
execution of the function block is in progress.
ERROR BOOL Set to 1 if an error is detected by the function block.
STATUS WORD Code providing a communication and operation report
(see page 202).
z Byte 0: communication report
z Byte 1: operation report

DIAG_BUFF ANY_ARRAY_INT Description:


z Byte 0: Percentage of buffer filled
z Byte 1: Diagnostic flags

33002539 07/2012 201


GET_TS_EVT_M

Parameter Type Comment


BUFFER ANY_ARRAY_INT Raw buffer containing event time stamp entries:
z Word 0:
z Byte 0: Reserved
z Byte1: Value of the variable after change
detection
z Word 1: Event ID
z Word 2: Number of seconds since 1970/01/01
midnight (Bit 15 to 0)
z Word 3: Number of seconds since 1970/01/01
midnight (Bit 31 to 16)
z Word 4: Fraction of second (Bit 15 to 0)
z Word 5:
z Byte 0: Fraction of second (Bit 23 to 16)
z Byte 1: Time quality

NB_EVENT INT Number of new events read in the BMX ERT 1604T
local buffer.

The following table describes the input/output parameters:

Parameter Type Comment


CTRLSTAMP DDT CTRL_STAMP Specifies the CPU raw record buffer:
z BEGIN index: INT
z END index: INT
z Operating MODE (a detailed description of the
Operating mode word (see page 203) is given
below): WORD.

STATUS Parameter Description


The following table describes the STATUS parameter:

Communication Report (byte 0) Operation Report (byte 1)


Value Description Value Description
00 hex Correct exchange (request processed 00 hex Positive result
successfully)
01 hex The number of events in the PLC buffer reaches
the maximal value.
02 hex The buffer is full and events have been
overwritten since the last exchange.
04 hex Buffer is full and the recording stops
01 hex Exchange stop on timeout 00 hex Default value
02 hex Exchange stop on user request (CANCEL) 00 hex Default value
03 hex Incorrect address format 00 hex Default value
04 hex Incorrect destination address 00 hex Default value

202 33002539 07/2012


GET_TS_EVT_M

Communication Report (byte 0) Operation Report (byte 1)


Value Description Value Description
06 hex Incorrect specific parameters 01 hex Invalid CMD parameter.
02 hex User parameters have changed between 2
invocations while the EFB execution is active.
09 hex Insufficient receive buffer size (<1 EVT) 00 hex Default value
0B hex No processor system resources 00 hex Default value
FF hex Incorrect exchange (request processed FF hex General communication error
with failure)

NOTE: ENO parameter is set to 1 on a correct exchange.

CTRLSTAMP Parameter Description


CTRL_STAMP DDT structure example and link with the PLC buffer:

The example above shows the CTRL_STAMP content after writing 32 events (1 event
entry is 6 words long) in the PLC buffer configured as follows:
z PLC buffer is located on %MW100 and there are 32 events to write
z Stop the recording when the buffer is full and continue with the previous value on
power on.
Operating MODE word structure:

33002539 07/2012 203


GET_TS_EVT_M

204 33002539 07/2012


Unity Pro
GET_TS_EVT_Q
33002539 07/2012

GET_TS_EVT_Q: Reading the


Quantum Time Stamped Event
Buffer 40
Description

Description of the function


The GET_TS_EVT_Q function block gets the time stamped data in a Modicon M340
BMX CRA 312 10 Ethernet RIO module or in a Modicon M340 BMX ERT 1604T
module in a remote IO drop (Quantum architecture). This function allows to read the
event buffer in the source time stamped IO module (BMX CRA 312 10 or
BMX ERT 1604T) and to make it available for the Quantum PLC application.
The additional parameters EN and ENO can be configured.

FBD representation
Representation:

33002539 07/2012 205


GET_TS_EVT_Q

LD representation
Representation:

IL representation
Representation:
CAL GET_TS_EVT_Q_Instance (ENABLE:=GetTsEnable,
ADR:=ModuleAddress, ABORT:=GetTsAbort,
NUMBER:=NbEventsToRead, TIMEOUT:=TimeToWait, CMD:=ModuleCmd,
DONE=>GetTsSuccessfull, ACTIVE=>GetTsActive,
ERROR=>GetTsFaulty, STATUS=>ErrorCode, DIAG_BUFF=>DiagBuffer,
BUFFER=>TimeStamp, NB_EVT=>NbNewEvents)

ST representation
Representation:
GET_TS_EVT_Q_Instance (ENABLE:=GetTsEnable,
ADR:=ModuleAddress, ABORT:=GetTsAbort,
NUMBER:=NbEventsToRead, TIMEOUT:=TimeToWait, CMD:=ModuleCmd,
DONE=>GetTsSuccessfull, ACTIVE=>GetTsActive,
ERROR=>GetTsFaulty, STATUS=>ErrorCode, DIAG_BUFF=>DiagBuffer,
BUFFER=>TimeStamp, NB_EVT=>NbNewEvents)

206 33002539 07/2012


GET_TS_EVT_Q

Description of the parameters


The following table describes the input parameters:

Parameter Type Comment


ENABLE BOOL Set to 1 to send the request to the concerned module.
ADR ANY_ARRAY_INT Array containing the Modbus slave address, result of
ADDMX (see Unity Pro, Communication, Block
Library) function.
ABORT BOOL Set to 1 to abort the current operation.
NUMBER INT Maximum number of events to be read in the module
local buffer.
TIMEOUT INT Maximum time to wait for the drop reply.
CMD INT Set to:
z 0: read the module buffer
z 1: reset the module buffer

The following table describes the output parameters:

Parameter Type Comment


DONE BOOL Function block completed indication. Set to 1 when the
execution of the function block is completed
successfully.
ACTIVE BOOL Function block in progress indication. Set to 1 when the
execution of the function block is in progress.
ERROR BOOL Set to 1 if an error is detected by the function block.
STATUS WORD Code providing a communication and operation report
(see page 208)
z Byte 0: communication report
z Byte 1: operation report

DIAG_BUFF ANY_ARRAY_INT Description:


z Byte 0: Percentage of buffer filled
z Byte 1: Diagnostic flags

33002539 07/2012 207


GET_TS_EVT_Q

Parameter Type Comment


BUFFER ANY_ARRAY_INT Raw buffer containing event time stamp entries:
z Word 0:
z Byte 0: Reserved
z Byte1: Value of the variable after change
detection
z Word 1: Event ID
z Word 2: Number of seconds since 1970/01/01
midnight (Bit 15 to 0)
z Word 3: Number of seconds since 1970/01/01
midnight (Bit 31 to 16)
z Word 4: Fraction of second (Bit 15 to 0)
z Word 5:
z Byte 0: Fraction of second (Bit 23 to 16)
z Byte 1: Time quality

NB_EVENT INT Number of new events read in the BMX CRA 312 10 or
BMX ERT 1604T local buffer (Ethernet RIO drop).

The following table describes the input/output parameters:

Parameter Type Comment


CTRLSTAMP DDT CTRL_STAMP Specifies the CPU raw record buffer:
z BEGIN index: INT
z END index: INT
z Operating MODE (a detailed description of the
Operating mode word (see page 209) is given
below): WORD.

STATUS Parameter Description


The following table describes the STATUS parameter:

Communication Report (byte 0) Operation Report (byte 1)


Value Description Value Description
00 hex Correct exchange (request processed 00 hex Positive result
successfully)
01 hex The number of events in the PLC buffer reaches
the maximal value.
02 hex The buffer is full and events have been
overwritten since the last exchange.
04 hex Buffer is full and the recording stops
01 hex Exchange stop on timeout 00 hex Default value
02 hex Exchange stop on user request (CANCEL) 00 hex Default value
03 hex Incorrect address format 00 hex Default value
04 hex Incorrect destination address 00 hex Default value

208 33002539 07/2012


GET_TS_EVT_Q

Communication Report (byte 0) Operation Report (byte 1)


Value Description Value Description
06 hex Incorrect specific parameters 01 hex Invalid CMD parameter.
02 hex User parameters have changed between 2
invocations while the EFB execution is active.
09 hex Insufficient receive buffer size (<1 EVT) 00 hex Default value
0B hex No processor system resources 00 hex Default value
FF hex Incorrect exchange (request processed FF hex General communication error
with failure)

NOTE: ENO parameter is set to 1 on a correct exchange.

CTRLSTAMP Parameter Description


CTRL_STAMP DDT structure example and link with the PLC buffer:

The example above shows the CTRL_STAMP content after writing 32 events (1 event
entry is 6 words long) in the PLC buffer configured as follows:
z PLC buffer is located on %MW100 and there are 32 events to write
z Stop the recording when the buffer is full and continue with the previous value on
power on.
Operating MODE word structure:

33002539 07/2012 209


GET_TS_EVT_Q

210 33002539 07/2012


Unity Pro
PTC
33002539 07/2012

PTC: Reading the stop date and


code
41
Description

Description of the function


The PTC function reads the date and code of the most recent PLC stop, and saves
the information in an integer table.
The additional parameters EN and ENO can be configured.

FBD representation
Representation:

LD representation
Representation:

IL representation
Representation:
PTC
ST Stop_Date

33002539 07/2012 211


PTC

ST representation
Representation:
PTC (Stop_Date);

Description of the parameters


The following table describes the output parameters:

Parameter Type Comment


Stop_Date ARRAY [0..4] OF INT Table of 5 integers containing the date in the first four
words (equivalent of %SW54 (see page 266) to
%SW57 (see page 266)) and the error code
in the last word. The error code is the
one indicated in the %SW58 (see page 266)
system word:
z 1 = switch from RUN to STOP by the terminal,
z 2 = stop on software fault (PLC task overflow),
z 4 = mains power cut,
z 5 = stop on hardware fault,
z 6 = stop on HALT instruction.

Example: Stop at 22:53:10 on January 8, 2001. The


contents of Stop_Date were as follows:
Stop_Date[0]=16#0010
Stop_Date[1]=16#2253
Stop_Date[2]=16#0108
Stop_Date[3]=16#2001
Stop_Date[4]=16#0006

212 33002539 07/2012


Unity Pro
RRTC_DT
33002539 07/2012

RRTC_DT: Reading the system


date
42
Description

Description of the function


The RRTC_DT function captures the current date from the PLCs real-time clock.
You have to configure at least once the PLC Time with Unity Pro in the PLC Screen
(tab Real-time clock).
The additional parameters EN and ENO can be configured.

FBD representation
Representation:

LD representation
Representation:

33002539 07/2012 213


RRTC_DT

IL representation
Representation:
RRTC_DT
ST Result_Date

ST representation
Representation:
RRTC_DT(Result_Date);

Description of the parameters


The following table describes the output parameters:

Parameter Type Comment


Result_Date DT Result_Date contains the current date value in DT
format.

214 33002539 07/2012


Unity Pro
RRTC_DT_MS
33002539 07/2012

RRTC_DT_MS: Network real-time


clock function
43
Description

Description of the Function


The RRTC_DT_MS function is used to recover the PLC date and time in 10 ms
precision. The function result will be returned by two outputs that have different
format:
z A display format.
z A calculation format.
The additional parameters EN and ENO can be configured.

FBD Representation
Representation:

33002539 07/2012 215


RRTC_DT_MS

LD Representation
Representation:

IL Representation
Representation:
RRTC_DT_MS(Display, Calc, Status)

ST Representation
Representation:
RRTC_DT_MS(Display, Calc, Status);

Description of the Parameters


The following table describes the output parameters:

Parameter Type Comment


Display Display_NTPC The Display output contains the PLC date and time.
The Display_NTPC type is a predefined structure
comprising a DT type element and an INT type element.
This gives us:
z Display.DT_value containing the date,
z Display.Milisecond containing the number of
milliseconds of this date, as the second is the
minimum measurement unit for the DT format.

216 33002539 07/2012


RRTC_DT_MS

Parameter Type Comment


Calc Calc_NTPC The Calc output contains the PLC date and time (as in
a Display variable, only with a different format). The
Calc_NTPC type is a predefined structure comprising a
UDINT type element and an INT type element. This
gives us:
z Calc.Seconds containing the number of seconds
passed since January 1, 1980, at 00:00.
z Calc.Fraction_Second containing the number of
milliseconds to add for the precision of the result to
be around a millisecond.
STATUS INT The STATUS output can have the following values:
z 0: valid date and time returned,
z 16#3200: impossible to return a valid date and time
in the case of an access clash for the real-time clock,
z 16#32FF: real-time clock is missing in PLC.

33002539 07/2012 217


RRTC_DT_MS

218 33002539 07/2012


Unity Pro
R_NTPC
33002539 07/2012

R_NTPC: Network real-time clock


function
44
Description

Description of the Function


The R_NTPC function is available for M340, Premium and Quantum PLCs. It is used
to recover the date and time for an NTP server in two formats:
z A display format.
z A calculation format.
NOTE: This function requires connection to an Ethernet network enabling access to
an NTP (see Modicon Quantum with Unity, Ethernet Network Modules, User
Manual) server.
The additional parameters EN and ENO can be configured.

FBD Representation
Representation:

33002539 07/2012 219


R_NTPC

LD Representation
Representation:

IL Representation
Representation:
R_NTPC(Display, Calc, Status)

ST Representation
Representation:
R_NTPC(Display, Calc, Status);

Description of the Parameters


The following table describes the output parameters:

Parameter Type Comment


Display Display_NTPC The Display output contains the date and time
acquired on an NTP server. The Display_NTPC type
is a predefined structure comprising a DT type element
and an INT type element. This gives us:
z Display.DT_value containing the date,
z Display.Milisecond containing the number of
milliseconds of this date, as the second is the
minimum measurement unit for the DT format.

220 33002539 07/2012


R_NTPC

Parameter Type Comment


Calc Calc_NTPC The Calc output contains the date and time acquired
on an NTP server (as in a Display variable, only with
a different format). The Calc_NTPC type is a
predefined structure comprising a UDINT type element
and an INT type element. This gives us:
z Calc.Seconds containing the number of seconds
passed since January 1, 1900, at 00:00.
z Calc.Fraction_Second containing the number of
milliseconds to add for the precision of the result to
be around a millisecond.
STATUS INT The low byte is managed by the CPU. When the low
byte is set to 0:
z the clock value is not available
z the date and time are not updated within last two
minutes
When the low byte is set to 1:
z the date and time are updated within the last two
minutes
z the date and time are acceptable

The high byte is managed by the Ethernet module.


When the high byte is set to 0, the clock value
transferred to CPU is not acceptable.
When the high byte is set to 1, the updated date/time
received from server and sent to module is:
z within two minute time interval
z acceptable (10 ms or less error)

For a valid time in CPU, the low and high bytes of the STATUS parameter
must be set to 1.

33002539 07/2012 221


R_NTPC

222 33002539 07/2012


Unity Pro
SCHEDULE
33002539 07/2012

SCHEDULE: Real-time clock


function
45
Description

Description of the function


The SCHEDULE function is used to control actions at pre-defined or calculated times
and dates.
It sets the OUT output to 1 if the date provided by the PLC clock at the time the
function is called falls within the period programmed in the input parameters.
The additional parameters EN and ENO can be configured.

FBD representation
Representation:

33002539 07/2012 223


SCHEDULE

LD representation
Representation:

IL representation
Representation:
LD DBEG
SCHEDULE DEND, WEEK, HBEG, HEND, Date_OK

ST representation
Representation:
SCHEDULE(DBEG, DEND, WEEK, HBEG, HEND, Date_OK);

Description of the parameters


The following table describes the input parameters:

Parameter Type Comment


DBEG INT Integer coding the start date of the period (month-day) in BCD
(threshold values: 01-01 to 12-31).
DEND INT Integer coding the end date of the period (month-day) in BCD
(threshold values: 01-01 to 12-31).
WEEK INT Integer coding the day(s) of the week taken into account in the
period defined by the DBEG and DEND parameters.
The 7 least significant bits represent the 7 days of the week:
bit 6 = Monday, bit 5 = Tuesday, etc., bit 0 = Sunday.
HBEG DINT Double integer coding the start time of the period in the day
(hours-minutes-seconds) in BCD day time format. Threshold
values: 00:00:00, 23:59:59.

224 33002539 07/2012


SCHEDULE

Parameter Type Comment


HEND DINT Double integer coding the end time of the period in the day
(hours-minutes-seconds) in BCD day time format. Threshold
values : 00:00:00, 23:59:59.

The following table describes the output parameters:

Parameter Type Comment


Date_OK EBOOL The Date_OK output is set to 1 if the date provided by the
PLC clock at the time the function is called falls within the
period programmed in the input parameters.

NOTE:
z The two parameters DBEG and DEND define a range of days in the year. This
period may extend over two calendar years. Example : from October 10 to April
7. February 29 may be used in this period, and will be ignored in non-leap years.
z The two parameters HBEG and HEND define a range of time in the day. This range
may extend over two days. Example : from 22:00 to 06:10:20.
z If one of the DBEG and DEND dates, or one of the HBEG and HEND times is
incorrect, (i.e. does not correspond to a real date or time) the Date_OK output will
be 0 and the %S18 bit will be set to 1.
z It is possible to lighten the load on the PLC processor when the requirement for
precision is low by pacing calls to the SCHEDULE function via the %S6 or %S7
system bits.

Examples
Programming two non-continuous time ranges:

SCHEDULE (16#0501, (*start date: 1st May*)


16#1031, (*end date: October 31*)
2#0000000001111100, (*Monday to Friday*)
16"08300000, (*start time: 08:30*)
16#12000000, (*end time: 12:00*)
Date1_OK); (*result in Date1_OK*)
SCHEDULE (16#0501, (*start date: 1st May*)
16#1031, (*end date: October 31*)
2#0000000001111100, (*Monday to Friday*)
16"14000000, (*start time: 14:00*)
16#18000000, (*end time: 18:00*)
Date2_OK); (*result in Date2_OK*)
%Q0.0 :=Date1_OK OR Date2_OK; (*assignment of the output to Date1_OK or
Date2_OK*)

33002539 07/2012 225


SCHEDULE

226 33002539 07/2012


Unity Pro
WRTC_DT
33002539 07/2012

WRTC_DT: Updating the system


date
46
Description

Description of the function


The WRTC_DT function updates the current date in the PLCs real-time clock.
The additional parameters EN and ENO can be configured.

FBD representation
Representation:

LD representation
Representation:

IL representation
Representation:
LD Date1
WRTC_DT

33002539 07/2012 227


WRTC_DT

ST representation
Representation:
WRTC_DT(Date1);

Description of the parameters


The following table describes the input parameters:

Parameter Type Comment


Date1 DT Date1 must contain the current date value in DT
format. The contents of this variable must be assigned
by the program before launching the function.

228 33002539 07/2012


Unity Pro
System Specials
33002539 07/2012

System Specials

VII
Overview
This section describes the elementary functions and elementary function blocks of
the System Specials family.

What Is in This Part?


This part contains the following chapters:
Chapter Chapter Name Page
47 IS_PAR_CON: Is Parameter Connected 231
48 IS_BIT_FORCED:Function Block 235
49 UNFORCE_BIT: Function Block 237
50 FORCE_BIT : Function Block 239
51 SIG_WRITE: Write a Signature 241
52 SIG_CHECK: Check a Signature 245

33002539 07/2012 229


System Specials

230 33002539 07/2012


Unity Pro
IS_PAR_CON
33002539 07/2012

IS_PAR_CON: Is Parameter
Connected
47
Introduction
This chapter describes the function block IS_PAR_CON.

What Is in This Chapter?


This chapter contains the following topics:
Topic Page
Description 232
How to Use 234

33002539 07/2012 231


IS_PAR_CON

Description

Function description
This function is used in a DFB code to know if an input parameter (pin) or an
input/output parameter (pin) is connected or linked to a variable when you use an
instance of this DFB.
NOTE: The function is only usable inside a DFB code. It is not pertmitted to use
IS_PAR_CON outside a DFB code.
In the DFB code you must enter the name of the input or input/output parameters
you want to check. It is not possible to enter the pin number. Please refer to
Example, page 234.
EN and ENO can be configured as additional parameters.

Representation in FBD
Representation:

Representation in LD
Representation:

Representation in IL
Representation:
LD Pin_to_check
IS_PAR_CON
ST Result

232 33002539 07/2012


IS_PAR_CON

Representation in ST
Representation:
Result := IS_PAR_CON (Pin_to_check) ;

Parameter description
Description of the input parameters:

Parameter Data type Meaning


INP Any name of the parameter (DFB pin) to be checked

Description of the output parameter:

Parameter Data type Meaning


OUTP BOOL 1: Parameter (DFB pin) is connected
0: Parameter (DFB pin) is not connected

33002539 07/2012 233


IS_PAR_CON

How to Use

Example
In the example, the input parameters (pins) of the following DFB shall be checked
whether they are connected or not.

In this case the code of the DFB looks as follows:


(* Functional code of MY_COUNTER *)
IF RE (Reset) THEN
internal_value:=0;
END_IF;
IF RE (Count) THEN
internal_value:=internal_value+1;
END_IF;IF(internal_value>=Preset) THEN
SET (Done);
ELSE
RESET (Done);
END_IF;

(* Check if parameters are connected *)


ResetConnected := IS_PAR_CON (Reset) ;
PresetConnected := IS_PAR_CON (Preset) ;
CountConnected := IS_PAR_CON (Count) ;

234 33002539 07/2012


Unity Pro
IS_BIT_FORCED
33002539 07/2012

IS_BIT_FORCED:Function Block

48
Description

Function description
The IS_BIT_FORCED function tests if a boolean variable of type EBOOL is forced.
The additional parameters EN and ENO can be configured.

Representation in LD
Representation:

Representation in FBD
Representation:

Representation in IL
Representation:
LD %M0
IS_BIT_FORCED
ST Output

33002539 07/2012 235


IS_BIT_FORCED

Representation in ST
Representation:
Output:= IS_BIT_FORCED(%M0);

Description of parameters
The following table describes the input parameter:

Parameter Type Comment


IN EBOOL Variable to be tested as forced

The following table describes the output parameter:

Parameter Type Comment


OUT BOOL Result:
z true if IN is forced
z false if IN is not forced

236 33002539 07/2012


Unity Pro
UNFORCE_BIT
33002539 07/2012

UNFORCE_BIT: Function Block

49
Description

Function description
The UNFORCE_BIT function unforces a boolean variable of type EBOOL. If the
variable is not forced, this EF has not effect.
This EF is only available for variables responding to these conditions:
z the variable must be an EBOOL type,
z it must be a located variable.

The additional parameters EN and ENO can be configured.


NOTE: The EN input parameter should be a variable that could be modified in an
animation table. Resetting the EN input variable will stop the EF execution and so
allow to force or unforce a variable with an animation table.
NOTE:
The behavior of forced outputs (%M) is different for Modsoft/NxT/Concept and Unity
Pro.
z With Modsoft/NxT/Concept you cannot force outputs when the Memory Protect
switch of the Quantum CPU is set to the "On" position.
With Unity Pro you can force outputs even when the Memory Protect switch of
the Quantum CPU is set to the "On" position.
z With Modsoft/NxT/Concept, forced outputs maintain their values following to a
cold start.
With Unity Pro, forced outputs lose their values following to a cold start.

WARNING
UNEXPECTED VARIABLE BEHAVIOR
Ensure that the behavior of the forced outputs is consistent with the application.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

33002539 07/2012 237


UNFORCE_BIT

Representation in LD
Representation:

Representation in FBD
Representation:

Representation in IL
Representation:
LD %M0
UNFORCE_BIT

Representation in ST
Representation:
UNFORCE_BIT (%M0,0);

Description of parameters
The following table describes the input parameter:

Parameter Type Comment


IN EBOOL Variable to be unforced

238 33002539 07/2012


Unity Pro
FORCE_BIT
33002539 07/2012

FORCE_BIT : Function Block

50
Description

Function description
The FORCE_BIT function allows to force a boolean variable of type EBOOL to 0 or 1.
I f the variable is already forced to 0 (or to 1), this EF can change the forced value
to 1 (or to 0) without needing to call the UNFORCE_BIT EF before.
This EF is only available for variables responding to these conditions:
z the variable must be an EBOOL type,
z it must be a located variable.

The additional parameters EN and ENO can be configured.


NOTE: The EN input parameter should be a variable that could be modified in an
animation table. Resetting the EN input variable will stop the EF execution and so
allow to force or unforce a variable with an animation table.
NOTE:
The behavior of forced outputs (%M) is different for Modsoft/NxT/Concept and Unity
Pro.
z With Modsoft/NxT/Concept you cannot force outputs when the Memory Protect
switch of the Quantum CPU is set to the "On" position.
With Unity Pro you can force outputs even when the Memory Protect switch of
the Quantum CPU is set to the "On" position.
z With Modsoft/NxT/Concept, forced outputs maintain their values following to a
cold start.
With Unity Pro, forced outputs lose their values following to a cold start.

WARNING
UNEXPECTED VARIABLE BEHAVIOR
Ensure that the behavior of the forced outputs is consistent with the application.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.

33002539 07/2012 239


FORCE_BIT

Representation in LD
Representation:

Representation in FBD
Representation:

Representation in IL
Representation:
LD %M0
FORCE_BIT

Representation in ST
Representation:
FORCE_BIT (%M0,1);

Description of parameters
The following table describes the input parameters:

Parameter Type Comment


VARIABLE EBOOL Variable to be forced
VALUE BOOL Forcing value

240 33002539 07/2012


Unity Pro
SIG_WRITE
33002539 07/2012

SIG_WRITE: Write a Signature

51
SIG_WRITE: Write a Signature in Memory Card

Function Description
The SIG_WRITE function allows writing a specific signature to a memory card
BMX RM . An application embedding the SIG_CHECK EF only runs on a memory
card that contains an expected signature.
SIG_WRITE writes a signature to the memory card inserted in a BMX P34 CPU.
The signature consists of 8 words (16 bytes).
This EF can take several tenths of milliseconds to perform a physical write to the
memory card, therefore, make sure that the application can support the extra time.
NOTE: %S62 is set to 1 when a card contains a signature, no matter what the value
of the 8 words written.
NOTE: This EF can only be used on a BMX P34 , Version 2.2 or higher.

FBD Representation
The representation in FBD of the SIG_WRITE function (with example data) is as
follows:

33002539 07/2012 241


SIG_WRITE

Ladder Representation
The representation in Ladder of the SIG_WRITE function (with example data) is as
follows:

IL Representation
The representation in IL of the SIG_WRITE function (with example data) is as
follows:
SIG_WRITE (
SIG0 := 16#45de,
SIG1 := 16#78aa,
SIG2 := 16#2cde,
SIG3 := 16#ac3f,
SIG4 := 16#5c81,
SIG5 := 16#2702,
SIG6 := 16#b312,
SIG7 := 16#2ed4,
)
ST sigStat

ST Representation
The representation in ST of the SIG_WRITE function is as follows:
STATUS:=SIG_WRITE(SIG0, SIG1, SIG2, SIG3, SIG4, SIG5, SIG6,
SIG7);

242 33002539 07/2012


SIG_WRITE

Parameter Description
The following table describes the SIG_WRITE Input parameters:

Parameter Type Comment


SIG0..SIG7 WORD 8 Words containing the signature to write into the
memory card

The following table describes the SIG_WRITE Output parameters:

Parameter Type Comment


STATUS WORD Result of writing operation:
1. No detected error
2. Detected error, such as no memory card or the card
is write protected

33002539 07/2012 243


SIG_WRITE

244 33002539 07/2012


Unity Pro
SIG_CHECK
33002539 07/2012

SIG_CHECK: Check a Signature

52
SIG_CHECK: Check Signature in Memory Card

Function Description
The SIG_CHECK function prevents an application from running when the SD-card
does not have the expected signature.
The signature consists of 8 words (16 bytes). Use the SIG_WRITE (see page 241)
function to write the signature to a SD-card.
This EF checks a signature given as parameter against the one that is stored in the
memory card BMX RM inserted in the CPU.
If the signature in the memory card is different, the CPU goes to the Halt state with
error code 0002 in %SW125.
NOTE: %S62 is set to 1 when a card contains a signature, no matter the value of the
8 words written.
NOTE: This EF can only be used on a BMX P34 , Version 2.2 or higher.

33002539 07/2012 245


SIG_CHECK

FBD Representation
The representation in FBD of the SIG_CHECK function (with example data) is as
follows:

Ladder Representation
The representation in LD of the SIG_CHECK function (with example data) is as
follows:

246 33002539 07/2012


SIG_CHECK

IL Representation
The representation in IL of the SIG_CHECK function (with example data) is as
follows:
SIG_CHECK (
SIG0 := 16#45de,
SIG1 := 16#78aa,
SIG2 := 16#2cde,
SIG3 := 16#ac3f,
SIG4 := 16#5c81,
SIG5 := 16#2702,
SIG6 := 16#b312,
SIG7 := 16#2ed4,
)
ST %M0

ST Representation
The representation in ST of the SIG_CHECK function is as follows:
SIG_CHECK(SIG0, SIG1, SIG2, SIG3, SIG4, SIG5, SIG6, SIG7);

Parameter Description
The following table describes the SIG_CHECK Input parameters:

Parameter Type Comment


SIG0..SIG7 WORD Words containing the signature to check

The following table describes the SIG_CHECK Output parameters:

Parameter Type Comment


OUTP BOOL Always TRUE
ENO BOOL Always TRUE

33002539 07/2012 247


SIG_CHECK

248 33002539 07/2012


Unity Pro

33002539 07/2012

Appendices

33002539 07/2012 249


250 33002539 07/2012
Unity Pro
System objects
33002539 07/2012

System objects

A
Subject of this Chapter
This chapter describes the system bits and words of Unity Pro language.
Note: The symbols, associated with each bit object or system word, mentioned in
the descriptive tables of these objects, are not implemented as standard in the
software, but can be entered using the data editor.
They are proposed in order to ensure the homogeneity of their names in the different
applications.

What Is in This Chapter?


This chapter contains the following topics:
Topic Page
System Bit Introduction 252
Description of System Bits %S0 to %S7 253
Description of System Bits %S15 to %S21 255
Description of System Bits %S30 to %S59 258
Description of System Words %SW12 to %SW29 261
Description of System Words %SW48 to %SW59 266
Description of Quantum System Words %SW60 to %SW66 268

33002539 07/2012 251


System objects

System Bit Introduction

General
The Modicon M340, Premium, Atrium and Quantum PLCs use %Si system bits
which indicate the state of the PLC, or they can be used to control how it operates.
These bits can be tested in the user program to detect any functional development
requiring a set processing procedure.
Some of these bits must be reset to their initial or normal state by the program.
However, the system bits that are reset to their initial or normal state by the system
must not be reset by the program or by the terminal.

252 33002539 07/2012


System objects

Description of System Bits %S0 to %S7

Detailed Description
Description of system bits %S0 to %S7:

Bit Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%S0 Cold start Normally on 0, this bit is set on 1 by: 1 YES YES YES
COLDSTART z power restoral with loss of data (battery (1 cycle)
fault)
z the user program
z the terminal
z a change of cartridge

This bit is set to 1 during the first complete


restored cycle of the PLC either in RUN or in
STOP mode. It is reset to 0 by the system
before the following cycle.
To detect the first cycle in run after cold
start, please refer to %SW10.
In Safe mode, this bit is not available on
Quantum safety PLCs.
%S0 is not always set in the first scan of the
PLC. If a signal set for every start of the PLC
is needed, %S21 should be used instead.
For Premium and Quantum, Processing on
Cold Start for Premium/Quantum PLCs
(see Unity Pro, Program Languages and
Structure, Reference Manual )
For Modicon M340, Processing on Cold
Start for Modicon M340 PLCs (see Unity
Pro, Program Languages and Structure,
Reference Manual )
%S1 Warm Normally at 0, this bit is set to 1 by: 0 YES YES YES
WARMSTART restart z power is restored with data save, (except
z the user program, for safety
z the terminal, PLCs)
It is reset to 0 by the system at the end of the
first complete cycle and before the outputs
are updated.
This bit is not available on Quantum safety
PLCs.
%S1 is not always set in the first scan of the
PLC. If a signal set for every start of the PLC
is needed, %S21 should be used instead.

33002539 07/2012 253


System objects

Bit Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%S4 Timebase An internal timer regulates the change in - YES YES YES
TB10MS 10 ms status of this bit. (except
It is asynchronous in relation to the PLC for safety
cycle. PLCs)
Graph:

This bit is not available on Quantum safety


PLCs.
%S5 Timebase Idem %S4 - YES YES YES
TB100MS 100 ms (except
for safety
PLCs)
%S6 Time base Idem %S4 - YES YES YES
TB1SEC 1s (except
for safety
PLCs)
%S7 Time base Idem %S4 - YES YES YES
TB1MIN 1 min (except
for safety
PLCs)

254 33002539 07/2012


System objects

Description of System Bits %S15 to %S21

Detailed Description
Description of system bits %S15 to %S21:

Bit Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%S15 Character Normally set to 0, this bit is set to 1 when 0 YES YES YES
STRINGERROR string fault the destination zone for a character string (except for
transfer is not of sufficient size (including safety
the number of characters and the end of PLCs)
string character) to receive this character
string.
The application stops in error state if the
%S78 bit has been to set to 1.
This bit must be reset to 0 by the
application.
This bit is not available on Quantum safety
PLCs.
%S16 Task Normally set to 1, this bit is set to 0 by the 1 YES YES YES
IOERRTSK input/output system when a fault on an in-rack module
fault or device on Fipio is detected (e.g. non-
compliant configuration, exchange fault,
hardware fault, etc.).
This bit must be reset to 1 by the user.

CAUTION
UNEXPECTED APPLICATION BEHAVIOR - SPECIFIC VARIABLE BEHAVIOR
On Quantum, network communication errors with remote devices detected by
communication modules (NOM, NOE, NWM, CRA, CRP) and motion modules
(MMS) are not reported on bits %S10, %S16 and %S119.
Failure to follow these instructions can result in injury or equipment damage.

33002539 07/2012 255


System objects

Bit Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%S17 Rotate shift Normally at 0. 0 YES YES YES
CARRY output During a rotate shift operation, this bit
takes the state of the outgoing bit.
%S18 Overflow or Normally set to 0, this bit is set to 1 in the 0 YES YES YES
OVERFLOW arithmetic event of a capacity overflow if there is:
error z a result greater than + 32 767 or less
than - 32 768, in single length,
z result greater than + 65 535, in
unsigned integer,
z a result greater than + 2 147 483 647
or less than - 2 147 483 648, in double
length,
z result greater than +4 294 967 296, in
double length or unsigned integer,
z real values outside limits,
z division by 0,
z the root of a negative number,
z forcing to a non-existent step on a
drum,
z stacking up of an already full register,
emptying of an already empty register.
There is only one case for which bit %S18
is not raised by the Modicon M340 PLCs
when real values are outside limits. It is
only if denormalized operands or some
operations which generate denormalized
results are used (gradual underflow).
It must be tested by the user program after
each operation where there is a risk of
overflow, then reset to 0 by the user if
there is indeed an overflow.
When the %S18 bit switches to 1, the
application stops in error state if the %S78
bit has been to set to 1.
%S19 Task period Normally set to 0, this bit is set to 1 by the 0 YES YES YES
OVERRUN overrun system in the event of a time period
(periodical overrun (i.e. task execution time is greater
scanning) than the period defined by the user in the
configuration or programmed into the
%SW word associated with the task). The
user must reset this bit to 0. Each task
manages its own %S19 bit.

256 33002539 07/2012


System objects

Bit Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%S20 Index Normally set to 0, this bit is set to 1 when 0 YES YES YES
INDEXOVF overflow the address of the indexed object (except
becomes less than 0 or exceeds the for safety
number of objects declared in the PLCs)
configuration.
In this case, it is as if the index were equal
to 0.
It must be tested by the user program after
each operation where there is a risk of
overflow, then reset to 0 if there is indeed
an overflow.
When the %S20 bit switches to 1, the
application stops in error state if the %S78
bit has been to set to 1.
This bit is not available on Quantum safety
PLCs.
%S21 First task Tested in a task (Mast, Fast, Aux0, Aux1, 0 YES YES YES
1RSTTASKRUN cycle Aux2 Aux3), the bit %S21 indicates the
first cycle of this task, including after a cold
start with automatic start in run and a
warm start. %S21 is set to 1 at the start of
the cycle and reset to zero at the end of
the cycle.
Note: The bit %S21 does not have the
same meaning in PL7 as in Unity Pro.

33002539 07/2012 257


System objects

Description of System Bits %S30 to %S59

Detailed Description
Description of system bits %S30 to %S59:

Bit Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%S30 Activation/deactivation Normally set to 1. The master 1 YES YES YES
MASTACT of the master task task is deactivated when the (except for
user sets the bit to 0. safety
This bit is taken into PLCs)
consideration by the system at
the end of each MAST task
cycle.
This bit is not available on
Quantum safety PLCs.
%S31 Activation/deactivation Normally set to 1 when the user 1 YES YES YES
FASTACT of the fast task creates the task. The task is (except for
deactivated when the user sets safety
the bit to 0. PLCs)
This bit is not available on
Quantum safety PLCs.
%S32 Activation/deactivation Normally set to 1 when the user 0 NO YES YES
AUX0ACT of the auxiliary task 0 creates the task. The auxiliary (except for
task is deactivated when the safety
user sets the bit to 0. PLCs)
This bit is not available on
Quantum safety PLCs.
%S33 Activation/deactivation Normally set to 1 when the user 0 NO YES YES
AUX1ACT of the auxiliary task 1 creates the task. The auxiliary (except for
task is deactivated when the safety
user sets the bit to 0. PLCs)
This bit is not available on
Quantum safety PLCs.
%S34 Activation/deactivation Normally set to 1 when the user 0 NO YES YES
AUX2ACT of the auxiliary task 2 creates the task. The auxiliary (except for
task is deactivated when the safety
user sets the bit to 0. PLCs)
This bit is not available on
Quantum safety PLCs.
%S35 Activation/deactivation Normally set to 1 when the user 0 NO YES YES
AUX3ACT of the auxiliary task 3 creates the task. The auxiliary (except for
task is deactivated when the safety
user sets the bit to 0. PLCs)
This bit is not available on
Quantum safety PLCs.

258 33002539 07/2012


System objects

Bit Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%S38 Enabling/inhibition of Normally set to 1. Events are 1 YES YES YES
ACTIVEVT events inhibited when the user sets the (except for
bit to 0. safety
This bit is not available on PLCs)
Quantum safety PLCs.
%S39 Saturation in event This bit is set to 1 by the system 0 YES YES YES
EVTOVR processing to indicate that one or more (except for
events cannot be processed safety
following saturation of the PLCs)
queues.
The user must reset this bit to 0.
This bit is not available on
Quantum safety PLCs.
%S40 Rack 0 input/output The %S40 bit is assigned to rack 1 YES YES NO
RACK0ERR fault 0.
Normally set to 1, this bit is set to
0 when a fault occurs on the
racks I/Os.
In this case:
z the %S10 bit is set to 0,
z the I/O processor LED is on,
z the %Ir.m.c.Err module bit is
set to 1.
This bit is reset to 1 when the
fault disappears.
%S41 Rack 1 input/output Idem %S40 for rack 1. 1 YES YES NO
RACK1ERR fault
%S42 Rack 2 input/output Idem %S40 for rack 2. 1 YES YES NO
RACK2ERR fault
%S43 Rack 3 input/output Idem %S40 for rack 3. 1 YES YES NO
RACK3ERR fault
%S44 Rack 4 input/output Idem %S40 for rack 4. 1 YES YES NO
RACK4ERR fault
%S45 Rack 5 input/output Idem %S40 for rack 5. 1 YES YES NO
RACK5ERR fault
%S46 Rack 6 input/output Idem %S40 for rack 6. 1 YES YES NO
RACK6ERR fault
%S47 Rack 7 input/output Idem %S40 for rack 7. 1 YES YES NO
RACK7ERR fault

33002539 07/2012 259


System objects

Bit Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%S50 Updating of time and Normally set to 0, this bit is set to 0 YES YES YES
RTCWRITE date via words %SW50 1 or 0 by the program or the
to %SW53 terminal.
z set to 0: update of system
words %SW50 to %SW53 by
the date and time supplied by
the PLC real-time clock.
z set to 1: system words
%SW50 to %SW53 are no
longer updated, therefore
making it possible to modify
them.
z The switch from 1 to 0
updates the real-time clock
with the values entered in
words %SW50 to %SW53.
%S51 Time loss in real time This system-managed bit set to YES YES YES
RTCERR clock 1 indicates that the real-time
clock is missing or that its
system words (%SW50 to
%SW53) are meaningless. In
this case the clock must be reset
to the correct time.
%S59 Incremental update of Normally set to 0, this bit can be 0 YES YES YES
RTCTUNING the time and date via set to 1 or 0 by the program or
word %SW59 the terminal:
z set to 0: the system does not
manage the system word
%SW59,
z set to 1: the system manages
edges on word %SW59 to
adjust the date and current
time (by increment).

260 33002539 07/2012


System objects

Description of System Words %SW12 to %SW29

Detailed Description
Description of system words %SW12 to %SW29:

Word Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%SW12 Processor For Premium: Uni-Telway address - YES YES NO
UTWPORTADDR serial port of terminal port (in slave mode) as (see
address defined in the configuration and %SW12
loaded into this word on cold start. below)
The modification of the value of this
word is not taken into account by
the system.
For Modicon M340: Gives the
Modbus slave address of the CPU
serial port. Modification is not taken
into account. Is 0 if the CPU does
not have a Serial Port link.
%SW12 Mode of the For Quantum safety PLC only, this 16#A501 NO NO YES
APMODE application word indicates the operating mode Only on
processor of the application processor of the safety
CPU module. PLCs
z 16#A501 = maintenance mode
z 16#5AFE = safe mode

Any other value is interpreted as an


error.
Note: In a HotStand By safety
system, this word is exchanged
from the primary to the standby
PLC to inform the standby PLC of
the safe or maintenance mode.
%SW13 Main This word indicates the following for 254 NO YES NO
XWAYNETWADDR address of the main network (Fipway or (16#00FE) (see
the station Ethway): %SW13
z the station number (least below)
significant byte) from 0 to 127,
z the network number (most
significant byte) from 0 to 63,
(value of the micro-switches on the
PCMCIA card).

33002539 07/2012 261


System objects

Word Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%SW13 Mode of the For Quantum safety PLC only, this - NO NO YES
INTELMODE Intel word indicates the operating mode Only on
processor of the Intel Pentium processor of safety
the CPU module. PLCs
z 16#501A = maintenance mode
z 16#5AFE = safe mode

Any other value is interpreted as an


error.
Note: In a HotStand By safety
system, this word is exchanged
from the primary to the standby
PLC to inform the standby PLC of
the safe or maintenance mode.
%SW14 Commercial This word contains the current - YES YES YES
OSCOMMVERS version of Operating System (OS) version of
PLC the PLC processor.
processor Example: 16#0135
version: 01
issue number: 35
%SW15 PLC This word contains the commercial - YES YES YES
OSCOMMPATCH processor version of the PLC processor
patch patch.
version It is coded onto the least significant
byte of the word.
Coding: 0 = no patch, 1 = A, 2 = B...
Example: 16#0003 corresponds to
patch C.
%SW16 Firmware This word contains the Firmware - YES YES YES
OSINTVERS version version number in hexadecimal of
number the PLC processor firmware.
Example: 16#0011
version: 2.1
VN: 17

262 33002539 07/2012


System objects

Word Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%SW17 Error status When an error in a floating 0 YES YES YES
FLOATSTAT on floating arithmetic operation is detected, bit Only on
operation %S18 is set to 1 and %SW17 error safety
status is updated according to the PLCs
following coding:
z %SW17.0 = Invalid operation /
result is not a number,
z %SW17.1 =Denormalized
operand / result is acceptable
(flag not managed by Modicon
M340 or Quantum Safety
PLCs),
z %SW17.2 = Division by 0 / result
is infinity,
z %SW17.3 = Overflow / result is
infinity,
z %SW17.4 = Underflow / result is
0,
z %SW17.5 to 15 = not used.

This word is reset to 0 by the


system on cold start, and also by
the program for re-usage purposes.
%SD18: Absolute %SW18 represents the least 0 YES YES YES
%SW18 and time counter significant bytes and %SW19 the
%SW19 most significant bytes of the double
100MSCOUNTER word %SD18, which is incremented
by the system every 1/10th of a
second. The application can read
or write these words in order to
perform duration calculations.
%SD18 is incremented
systematically, even in STOP mode
and equivalent states. However,
times when the PLC is switched off
are not taken into account, since
the function is not linked to the real-
time scheduler, but only to the real-
time clock.
For Quantum safety PLC, knowing
that the 2 processors must process
exactly the same data, the value of
%SD18 is updated at the beginning
of the mast task, and then frozen
during the application execution.

33002539 07/2012 263


System objects

Word Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%SD20: Absolute For M340 and Quantum PLCs 0 YES YES YES
%SW20 and time counter %SD20 is incremented every
%SW21 1/1000th of a second by the system
MSCOUNTER (even when the PLC is in STOP,
%SD20 is no longer incremented if
the PLC is powered down). %SD20
can be read by the user program or
by the terminal.
%SD20 is reset on a cold start.
%SD20 is not reset on a warm start.
For Premium
TSX P57 14M/24M/34M/C024M/
024M and TSX PCI57 204M/354M
PLCs, %SD20 is incremented by 5
every 5/1000th of a second by the
system. For all the others Premium
PLCs, %SD20 is time counter at 1
ms like Quantum and M340 PLCs.
For Quantum safety PLC, knowing
that the 2 processors must process
exactly the same data, the value of
%SD18 is updated at the beginning
of the mast task, and then frozen
during the application execution.
%SW23 Rotary The least significant byte contains - YES NO NO
switch value the Ethernet processor rotary
switch.
It can be read by the user program
or by the terminal.
%SW26 Number of This system word allows to verifiy - YES NO NO
requests on server side the number of
processed requests processed by PLC per
second.

264 33002539 07/2012


System objects

Word Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%SW27 System z %SW27 is the last system - YES NO NO
%SW28 overhead overhead time.
%SW29 time z %SW28 contains the maximum
system overhead time.
z %SW29 contains the minimum
system overhead time.
The system overhead time
depends on the configuration
(number of I/O...) and on the
current cycle requests
(communication, diagnostics).
System overhead time = Mast
Cycle Time - User code execution
time.
These can be read and written by
the user program or by the terminal.

33002539 07/2012 265


System objects

Description of System Words %SW48 to %SW59

Detailed Description
Description of system words %SW48 to %SW59.

Word Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%SW48 Number of This word indicates the IO events and 0 YES YES YES
IOEVTNB events telegram processed since the last cold (except
start. This word can be written by the for safety
program or the terminal PLCs)
This word is not available on Quantum
safety PLCs.
NOTE: TELEGRAM is available only
for PREMIUM (not on Quantum or
M340).
%SW49 Real-time System words containing date and - YES YES YES
DAYOFWEEK clock current time (in BCD):
%SW50 function z %SW49: day of the week:
SEC z 1 = Monday,
%SW51 z 2 = Tuesday,
HOURMIN z 3 = Wednesday,
%SW52 z 4 = Thursday,
MONTHDAY z 5 = Friday,
%SW53 z 6 = Saturday,
YEAR z 7 = Sunday,

z %SW50: Seconds (16#SS00),


z %SW51: Hours and Minutes
(16#HHMM),
z %SW52: Month and Day
(16#MMDD),
z %SW53: Year (16#YYYY).

These words are managed by the


system when the bit %S50 is set to 0.
These words can be written by the user
program or by the terminal when the bit
%S50 is set to 1.

266 33002539 07/2012


System objects

Word Function Description Initial Modicon Premium Quantum


Symbol state M340 Atrium
%SW54 Real-time System words containing date and - YES YES YES
STOPSEC clock time of the last power failure or PLC
%SW55 function on stop (in Binary Coded Decimal):
STOPHM last stop z %SW54: Seconds (00SS),
%SW56 z %SW55: Hours and Minutes
STOPMD (HHMM),
%SW57 z %SW56: Month and Day (MMDD),
STOPYEAR z %SW57: Year (YYYY),
%SW58 z %SW58: the most significant byte
STOPDAY contains the day of the week (1 for
Monday through to 7 for Sunday),
and the least significant byte
contains the code for the last stop:
z 1 = change from RUN to STOP
by the terminal or the dedicated
input,
z 2 = stop by watchdog (PLC task
or SFC overrun),
z 4 = power outage or memory
card lock operation,
z 5 = stop on hardware fault,
z 6 = stop on software fault.
Details on the type of software
fault are stored in %SW125.
%SW59 Adjustment Contains two 8-bit series to adjust the 0 YES YES YES
ADJDATETIME of current current date.
date The action is always performed on the
rising edge of the bit.
This word is enabled by bit %S59=1.
In the following illustration, bits in the
left column increment the value, and
bits in the right column decrement the
value:

33002539 07/2012 267


System objects

Description of Quantum System Words %SW60 to %SW66

Detailed Description
System words description %SW60 to %SW66.

268 33002539 07/2012


System objects

Word Function Description Initial


Symbol state
%SW60 Quantum Hot Different bits meaning of the word %SW60: 0
HSB_CMD Standby z %SW60.0 = 1 invalidates the commands entered in the display
command (keypad).
register z %SW60.1
z 0 sets PLC A to OFFLINE mode.
z 1 sets PLC A to ONLINE mode.

z %SW60.2
z 0 sets PLC B to OFFLINE mode.
z 1 sets PLC B to ONLINE mode.

NOTE: The Primary CPU controller goes to RUN Offline only if the
secondary CPU is RUN Standby.
At Startup of the Secondary PLC, the secondary CPU goes to Online
mode (RUN Standby) only if both bits %SW60.1 and %SW60.2 are set
to 1 (regardless of A/B assignment).
If bits %SW60.1 and %SW60.2 are set to 0 simultaneously, a switchover
occurs:
z Primary controller goes RUN Offline, and,
z Standby controller now operates as RUN Primary.

To complete the switchover, bits %SW60.1 and %SW60.2 must be set


back to 1. This makes the Offline CPU going back to Online mode (Run
Standby).
The OFFLINE/ONLINE mode controlled by the %SW60.1 and %SW60.2
bits is not linked to the LCD Keypad ONLINE/OFFLINE mode
(see Modicon Quantum with Unity, Ethernet Network Modules, User
Manual).
z %SW60.3
z 0 If an application mismatch is detected, Standby CPU is forced to
OFFLINE mode.
z 1 Standby CPU operates normally even if a mismatch occurs.

z %SW60.4
z 0 authorizes an update of the firmware only after the application
has stopped.
z 1 authorizes an update of the firmware without the application
stopping.
z %SW60.5
z 0 no action (default)
z 1 request for an application transfer from the Primary to the
Standby
z %SW60.8
z 0 address switch on Modbus port 1 during a primary swap.
z 1 no address switch on Modbus port 1 during a primary swap.

33002539 07/2012 269


System objects

Word Function Description Initial


Symbol state
%SW60 Quantum Hot continued: 0
HSB_CMD Standby z %SW60.9
command z 0 address switch on Modbus port 2 during a primary swap.
register z 1 no address switch on Modbus port 2 during a primary swap.

z %SW60.10
z 0 address switch on Modbus port 3 during a primary swap.
z 1 no address switch on Modbus port 3 during a primary swap.

%SW61 Quantum Meaning of the different bits of the word %SW61: 0


HSB_STS status register z %SW61.0 and %SW61.1 PLC operating mode bits
z %SW61.1 = 0, %SW61.0 = 1: OFFLINE mode.
z %SW61.1 = 1, %SW61.0 = 0: primary mode.
z %SW61.1 = 1, %SW61.0 = 1: secondary mode (Standby).

z %SW61.2 and %SW61.3 operating mode bits from the other PLC
z %SW61.3 = 0, %SW61.2 = 1: OFFLINE mode.
z %SW61.3 = 1, %SW61.2 = 0: primary mode.
z %SW61.3 = 1, %SW61.2 = 1: secondary mode (Standby).
z %SW61.3 = 0, %SW61.2 = 0: the remote PLC is not accessible
(switched off, no communication).
z %SW61.4 = 0 the applications are identical on both PLCs.
z %SW61.5
z 0 the PLC is used as unit A.
z 1 the PLC is used as unit B.

z %SW61.6 indicates if the CPU-sync link between the two PLC is valid
z 0 The CPU-sync link is operating properly. The contents of bit 5
are significant.
z 1 the CPU-sync link is not valid. In this case, the contents of the bit
5 is not significant because the comparison of the two MAC
addresses cannot be performed.
z %SW61.7
z 0 Same PLC OS version.
z 1 Different PLC version.

z %SW61.8
z 0 Same Copro OS version.
z 1 Different Copro version.

z %SW61.12
z 0 Information given by bit 13 is not relevant
z 1 Information given by bit 13 is valid

z %SW61.13
z 0 NOE address set to IP
z 1 NOE address set to IP + 1
z %SW61.15
z 0 Hot Standby not activated.
z 1 Hot Standby activated.

270 33002539 07/2012


System objects

Word Function Description Initial


Symbol state
%SW62 Hot Standby These 4 words may be modified is the Hot Standby MAST task first 0
HSBY_REVERSE0 reverse section of the user application program.
%SW63 transfer word They are then transferred automatically from the Standby processor to
HSBY_REVERSE1 update the Primary PLC.
%SW64 They may be read on the Primary PLC and used in the Hot Standby
HSBY_REVERSE2 application.
%SW65
HSBY_REVERSE3
%SW66 Status of an Meaning of the bytes of the word %SW66 (XXYY): 0
CCOTF_STATUS Ethernet I/O z XX: The higher byte of the word is associated with the CCOTF status
configuration codes 00 to 1F (in hex):
change z 00: Idle
z 01: Request length invalid
z 02: Request header invalid
z 03: Request descriptor invalid
z 04: Request signature invalid
z 05: Request server invalid
z 06: FDR server invalid
z 07: Header request ID invalid
z 08: Header Drop ID invalid
z 09: Header device name invalid
z 0A: Descriptor length invalid
z 0B: Descriptor RTE invalid
z 0C: Descriptor offset invalid
z 0D: Signature length invalid
z 0E: Signature data invalid
z 0F: Signature count invalid
z 10: FDR IP invalid
z 11: FDR subnet mask invalid
z 12: FDR gateway invalid
z 13: EIP CID invalid
z 14: EIP device number invalid
z 15: EIP IP invalid
z 16: EIP vender ID invalid
z 17: EIP product type invalid
z 18: EIP product code invalid
z 19: EIP time-out invalid
z 1A: EIP OT RPI invalid
z 1B: EIP TO RPI
z 1C: EIP path invalid
z 1D: Process succeed
z 1E: Process busy
z 1F: Drop does not exist

33002539 07/2012 271


System objects

Word Function Description Initial


Symbol state
%SW66 Status of an Continued: 0
CCOTF_STATUS Ethernet I/O z XX: The higher byte of the word is associated with the CCOTF status
configuration codes 20 to FF (in hex):
change z 20: Drop already exists
z 21: Drop not reachable
z 22: Process device manager detected error
z 23: Process FDR builder detected error
z 24: Process FDR server detected error
z 25: Process EIP scanner detected error
z 26: Process EIP signature mismatch
z 27: Process EIP connection rejected
z 28: Process unknown detected error
z 29:...3F: Reserved
z 4C: Maximum CCOTF retries reached
z 4D: Invalid signature detected by CPU
z 4E: For CPU: Detected error for communication to CRP
z 4F: For CPU: IOPL error (build or swap)
z 50: CRA received wrong communication parameter detected error
z 51: FDR server did not respond
z 52: Detected error when downloading PRM file from server
z 53: CRA downloaded a zero size file from FDR server
z 54: Invalid configuration in PRM (for example, invalid CRC, invalid
Conf, or Signature mismatch: managed by MC)
z 55: PRM download time-out
z 56: All other detected error, for example, CCOTF count difference
between new and old conf more greater than 1)
z 57:...FE: Reserved
z FF: Unknown detected error

z YY: The lower byte of the word is associated with the CCOTF
processing status (in hex):
z 00: Idle
z 01: In progress
z 02: Completed
z 03: Did not complete, but can recover
z 04: Did not complete, cannot recover
z 05: Did not complete, CCOTF was rejected by the Drop

272 33002539 07/2012


Unity Pro
Glossary
33002539 07/2012

Glossary

0-9

%I
According to the CEI standard, %I indicates a language object of type discrete IN.

%IW
According to the CEI standard, %IW indicates a language object of type analog IN.

%KW
According to the CEI standard, %KW indicates a language object of type constant
word.

%M
According to the CEI standard, %M indicates a language object of type memory bit.

%MW
According to the CEI standard, %MW indicates a language object of type memory
word.

%Q
According to the CEI standard, %Q indicates a language object of type discrete OUT.

%QW
According to the CEI standard, %QW indicates a language object of type analog OUT.

33002539 07/2012 273


Glossary

ADDM_TYPE
This predefined type is used as an output for the ADDM function. This is an
ARRAY[0..8] OF Int. You can find it in the library, in the same family as the EFs that
use it.

ADDR_TYPE
This predefined type is used as an output for the ADDR function. This is an
ARRAY[0..5] OF Int. You can find it in the library, in the same family as the EFs that
use it.

ANL_IN
ANL_IN is the abbreviation of the analog input data type. It is used when processing
analog values. %IW addresses in the configured analog input module, which are
specified in the list of I/O components, are automatically assigned to data types, and
therefore must be occupied by unassigned variables only.

ANL_OUT
ANL_OUT is the abbreviation of the analog output data type. It is used when
processing analog values. %MW addresses in the configured analog input module,
which are specified in the list of I/O components, are automatically assigned to data
types, and therefore must be occupied by unassigned variables only.

274 33002539 07/2012


Glossary

ANY
There is a hierarchy among the various data types. In the DFBs, it is sometimes
possible to declare variables that can contain several types of values. In that case
we use ANY_xxx types.
The figure below describes this hierarchical structure:

33002539 07/2012 275


Glossary

ARRAY
An ARRAY is a table containing elements of a single type.
The syntax is as follows: ARRAY [<limits>] OF <Type>
Example:
ARRAY [1..2] OF BOOL is a one-dimensional table with two elements of type
BOOL.
ARRAY [1..10, 1..20] OF INT is a two-dimensional table with 10x20
elements of type INT.

Assigned variables
A variable whose position in the PLC memory can be known. For example, the
Water_pressure variable is associated with %MW102. Water_pressure is said
to be assigned.

BCD
BCD is the abbreviation of the Binary Coded Decimal format.
BCD can be used to represent decimal numbers between 0 and 9 using a set of four
bits (nybble).
In this format, the four bits used to encode decimal numbers have an unused range
of combinations.
Example of BCD encoding:
z The number 2,450
z is encoded: 0010 0100 0101 0000

BOOL
BOOL is the abbreviation for the Boolean type. This is the basic data type in
computing. A BOOL variable can have either of the following two values: 0 (FALSE)
or 1 (TRUE).
A bit extracted from a word is of type BOOL, for example: %MW10.4.

BYTE
When 8 bits are grouped together, they are called a BYTE. You can enter a BYTE
either in binary mode or in base 8.
The BYTE type is encoded in an 8 bit format which, in hexadecimal format, ranges
from 16#00 to 16#FF.

276 33002539 07/2012


Glossary

DATE
The DATE type, encoded in BCD in a 32 bit format, contains the following
information:
z the year encoded in a 16 bit field;
z the month encoded in an 8 bit field;
z the day encoded in an 8 bit field.
The DATE type must be entered as follows: D#<Year>-<Month>-<Day>
This table shows the upper/lower limits of each field:

Field Limits Comment


Year [1990,2099] Year
Month [01,12] The leading 0 is displayed; it can be omitted during data
entry.
Day [01,31] For months 01/03/05/07/08/10/12
[01,30] For months 04/06/09/11
[01,29] For month 02 (leap years)
[01,28] For month 02 (non-leap years)

DATE_AND_TIME
See DT.

DBCD
Representation of a double integer in double BCD format.
BCD format can be used to represent decimal numbers between 0 and 9 using a set
of four bits.
In this format, the four bits used to encode decimal numbers have an unused range
of combinations.
Example of DBCD encoding:
z The number 78,993,016
z is encoded: 0111 1000 1001 1001 0011 0000 0001 0110

DDT
DDT is the abbreviation of Derived Data Type.
A derived data type is a set of elements with the same type (ARRAY) or with different
types (structure).

33002539 07/2012 277


Glossary

DFB
DFB is the abbreviation of Derived Function Block.
DFB types are function blocks that can be defined by the user in ST, IL, LD or FBD
language.
Using these DFB types in an application makes it possible to:
z simplify the design and entry of the program;
z make the program easier to read;
z make it easier to debug;
z reduce the amount of code generated.

DINT
DINT is the abbreviation of Double INTeger (encoded in 32 bits).
The upper/lower limits are as follows: -(2 to the power of 31) to (2 to the power of
31) - 1.
Example:
-2147483648, 2147483647, 16#FFFFFFFF.

DT
DT is the abbreviation of Date and Time.
The DT type, encoded in BCD in a 64 bit format, contains the following information:
z the year encoded in a 16 bit field;
z the month encoded in an 8 bit field;
z the day encoded in an 8 bit field;
z the time encoded in an 8 bit field;
z the minutes encoded in an 8 bit field;
z the seconds encoded in an 8 bit field.
NOTE: The 8 least significant bits are not used.
The DT type must be entered as follows:
DT#<Year>-<Month>-<Day>-<Hour>:<Minutes>:<Seconds>

278 33002539 07/2012


Glossary

This table shows the upper/lower limits of each field:

Field Limits Comment


Year [1990,2099] Year
Month [01,12] The leading 0 is displayed; it can be omitted during
data entry.
Day [01,31] For months 01/03/05/07/08/10/12
[01,30] For months 04/06/09/11
[01,29] For month 02 (leap years)
[01,28] For month 02 (non-leap years)
Hour [00,23] The leading 0 is displayed; it can be omitted during
data entry.
Minute [00,59] The leading 0 is displayed; it can be omitted during
data entry.
Second [00,59] The leading 0 is displayed; it can be omitted during
data entry.

DWORD
DWORD is the abbreviation of Double Word.
The DWORD type is encoded in a 32 bit format.
This table shows the upper/lower limits of each of the bases that can be used:

Base Lower limit Upper limit


Hexadecimal 16#0 16#FFFFFFFF
Octal 8#0 8#37777777777
Binary 2#0 2#11111111111111111111111111111111

Examples of representation:

Data Representation in one of the bases


00000000000010101101110011011110 16#ADCDE
00000000000000010000000000000000 8#200000
00000000000010101011110011011110 2#10101011110011011110

33002539 07/2012 279


Glossary

EBOOL
EBOOL is the abbreviation of Extended BOOLean. An EBOOL type has a value (0
(FALSE) or 1 (TRUE), but also rising or falling edges and forcing functions.
An EBOOL variable occupies one byte in memory.
The byte contains the following information:
z one bit for the value;
z one bit for the history (whenever the object changes state, the value is copied to
the history bit);
z one bit for forcing (equal to 0 if the object is not forced, or 1 if the bit is forced).
The default value of each bit is 0 (FALSE).

EF
EF is the abbreviation of Elementary Function.
This is a block used in a program which performs a predefined logical function.
A function does not have any information on the internal state. Several calls to the
same function using the same input parameters will return the same output values.
You will find information on the graphic form of the function call in the "[functional
block (instance)]". Unlike a call to a function block, function calls include only an
output which is not named and whose name is identical to that of the function. In
FBD, each call is indicated by a unique [number ] via the graphic block. This number
is managed automatically and cannot be modified.
You position and configure these functions in your program in order to execute your
application.
You can also develop other functions using the SDKC development kit.

EFB
EFB is the abbreviation of Elementary Function Block.
This is a block used in a program which performs a predefined logical function.
EFBs have states and internal parameters. Even if the inputs are identical, the
output values may differ. For example, a counter has an output indicating that the
preselection value has been reached. This output is set to 1 when the current value
is equal to the preselection value.

Elementary function
See EF.

280 33002539 07/2012


Glossary

EN
EN stands for ENable; it is an optional block input. When the EN input is enabled, an
ENO output is set automatically.
If EN = 0, the block is not enabled; its internal program is not executed, and ENO is
set to 0.
If EN = 1, the blocks internal program is run and ENO is set to 1. If an error occurs,
ENO is set to 0.
If the EN input is not connected, it is set automatically to 1.

ENO
ENO stands for Error NOtification; this is the output associated with the optional input
EN.
If ENO is set to 0 (because EN = 0 or in case of an execution error):
z the status of the function block outputs remains the same as it was during the
previous scanning cycle that executed correctly;
z the output(s) of the function, as well as the procedures, are set to "0".

FBD
FBD is the abbreviation of Function Block Diagram.
FBD is a graphical programming language that works like a flowchart. By adding
simple logical blocks (AND, OR, etc.), each function or function block in the program
is represented in this graphical format. For each block, the inputs are on the left and
the outputs on the right. Block outputs can be linked to inputs of other blocks in order
to create complex expressions.

FFB
Collective term for EF (elementary function), EFB (elementary function block) and
DFB (derived function block).

FTP
File Transfer Protocol.

Function
See EF.

33002539 07/2012 281


Glossary

Function Block Diagram


See FBD.

Global Data
Global Data provides the automatic exchange of data variables for the coordination
of PLC applications.

GRAY
The Gray code, or "reflected binary", is used to encode a numerical value developed
in a string of binary configurations that may be differentiated by changing the status
of a single bit.
For example, this code can be used to avoid the following random event: in pure
binary, changing the value 0111 to 1000 may produce a range numbers between 0
and 1,000, given that the bits do not all change value at the same time.
Equivalence between decimal, BCD and Gray:

HTTP
Hypertext Transfer Protocol

I/O scanning
An I/O scan continuously polls I/O modules to collect data bits and status, error, and
diagnostics information. This process monitors inputs and control outputs.

282 33002539 07/2012


Glossary

IEC 61131-3
International standard: programmable logic controllers
Part 3: programming languages

IL
IL is the abbreviation of Instruction List.
This language is a series of basic instructions.
It is very close to assembly language used to program processors.
Each instruction is made up of an instruction code and an operand.

INF
Used to indicate that a number exceeds the authorized limits.
For an integer, the value ranges (shown in gray) are as follows:

When a result is:


z less than -3.402824e+38, the symbol -INF (for -infinity) is displayed;
z greater than +3.402824e+38, the symbol INF (for +infinity) is displayed;

INT
INT is the abbreviation of single INTeger (encoded in 16 bits).
The upper/lower limits are as follows: -(2 to the power of 15) to (2 to the power of
15) - 1.
Example:
-32768, 32767, 2#1111110001001001, 16#9FA4.

IODDT
IODDT is the abbreviation of Input/Output Derived Data Type.
The term IODDT indicates a structured data type representing a module or a
channel of a PLC module. Each expert module has its own IODDTs.

33002539 07/2012 283


Glossary

Keyword
A keyword is a unique combination of characters used as a syntax element in a
programming language (see the definition provided in appendix B of the IEC 61131-
3 standard. All the keywords used in Unity Pro and included in the IEC 61131-3
standard appear in appendix C of that standard. Keywords cannot be used as
identifiers [names of variables, sections, DFB types, etc.] in your program).

LD
LD is the abbreviation of Ladder Diagram.
LD is a programming language that represents instructions to be executed as
graphical diagrams very similar to electrical diagrams (contacts, coils, etc.).

Literal value in base 10


A literal value in base 10 is used to represent a decimal integer value. This value
may be preceded by the "+" and "-" signs. If the "_" character is used in the literal
value, it is not significant.
Example:
-12, 0, 123_456, +986

Literal value in base 16


A literal value in base 16 is used to represent a hexadecimal integer. The base is
determined by the number "16" and the "#" sign. The "+" and "-" signs are prohibited.
To make it easier to read, you can use the "_" sign between the bits.
Example:
16#F_F or 16#FF (decimal 255)
16#E_0 or 16#E0 (decimal 224)

284 33002539 07/2012


Glossary

Literal value in base 2


A literal value in base 2 is used to represent a binary integer. The base is determined
by the number "2" and the "#" sign. The "+" and "-" signs are prohibited. To make it
easier to read, you can use the "_" sign between the bits.
Example:
2#1111_1111 or 2#11111111 (decimal 255)
2#1110_0000 or 2#11100000 (decimal 224)

Literal value in base 8


A literal value in base 8 is used to represent an octal integer. The base is determined
by the number "8" and the "#" sign. The "+" and "-" signs are prohibited. To make it
easier to read, you can use the "_" sign between the bits.
Example:
8#3_77 or 8#377 (decimal 255)
8#34_0 or 8#340 (decimal 224)

Literal value of a real


A literal real value is a number expressed with one or more decimals.
Example:
-12,0, 0,0, +0,456, 3,14159_26

Literal value of a real with an exponent


Number that may be expressed using standard scientific notation. In that case the
representation is as follows: mantissa + exponent.
Example:
-1.34E-12 or -1.34e-12
1.0E+6 or 1.0e+6
1.234E6 or 1.234e6

Literal value of an integer


A literal value of an integer is used to enter integer values in the decimal system.
Values may be preceded by the "+" and "-" signs. Underscore signs (_) separating
numbers are not significant.
Example:
-12, 0, 123_456, +986

33002539 07/2012 285


Glossary

Literal value of time


The TIME type has the following units: days (d), hours (h), minutes (m), seconds (s)
and milliseconds (ms). A literal value of type TIME is represented by a combination
of the preceding types prefixed with T#, t#, TIME# or time#.
Examples: T#25h15m, t#14,7S, TIME#5d10h23m45s3ms

Multitoken
Operating mode of an SFC. In multitoken mode, the SFC can have several steps
that are active simultaneously.

Naming conventions (identifier)


An identifier is a series of letters, digits, and underscores starting with a letter or an
underscore (e.g. the name of a function block type, an instance, a variable, or a
section). Accented letters (such as , , and ) may be used, except in names of
projects and DFBs. Underscore signs are significant in identifiers. For example,
A_BCD and AB_CD are interpreted as different identifiers. You cannot use several
underscores in succession or at the start of an identifier.
Identifiers cannot contain spaces. They do not differentiate uppercase and
lowercase characters. For example, ABCD and abcd are interpreted as the same
identifier.
According to the IEC 61131-3 standard, leading digits are not authorized in
identifiers. However, you can use them if, from the Tools Project options dialog
box, in the Language extensions tab, you check the Leading digits authorized
box.
Identifiers cannot be keywords.

286 33002539 07/2012


Glossary

NAN
Used to indicate that the result of an operation is not a number (NAN = Not A
Number).
Example: calculating the square root of a negative number.
NOTE: The CEI 559 standard defines two classes of NAN: the silent NAN (QNAN)
and the signaling NAN (SNAN). A QNAN is a NAN with a most significant fraction
bit while an SNAN is a NAN without a most significant fraction bit (bit number 22).
QNANs can be propagated via most arithmetic operations without throwing an
exception. As for SNANs, they generally indicate an invalid operation when they are
used as operands in arithmetic operations (see %SW17 and %S18).

Network
There are two meanings of the work "network".
z In LD:
a network is a set of interconnected graphic elements. The scope of a network
is local, concerning the organizational unit (section) of the program containing the
network.
z With expert communication modules:
a network is a set of stations that intercommunicate. The term "network" is also
used to define a group interconnected graphic elements. This group then makes
up part of a program that may comprise a group of networks.

Peer cop
Peer Cop service is a mechanism for automatic exchange between stations
connected on the same Modbus Plus segment.

Procedure
Procedures are technically functional views. The only difference with elementary
functions is the fact that procedures can include more than one output and that they
handle the VAR_IN_OUT data type. In appearance, procedures are no different from
elementary functions.
Procedures are an extension to the IEC 61131-3 standard.

33002539 07/2012 287


Glossary

REAL
The REAL type is encoded in a 32 bit format.
The possible value ranges are shown in the figure below:

When a result is:


z between -1,175494e-38 and 1,175494e-38, it is considered to be a DEN;
z less than -3.402824e+38, the symbol -INF (for - infinity) is displayed;
z greater than +3.402824e+38, the symbol INF (for + infinity) is displayed;
z undefined (square root of a negative number), the symbolNAN is displayed.
NOTE: The IEC 559 standard defines two classes of NAN: the silent NAN (QNAN)
and the signaling NAN (SNAN). A QNAN is a NAN with a most significant fraction
bit while an SNAN is a NAN without a most significant fraction bit (bit number 22).
QNANs can be propagated via most arithmetic operations without throwing an
exception. As for SNANs, they generally indicate n invalid operation when they are
used as operands in arithmetic operations (see %SW17 and %S18).
NOTE: When a DEN (non-standardized number) is used as an operand, the result is
not significant.

SFC
SFC is the abbreviation of Sequential Function Chart.
An SFC can be used to graphically represent in a structured manner the operation
of a sequential PLC. This graphical description of the PLCs sequential behavior and
of the various resulting situations is created using simple graphic symbols.

288 33002539 07/2012


Glossary

SIL
Safety Integrity Level
Safety functions are executed to achieve and maintain the safe state of a system.
The IEC 61508 specifies 4 levels of safety performance for a safety function. These
are called safety integrity levels (SIL), ranging from 1 (the lowest) to 4 (the highest).
The Quantum Safety PLC is certified for use in SIL2 applications in which the de-
energized state is the safe state, for example in an Emergency Shutdown (ESD)
system.
You can use the Schneider safety products for creating a Hot Standby (HSBY)
solution if you require high availability for a safety system.

Single token
Operating mode for an SFC diagram in which only one step can be active at a given
time.

SNMP
Simple Network Management Protocol.

ST
ST is the abbreviation of Structured Text.
The structured literal language is a developed language similar to computer
programming languages. It can be used to organize a series of instructions.

STRING
A STRING variable is a series of ASCII characters. The maximum length of a string
is 65,534 characters.

TIME
The TIME type expresses a time in milliseconds. Encoded in 32 bits, this type can
be used to obtain times from 0 to 2 32-1 milliseconds.
The TIME type has the following units: days (d), hours (h), minutes (m), seconds (s)
and milliseconds (ms). A literal value of type TIME is represented by a combination
of the preceding types prefixed with T#, t#, TIME# or time#.
Examples: T#25h15m, t#14,7S, TIME#5d10h23m45s3ms

33002539 07/2012 289


Glossary

TIME_OF_DAY
See TOD.

TOD
TOD is the abbreviation of Time Of Day.
The TOD type, encoded in BCD in a 32 bit format, contains the following information:
z the hour encoded in an 8 bit field;
z the minutes encoded in an 8 bit field;
z the seconds encoded in an 8 bit field.
NOTE: The 8 least significant bits are not used.
The TOD type must be entered as follows: TOD#<Hour>:<Minutes>:<Seconds>
This table shows the upper/lower limits of each field:

Field Limits Comment


Hour [00,23] The leading 0 is displayed; it can be omitted during data entry.
Minute [00,59] The leading 0 is displayed; it can be omitted during data entry.
Second [00,59] The leading 0 is displayed; it can be omitted during data entry.

Example: TOD#23:59:45.

Token
Active step in an SFC.

TOPO_ADDR_TYPE
This predefined type is used as an output for the READ_TOPO_ADDR function.
This is an ARRAY[0..4] OF Int. You can find it in the library, in the same family as
the EFs that use it.

UDINT
UDINT is the abbreviation of Unsigned Double INTeger (encoded in 32 bits). The
upper/lower limits are as follows: 0 to (2 to the power of 32) - 1.
Example:
0, 4294967295, 2#11111111111111111111111111111111, 8#37777777777,
16#FFFFFFFF.

290 33002539 07/2012


Glossary

UDP
user datagram protocol. UDP is a connectionless Internet communications protocol
defined by IETF RFC 768. This protocol facilitates the direct transmission of
datagrams on IP networks. UDP/IP messages do not expect a response, and are
therefore ideal for applications in which dropped packets do not require
retransmission (such as streaming video and networks that demand real-time
performance).

UINT
UINT is the abbreviation of the Unsigned INTeger format (encoded in 16 bits). The
upper/lower limits are as follows: 0 to (2 to the power of 16) - 1.
Example:
0, 65535, 2#1111111111111111, 8#177777, 16#FFFF.

Unassigned variables
A variable whose position in the PLC memory cannot be known. A variable that is
not linked to an address is called unassigned variable.

Variable
Memory entity of type BOOL, WORD, DWORD, etc., whose contents can be modified by
the program currently running.

WORD
The type WORD is encoded in a 16 bit format and is used to perform processing on
series of bits.
This table shows the upper/lower limits of each of the bases that can be used:

Base Lower limit Upper limit


Hexadecimal 16#0 16#FFFF
Octal 8#0 8#177777
Binary 2#0 2#1111111111111111

33002539 07/2012 291


Glossary

Examples of representation

Data Representation in one of the bases


0000000011010011 16#D3
1010101010101010 8#125252
0000000011010011 2#11010011

292 33002539 07/2012


Unity Pro
Index
33002539 07/2012

Index
B
AC
A F
availability of the instructions, 23 file management - instructions
CLOSE_FILE, 69
CREATE_FILE, 39
C DELETE_FILE, 71
CLEARCHART, 143 general information, 27
CLOSE_FILE, 69 GET_FILE_INFO, 49
CREATE_FILE, 39 GET_FREESIZE, 53
OPEN_FILE, 43
RD_FILE_TO_DATA, 65
D SEEK_FILE, 57
DELETE_FILE, 71 SET_FILE_ATTRIBUTES, 47
WR_DATA_TO_FILE, 61
FORCE_BIT, 239
E FREERUN, 197
event management - instructions FREEZECHART, 147
HALT, 113
ITCNTRL, 115
MASKEVT, 119
G
UNMASKEVT, 121 GET_FILE_INFO, 49
GET_FREESIZE, 53
GET_TS_EVT_M, 199
time stamping, 199
GET_TS_EVT_Q, 205
time stamping, 205

H
HALT, 113

33002539 07/2012 293


Index

hot standby - instructions READ_U_PCMCIA, 93, 97


HSBY_RD, 125 READ_V_PCMCIA, 103
HSBY_ST, 129 RESETSTEP, 155
HSBY_WR, 133 REV_XFER, 137, 137
REV_XFER, 137 RRTC_DT, 213
HSBY_RD, 125, 125 RRTC_DT_MS, 215
HSBY_ST, 129, 129
HSBY_WR, 133, 133
S
SCHEDULE, 223
I SEEK_FILE, 57
INITCHART, 151 SET_FILE_ATTRIBUTES, 47
instructions SETSTEP, 159
availability, 23 SFC management - instructions
IS_BIT_FORCED, 235 CLEARCHART, 143
IS_PAR_CON, 231 FREEZECHART, 147
ITCNTRL, 115 INITCHART, 151
RESETSTEP, 155
SETSTEP, 159
M SFC_RESTORE, 175
MASKEVT, 119 SFCCNTRL, 163
memory card management function SFC_RESTORE, 175
SIG_CHECK, 245 SFCCNTRL, 163
SIG_WRITE, 241 SIG_CHECK, 245
SIG_WRITE, 241
system specials - instructions
O FORCE_BIT, 239
OPEN_FILE, 43 IS_BIT_FORCED, 235
IS_PAR_CON, 231
UNFORCE_BIT, 237
P system time and date - instructions
PCMCIA card - instructions FREERUN, 197
READ_U_PCMCIA, 93 GET_TS_EVT_M, 199
WRITE_U_PCMCIA, 89 GET_TS_EVT_Q, 205
PRJ_VERS, 107 PTC, 211
Project Version R_NTPC, 219
PRJ_VERS, 107 RRTC_DT, 213
PTC, 211 RRTC_DT_MS, 215
SCHEDULE, 223
WRTC_DT, 227
R
R_NTPC, 219
RD_FILE_TO_DATA, 65
Read Variable from PCMCIA Card
READ_V_PCMCIA, 103

294 33002539 07/2012


Index

T
time stamping
GET_TS_EVT_M, 199
GET_TS_EVT_Q, 205
timer - instructions
FREERUN, 197

U
UNFORCE_BIT, 237
UNMASKEVT, 121

W
WR_DATA_TO_FILE, 61
Write Variable to PCMCIA Card
WRITE_V_PCMCIA, 99
WRITE_U_PCMCIA, 89, 97
WRITE_V_PCMCIA, 99
WRTC_DT, 227

33002539 07/2012 295


Index

296 33002539 07/2012

You might also like