Remanent data, Example for remanent data in the function block – BECKHOFF BC3150 User Manual

Page 57

Advertising
background image

Safety Instructions

Fieldbus Components

55

Remanent data

2 kB of remanent data are available for the BX controller. These data are declared as VAR RETAIN in PLC Control:
Example:

VAR RETAIN
Test :BOOL;
Count :INT;
END_VAR

Retain data are located between VAR RETAIN and END_VAR. These data are stored in a NOVRAM and are
consistent across the whole 2 kB range. The RETAIN data are stored in the NOVRAM after each cycle. For 2 kB
approx. 2 ms are required (for 1 kB approx. 1 ms). The variables can be configured locally or globally. Variables are
located (%I...,%Q.., %M...) are not use as a Retain data.

Note

VAR_RETAIN should not be used in function blocks. All FB data are copied into the retain
memory. This leads to an unnecessary increase in cycle time, and the retain memory is
filled with unnecessary data.

Note

Variables, they have an address (%I...,%Q.., %M...), are not allowed to declare as a retain
variables.

Example for remanent data in the function block

Because all the data in a function block will be saved if even only one remanent bit is included, this should be
avoided if at all possible. A programming example can be found below.

Function block Test (no program code required - in ST a semicolon is sufficient)

FUNCTION_BLOCK Test

VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
END_VAR
VAR_IN_OUT
Counter :INT;
END_VAR

MAIN program

PROGRAM MAIN

VAR
fb_Test:Test;
END_VAR
VAR RETAIN
iCounter1:INT;
END_VAR

fb_Test(Counter:=iCounter1);

Advertising