Function and Function Block Representation. Schneider Electric EcoStruxure Machine Expert Modbus TCP, EcoStruxure Machine Expert
Iklan
Iklan
Modbus TCP
Function and Function Block Representation
Function and Function Block Representation
What’s in This Chapter
Differences Between a Function and a Function Block .....................................64
How to Use a Function or a Function Block in IL Language ...............................65
How to Use a Function or a Function Block in ST Language .............................67
Overview
Each function can be represented in the following languages:
• IL: Instruction List
• ST: Structured Text
• LD: Ladder Diagram
• FBD: Function Block Diagram
• CFC: Continuous Function Chart
This chapter provides functions and function blocks representation examples and explains how to use them for IL and ST languages.
Differences Between a Function and a Function Block
Function
A function:
• is a POU (Program Organization Unit) that returns one immediate result.
• is directly called with its name (not through an instance).
• has no persistent state from one call to the other.
• can be used as an operand in other expressions.
Examples: boolean operators ( AND ), calculations, conversion ( BYTE_TO_INT )
Function Block
A function block:
• is a POU (Program Organization Unit) that returns one or more outputs.
• needs to be called by an instance (function block copy with dedicated name and variables).
• each instance has a persistent state (outputs and internal variables) from one call to the other from a function block or a program.
Examples: timers, counters
64 EIO0000003826.02
Function and Function Block Representation
In the example, Timer_ON is an instance of the function block TON :
Modbus TCP
How to Use a Function or a Function Block in IL Language
General Information
This part explains how to implement a function and a function block in IL language.
Functions IsFirstMastCycle and SetRTCDrift and Function Block TON are used as examples to show implementations.
Using a Function in IL Language
2
3
4
Step
1
5
6
This procedure describes how to insert a function in IL language:
Action
Open or create a new POU in Instruction List language.
NOTE: The procedure to create a POU is not detailed here. For more information, refer to Adding and Calling POUs (see
EcoStruxure Machine Expert, Programming Guide).
Create the variables that the function requires.
If the function has 1 or more inputs, start loading the first input using LD instruction.
Insert a new line below and:
• type the name of the function in the operator column (left field), or
• use the Input Assistant to select the function (select Insert Box in the context menu).
If the function has more than 1 input and when Input Assistant is used, the necessary number of lines is automatically created with ???
in the fields on the right. Replace the ???
with the appropriate value or variable that corresponds to the order of inputs.
Insert a new line to store the result of the function into the appropriate variable: type ST instruction in the operator column (left field) and the variable name in the field on the right.
To illustrate the procedure, consider the Functions IsFirstMastCycle (without input parameter) and SetRTCDrift (with input parameters) graphically presented below:
EIO0000003826.02
65
Modbus TCP
Function without input parameter:
IsFirstMastCycle
Graphical Representation with input parameters:
SetRTCDrift
Function and Function Block Representation
Function
IL example of a function without input parameter:
IsFirstMastCycle
In IL language, the function name is used directly in the operator column:
Representation in POU IL Editor
IL example of a function with input parameters:
SetRTCDrift
Using a Function Block in IL Language
This procedure describes how to insert a function block in IL language:
Step
1
2
Action
Open or create a new POU in Instruction List language.
NOTE: The procedure to create a POU is not detailed here. For more information, refer to Adding and Calling POUs (see
EcoStruxure Machine Expert, Programming Guide).
Create the variables that the function block requires, including the instance name.
66 EIO0000003826.02
Function and Function Block Representation
Modbus TCP
4
5
Step
3
Action
Function Blocks are called using a CAL instruction:
• Use the Input Assistant to select the FB (right-click and select Insert Box in the context menu).
• Automatically, the CAL instruction and the necessary I/O are created.
Each parameter (I/O) is an instruction:
• Values to inputs are set by " := ".
• Values to outputs are set by " => ".
In the CAL right-side field, replace ???
with the instance name.
Replace other ???
with an appropriate variable or immediate value.
Function
Block
TON
Graphical Representation
To illustrate the procedure, consider this example with the TON Function Block graphically presented below:
In IL language, the function block name is used directly in the operator column:
Function
Block
TON
Representation in POU IL Editor
How to Use a Function or a Function Block in ST
Language
General Information
This part explains how to implement a Function and a Function Block in ST language.
Function SetRTCDrift and Function Block TON are used as examples to show implementations.
EIO0000003826.02
67
Modbus TCP
Using a Function in ST Language
2
3
Step
1
Function and Function Block Representation
This procedure describes how to insert a function in ST language:
Action
Open or create a new POU in Structured Text language.
NOTE: The procedure to create a POU is not detailed here. For more information, refer to Adding and Calling POUs
(see EcoStruxure Machine Expert, Programming Guide).
Create the variables that the function requires.
Use the general syntax in the POU ST Editor for the ST language of a function. The general syntax is:
FunctionResult:= FunctionName(VarInput1, VarInput2,.. VarInputx);
Function
SetRTCDrift
To illustrate the procedure, consider the function SetRTCDrift graphically presented below:
Graphical Representation
Function
SetRTCDrift
The ST language of this function is the following:
Representation in POU ST Editor
PROGRAM MyProgram_ST
VAR myDrift: SINT(-29..29) := 5; myDay: DAY_OF_WEEK := SUNDAY; myHour: HOUR := 12; myMinute: MINUTE; myRTCAdjust: RTCDRIFT_ERROR;
END_VAR myRTCAdjust:= SetRTCDrift(myDrift, myDay, myHour, myMinute);
Using a Function Block in ST Language
Step
1
2
3
This procedure describes how to insert a function block in ST language:
Action
Open or create a new POU in Structured Text language.
NOTE: The procedure to create a POU is not detailed here. For more information, refer to Adding and Calling POUs (see
EcoStruxure Machine Expert, Programming Guide).
Create the input and output variables and the instance required for the function block:
• Input variables are the input parameters required by the function block
• Output variables receive the value returned by the function block
Use the general syntax in the POU ST Editor for the ST language of a Function Block. The general syntax is:
FunctionBlock_InstanceName(Input1:=VarInput1, Input2:=VarInput2,... Ouput1=>VarOutput1,
Ouput2=>VarOutput2,...);
To illustrate the procedure, consider this example with the TON function block graphically presented below:
68 EIO0000003826.02
Function and Function Block Representation
Graphical Representation Function Block
TON
Function Block
TON
This table shows examples of a function block call in ST language:
Representation in POU ST Editor
Modbus TCP
EIO0000003826.02
69
Glossary
EIO0000003826.02
Modbus TCP
A
ATV:
The model prefix for Altivar drives (for example, ATV312 refers to the Altivar 312 variable speed drive).
B
byte:
A type that is encoded in an 8-bit format, ranging from 00 hex to FF hex.
C
CFC:
( continuous function chart ) A graphical programming language (an extension of the IEC 61131-3 standard) based on the function block diagram language that works like a flowchart. However, no networks are used and free positioning of graphic elements is possible, which allows feedback loops. For each block, the inputs are on the left and the outputs on the right. You can link the block outputs to the inputs of other blocks to create complex expressions.
CIP:
( common industrial protocol ) When a CIP is implemented in a network application layer, it can communicate seamlessly with other CIP-based networks without regard to the protocol. For example, the implementation of CIP in the application layer of an Ethernet TCP/IP network creates an EtherNet/IP environment.
Similarly, CIP in the application layer of a CAN network creates a DeviceNet environment. In that case, devices on the EtherNet/IP network can communicate with devices on the DeviceNet network through CIP bridges or routers.
D
device network:
A network that contains devices connected to a specific communication port of a logic controller. This controller is seen as a master from the devices point of view.
DHCP:
( dynamic host configuration protocol ) An advanced extension of BOOTP. DHCP is more advanced, but both DHCP and BOOTP are common. (DHCP can handle
BOOTP client requests.)
DTM:
( device type manager ) Classified into 2 categories:
• Device DTMs connect to the field device configuration components.
• CommDTMs connect to the software communication components.
The DTM provides a unified structure for accessing device parameters and configuring, operating, and diagnosing the devices. DTMs can range from a simple graphical user interface for setting device parameters to a highly sophisticated application capable of performing complex real-time calculations for diagnosis and maintenance purposes.
E
EDS:
( electronic data sheet ) A file for fieldbus device description that contains, for example, the properties of a device such as parameters and settings.
71
Modbus TCP
72
F
FB:
( function block ) A convenient programming mechanism that consolidates a group of programming instructions to perform a specific and normalized action, such as speed control, interval control, or counting. A function block may comprise configuration data, a set of internal or external operating parameters and usually
1 or more data inputs and outputs.
FDR:
( fast device replacement ) A service supported by the device, that facilitate the replacement of an inoperable equipment.
function block diagram:
One of the 5 languages for logic or control supported by the standard IEC 61131-
3 for control systems. Function block diagram is a graphically oriented programming language. It works with a list of networks where each network contains a graphical structure of boxes and connection lines representing either a logical or arithmetic expression, the call of a function block, a jump, or a return instruction.
H
health bit:
Variable that indicates the communication state of the channels.
health timeout:
Represents the maximal time (in ms) between a request of the Modbus IO scanner and a response of the slave.
I
IL:
( instruction list ) A program written in the language that is composed of a series of text-based instructions executed sequentially by the controller. Each instruction includes a line number, an instruction code, and an operand (refer to IEC 61131-
3).
INT:
( integer ) A whole number encoded in 16 bits.
%IW:
According to the IEC standard, %IW represents an input word register (for example, a language object of type analog IN).
L
LD:
( ladder diagram ) A graphical representation of the instructions of a controller program with symbols for contacts, coils, and blocks in a series of rungs executed sequentially by a controller (refer to IEC 61131-3).
M
MAC address:
( media access control address ) A unique 48-bit number associated with a specific piece of hardware. The MAC address is programmed into each network card or device when it is manufactured.
EIO0000003826.02
EIO0000003826.02
Modbus TCP
O
ODVA:
( open DeviceNet vendors association ) The family of network technologies that are built on CIP (EtherNet/IP, DeviceNet, and CompoNet).
P
post configuration:
( post configuration ) An option that allows to modify some parameters of the application without changing the application. Post configuration parameters are defined in a file that is stored in the controller. They are overloading the configuration parameters of the application.
POU:
( program organization unit ) A variable declaration in source code and a corresponding instruction set. POUs facilitate the modular re-use of software programs, functions, and function blocks. Once declared, POUs are available to one another.
Q
%QW:
According to the IEC standard, %QW represents an output word register (for example, a language object of type analog OUT).
R
repetition rate:
Polling interval of the Modbus request that is sent.
RJ45:
A standard type of 8-pin connector for network cables defined for Ethernet.
S
ST:
( structured text ) A language that includes complex statements and nested instructions (such as iteration loops, conditional executions, or functions). ST is compliant with IEC 61131-3.
U
UL:
( underwriters laboratories ) A US organization for product testing and safety certification.
V
variable:
A memory unit that is addressed and modified by a program.
73
Index
A
Advantys OTB
CONFIGURE_OTB ............................................56
B
bus cycle task
Modbus TCP IOScanner.....................................37
Modbus TCP
IOS_GETDIAGSTATUS.........................................60
get a diagnostic status........................................60
IOS_GETHEALTH.................................................54
getting the health bit value of a channel ...............54
IOS_GETSTATE ...................................................53
getting the state of the Modbus TCP IOScanner ...53
IOS_START..........................................................54
launching the Modbus TCP IOScanner ................54
IOS_STOP ...........................................................55
stopping the Modbus TCP IOScanner..................55
IosStateCodes
Data Types ........................................................58
IP addressing methods ..........................................14
C
CommunicationErrorCodes
Data Types ........................................................58
configuration of Advantys OTB
CONFIGURE_OTB ............................................56
configuration tool...................................................38
configurationOTBErrorCodes
Data Types ........................................................59
CONFIGURE_OTB ...............................................56
sending configuration of the Advantys OTB..........56
M
M251 Web server
protocol manager ...............................................44
Modbus TCP IOScanner
CONFIGURE_OTB ............................................56
IOS_GETHEALTH .............................................54
IOS_GETSTATE ................................................53
IOS_START ......................................................54
IOS_STOP ........................................................55
monitoring through EcoStruxure Machine Expert
protocol manager ...............................................45
D
data exchanges, out of process ..............................38
Data Types
CommunicationErrorCodes.................................58
configurationOTBErrorCodes..............................59
IosStateCodes ...................................................58
DHCP server ........................................................15
O
operating modes
protocol manager ...............................................40
out of process data exchanges ...............................38
E
enables or disables a communication channel
IOS_CONTROLCHANNEL .................................52
P
protocol manager
M251 Web server...............................................44
monitoring through EcoStruxure Machine
Expert .............................................................45
operating modes ................................................40
states................................................................40
troubleshooting ..................................................48
F
FDR service..........................................................14
functions differences between a function and a function
block ...............................................................64
how to use a function or a function block in IL
language .........................................................65
how to use a function or a function block in ST
language .........................................................67
S
states
protocol manager ...............................................40
G
get a diagnostic status
IOS_GETDIAGSTATUS .....................................60
T
troubleshooting
protocol manager ...............................................48
H
health bit
IOS_GETHEALTH .............................................54
I
IOS_CONTROLCHANNEL ....................................52
enables or disables a communication channel......52
EIO0000003826.02
75
Schneider Electric
35 rue Joseph Monier
92500 Rueil Malmaison
France
+ 33 (0) 1 41 29 70 00 www.se.com
As standards, specifications, and design change from time to time, please ask for confirmation of the information given in this publication.
© 2022 Schneider Electric . All rights reserved.
EIO0000003826.02
Unduh
Iklan