Professional Documents
Culture Documents
Legal information
Use of application examples
Application examples illustrate the solution of automation tasks through an interaction of several
components in the form of text, graphics and/or software modules. The application examples are
a free service by Siemens AG and/or a subsidiary of Siemens AG (“Siemens”). They are non-
binding and make no claim to completeness or functionality regarding configuration and
equipment. The application examples merely offer help with typical tasks; they do not constitute
customer-specific solutions. You yourself are responsible for the proper and safe operation of the
products in accordance with applicable regulations and must also check the function of the
respective application example and customize it for your system.
Siemens grants you the non-exclusive, non-sublicensable and non-transferable right to have the
application examples used by technically trained personnel. Any change to the application
examples is your responsibility. Sharing the application examples with third parties or copying the
application examples or excerpts thereof is permitted only in combination with your own products.
The application examples are not required to undergo the customary tests and quality inspections
of a chargeable product; they may have functional and performance defects as well as errors. It is
your responsibility to use them in such a manner that any malfunctions that may occur do not
result in property damage or injury to persons.
Disclaimer of liability
Siemens shall not assume any liability, for any legal reason whatsoever, including, without
limitation, liability for the usability, availability, completeness and freedom from defects of the
application examples as well as for related information, configuration and performance data and
any damage caused thereby. This shall not apply in cases of mandatory liability, for example
under the German Product Liability Act, or in cases of intent, gross negligence, or culpable loss of
life, bodily injury or damage to health, non-compliance with a guarantee, fraudulent
non-disclosure of a defect, or culpable breach of material contractual obligations. Claims for
damages arising from a breach of material contractual obligations shall however be limited to the
Siemens AG 2018 All rights reserved
foreseeable damage typical of the type of agreement, unless liability arises from intent or gross
negligence or is based on loss of life, bodily injury or damage to health. The foregoing provisions
do not imply any change in the burden of proof to your detriment. You shall indemnify Siemens
against existing or future claims of third parties in this connection except where Siemens is
mandatorily liable.
By using the application examples you acknowledge that Siemens cannot be held liable for any
damage beyond the liability provisions described.
Other information
Siemens reserves the right to make changes to the application examples at any time without
notice. In case of discrepancies between the suggestions in the application examples and other
Siemens publications such as catalogs, the content of the other documentation shall have
precedence.
The Siemens terms of use (https://support.industry.siemens.com) shall also apply.
Security information
Siemens provides products and solutions with industrial security functions that support the secure
operation of plants, systems, machines and networks.
In order to protect plants, systems, machines and networks against cyber threats, it is necessary
to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept.
Siemens’ products and solutions constitute one element of such a concept.
Customers are responsible for preventing unauthorized access to their plants, systems, machines
and networks. Such systems, machines and components should only be connected to an
enterprise network or the Internet if and to the extent such a connection is necessary and only
when appropriate security measures (e.g. firewalls and/or network segmentation) are in place.
For additional information on industrial security measures that may be implemented, please visit
https://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them more secure.
Siemens strongly recommends that product updates are applied as soon as they are available
and that the latest product versions are used. Use of product versions that are no longer
supported, and failure to apply the latest updates may increase customer’s exposure to cyber
threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed
at: https://www.siemens.com/industrialsecurity.
Table of Contents
Legal information ......................................................................................................... 2
1 Library Overview ................................................................................................ 5
1.1 General ................................................................................................. 5
1.2 Hardware and software requirements .................................................. 5
1.3 Library resources .................................................................................. 6
2 Working with the Library................................................................................... 8
2.1 General ................................................................................................. 8
2.2 Simulatability with SIMATIC S7-PLCSIM Advanced (NEW) ................ 9
3 Explanation of the Blocks ............................................................................... 11
3.0 Bit logic operations ............................................................................. 12
3.0.1 FB LGF_PulseRelay........................................................................... 12
3.1 Date and timer operations .................................................................. 14
3.1.1 FB LGF_Astro (correction) ................................................................. 14
3.1.2 FB LGF_SetTime ............................................................................... 18
3.1.3 FB LGF_TimerSwitch (correction) ...................................................... 21
3.1.4 FC LGF_CalendarDayWeek .............................................................. 24
3.1.5 FC LGF_GermanHoliday (NEW) ........................................................ 26
3.2 Counter operations ............................................................................. 28
3.2.1 FC LGF_CountFalInDWord ................................................................ 28
3.2.2 FC LGF_CountRisInDWord................................................................ 30
Siemens AG 2018 All rights reserved
5 History............................................................................................................. 126
5.1 Library versioning ............................................................................. 126
5.2 Change log ....................................................................................... 127
1 Library Overview
1.1 General
TIA Portal includes a vast number of "ready-to-use" instructions (mathematical
functions, times, counters etc.). Moreover, it offers other useful basic functions.
These functions are provided as a library and can be used freely. The ready-to-use
functions are freely adjustable and thus can be used universally.
The library described here is versioned and continuously expanded. Information on
the version system can be found in chapter 5.1 Library versioning.
Hardware
All blocks (FB, FC, DB,…) in the library can be used universally with the following
Siemens AG 2018 All rights reserved
controllers:
S7-1200 and S7-1200 F product families
S7-1500 and S7-1500 F product families
Simulation with S7-PLCSIM (as of V14)
Software
STEP 7 (TIA Portal) Basic or Professional as of V14
Note In general, it is possible to open a library using STEP 7 Basic, although elements
of STEP 7 Professional (e. g. S7-1500 controllers) are included. In this case, you
will be informed via a message when opening the library.
All elements (types and master copies) can be used if they are supported by the
hardware installed in TIA Portal.
If you try to copy elements with STEP 7 Basic from the library that are not
supported (e. g. S7-1500 controllers), an error message will be displayed.
Counter operations
FC LGF_CountFalInDWord V1.0.1 14890 1124 14896 1188
FC LGF_CountRisInDWord V1.0.1 14759 1124 14766 1188
Comparator operations
FC LGF_CompareVariant V1.0.2 10955 620 10966 684
FC LGF_CompareReal V1.0.0 6281 118 6302 182
Math operations
FC LGF_AverageAndDeviation V1.0.2 29602 3194 29614 3258
FB LGF_FloatingAverage V1.1.0 16590 748 16506 830
FC LGF_MatrixAddition V2.0.0 11514 489 11556 553
FC LGF_MatrixInverse V2.0.0 15936 1017 15976 1081
FC LGF_MatrixMultiplication V2.0.0 12172 546 12213 610
FC LGF_MatrixSubtraction V2.0.0 11545 489 11590 553
FC LGF_MatrixTranspose V2.0.0 9971 383 10010 447
FB LGF_MinMaxHistory V1.0.1 6150 114 6144 178
FC LGF_RandomBasic V1.0.0 6844 191 6868 255
FC LGF_RandomInt V1.0.1 9104 241 9115 305
FB LGF_RandomReal V1.0.2 9528 281 9550 345
FC LGF_SearchMinMax V1.0.1 36145 4642 36195 4706
FC LGF_XRoot V1.0.1 4688 49 4693 113
FC LGF_HighLowLimit V1.0.0 8978 262 9015 334
FC LGF_Integration V1.0.0 11058 323 11073 393
FC LGF_Factorial V1.0.0 6280 145 6293 209
FC LGF_Distance V1.0.0 5226 75 5171 127
Note Information on how to work with libraries is available in the Guideline on Library
Handling
https://support.industry.siemens.com/cs/ww/en/view/109747503
and in the “Programming Guideline for S7-1200/1500” in chapter “Libraries”.
https://support.industry.siemens.com/cs/ww/en/view/81318674
Siemens AG 2018 All rights reserved
Note All blocks in the LGF have been created according to the Programming
Styleguide.
https://support.industry.siemens.com/cs/ww/en/view/81318674
Which elements of STEP 7 (TIA Portal) can you store in a library as Type or as
Master Copy?
https://support.industry.siemens.com/cs/ww/en/view/109476862
When starting TIA Portal V13 onwards, how do you get a global library to open
automatically and use it as corporate library, for example?
https://support.industry.siemens.com/cs/ww/en/view/100451450
2. In your project, right-click a block (e. g. “LGF_FIFO”) in the project library and
Siemens AG 2018 All rights reserved
In the properties of the block (e. g. “LGF_FIFO”), the option "Can be simulated
with SIMATIC S7-PLCSIM (Advanced)” is enabled automatically.
Siemens AG 2018 All rights reserved
4. After loading, the block can be simulated with SIMATIC S7-PLCSIM Advanced.
5. In the project library, right-click the new version “[in test]”.
– If, after simulation, you want to keep the original version, select "Discard
changes and delete version".
Thus, you stay compatible with the LGF library.
– If, nevertheless, you want to keep the new version, select "Release
version".
Note Blocks with enabled simulatability require more memory space in the PLC.
Short description
This block corresponds to a current surge relay or a toggle flip-flop including set
and reset input.
Block
Figure 3-2: FB LGF_PulseRelay
FB LGF_PulseRelay
BOOL trigger out BOOL
BOOL set
BOOL reset
Input parameters
Siemens AG 2018 All rights reserved
Output parameters
Table 3-2: Output parameters
Parameter Data type Description
out BOOL Signal output
Function principle
Figure 3-3: LGF_PulseRelay signal diagram
trigger
1 1
set
2
reset
3 4
out
Tim
e
1. Every rising edge of the input “trigger” changes the Boolean value of the output
“out”.
Siemens AG 2018 All rights reserved
2. Every rising edge of the input “set” sets the Boolean value of the output “out” to
“TRUE”.
3. Every rising edge of the input “reset” sets the Boolean value of the output “out”
to “FALSE”.
4. If the inputs “set” and “reset” are set in the same cycle, the “reset” input has
priority.
The block can also be used as frequency divider. If the input “trigger” is supplied
with a fixed frequency, the output “out” provides half the frequency.
Short description
This block calculates the times of sunrise and sunset for a specific place on earth.
The exact position is transferred to the block as geographical coordinates
(longitude and latitude).
60°
South (-)
Siemens AG 2018 All rights reserved
30°
60°
South pole
Block
Figure 3-5: FB LGF_Astro
FB LGF_Astro
REAL latitudeDD sunrise DTL
REAL longitudeDD sunset DTL
BOOL modeDMS daytime BOOL
LGF_typeAstroDMS latitudeDMS actSystemTime DTL
LGF_typeAstroDMS longitudeDMS actLocalTime DTL
TIME offsetSunrise error BOOL
TIME offsetSunset statusID UINT
status WORD
Input parameters
Table 3-3: Input parameters
Parameter Data type Description
latitudeDD REAL Latitude in degrees with decimal places (unit: degrees decimal),
valid range of values [-90.00000..+90.00000]°
This is a common coordinate format in GPX files (GPS).
longitudeDD REAL Longitude in degrees with decimal places (unit: degrees
1
decimal) ,
valid range of values [-180.0000..+180.0000]°
modeDMS BOOL 1. Transfer format of the position in “degrees decimal" via the
formal parameters "latitudeDD" and "longitudeDD"
1. Transfer format of the position in direction, degrees, minutes
and seconds via the formal parameters “latitudeDMS" and
“longitudeDMS"
latitudeDMS LGF_typeAstroDMS Latitude in compass direction; degrees; minutes and seconds in
the PLC data type "LGF_typeAstroDMS".
valid parameter values [N, S]; [0..90]; [0..59]; [0..59]
valid range of values (total of parameter values) [N, S, n, s];
[0..90]°
This is a common coordinate format for navigation with maps.
longitudeDMS LGF_typeAstroDMS Longitude in direction; degrees; minutes and seconds in the PLC
data type "LGF_typeAstroDMS".
Siemens AG 2018 All rights reserved
Output parameters
Table 3-4: Output parameters
Parameter Data Description
type
sunrise DTL Sunrise at the specified location taking into account the "offsetSunrise"
sunset DTL Sunset at the specified location taking into account the “offsetSunset"
daytime BOOL If the local time of the controller is between "sunrise" and "sunset",
"daytime" provides the value "TRUE".
actSystemTime DTL Current system time (UTC)
actLocalTime DTL Current local time
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status" outputs the
error code.
statusID UINT "statusID" outputs the ID of the block that signals the status. See the table
below.
status WORD "status" outputs the status/error code (see table below).
"RD_SYS_T".
3 - Error/status of subordinate block -
“RD_LOC_T".
Note If "statusID" > 1, all values of the output "status" come from directly called
instructions (see table Output parameters). In this case, refer to the information
given in the TIA Portal Online Help on the corresponding instructions.
Function principle
If processes shall be automated depending on the change between day and night,
the function of an astronomic clock is required. This applies e. g. to switching on/off
an outdoor lighting or opening/closing roller shutters.
If these processes shall be carried out with a time delay, i. e. at a defined time
before or after sunrise or sunset, an offset will be required additionally.
Note For this function being carried out precisely, it has to be ensured that the system
time and the local time of the SIMATIC controller are set correctly.
The block calculates the times for sunrise and sunset based on the system
time/local time of the SIMATIC controller and the set coordinates. The offset times
are added to the sunrise and sunset and are output at the outputs "sunrise" and
"sunset". If the system time of the SIMATIC controller is between these values, the
output "daytime" will be set to the value "TRUE".
Note As the times for sunrise and sunset are changing every day, it might be that the
output "daytime" remains set to "TRUE" or "FALSE" for a longer period of time:
The coordinates can be entered in the format "DMS" (with PLC data type
"LGF_typeAstroDMS") or “Degree.Decimal".
You can use the formal parameter "modeDMS" to define which format is active
(see Table 3-3).
The coordinate values entered are checked for valid values. In case of invalid
values, a corresponding error code is output to "status" (see Table 3-5).
If an invalid coordinate value is present at a formal parameter and this formal
parameter has been activated via "modeDMS", the outputs "sunrise" and "sunset"
will be set to the value DTL#1970-01-01-00:00:00.
Example
The following example illustrates the function principle of the block.
Table 3-6: Geographic coordinates for Nuremberg-Moorenbrunn, date and system time
Longitude: + 11.07675° or E 11° 4' 36''
Siemens AG 2018 All rights reserved
Figure 3-6: FB LGF_Astro, monitoring the block online using the parameters as well as the
actual parameters via the watch table
3.1.2 FB LGF_SetTime
Short description
This block combines the functions System time, Local time and Set time zone.
Block
Figure 3-7: FB LGF_SetTime
FB LGF_SetTime
BOOL setSystemTimeUTC actSystemTime DTL
DTL systemTimeUTC actLocalTime DTL
BOOL setLocalTime lastSetTimeZone STRING
DTL localTime error BOOL
BOOL setTimeZone statusID UINT
INT timeZone status WORD
BOOL daylightSavingTime
Siemens AG 2018 All rights reserved
Input parameters
Table 3-7: Input parameters
Parameter Data type Description
setSystemTimeUTC BOOL Rising edge sets the defined system time at the input
"systemTimeUTC"
systemTimeUTC DTL Defined system time, corresponds to UTC (Coordinated
Universal Time)
setLocalTime BOOL Rising edge takes on the defined local time at the input
"localTime"
localTime DTL Defined local time
setTimeZone BOOL Rising edge takes on
the value at the input "timeZone"
the value at the input "daylightSavingTime"
timeZone INT Defined time zone (format [+-HHMM]
Examples:
UTC -12:00 [-1200]
UTC -03:30 [-330]
UTC [0]
UTC +13:00 [1300]
daylightSavingTime BOOL TRUE: Daylight saving time switchover activated (local time
+ 60 min)
– from last Sunday in March at 02:00 a.m.
– to last Sunday in October at 03:00 a.m.
FALSE: no daylight saving time switchover
Output parameters
Table 3-8: Output parameters
Parameter Data type Description
systemTime DTL Current system time (UTC)
localTime DTL Current local time
lastSetTimeZone STRING Time zone last set by the block
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
Note If "statusID" > 1, all values of the output "status" come from directly called
instructions (see table Output parameters). In this case, refer to the information
given in the TIA Portal Online Help on the corresponding instructions.
Function principle
This block combines the functions System time, Local time and Set time zone.
The following time zones can be set at the input "timeZone".
Input
Time zone
"timeZone"
Input
Time zone
"timeZone"
-330 (UTC -03:30) Newfoundland
-300 (UTC -03:00) Brasilia, Buenos Aires
-200 (UTC -02:00) Mid-Atlantic
-100 (UTC -01:00) Azores, Cape Verde Is.
0 (UTC) Dublin, Edinburgh, Lisbon, London
100 (UTC +01:00) Berlin, Bern, Brussels, Rome, Stockholm, Vienna
200 (UTC +02:00) Athens, Istanbul, Minsk, Bucharest
300 (UTC +03:00) Baghdad, Kuwait, Riyadh
330 (UTC +03:30) Iran
400 (UTC +04:00) Moscow, St. Petersburg, Volgograd, Abu Dhabi, Muscat
430 (UTC +04:30) Afghanistan
500 (UTC +05:00) Islamabad, Karachi, Tashkent
530 (UTC +05:30) India, Sri Lanka
545 (UTC +05:45) India, Sri Lanka
600 (UTC +06:00) Astana, Almaty, Dhaka, Colombo
630 (UTC +06:30) Coco Island, Myanmar
Siemens AG 2018 All rights reserved
Short description
This block is a timer. It allows to define daily, weekly, monthly, annual time switch
points as well as time switch points for weekdays or weekend days.
Block
Figure 3-8: FB LGF_TimerSwitch
FB LGF_TimerSwitch
USINT onMonth signal BOOL
USINT onDay actLocalTime DTL
USINT onWeekday error BOOL
USINT onWeekOfMonth statusID UINT
USINT onHour status WORD
USINT onMinute
USINT offMonth
USINT offDay
USINT offWeekday
Siemens AG 2018 All rights reserved
USINT offWeekOfMonth
USINT offHour
USINT offMinute
USINT mode
Input parameters
Table 3-10: Input parameters
Parameter Data type Description
onMonth USINT Month in which the signal is to be set.
onDay USINT Day on which the signal is to be set.
onWeekday USINT Weekday on which the signal is to be set.
(Sunday = 1)
onHour USINT Hour in which the signal is to be set.
onMinute USINT Minute in which the signal is to be set.
offMonth USINT Month in which the signal is to be reset.
offDay USINT Day on which the signal is to be reset.
offWeekday USINT Weekday on which the signal is to be reset.
(Sunday = 1)
offHour USINT Hour in which the signal is to be reset.
offMinute USINT Minute in which the signal is to be reset.
mode USINT Mode indication (see function principle).
Output parameters
Table 3-11: Output parameters
Parameter Data type Description
signal BOOL Output signal
actLocalTime DTL Current local time
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
Note If "statusID" > 1, all values of the output "status" come from directly called
instructions (see table Output parameters). In this case, refer to the information
given in the TIA Portal Online Help on the corresponding instructions.
Function principle
The block offers different types of a timer that can be determined in the parameter
"mode":
Daily timer (mode = 1)
Weekly timer (mode = 2)
Monthly timer (mode = 3)
Annual timer (mode = 4)
Weekdays, Monday to Friday (mode = 5)
Weekend, Saturday and Sunday (mode = 6)
If the set start time corresponds to the current local time of the controller, the output
"signal" will be set to "TRUE". If the set switch-off time corresponds to the current
local time of the controller, the output "signal" will be reset.
Hinweis Note that the block in the modes “Monthly timer“ (mode = 3) or “Annual
timer“ (mode = 4) is only triggered if the days you assign to the input parameters
“onDay” and “offDay” actually exist in that month.
3.1.4 FC LGF_CalendarDayWeek
Short description
This function uses the specified date to calculate the calendar week and the
number of days that have passed since the beginning of the year.
Block
Figure 3-9: FC LGF_ CalendarDayWeek
FC LGF_ CalendarDayWeek
DTL inDate daysPassed DINT
BOOL modeEU weekNumber DINT
error BOOL
status WORD
Input parameters
Table 3-14: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
inDate DTL Date for calculating the calendar week and the days that
st
have passed since January 1 .
modeEU BOOL Selection of the counting method for calendar weeks.
0: Counting method for the USA and many other countries
1: Counting method for European countries according to
ISO 8601
Output parameters
Table 3-15: Output parameters
Parameter Data type Description
st
daysPassed DINT Days that have passed since January 1 .
weekNumber DINT Number of the calendar week.
error BOOL Error display
0: No error.
1: Block error, "status" outputs the error code.
status WORD "status" outputs the status/error code (see table below).
Function principle
Two counting methods are available for determining the calendar week for the
stated date. Use the input "modeEU" to select the counting method:
modeEU = 0: Counting method for the USA and many other countries
modeEU = 1: Counting method for European countries according to ISO 8601
Short description
The FC LGF_GermanHoliday determines whether a given date is a holiday. All holidays in
Germany are taken into account. Holidays that are not uniform throughout Germany can be
switched on and off.
Block
Figure 3-10: FB LGF_GermanHoliday
FC LGF_GermanHoliday
DTL date Ret_Val BOOL
BOOL threeKings
BOOL roseMonday
BOOL ascension
BOOL corpusChristi
BOOL augsburgerFriedensfest
BOOL assumptionOfMary
BOOL reformationDay
Siemens AG 2018 All rights reserved
BOOL allSaintDay
BOOL bussUndBettag
Input parameters
Table-17: Input parameters
Parameter Data type Description
date DTL Date that is checked with regard to a holiday.
threeKings BOOL Epiphany
roseMonday BOOL Rose Monday
ascension BOOL Ascension Day
corpusChristi BOOL Feast of Corpus Christi
augsburgerFriedensfest BOOL “Augsburger Friedensfest”
assumptionOfMary BOOL Assumption Day
reformationDay BOOL Reformation Day
allSaintDay BOOL All Saints’ Day
bussUndBettag BOOL Penance Day
Output parameters
Table 3: Output parameters
Parameter Data type Description
Ret_Val BOOL With TRUE, the date at the input parameter "date" is a
holiday.
Function principle
The block calculates for a given date the holiday calendar of the year and indicates whether the
given date is a holiday. Optionally, it is possible to take into account holidays that are not
uniform throughout Germany, such as e. g. Epiphany, via the corresponding input parameter of
the block.
Siemens AG 2018 All rights reserved
Short description
This block analyzes a tag of the type DWORD and outputs how often a sequence
of 1-0 (falling edge) occurs in the tag.
Application example
Extract from the technology module TM Timer DIDQ 16x24V
With the oversampling function, the technology module detects the status of the
respective digital input for each application cycle (e. g. OB61) at 32 point in time in
a regular time intervals. The 32 status are returned together as a 32-bit value in the
feedback interface.
Figure 3-11: Example of an oversampling of DI0 at the TM Timer DIDQ 16x24V
Siemens AG 2018 All rights reserved
In this case, the block LGF_CountFalInDWord is used for counting how often a
falling edge occurs.
Block
Figure 3-12: FC LGF_CountFalInDWord
FC LGF_CountFalInDWord
DWORD dWordActCycle Ret_Val INT
DWORD dWordPrevCycle
Input parameters
Table 3-18: Input parameters
Parameter Data type Description
dWordActCycle DWORD Double word in which the falling edges are counted
dWordPrevCycle DWORD Double word from the previous cycle
Output parameters
Table 3-19: Output parameters
Parameter Data type Description
Ret_Val INT Number of falling edges in the double word
Function principle
In a tag of data type DWORD, the block counts the falling edges (1-0 transitions)
from left to right. For this, the output "Ret_Val" outputs the number of falling edges.
To ensure that also falling edges at the tag limits are detected, the input
"dWordPrevCycle" has to be interconnected with the tag of the previous cycle.
Example
The following example illustrates the function principle of the block. In this case, it
is assumed that a signal of unknown length is scanned in the form of double words
(DWORD) for each cycle.
Within this signal, the 1-0 sequences (falling edges) shall be counted and output
continuously. To ensure that – like in this example – the falling edges at the tag
limits are detected, the input "dWordPrevCycle" has to be interconnected with the
double word of the previous scan.
Siemens AG 2018 All rights reserved
3.2.2 FC LGF_CountRisInDWord
Short description
This block analyzes a tag of the type DWORD and outputs how often a sequence
of 0-1 (rising edge) occurs in the tag.
Application example:
Extract from the technology module TM Timer DIDQ 16x24V:
With the oversampling function, the technology module detects the status of the
respective digital input for each application cycle (e. g. OB61) at 32 point in time in
a regular time intervals. The 32 status are returned together as a 32-bit value in the
feedback interface.
Figure 3-13: Example of an oversampling of DI0 at the TM Timer DIDQ 16x24V
Siemens AG 2018 All rights reserved
In this case, the block LGF_CountRisInDWord is used for counting how often a
rising edge occurs.
Block
Figure 3-14: FC LGF_CountRisInDWord
FC LGF_CountRisInDWord
DWORD dWordActCycle Ret_Val INT
DWORD dWordPrevCycle
Input parameters
Table 3-21: Input parameters
Parameter Data type Description
dWordActCycle DWORD Double word in which the rising edges are counted
dWordPrevCycle DWORD Double word from the previous cycle
Output parameters
Table 3-22: Output parameters
Parameter Data type Description
Ret_Val INT Number of rising edges in the double word
Function principle
In a tag of data type DWORD, the block counts the rising edges (0-1 transitions)
from left to right. For this, the output "Ret_Val" outputs the number of rising edges.
To ensure that also rising edges at the tag limits are detected, the input
"dWordPrevCycle" has to be interconnected with the tag of the previous cycle.
Example
The following example illustrates the function principle of the block. In this case, it
is assumed that a signal of unknown length is scanned in the form of double words
(DWORD) for each cycle.
Within this signal, the 0-1 sequences (rising edges) shall be counted and output
continuously. To ensure that – like in this example – the rising edges at the tag
limits are detected, the input "dWordPrevCycle" has to be interconnected with the
double word of the previous scan.
Siemens AG 2018 All rights reserved
Short description
This block compares two structured (array, PLC data type) actual parameters and
outputs whether they correspond to the same type and have the same values.
Block
Figure 3-15: FC LGF_CompareVariant
FC LGF_CompareVariant
VARIANT variable1 (InOut) Ret_Val BOOL
VARIANT variable2 (InOut) error BOOL
statusID UINT
status WORD
Output parameters
Table 3-25: Output parameters
Parameter Data type Description
Ret_Val BOOL 0: Values of the comparator tags or PLC data types are
different.
1: Values of the comparator tags are equal and PLC data
types are identical.
error BOOL 0: No errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
statusID UINT "statusID" outputs the ID of the block that signals the status
(see table below).
status WORD "status" outputs the status/error code (see table below).
Function principle
This block compares two (structured) actual parameters and outputs whether they
correspond to the same value.
Note The following differences cannot be detected using the comparison method (byte
level):
It is not possible to compare tags of the data type "Struct".
For strings, there might be differences between the actual length and the maximum
length.
For REAL numbers in the structure, an inequality might be indicated even for “equal”
tags.
Tags of the type "ARRAY of BOOL" cannot be checked for equality using this
Siemens AG 2018 All rights reserved
function, as the used instruction "CountOfElements" also counts the filling elements
(e. g. 8 is returned for an ARRAY[0..1] of BOOL).
3.3.2 FC LGF_CompareReal
Short description
This function uses an approximation formula to check whether two REAL numbers
are equal.
Block
Figure 3-16: FC LGF_CompareReal
FC LGF_CompareReal
REAL valueA Ret_Val BOOL
REAL valueB error BOOL
status WORD
Input parameters
Table 3-27: Input parameters
Parameter Data type Description
valueA REAL Number to be compared.
valueB REAL Number to be compared.
Siemens AG 2018 All rights reserved
Output parameters
Table 3-28: Output parameters
Parameter Data type Description
Ret_Val BOOL 0: unequal
1: equal
error BOOL Error display
0: No error.
1: Block error, "status" outputs the error code.
status WORD "status" outputs the status/error code (see table below).
Function principle
An approximation formula is intended to check whether two REAL numbers
"valueA" and "valueB" are equal. To ensure that the comparison works
independently of the size of the numbers, the ratio of the two numbers is checked.
Approximation formula
|𝑣𝑎𝑙𝑢𝑒𝐴 − 𝑣𝑎𝑙𝑢𝑒𝐵|
≤ 𝐸𝑃𝑆𝐼𝐿𝑂𝑁
|𝑣𝑎𝑙𝑢𝑒𝐴| + |𝑣𝑎𝑙𝑢𝑒𝐵|
Two REAL numbers are considered to be equal if the ratio of the difference to the
total of the two numbers is less than or equal to 𝐸𝑃𝑆𝐼𝐿𝑂𝑁.
The value of 𝐸𝑃𝑆𝐼𝐿𝑂𝑁 specifies the accuracy with which the two numbers are
considered to be equal. In the function, 𝐸𝑃𝑆𝐼𝐿𝑂𝑁 is defined as a constant with the
value 1.0 ∙ 10−6 .
To avoid a division by zero, the approximation formula is changed in the function:
|𝑣𝑎𝑙𝑢𝑒𝐴 − 𝑣𝑎𝑙𝑢𝑒𝐵| ≤ 𝐸𝑃𝑆𝐼𝐿𝑂𝑁 ∗ (|𝑣𝑎𝑙𝑢𝑒𝐴| + |𝑣𝑎𝑙𝑢𝑒𝐵|)
The following table shows two examples to illustrate the function principle.
Table 3-30
Example 1 Example 2
|𝑣𝑎𝑙𝑢𝑒𝐴| + |𝑣𝑎𝑙𝑢𝑒𝐵| 5 5.000.000
𝐸𝑃𝑆𝐼𝐿𝑂𝑁 1.0 ∙ 10−6
Maximum difference of "𝑣𝑎𝑙𝑢𝑒𝐴" and "𝑣𝑎𝑙𝑢𝑒𝐵" for which the 0.000005 5
two numbers are still considered to be equal.
Note If for your application you need a different accuracy for evaluating the ratio of the
numbers, adapt the constant 𝐸𝑃𝑆𝐼𝐿𝑂𝑁 in the function to your requirements.
Siemens AG 2018 All rights reserved
Short description
This block determines the arithmetic average and the standard deviation from a
series of numbers.
Block
Figure 3-17: FC LGF_AverageAndDeviation
FC LGF_AverageAndDeviation
VARIANT variableArray arithmeticAverage REAL
standardDeviation REAL
error BOOL
statusID UINT
status WORD
Siemens AG 2018 All rights reserved
Input parameters
Table 3-31: Input parameters
Parameter Data type Description
variableArray VARIANT Number series to be used for calculating
Output parameters
Table 3-32: Output parameters
Parameter Data type Description
arithmeticAverage REAL Arithmetic average
standardDeviation REAL Standard deviation
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
Note If "statusID" > 1, all values of the output "status" come from directly called
instructions (see table Output parameters). In this case, refer to the information
given in the TIA Portal Online Help on the corresponding instructions.
Function principle
An array of any size is connected via the input "variableArray". Following a data
Siemens AG 2018 All rights reserved
type request in the block, the values are used to calculate the arithmetic average
as well as the standard deviation and both are output.
Note An array with too many elements might lead to the cycle monitoring time being
exceeded.
Note Note: Only the data types Int, UInt, DInt, UDInt, USInt, SInt and Real are
supported.
3.4.2 FB LGF_FloatingAverage
Short description
This block calculates a floating arithmetic average from REAL values. This method
can be applied for smoothing of data series. The values can be read in cyclically or
in a triggered way.
Block
Figure 3-18: LGF_FloatingAverage
FB LGF_FloatingAverage
REAL value average LREAL
INT mode windowSizeReached BOOL
INT windowSize error BOOL
BOOL trigger status WORD
BOOL reset
Input parameters
Table 3-34: Input parameters
Siemens AG 2018 All rights reserved
Note The block "LGF_FloatingAverage" does not carry out any data type requests for
the input parameter "value". For other data types than REAL, either an implicit
conversion is carries out automatically or a compiling error is generated.
For more information, please refer to the chapter “Overview of data type
conversion” in the TIA Portal Online Help or at:
https://support.industry.siemens.com/cs/ww/en/view/109011420/58427923211
Output parameters
Table 3-35: Output parameters
Parameter Data type Description
average LREAL Floating average
windowSizeReached BOOL 0: maximum window size not reached yet
1: maximum window size reached
error BOOL 0: no errors
1: Block error
status WORD Status/error code (see table below)
Function principle
The block calculates the (floating) average by means of the set window size. The
window size specifies the maximum number of the values last read. After the
maximum number of values has been read, the output "windowSizeReached" is set
and every new value read replaces the respective oldest value (FIFO principle).
For reading the values, two modes are available that can be defined using the
parameter "mode".
mode = 1: Reading with every pulse at the input "trigger"
mode = 2: Cyclic read
The block will be enabled as soon as you have selected a mode. It is possible to
change the modes during operation.
3.4.3 FC LGF_MatrixAddition
Short description
This block adds two matrices of equal size of the data type ARRAY of REAL.
Block
Figure 3-19: FC LGF_MatrixAddition
FC LGF_MatrixAddition
ARRAY of REAL matrix1 matrixResult ARRAY of REAL
ARRAY of REAL matrix2 error BOOL
statusID UINT
status WORD
Input parameters
Table 3-37: Input parameters
Parameter Data type Description
matrix1 ARRAY of REAL First summand (matrix)
Siemens AG 2018 All rights reserved
Output parameters
Table 3-38: Output parameters
Parameter Data type Description
matrixResult ARRAY of REAL Total (matrix)
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
Function principle
The block adds two matrices of equal size. The individual fields of the two incoming
matrices are read, added and then output in the matrix "matrixResult".
Note Please note that all input and output matrices must have the same lower and
upper limits and thus the same number of columns and rows.
Siemens AG 2018 All rights reserved
3.4.4 FC LGF_MatrixInverse
Short description
This block inverts a square matrix of the data type ARRAY of REAL.
Block
Figure 3-20: FC LGF_MatrixInverse
FC LGF_MatrixInverse
ARRAY of REAL matrix matrixResult ARRAY of REAL
error BOOL
statusID UINT
status WORD
Input parameters
Table 3-40: Input parameters
Parameter Data type Description
matrix ARRAY of REAL Input matrix
Siemens AG 2018 All rights reserved
Output parameters
Table 3-41: Output parameters
Parameter Data type Description
matrixResult ARRAY of REAL Inverted matrix
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
Function principle
The block inverts a square matrix of any size according to the Shipley-Coleman
method.
Note Please note that the input matrix must be square. This means that the number of
rows must be equal to the number of columns.
The output matrix must have the same size and the same array limits as the
input matrix.
Siemens AG 2018 All rights reserved
3.4.5 FC LGF_MatrixMultiplication
Short description
This block multiplies two matrices of the data type ARRAY of REAL.
Block
Figure 3-21: FC LGF_MatrixMultiplication
FC LGF_MatrixMultiplication
ARRAY of REAL matrix1 matrixResult ARRAY of REAL
ARRAY of REAL matrix2 error BOOL
statusID UINT
status WORD
Input parameters
Table 3-43: Input parameters
Parameter Data type Description
matrix1 ARRAY of REAL First factor: Matrix to be multiplied
Siemens AG 2018 All rights reserved
Output parameters
Table 3-44: Output parameters
Parameter Data type Description
matrixResult ARRAY of REAL Product: The resulting matrix
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
Function principle
The block multiplies two matrices of variable size. The individual elements of the
two incoming matrices are read, multiplied and then output in the matrix
"matrixResult".
Note Please note that the number of columns of the first matrix must be equal to the
number of rows of the second matrix.
Siemens AG 2018 All rights reserved
The size of the output matrix (m * n) results from the number of rows (m) of
"matrix1" and the number of columns (n) of "matrix2".
3.4.6 FC LGF_MatrixSubtraction
Short description
This block subtracts a matrix of the data type ARRAY of REAL from another one.
Block
Figure 3-22: FC LGF_MatrixSubtraction
FC LGF_MatrixSubtraction
ARRAY of REAL matrix1 matrixResult ARRAY of REAL
ARRAY of REAL matrix2 error BOOL
statusID UINT
status WORD
Input parameters
Table 3-46: Input parameters
Parameter Data type Description
matrix1 ARRAY of REAL Minuend: "matrix2" is subtracted from this matrix.
Siemens AG 2018 All rights reserved
Output parameters
Table 3-47: Output parameters
Parameter Data type Description
matrixResult ARRAY of REAL Difference: The resulting matrix
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
Function principle
The block subtracts two matrices of variable size. The individual fields of the two
matrices are read, subtracted and then output in the matrix "matrixResult".
Note Please note that all input and output matrices must have the same number of
columns and rows.
Siemens AG 2018 All rights reserved
3.4.7 FC LGF_MatrixTranspose
Short description
This block transposes a matrix of the data type ARRAY of REAL.
Condition: Input matrix (m x n) = output matrix (n x m)
Block
Figure 3-23: FC LGF_MatrixTranspose
FC LGF_MatrixTranspose
ARRAY of REAL matrix matrixResult ARRAY of REAL
error BOOL
statusID UINT
status WORD
Input parameters
Table 3-49: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
Output parameters
Table 3-50: Output parameters
Parameter Data type Description
matrixResult ARRAY of REAL resulting matrix
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
3.4.8 FB LGF_MinMaxHistory
Short description
Every time it is called, this block reads in the value of a tag and outputs the
maximum and minimum values that have been read in since the first call.
If necessary, the evaluation can be reset. The block supports the data type LREAL.
Block
Figure 3-24: FB LGF_MinMaxHistory
FB LGF_MinMaxHistory
LREAL variable minValue LREAL
BOOL reset maxValue LREAL
Input parameters
Table 3-52: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
variable LREAL Tag the value of which is checked for maximum and
minimum.
reset BOOL The block is reset and evaluation starts again.
Output parameters
Table 3-53: Output parameters
Parameter Data type Description
minValue LREAL Minimum value since first call or since the input "reset" has
been enabled.
maxValue LREAL Maximum value since first call or since the input "reset" has
been enabled.
3.4.9 FC LGF_RandomBasic
Short description
Every time it is called, this function generated a random value between 0.0 and 1.0.
The random number is of data type REAL.
Block
Figure 3-25: FC LGF_RandomBasic
FC LGF_RandomBasic
Ret_Val REAL
Output parameters
Table 3-54: Output parameters
Parameter Data type Description
Ret_Val REAL Random number
Siemens AG 2018 All rights reserved
Function principle
The function generates random values in the range of 0.0 ≤ Ret_Val ≤ 1.0.
Background information
The random value is calculated from the nanoseconds of the current system time
of the CPU. For this, the byte order of this value is inverted and then converted to a
standardized floating-point number.
Short description
For each call, this block generates a “random” value between a defined maximum
and minimum value. The random number is of data type INT / REAL.
Block
Figure 3-26: FC LGF_RandomINT / FC LGF_RandomReal
FC LGF_Random…
INT / REAL maxValue Ret_Val INT / REAL
INT / REAL minValue error BOOL
statusID UINT
status WORD
Input parameters
Table 3-55: Input parameters
Siemens AG 2018 All rights reserved
Output parameters
Table 3-56: Output parameters
Parameter Data type Description
Ret_Val INT / REAL Random number
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
Note If "statusID" > 1, all values of the output "status" come from directly called
instructions (see table Output parameters). In this case, refer to the information
given in the TIA Portal Online Help on the corresponding instructions.
Function principle
The block generates random values lying between the specified "minValue" and
"maxValue". This random value is output via "Ret_Val".
Background information
The random value is calculated from the nanoseconds of the current system time
of the CPU. For this, the byte order of this value is inverted and then converted to a
standardized floating-point number.
Note If no maximum and minimum value (= 0) is specified, the block outputs random
values over the entire range of values of INT / REAL.
Siemens AG 2018 All rights reserved
3.4.11 FC LGF_SearchMinMax
Short description
This block searches for the maximum and minimum value in an array as well as the
respective index in the array.
The following data types of the array elements are supported:
Int, DInt, UInt, UDInt, USInt, SInt and Real.
Block
Figure 3-27: FC LGF_SearchMinMax
FC LGF_SearchMinMax
VARIANT variableArray min VARIANT
minArrayIndex INT
max VARIANT
maxArrayIndex INT
error BOOL
statusID UINT
status WORD
Siemens AG 2018 All rights reserved
Input parameters
Table 3-58: Input parameters
Parameter Data type Description
variableArray VARIANT Array in the fields of which the maximum and minimum
values are searched for.
Output parameters
Table 3-59: Output parameters
Parameter Data type Description
minValue VARIANT Lowest value found.
minArrayIndex INT The start index of the array plus minArrayIndex results in the
array index of the lowest value. The index starts with 0.
maxValue VARIANT Highest value found.
maxArrayIndex INT Start index of the array plus maxArrayIndex results in the
array index of the highest value. The index starts with 0.
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
Note If "statusID" > 1, all values of the output "status" come from directly called
instructions (see table Output parameters). In this case, refer to the information
given in the TIA Portal Online Help on the corresponding instructions.
Siemens AG 2018 All rights reserved
Function principle
An array of any size is connected via the input "variableArray". After a data type
request in the block, the elements are copied one by one into a tag of the
corresponding type and compared. The lowest and the highest value as well as
their corresponding index in the array are output.
Note In case of several identical minimum or maximum values, the index of the first
minimum or maximum value is output.
3.4.12 FC LGF_XRoot
Short description
th
This block calculates the x root of a numerical tag.
Block
Figure 3-28: FC LGF_Random
FC LGF_XRoot
REAL variable Ret_Val REAL
REAL root
Input parameters
Table 3-61: Input parameters
Parameter Data type Description
variable REAL Tag from which the root is to be calculated.
rd
root REAL Root (e. g. 3 as 3 root)
Siemens AG 2018 All rights reserved
Output parameters
Table 3-62: Output parameters
Parameter Data type Description
Ret_Val REAL Output of the result
Function principle
th
This block calculates the n root of a number. To implement this function, the
following formula is expanded.
(…)
In STEP 7 (TIA Portal), the function "EXP" corresponds to e and the function
"LN" corresponds to ln(…).
This results in the following formula:
𝑅𝑒𝑡_𝑉𝑎𝑙 = 𝐸𝑋𝑃((1⁄𝑟𝑜𝑜𝑡 ) ∗ LN(𝑛𝑢𝑚𝑏𝑒𝑟))
3.4.13 FC LGF_HighLowLimit
Short description
This function checks whether a value is within a defined range of values. The range
of values is defined with a setpoint and a dead band around this setpoint. The
function calculates the lower and upper limit of the range of values.
Block
Figure 3-29: FC LGF_HighLowLimit
FC LGF_HighLowLimit
REAL value valueInRange BOOL
REAL setpoint highLimitExceeded BOOL
REAL deadband lowLimitExceeded BOOL
error BOOL
status WORD
Input parameters
Siemens AG 2018 All rights reserved
Output parameters
Table 3-64: Output parameters
Parameter Data type Description
valueInRange BOOL "TRUE" if "value" is within the range of values (dead band
around the setpoint).
valueOverHighLimit BOOL "TRUE" if "value" is higher than the upper limit ("setpoint" +
0.5 * "deadband").
valueUnderLowLimit BOOL "TRUE" if "value" is lower than the lower limit ("setpoint" -
0.5 * "deadband").
error BOOL "FALSE": no errors
"TRUE": Block error
status WORD "status" outputs the status/error code (see table below).
Function principle
The tags "setpoint" and "deadband" define a range of values. The function checks
whether the value "value" is below, within or above the range of values. The
outputs "valueUnderLowLimit", "valueInRange" or "valueOverHighLimit" output
where the value "value" is.
setpoint
valueUnderLowLimit valueInRange valueOverHighLimit
value
deadband * 0,5 deadband * 0,5
deadband
Siemens AG 2018 All rights reserved
3.4.14 FB LGF_Integration
Short description
This block approximately calculates the area below a function trend. The function
trend is transferred as analog value (REAL) that varies over time. At the output, the
integral value is output.
Block
Figure 3-31: FB LGF_Integration
FB LGF_Integration
REAL value integral REAL
BOOL enable error BOOL
BOOL reset statusID UINT
status WORD
Input parameters
Table 3-66: Input parameters
Siemens AG 2018 All rights reserved
Output parameters
Table 3-67: Output parameters
Parameter Data type Description
integral LREAL Integrated value
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
Note If "statusID" > 1, all values of the output "status" come from directly called
instructions (see table Output parameters). In this case, refer to the information
given in the TIA Portal Online Help on the corresponding instructions.
Function principle
The integral calculation includes adding all those trapezoid areas spanned
between the last two function values at the input "value" and the time. The elapsed
time is calculated using the system time of the CPU. This trapezoid area is identical
to the product of the average of the two process values and the time interval.
1 1
𝐴= ∗ (𝐹(𝑡1) + 𝐹(𝑡0) ) ∗ (𝑡1 − 𝑡0) + 2 ∗ (𝐹(𝑡2) + 𝐹(𝑡1) ) ∗ (𝑡2 − 𝑡1) + ⋯)
2
Figure 3-32: Function principle
Siemens AG 2018 All rights reserved
To start the integral calculation for the input value of the parameter "value", you
have to
set the parameter "enable" to the value "TRUE",
set the parameter "reset" to the value "FALSE".
If the parameter "enable" is set to the value "FALSE", integral calculation will be
stopped and the output "integral" outputs the last calculated value.
If the parameter "reset" is set to the value "TRUE", the output "integral" will be
reset to "0.0".
Short description
This function calculates the factorial of a natural number.
Block
Figure 3-33: LGF_Factorial
FC LGF_Factorial
INT n Ret_Val DINT
error BOOL
status WORD
Input parameters
Table 3-69: Input parameters
Parameter Data type Description
n INT Natural number
Siemens AG 2018 All rights reserved
Output parameters
Table 3-70: Output parameters
Parameter Data type Description
Ret_Val DINT Calculated factorial
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
status WORD "status" outputs the status/error code (see table below).
Function principle
This function calculates the factorial of a natural number. The permissible range of
values for the input parameter "n" is between 0 and 12.
Short description
This function calculates the distance between two points.
Block
Figure 3-34: FC LGF_Distance
FC LGF_Distance
REAL x1 Ret_Val REAL
REAL y1
REAL x2
REAL y2
Input parameters
Table 3-72: Input parameters
Parameter Data type Description
x1 REAL X-coordinate point 1
Siemens AG 2018 All rights reserved
Output parameters
Table 3-73: Output parameters
Parameter Data type Description
Ret_Val REAL Calculated distance
Function principle
This block calculates the distance between two points in a Cartesian coordinate
system.
The distance is calculated using the following formula:
𝑟𝑜𝑜𝑡
𝑅𝑒𝑡_𝑉𝑎𝑙 = √(𝑥2 − 𝑥1)² + (𝑦2 − 𝑦1)²
y2 P2
Ret_Val
y1 P1
x1 x2 x
Short description
This block stores incoming jobs/data and outputs the oldest job that has not yet
been processed.
Block
Figure 3-36: FB LGF_FIFO
FB LGF_FIFO
BOOL execute done BOOL
BOOL mode error BOOL
VARIANT initialValue statusID UINT
BOOL resetBuffer status WORD
Input parameters
Table 3-74: Input parameters
Parameter Data type Description
execute BOOL Request for a run.
mode BOOL Selecting the mode.
TRUE: Writing the value from "item" into "buffer"
FALSE: Reading the value from "buffer" and output to "item"
initialValue VARIANT Value for initializing the buffer (mostly: 0)
resetBuffer BOOL Clearing and initializing the buffer.
Output parameters
Table 3-76: Output parameters
Parameter Data type Description
done BOOL 1: Run completed.
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
"buffer".
1 16#8201 The data type of the InOut parameter -
"item" does not correspond to the data
type of the array elements of the input
"buffer".
1 16#8202 The data type of the input -
"initialValue" does not correspond to
the data type of the InOut parameter
"item".
1 16#8601 The tag "nextEmptyItemIndex" is not -
within the array limits.
1 16#8602 The tag "firstItemIndex" is not within -
the array limits.
2 - Error/status of subordinate block -
"MOVE_BLK_VARIANT".
Note If "statusID" > 1, all values of the output "status" come from directly called
instructions (see table Output parameters). In this case, refer to the information
given in the TIA Portal Online Help on the corresponding instructions.
Function principle
For the block to be started, a positive edge must be recognized at the input
"execute".
To request the next read job to be processed, the value "FALSE" must be present
at the input "mode". If this is the case, the next job/data to be processed is output
at the InOut parameter "item" and this field is replaced in the buffer with the value
of the parameter "initialValue".
To store a new write job in the buffer, the value "TRUE" must be present at the
input "mode". If this is the case, the value or job present at the InOut parameter
"item" is stored in the buffer at the next free location.
If the value "TRUE" is present at the input "resetBuffer" during a run, all fields in the
buffer will be reset to the value stated at the input "InitialValue". Afterwards, the
buffer can be filled with jobs/data again.
Siemens AG 2018 All rights reserved
Short description
This block stores incoming jobs/data and outputs the newest job/data that has not
yet been processed.
Block
Figure 3-37: FB LGF_LIFO
FB LGF_LIFO
BOOL execute done BOOL
BOOL mode error BOOL
VARIANT initialValue statusID UINT
BOOL resetBuffer status WORD
Input parameters
Table 3-78: Input parameters
Parameter Data type Description
execute BOOL Request for a run.
mode BOOL Selecting the mode.
TRUE: Writing the value from "item" into "buffer"
FALSE: Reading the value from "buffer" and output to "item"
initialValue VARIANT Value for initializing the buffer (mostly: 0)
resetBuffer BOOL Clearing and initializing the buffer.
Output parameters
Table 3-80: Output parameters
Parameter Data type Description
done BOOL 1: Run completed.
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
Note If "statusID" > 1, all values of the output "status" come from directly called
instructions (see table Output parameters). In this case, refer to the information
given in the TIA Portal Online Help on the corresponding instructions.
Function principle
For the block to be started, a positive edge must be recognized at the input
"execute".
To request the next read job to be processed, the value "FALSE" must be present
at the input "mode". If this is the case, the next job/data to be processed is output
at the InOut parameter "item" and this field is replaced in the buffer with the value
of the parameter "initialValue".
To store a new write job in the buffer, the value "TRUE" must be present at the
input "mode". If this is the case, the value or job present at the InOut parameter
"item" is stored in the buffer at the next free location.
If the value "TRUE" is present at the input "resetBuffer" during a run, all fields in the
buffer will be reset to the value stated at the input "initialValue". Afterwards, the
buffer can be filled with jobs/data again.
Siemens AG 2018 All rights reserved
Short description
This block stores data in an array of any size. As soon as all elements in the array
have been written on, the oldest element is overwritten. The newest value is
always at the first position in the array.
Block
Figure 3-38: FB LGF_RingBuffer
FB LGF_RingBuffer
BOOL write
BOOL resetBuffer
WORD newValue
ARRAY of WORD buffer (InOut)
Input parameters
Table 82: Input parameters
Siemens AG 2018 All rights reserved
Note If a data type other than WORD is to be processed, change the data type of
"newValue" and "buffer" in the block interface.
Function principle
With a positive edge at the input parameter "write", the value at the input parameter
Siemens AG 2018 All rights reserved
"newValue" is written to the first position of the ring buffer. This ring buffer must be
provided in the form of an array at the input/output parameter "buffer". The limits of
the array are determined by the block.
Before a value is written into the ring buffer, the previous elements of the ring
buffer are moved by one position. If all elements are occupied, the oldest element
will be overwritten.
If the value "TRUE" is present at the input "resetBuffer", all fields in the buffer will
be reset to the value "0". If "FALSE" is present at "resetBuffer" again, the buffer
can be filled with jobs/data again.
Note As the input parameter "write" responds to rising edges only, data can only be
stored in the ring buffer every second cycle.
Short description
This block sorts an array with any number of elements (max. 1000) in ascending or
descending order. The following data types are supported:
Array of type "Int": LGF_ShellSortInt
Array of type "UInt": LGF_ShellSortUInt
Array of type "Real": LGF_ShellSortReal
Block
Figure 3-39: FB LGF_ShellSort…
FB LGF_ShellSort…
BOOL mode done BOOL
error BOOL
VARIANT variantArray (InOut) statusID UINT
status WORD
Siemens AG 2018 All rights reserved
Input parameters
Table 3-84: Input parameters
Parameter Data type Description
mode BOOL 0: sort in ascending order (default)
1: sort in descending order
Output parameters
Table 3-86: Output parameters
Parameter Data type Description
done BOOL 1: Sorting completed.
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code.
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below).
Note If "statusID" > 1, all values of the output "status" come from directly called
instructions (see table Output parameters). In this case, refer to the information
given in the TIA Portal Online Help on the corresponding instructions.
Function principle
This block sorts according to the Shell sorting method. Please note that the
execution time of the block strongly depends on how many elements the array to
be sorted has. The following overview shows some measured values of the block
depending on the number of array elements.
Table 3-88: Execution times of the block "LGF_ShellSort…"
Number of
S7-1212C DC/DC/DC S7-1516-3 PN/DP
array elements
100 approx. 11 to 16 ms approx. 1 to 2 ms
1000 approx. 185 to 205 ms approx. 10 to 12 ms
Note The block is executed synchronously and is not distributed over several PLC
cycles. Thus, the execution time directly affects the PLC cycle time. Please
observe this behavior with regard to your project and to the controller used and
adjust the monitoring time of the controller, if necessary.
Short description
CRC calculation is used for error detection during data transmission. The result of
a calculation provides a CRC value concerning the data send. The receiver detects
an incorrect transmission due to the CRC value not being identical. The function
"LGF_CRC8" uses an 8-bit generator polynomial (mask).
Block
Figure 3-40: FB LGF_CRC8
FC LGF_CRC8
BYTE initValue Ret_Val BYTE
BYTE mask
ARRAY of BYTE inputArray
Input parameters
Table 89: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
initValue BYTE Start value used for calculating. If you do not need a start
value, assign 0x0 to the parameter.
mask BYTE Generator polynomial used for calculating.
Output parameters
Table 91: Output parameters
Parameter Data type Description
Ret_Val BYTE Calculated CRC value (return value of the function).
Function principle
This block calculates the CRC value from a data stream of any size. The data stream consists
of the individual elements of the array at the input/output parameter "inputArray". The start value
"initValue" and the generator polynomial "mask" can be selected as desired.
Short description
CRC calculation is used for error detection during data transmission. The result of
a calculation provides a CRC value concerning the data send. The receiver detects
an incorrect transmission due to the CRC value not being identical. The function
"LGF_CRC8For1Byte" uses an 8-bit generator polynomial (mask).
Block
Figure 3-41: FB LGF_CRC8For1Byte
FC LGF_CRC8For1Byte
BYTE initValue Ret_Val BYTE
BYTE mask
BYTE inputByte
Input parameters
Table 92: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
initValue BYTE Start value used for calculating. If you do not need a start
value, assign 0x0 to the parameter.
mask BYTE Generator polynomial used for calculating.
inputByte BYTE Data byte for which the CRC value is to be calculated.
Output parameters
Table 93: Output parameters
Parameter Data type Description
Ret_Val BYTE Calculated CRC value (return value of the function).
Function principle
This block calculates the CRC value from a data byte. The start value "initValue" and the
generator polynomial "mask" can be selected as desired.
Short description
CRC calculation is used for error detection during data transmission. The result of
a calculation provides a CRC value concerning the data send. The receiver detects
an incorrect transmission due to the CRC value not being identical. The function
“LGF_CRC16" uses a 16-bit generator polynomial (mask).
Block
Figure 3-42: FB LGF_CRC16
FC LGF_CRC16
WORD initValue Ret_Val WORD
WORD mask
ARRAY of BYTE inputArray
Input parameters
Table 94: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
initValue WORD Start value used for calculating. If you do not need a start
value, assign 0x0 to the parameter.
mask WORD Generator polynomial used for calculating.
Output parameters
Table 96: Output parameters
Parameter Data type Description
Ret_Val WORD Calculated CRC value (return value of the function).
Function principle
This block calculates the CRC value from a data stream of any size. The data stream consists
of the individual elements of the array at the input/output parameter "inputArray". The start value
"initValue" and the generator polynomial "mask" can be selected as desired.
Short description
CRC calculation is used for error detection during data transmission. The result of
a calculation provides a CRC value concerning the data send. The receiver detects
an incorrect transmission due to the CRC value not being identical. The function
"LGF_CRC32" uses a 32-bit generator polynomial (mask).
Block
Figure 3-43: FB LGF_CRC32
FC LGF_CRC32
DWORD initValue Ret_Val DWORD
DWORD mask
DWORD finalXorValue
BOOL reflectInput
BOOL reflectResult
ARRAY of BYTE inputArray
Siemens AG 2018 All rights reserved
Input parameters
Table 97: Input parameters
Parameter Data type Description
initValue DWORD Start value used for calculating. If you do not need a start
value, assign 0x0 to the parameter.
mask DWORD Generator polynomial used for calculating.
finalXorValue DWORD Value with which another XOR operation will be carried out
at the end
reflectInput BOOL If the value is TRUE, the order of bits within the input byte
will be mirrored. The order 0…7 turns into 7…0.
reflectResult BOOL If the value is TRUE, the order of bits within the result byte
will be mirrored. The order 0…7 turns into 7…0.
Output parameters
Table 99: Output parameters
Parameter Data type Description
Ret_Val DWORD Calculated CRC value (return value of the function).
Function principle
This block calculates the CRC value from a data stream of any size. The data stream consists
of the individual elements of the array at the input/output parameter "inputArray". The start value
"initValue" and the generator polynomial "mask" can be selected as desired. Optionally, you can
use the Boolean input parameters "reflectInput" and "reflectResult" to mirror the bits of the input
data or of the CRC value (see input parameters). Moreover, at the end, the CRC value is used
for an XOR operation with the value present at "finalXOR".
Siemens AG 2018 All rights reserved
Short description
This block converts a binary-coded value to a Gray-coded value.
Block
Figure 3-44: FC LGF_BinaryToGray
FC LGF_BinaryToGray
DWORD variableBinary Ret_Val DWORD
Input parameters
Table 3-100: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
Output parameters
Table 3-101: Output parameters
Parameter Data type Description
Ret_Val DWORD Gray-coded value
3.6.2 FC LGF_GrayToBinary
Short description
This block converts a Gray-coded value to a binary-coded value.
Block
Figure 3-45: FC LGF_GrayToBinary
FC LGF_GrayToBinary
DWORD variableGray Ret_Val DWORD
Input parameters
Table 3-102: Input parameters
Parameter Data type Description
variableGray DWORD Gray-coded value
Siemens AG 2018 All rights reserved
Output parameters
Table 3-103: Output parameters
Parameter Data type Description
Ret_Val DWORD Binary-coded value
3.6.3 FC LGF_BitsToWord
Short description
This block converts 16 BOOL tags to a WORD tag.
Block
Figure 3-46: FC LGF_BitsToWord
FC LGF_BitsToWord
BOOL bit0 Ret_Val WORD
BOOL bit1
BOOL bit2
BOOL bit3
BOOL bit4
BOOL bit5
BOOL bit6
BOOL bit7
BOOL bit8
BOOL bit9
Siemens AG 2018 All rights reserved
BOOL bit10
BOOL bit11
BOOL bit12
BOOL bit13
BOOL bit14
BOOL bit15
Input parameters
Table 3-104: Input parameters
Parameter Data type Description
bit0 BOOL Bit tags
…
bit15
Output parameters
Table 3-105: Output parameters
Parameter Data type Description
Ret_Val WORD Word tag
3.6.4 FC LGF_WordToBits
Short description
This block converts a WORD tag to 16 BOOL tags.
Block
Figure 3-47: FC LGF_WordToBits
FC LGF_WordToBits
WORD word bit0 BOOL
bit1 BOOL
bit2 BOOL
bit3 BOOL
bit4 BOOL
bit5 BOOL
bit6 BOOL
bit7 BOOL
bit8 BOOL
bit9 BOOL
Siemens AG 2018 All rights reserved
bit10 BOOL
bit11 BOOL
bit12 BOOL
bit13 BOOL
bit14 BOOL
bit15 BOOL
Input parameters
Table 3-106: Input parameters
Parameter Data type Description
Word WORD WORD tag
Output parameters
Table 3-107: Output parameters
Parameter Data type Description
bit0 BOOL Bit tags
…
bit15
3.6.5 FC LGF_DTLtoString
Short description
This block converts a date of the DTL data type to a string of the STRING data
type.
Block
Figure 3-48: FC LGF_DTLtoString
FC DTLtoString
DTL inDTL Ret_Val STRING
BOOL format
CHAR separatorDate
Input parameters
Table 3-108: Input parameters
Parameter Data type Description
inDTL DTL Date
Siemens AG 2018 All rights reserved
Output parameters
Table 3-109: Output parameters
Parameter Data type Description
Ret_Val STRING Output string
Function principle
The block reads a date of the data type DTL and converts the individual
components of the date (year, month, day, hour) to a string and outputs them. The
individual components are placed at the correct position in the string according to
the selected format. The separator between the components of the date is variable.
Format selection
You can use the input parameter "format" to choose between the international (ISO
8601) and the traditional (DE) date format for the output string.
6. International format (ISO 8601)
If the input parameter "format" is not set (format = FALSE), the date will be
output as a string in the international format.
Example: 2016-03-16 13:34:12.123456789
The figure below shows the positions of the individual characters in the string.
The figure below shows the positions of the individual characters in the string.
Figure 3-50: Positions of the individual characters
Separators
At the input parameter "separatorDate", you have to specify the separator between
the components of the calendar date.
Example: separatorDate = ‘/’
outString = ‘2016/03/16 …’
Siemens AG 2018 All rights reserved
separatorDate = ‘-‘
outString = ‘2016-03-16 …’
3.6.6 FC LGF_StringToDTL
Short description
This block converts a string from the string format with date components to the
data type DTL.
Block
Figure 3-51: FC LGF_StringToDTL
FC LGF_StringToDTL
STRING inString Ret_Val DTL
BOOL format error Bool
status WORD
Input parameters
Table 3-110: Input parameters
Parameter Data type Description
inString STRING Date as string
Siemens AG 2018 All rights reserved
Output parameters
Table 3-111: Output parameters
Parameter Data type Description
Ret_Val DTL Outputs the date read in
error BOOL 0: no error
1: Block error, "status" outputs the error code
status WORD "status" outputs the status/error code (see table below)
Function principle
The block reads a date as a string and converts it to the datatype DTL. The
individual date components in the string are separated according to the format
selected (positioning of the date components within the string). For this, the
separator between the components in the string is irrelevant.
Format selection
You can use the input parameter "format" to select whether the string read in is
shown in the international (ISO 8601) or traditional (DE) date format.
1. International format (ISO 8601)
If the input parameter "format" is not set (format = FALSE), the date in the
string will be read in the international format.
Siemens AG 2018 All rights reserved
Figure 2-10 shows the positions of the individual characters in the string.
Figure 3-52: Positions of the individual characters
The figure below shows the positions of the individual characters in the string.
Figure 3-53: Positions of the individual characters
3.6.7 FC LGF_TemperatureConvert
Short description
This block converts °Celsius to °Fahrenheit or Kelvin as well as °Fahrenheit to
Kelvin and vice versa.
Block
Figure 3-54: FC LGF_TemperatureConvert
FC LGF_TemperatureConvert
INT mode Ret_Val REAL
REAL temperature error BOOL
Status WORD
Input parameters
Table 3-113: Input parameters
Parameter Data type Description
mode INT Mode
Siemens AG 2018 All rights reserved
1. °Celsius to °Fahrenheit
2. °Fahrenheit to °Celsius
3. °Celsius to Kelvin
4. Kelvin to °Celsius
5. °Fahrenheit to Kelvin
6. Kelvin to °Fahrenheit
temperature REAL Temperature to be converted
Output parameters
Table 3-114: Output parameters
Parameter Data type Description
Ret_Val REAL Converted temperature
error BOOL 0: no errors
1: Block error
status WORD "status" outputs the status/error code (see table below).
3.6.8 FC LGF_ScaleLinear
Short description
This function scales the input value using a linear equation.
Block
Figure 3-55: FC LGF_ScaleLinear
FC LGF_ScaleLinear
VARIANT x y VARIANT
VARIANT x1 error BOOL
VARIANT y1 status WORD
VARIANT x2
VARIANT y2
VARIANT yMin
VARIANT yMax
Input parameters
Table 3-116: Input parameters
Siemens AG 2018 All rights reserved
Output parameters
Table 3-117: Output parameters
Parameter Data type Description
y VARIANT Output value, scaled.
error BOOL Error display
0: No error.
1: Block error, "status" outputs the error code.
status WORD "status" outputs the status/error code (see table below).
Function principle
This function scales an input quantity (e. g. an analog input value) linearly to a
particular output quantity (e. g. filling level).
To determine the output quantity, the function uses the following linear equation:
𝑦2 − 𝑦1
𝑦= ∙ (𝑥 − 𝑥1 ) + 𝑦1
𝑥2 − 𝑥1
The line is defined by the two points P1 and P2,. Specify the points in terms of a
Cartesian coordinate system by x and y coordinates.
Note If the values of the parameters "x1" and "x2" are equal, the output "y" will output
Siemens AG 2018 All rights reserved
By specifying "yMin" and "yMax", you can restrict the calculated value of "y" to a
range with a lower and upper limit. Thus, high range and low range errors can be
avoided.
Figure 3-56: Scaling
.
yMax
y2
P2
y*
y1
P1.
yMin
x1 x** x2
*) resulting scaled value
**) value to be scaled
You can configure formal parameters using the following data types:
Example
A signal of 4 to 20mA is present at an analog input module. This signal is
converted to a CPU internal value between 0 and 27648 in order to measure a
filling level. For this, 0 corresponds to a filling level of 0.0 m and 27648
corresponds to a filling level of 1.7 m.
Thus, you have to configure the block as follows:
x1 = 0; y1 = 0.0 (P1)
x2 = +27648; y2 = 1.7 (P2)
yMin = 0.0
yMax = 1.7
Siemens AG 2018 All rights reserved
3.6.9 FC LGF_StringToTaddr
Short description
The system data type "TADDR_Param" contains address information consisting of
an IPV4 address and the port number.
The function LGF_StringToTaddr converts a tag of data type "String" to a tag of
system data type "TADDR_Param".
Block
Figure 3-57: FC LGF_StringToTaddr
FC LGF_StringToTaddr
STRING ipAddressString Ret_Val TADDR_param
error BOOL
status WORD
Input parameters
Table 3-120: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
Output parameters
Table 3-121: Output parameters
Parameter Data type Description
Ret_Val TADDR_param IPV4 address
error BOOL 0: no errors
1: Block error
status WORD "status" outputs the status/error code (see table below).
Function principle
The function converts the IPV4 address with or without port number of the data
type "STRING" to "TADDR_param". The string must correspond to the following
form:
[0..255].[0..255].[0..255].[0..255] without port number
or
[0..255].[0..255].[0..255].[0..255]:[0..65535] with port number
Example
Standard string format for an IPV4 address without port number:
‘192.168.11.11’
Standard string format for an IPV4 address with port number:
'192.168.11.11:3294'
Note Without any port number specified in the parameter "ipAddressString", the
parameter "Ret_Val.REM_PORT_NR" outputs the value "0".
Siemens AG 2018 All rights reserved
3.6.10 FC LGF_TaddrToString
Short description
The system data type "TADDR_Param" contains address information consisting of
an IPV4 address and the port number.
The function LGF_TaddrToString converts a tag of system data type
"TADDR_Param" to a tag of data type "String".
Block
Figure 3-58: FC LGF_TaddrToString
FC LGF_TaddrToString
TADDR_Param ipAdressTaddr Ret_Val STRING
Input parameters
Table 3-123: Input parameters
Parameter Data type Description
ipAdressTaddr TADDR_Param IPV4 address
Siemens AG 2018 All rights reserved
Output parameters
Table 3-124: Output parameters
Parameter Data type Description
Ret_Val STRING IPV4 address
Function principle
The function converts the IPV4 address with or without port number. The system
data type "TADDR_Param" is a structured data type. This structure includes the
tag "REM_PORT_NR". If this tag is "0", no port will be written in the parameter
"Ret_Val".
Example
Ret_val without port number: ‘192.168.11.11’
Ret_val with port number: '192.168.11.11:3294'
Short description
This block converts a tag of system data type "DInt" to a tag of data type "String".
Block
Figure 3-59: FC LGF_IntToString
FC LGF_IntToString
DINT intValue Ret_Val STRING
Input parameters
Table 3-125: Input parameters
Parameter Data type Description
intValue DINT Integer value
Siemens AG 2018 All rights reserved
Output parameters
Table 3-126: Output parameters
Parameter Data type Description
Ret_Val STRING Converted value as string
Short description
This block converts a tag of system data type "Time" to a tag of data type "String".
Block
Figure 3-60: FC LGF_TimeToString
FC LGF_TimeToString
TIME timeValue Ret_Val STRING
Input parameters
Table 3-127: Input parameters
Parameter Data type Description
intValue TIME Integer value
Siemens AG 2018 All rights reserved
Output parameters
Table 3-128: Output parameters
Parameter Data type Description
Ret_Val STRING Converted time as string
Short description
This block generates a signal that toggles between the values "0" and "1"
depending on a defined frequency and a pulse pause ratio.
Block
Figure 3-61: FB LGF_Frequency
FB LGF_Frequency
REAL frequency clock BOOL
REAL pulsePauseRatio countdown TIME
Input parameters
Table 3-129: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
Output parameters
Table 3-130: Output parameters
Parameter Data type Description
clock BOOL Output toggles with defined frequency
countdown TIME Remaining time of the current state of "clock"
Function principle
The output "clock" is a Boolean value that toggles at the defined frequency. The
pulse pause ratio can be set using the input "pulsePauseRatio".
The output "countdown" outputs the remaining time of the current state of "clock".
If the desired frequency or the pulse pause ratio is less than or equal to "0.0", then
the output "clock" = FALSE and "countdown" = "0 s".
Example
Figure 3-62: FB LGF_Frequency
FB LGF_Frequency
𝑡𝑜 3
𝑢𝑙 𝑒𝑃𝑎𝑢 𝑒𝑅𝑎𝑡 𝑜 = =
𝑡𝑜 1
T
ton toff T =2s
ton = 1.5 s
clock toff = 0.5 s
Siemens AG 2018 All rights reserved
3.7.2 FB LGF_Impulse
Short description
This block generates pulses at a specified frequency. The pulse is always pending
for a (control) cycle.
Block
Figure 3-63: FB LGF_Impulse
FB LGF_Impulse
REAL frequency impulse BOOL
countdown TIME
Input parameters
Table 3-131: Input parameters
Parameter Data type Description
frequency REAL Clock frequency in Hz
Siemens AG 2018 All rights reserved
Output parameters
Table 3-132: Output parameters
Parameter Data type Description
impulse BOOL Signal with pulses
countdown TIME Time until next pulse
Function principle
This block generates pulses at the output "impulse" at the frequency "frequency".
The block always starts with a pulse and sets the following pulse after the period
duration has elapsed.
Example
Figure 3-64: Example
FB LGF_Impulse
impulse TRUE
0.5 frequency Period duration: 2 seconds
countdown T#0S_703MS
3.7.3 FB LGF_SawTooth
Short description
This block generates a saw-tooth signal characteristic. Each saw tooth consists of
a defined number of steps (increments).
Block
Figure 3-65: FB LGF_SawTooth
FB LGF_SawTooth
INT startValue value INT
TIME timeRange
INT incrementRange
INT numberSteps
BOOL endlessSteps
BOOL restart
Input parameters
Siemens AG 2018 All rights reserved
Note Please note that changes at the input parameters will only become effective with
"restart".
Output parameters
Table 3-134: Output parameters
Parameter Data type Description
value INT Current value of the saw-tooth signal.
Function principle
This block calculates the values for a saw-tooth signal characteristic which are
output at the output parameter "value". The signal starts with the start value
"startValue" and is added to the value "Time" each time the time interval
"timeRange" has elapsed. The value can be a negative one as well.
If the tag "endlessSteps" is set to "FALSE", the number of adding processes will be
counted. If this number exceeds the value "numberSteps", the output parameter
"value" is reset to the start value. A new saw tooth starts.
If the tag "endlessSteps" is set to "TRUE", the value "increment" will be added
without interruption – once and starting at "startValue". If the maximum positive INT
value range (32767) of the output parameter "value" is exceeded, "value" will
change to the maximum negative INT value range (-32768) and will be added
further.
value
endless Steps= true
Siemens AG 2018 All rights reserved
incrementRange
startValue
time
restart = false
Short description
This block generates a saw-tooth signal characteristic.
Block
Figure 3-67: FB LGF_SawToothCI
FB LGF_SawToothCI
REAL amplitude sawToothValues REAL
REAL offset error BOOL
UDINT periodeMS statusID UINT
OB_CYCLIC callOB status WORD
BOOL reset
Input parameters
Table 3-135: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
Output parameters
Table 3-136: Output parameters
Parameter Data type Description
sawToothValues REAL Current value of the saw-tooth signal.
Function principle
This block calculates the values for a saw-tooth signal characteristic which are
output at the output parameter "sawToothValues".
The amplitude "amplitude", the offset in Y direction "offset" and the period duration
"periodeMS" can be specified at the input parameters.
You can use the input parameter "reset" to reset the signal characteristic. At the
output parameter "sawToothValues", the value "0" is output as long as "reset" is
set to "TRUE".
The block must be called in a cyclic interrupt OB. The clock cycle of the calling
cyclic interrupt OB is determined in the FB with the instruction "QRY_CINT". For
this, the constant name of the calling cyclic interrupt OB must be interconnected at
the input parameter "callOB".
The number of calculated values of the signal characteristic for each period
Siemens AG 2018 All rights reserved
Note To maintain a continuous signal characteristic of the curve, the clock cycle of the
calling cyclic interrupt OB depending on the period duration should not be
selected to large.
The figure below shows the signal characteristic of the calculated values.
Amplitude
0
Time
-Amplitude
Period duration
Short description
This block generates a triangle signal characteristic.
Block
Figure 3-70: FB LGF_TriangleCI
FB LGF_TriangleCI
REAL amplitude triangleValues REAL
REAL offset error BOOL
UDINT periodeMS statusID UINT
OB_CYCLIC callOB status WORD
BOOL reset
Input parameters
Table 3-138: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
Output parameters
Table 3-139: Output parameters
Parameter Data type Description
triangleValues REAL Current value of the triangle signal.
Function principle
This block calculates the values for a triangle signal characteristic which are output
at the output parameter "triangleValues".
The amplitude "amplitude", the offset in Y direction "offset" and the period duration
"periodeMS" can be specified at the input parameters.
You can use the input parameter "reset" to reset the signal characteristic. At the
output parameter "triangleValues", the value "0" is output as long as "reset" is set
to "TRUE".
The block must be called in a cyclic interrupt OB. The clock cycle of the calling
cyclic interrupt OB is determined in the FB with the instruction "QRY_CINT". For
this, the constant name of the calling cyclic interrupt OB must be interconnected at
the input parameter "callOB".
The number of calculated values of the signal characteristic for each period
Siemens AG 2018 All rights reserved
Note To maintain a continuous signal characteristic of the curve, the clock cycle of the
calling cyclic interrupt OB depending on the period duration should not be
selected to large.
The figure below shows the signal characteristic of the calculated values.
Amplitude
0
Time
-Amplitude
Period duration
Short description
This block generates a rectangular signal characteristic.
Block
Figure 3-73: FB LGF_RectangleCI
FB LGF_RectangleCI
REAL amplitude rectangleValues REAL
REAL offset error BOOL
UDINT periodeMS statusID UINT
OB_CYCLIC callOB status WORD
BOOL reset
Input parameters
Table 3-141: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
Output parameters
Table 3-142: Output parameters
Parameter Data type Description
rectangleValues REAL Current value of the rectangular signal.
Function principle
This block calculates the values for a rectangular signal characteristic which are
output at the output parameter "rectangleValues".
The amplitude "amplitude", the offset in Y direction "offset" and the period duration
"periodeMS" can be specified at the input parameters.
You can use the input parameter "reset" to reset the signal characteristic. At the
output parameter "rectangleValues", the value "0" is output as long as "reset" is set
to "TRUE".
The block must be called in a cyclic interrupt OB. The clock cycle of the calling
cyclic interrupt OB is determined in the FB with the instruction "QRY_CINT". For
this, the constant name of the calling cyclic interrupt OB must be interconnected at
the input parameter "callOB".
The number of calculated values of the signal characteristic for each period
Siemens AG 2018 All rights reserved
Note To maintain a continuous signal characteristic of the curve, the clock cycle of the
calling cyclic interrupt OB depending on the period duration should not be
selected to large.
The figure below shows the signal characteristic of the calculated values.
Amplitude
0
Time
-Amplitude
Period duration
Short description
This block generates a sinusoidal signal characteristic.
Block
Figure 3-76: FB LGF_SinusCI
FB LGF_SinusCI
REAL amplitude sinusValues REAL
REAL offset error BOOL
UDINT periodeMS statusID UINT
OB_CYCLIC callOB status WORD
BOOL reset
Input parameters
Table 3-144: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
Output parameters
Table 3-145: Output parameters
Parameter Data type Description
sinusValues REAL Current value of the triangle signal.
Function principle
This block calculates the values for a sinusoidal signal characteristic which are
output at the output parameter "sinusValues".
The amplitude "amplitude", the offset in Y direction "offset" and the period duration
"periodeMS" can be specified at the input parameters.
You can use the input parameter "reset" to reset the signal characteristic. At the
output parameter "sinusValues", the value "0" is output as long as "reset" is set to
"TRUE".
The block must be called in a cyclic interrupt OB. The clock cycle of the calling
cyclic interrupt OB is determined in the FB with the instruction "QRY_CINT". For
this, the constant name of the calling cyclic interrupt OB must be interconnected at
the input parameter "callOB".
The number of calculated values of the signal characteristic for each period
Siemens AG 2018 All rights reserved
Note To maintain a continuous signal characteristic of the curve, the clock cycle of the
calling cyclic interrupt OB depending on the period duration should not be
selected to large.
The figure below shows the signal characteristic of the calculated values.
Amplitude
0
Time
-Amplitude
Period duration
Short description
This block generates a cosinusoidal signal characteristic.
Block
Figure 3-79: FB LGF_CosinusCI
FB LGF_CosinusCI
REAL amplitude cosinusValues REAL
REAL offset error BOOL
UDINT periodeMS statusID UINT
OB_CYCLIC callOB status WORD
BOOL reset
Input parameters
Table 3-147: Input parameters
Parameter Data type Description
Siemens AG 2018 All rights reserved
Output parameters
Table 3-148: Output parameters
Parameter Data type Description
cosinusValues REAL Current value of the triangle signal.
Function principle
This block calculates the values for a cosinusoidal signal characteristic which are
output at the output parameter "cosinusValues".
The amplitude "amplitude", the offset in Y direction "offset" and the period duration
"periodeMS" can be specified at the input parameters.
You can use the input parameter "reset" to reset the signal characteristic. At the
output parameter "cosinusValues", the value "0" is output as long as "reset" is set
to "TRUE".
The block must be called in a cyclic interrupt OB. The clock cycle of the calling
cyclic interrupt OB is determined in the FB with the instruction "QRY_CINT". For
this, the constant name of the calling cyclic interrupt OB must be interconnected at
the input parameter "callOB".
The number of calculated values of the signal characteristic for each period
Siemens AG 2018 All rights reserved
Note To maintain a continuous signal characteristic of the curve, the clock cycle of the
calling cyclic interrupt OB depending on the period duration should not be
selected to large.
The figure below shows the signal characteristic of the calculated values.
Amplitude
0
Time
-Amplitude
Period duration
Short description
This block limits the rate of change of an input value. A jump function becomes a
ramp function.
Block
Figure 3-82: FB LGF_LimRateOfChangeBasic
FB LGF_LimRateOfChangeBasic
REAL inputValue outputValue REAL
REAL setRateLim error BOOL
REAL defaultOutValue statusID UINT
BOOL onDefaultOutValue status WORD
OB_CYCLIC callOB
Siemens AG 2018 All rights reserved
Input parameters
Table 3-150: Input parameters
Parameter Data type Description
inputValue REAL Input value (jump function)
setRateLim REAL Rate of change of the ramp function (1/second)
onDefaultOutValue BOOL Preassign the output quantity
defaultOutValue REAL Value for preassigning the output quantity
callOB OB_CYCLIC Calling cyclic interrupt OB
Output parameters
Table 3-151: Output parameters
Parameter Data type Description
outputValue REAL output quantity
error BOOL 0: no errors
1: Block error, "statusID" outputs the error source, "status"
outputs the error code
statusID UINT "statusID" outputs the ID of the block that signals the status.
See the table below.
status WORD "status" outputs the status/error code (see table below)
Note If "statusID" > 1, all values of the output "status" come from directly called
instructions (see table Output parameters). In this case, refer to the information
given in the TIA Portal Online Help on the corresponding instructions.
Siemens AG 2018 All rights reserved
Function principle
The ramp is a limitation line and refers to a rate of change per second. If, for
example, "setRateLim = 10.0" is configured, 10.0/1.0/0.1 is added to "outputValue"
for a sampling time of 1s/100ms/10ms with each call of a block if "inputValue >
outputValue" until "inputValue" is reached.
The limitation of the rate of change applies both in the positive and negative range
of values as well as for an increase and a decrease.
The output "outputValue" can be preassigned or initialized.
The clock cycle of the calling cyclic interrupt OB in which the calling cyclic interrupt
OB is interconnected at the input parameter “callOB” is determined.
Function characteristics
Figure 3-84: Ramp function characteristic
onDefaultOutValue
outputValue
inputValue (t)
defaultOutValue
t
Siemens AG 2018 All rights reserved
3.8.2 FB LGF_LimRateOfChangeAdvanced
Short description
The block LGF_LimRateOfChangeAdvanced limits the rate of change of an input
value. Jump functions become ramp functions. Additionally, the block offers various
operating modes.
Block
Figure 3-85: FB LGF_LimRateOfChangeAdvanced
FB LGF_LimRateOfChangeAdvanced
REAL inputValue outputValue REAL
REAL setPosUpRateLim posUpRateLim BOOL
REAL setPosDownRateLim posDownRateLim BOOL
REAL setNegUpRateLim negUpRateLim BOOL
REAL setNegDownRateLim negDownRateLim BOOL
REAL setHighLim highLim BOOL
REAL setLowLim lowLim BOOL
REAL processValue error BOOL
REAL defaultOutValue statusID UINT
Siemens AG 2018 All rights reserved
Input parameters
Table 3-153: Input parameters
Parameter Data type Description
inputValue REAL Input value (jump function)
Rate of change per second for rising ramp in the positive
setPosUpRateLim REAL
range of values
Rate of change per second for falling ramp in the positive
setPosDownRateLim REAL
range of values
Rate of change per second for rising ramp in the negative
setNegUpRateLim REAL
range of values
Rate of change per second for falling ramp in the negative
setNegDownRateLim REAL
range of values
setHighLim REAL Upper limit
setLowLim REAL Lower limit
processValue REAL Process value
defaultOutValue REAL Value for preassigning the output quantity
onDefaultOutValue BOOL Preassign the output quantity
track BOOL Switching an input value (tracking)
manOp BOOL Switching a process value
Output parameters
Table 3-154: Output parameters
Parameter Data Description
type
outputValue REAL output quantity
posUpRateLim BOOL Rise limitation in the positive range activated
posDownRateLim BOOL Fall limitation in the positive range activated
negUpRateLim BOOL Rise limitation in the negative range activated
negDownRateLim BOOL Fall limitation in the negative range activated
highLim BOOL Upper limit activated
lowLim BOOL Lower limit activated
0: no errors
error BOOL 1: Block error, "statusID" outputs the error source, "status" outputs
the error code
Siemens AG 2018 All rights reserved
"statusID" outputs the ID of the block that signals the status. See
statusID UINT
table below
status WORD "status" outputs the status/error code (see table below)
Note If "statusID" > 1, all values of the output "status" come from directly called
instructions (see table Output parameters). In this case, refer to the information
given in the TIA Portal Online Help on the corresponding instructions.
Siemens AG 2018 All rights reserved
Function principle
For the positive/negative range of values, two rates of change can be configured
each for the ramp (increasing and decreasing values). The following operating
modes can be selected via control inputs:
Restart
Preassigning the output
Normal operation (automatic)
Tracking
Switching a process value (manual)
The output quantity can be limited by two configurable limits. An active limitation of
the rate of change of a ramp as well as an active limitation of the output quantity
are signaled via outputs.
The clock cycle of the calling cyclic interrupt OB in which the calling cyclic interrupt
OB is interconnected at the input parameter “callOB” is determined.
Restart
With restart set to "reset = TRUE", the output "outputValue" is reset to 0.0. If
"onDefaultOutValue = TRUE" is set, "defaultOutValue" will be output. All signal
outputs are set to FALSE.
Normal operation
The ramps are limitation lines and refer to a rate of change per second. If, for
example, "setPosUpRateLim = 10.0" is configured, 10.0/1.0/0.1 is added to
"outputValue" for a sampling time of 1s/100ms/10ms with each call of a block if
"inputValue > outputValue" until "inputValue" is reached.
The limitation of the rate of change can be configured in the positive and negative
range of values respectively for an increase and a decrease.
Table 3-156: Designation of the ramps
Siemens AG 2018 All rights reserved
Parameter Ramp
setPosUpRateLim outputValue > 0 and |outputValue| rising
setPosDownRateLim outputValue > 0 and |outputValue| falling
setNegUpRateLim outputValue < 0 and |outputValue| rising
setNegDownRateLim outputValue < 0 and |outputValue| falling
If the ramps are not configured ("setPosUpRateLim", "setPosDownRateLim",
"setNegUpRateLim" and "setNegDownRateLim" equal to 0.0), the output remains
at the value 0.0 and normal operation is out of operation.
Tracking
If the input is set to "track = TRUE", the input value “inputValue” will be
interconnected directly to the output quantity “outputValue”. Thus, jumps of the
input quantity are output as well.
Function characteristics
Figure 3-87: Ramp function characteristic, operating modes
manOp
track
onDefaultOutValue
outputValue
setHighLim
inputValue (t)
defaultOutValue
processValue (t)
setLowLim
Siemens AG 2018 All rights reserved
highLim
lowLim
posUpRateLim
posNegRateLim
negDownRateLim
negUpRateLim
3.8.3 FB LGF_Ramp
Short description
This block generates a speed curve by means of a support point table. Between
the points, there is a linear interpolation within the specified time.
Block
Table 3-157: FB LGF_Ramp
FB LGF_Ramp
REAL defaultOutValue outputValue REAL
INT contStepNbr actTimeTable BOOL
TIME contStepTime stepNumber INT
BOOL onDefaultOutValue remainTime TIME
BOOL start totalTime TIME
BOOL hold remainTotalTime TIME
BOOL continue error BOOL
BOOL cyclicOP statusID UINT
BOOL updateTime status WORD
BOOL reset
Siemens AG 2018 All rights reserved
OB_CYCLIC callOB
ARRAY of
"typeTimeTable" setpoints
Input parameters
Table 3-158: Input parameters
Parameter Data type Description
Output parameters
Table 3-159: Output parameters
Parameter Data type Description
outputValue REAL output quantity
actTimeTable BOOL Support point table is currently being processed.
stepNumber INT Current support point number (support point that is switched)
remainTime TIME Remaining time until the next support point is reached
totalTime TIME Total time
remainTotalTime TIME Total remaining time
error 0: no errors
1: Block error, "statusID" outputs the error source, "status"
BOOL outputs the error code.
statusID "statusID" outputs the ID of the block that signals the status.
UINT See the table below.
status WORD "status" outputs the status/error code (see table below).
Note If "statusID" > 1, all values of the output "status" come from directly called
instructions (see table Output parameters). In this case, refer to the information
given in the TIA Portal Online Help on the corresponding instructions.
Global data
Together with the block, you automatically receive the PLC data type
"typeTimeTable" consisting of the parameters "outVal" for the value of a support
point and "time" for the time until the next support point is reached. The declaration
is done in a one-dimensional array of the data type "typeTimeTable", beginning
with the index 0. The array is created in a global data block and is then transferred
to the block "LGF_Ramp".
The parameter "time" of the last support point needs to be configured with 0s, since
there is no longer any subsequent support point.
Function principle
With the block, speed curves can be performed by means of configured support
points. In each call cycle, values are output according to a time schedule and there
is an interpolation between the support points.
In each cycle, the currently switched support point number “stepNumber”, the
current remaining time “remainTime” until the support point has been reached, the
total time “totalTime” and the total remaining time “remainTotalTime” until the
speed curve end has been reached are output. Also, the “actTimeTable” output is
Siemens AG 2018 All rights reserved
Operating mode onDefault start hold continue cyclicOP updateTime reset Output/action
OutValue
Restart
A rising edge at the input "reset" resets the output "outValue" to 0.0. With
"onDefaultOutValue" = TRUE, "defaultOutValue" is output at the output. The total
time and total remaining time are updated and output at the output.
If the speed curve shall start with a particular output value, then
"onDefaultOutValue" = TRUE must be set. In this case, the value
"defaultOutValue" is present at the output of the timer. All the while, the internal
processing of the speed curve continues. If "onDefaultOutValue" switches to
FALSE again, it will be interpolated to the currently active support point.
Function characteristics
Figure 3-90: Function characteristics
onDefaultOutValue
start
hold
continue
3 4/ 4* = contStepNbr
T1*
defaultOutValue
1 2 T1*
0 5 5* 6 6*
setpoints[…].outVal
setpoints[…].time 0 1 2 3 4 5 t
4 + T1* 5
actTimeTable
3.8.4 FB LGF_NonLin
Short description
The block realizes a characteristic. The characteristic is specified via a support
point table with linear interpolation between the support points. In every cycle, a
specified input value generates an output value by means of the characteristic from
the support point table.
Block
Figure 3-91: FB LGF_NonLin
FB LGF_NonLin
REAL inputValue outputValue REAL
REAL defaultOutValue
BOOL onDefaultOutValue
BOOL track
BOOL reset
LGF_type
NonLinSetpoints setpoints
Siemens AG 2018 All rights reserved
Input parameters
Table 3-162: Input parameters
Parameter Data type Description
inputValue REAL Input value for calculating the output value via the defined
characteristic.
defaultOutValue REAL Default output value without using the characteristic
onDefaultOutValue BOOL Activating the default output value
The default output value will be output as long as this input
is set.
track BOOL The value of the output "outputValue" tracks the value of the
input "inputValue" without using the characteristic as long as
this input is set.
reset BOOL If the support point table is changed during operation, the
input "reset" needs to be activated subsequently. Otherwise,
the block might not function properly.
Output parameters
Table 3-164: Output parameters
Parameter Data type Description
outputValue REAL Output value that has been calculated using the input value
via the defined characteristic.
Function principle
The value of the output "outputValue" is output based on the following priority:
1. As long as the input "onDefaultOutValue" is set, the value defined via the
parameter "defaultOutValue" will be output as output value.
2. As long as the input "reset" is set, the block will be reset and the value 0.0 will
be output as output value.
3. As long as the input "track" is set, the input value will be directly output as
output value, without taking into account the characteristic.
4. On the basis of the input value, a characteristic value is calculated via the
linearly interpolated support point table and output as output value.
– If the input value is located between two support points within the support
point table, the output value is calculated as intersection with the
connection line between the previous and the next support point (see
Siemens AG 2018 All rights reserved
Figure 3-92).
– If the input value is located before the first support point (lowest value that
has been defined in the support point table), the output value is calculated
as intersection of the line that is formed by the first two support points of
the support point table.
– If the input value is located after the last support point (highest value that
has been defined in the support point table), the output value is calculated
as intersection of the line that is formed by the last two support points of
the support point table.
Figure 3-92: Exemplary characteristic of the output signal
Output signal
Input signal
ATTENTION To keep the calculating time of the block as low as possible, no check of the
configuration or the support point table data will be performed.
When the support points are entered in the support point table, the following
particularities need to be observed. Otherwise, malfunction of the block may occur.
At least two support points need to be entered in the support point table.
The support points in the support point table need to be entered in ascending
order of the input values in the table.
Example
Figure 3-93: Exemplary data block
Siemens AG 2018 All rights reserved
This entry provides you with the block library "LSim" for simulating controlled
systems for the SIMATIC S7-1200 and S7-1500 controller families.
https://support.industry.siemens.com/cs/ww/en/view/79047707
5 History
5.1 Library versioning
The library and library elements are maintained according to the following table:
Table 5-1: Definition of the version
V 1. 2. 3.
Non-compatible changes Compatible changes Error correction
Reduction of interfaces Extension of Bugfix
Modification of interfaces Upgrade to new
interfaces Compatible TIA Portal version
Incompatible extension extension of
of functionality functionality
Versioning example
Table 5-2: Example for changing the version
Library FB1 FB2 FC1 FC2 Comment
1.0.0 1.0.0 1.0.0 1.0.0 - Released
Siemens AG 2018 All rights reserved
Error correction
LGF_FIFO V1.0.1
Error correction
V2.0 07/2016 New:
Chapter 1.3 Library resources
FB LGF_PulseRelay V1.0.0
FB LGF_SetTime V1.0.0
FB LGF_FloatingAverage V1.0.0
FC LGF_DTLtoString V1.0.0
FC LGF_StringToDTL V1.0.0
FB LGF_LimRateOfChangeBasic V1.0.0
FB LGF_LimRateOfChangeAdvanced V1.0.0
Revised:
LGF_Astro V1.1.1
Outputs systemTime and localTime added
FB LGF_TimerSwitch V1.1.0
Two new modes: Weekday, weekend
FB LGF_ShallSort… V1.1.0
New mode: Sort in descending order
FB LGF_Frequency V1.1.0
New function: Pulse-pause ratio adjustable
FB LGF_Impulse V1.1.0
Calls new LGF_Frequency V1.1.0.
V2.0.1 01/2017 Revised:
LGF_Astro V1.1.2
Error correction for sunrise and sunset calculation.
V2.0.2 01/2017 Revised:
All blocks: Upgrade TIA V14
V3.0.0 03/2017 New:
Revised:
Supplementation in chapter 5.1 Library versioning
FB LGF_PulseRelay V1.0.2
Commentary correction
FB LGF_Astro V1.1.4
Code optimization
FB LGF_SetTime V1.0.2
Correction: FB number: automatic
FB LGF_FloatingAverage V1.1.0
Siemens AG 2018 All rights reserved
Code optimization
New input parameter "windowSize"
FC LGF_MatrixAddition V2.0.0
Code optimization
Input parameters changed to ARRAY*
FC LGF_MatrixInverse V2.0.0
Code optimization
Input parameters changed to ARRAY*
FC LGF_MatrixMultiplication V2.0.0
Code optimization
Input parameters changed to ARRAY*
FC LGF_MatrixSubtraction V2.0.0
Code optimization
Input parameters changed to ARRAY*
FC LGF_MatrixTranspose V2.0.0
Code optimization
Input parameters changed to ARRAY*
FB LGF_Impulse V1.2.0
Code optimization: No call of LGF_Frequency any
longer
Revised:
Supplementation in chapter 2.2 Simulatability with SIMATIC
S7-PLCSIM Advanced (NEW)
FB LGF_Astro V1.1.5
Code optimization
FB LGF_TimerSwitch V1.1.2
Code optimization