FB_HVACPersistentDataHandling

FB_HVACPersistentDataHandling 1:

With this function block, all PLC variables that are declared as persistent (VAR PERSISTENT) are written fail-safe to a file. The PLC variables declared as persistent within the function blocks from the Tc2_HVAC are written to this file in case of a change. This file is saved in the ..\TwinCAT\3.1\Boot\PLC directory and is named as follows: Port_c.bootdata (x = number of the runtime system). So that the new status is not saved immediately after a change of the persistent variables, a timeframe of 5 sec is built into the standard setting. This timeframe can be changed by the user. He must assign the new time to the globally declared constant parameter g_tHVACWriteBackupDataTime: TIME := t#5s.

The new status is only saved after the timeframe has elapsed. In the worst case this can mean that changes made within the last timeframe are not saved if a power failure occurs during that time.

Each time the controller is restarted, the status of the persistent data is read from the file. The output variable udiStatus indicates whether or not the data is valid.

In order to secure the persistent variables inside the function block voltage failure safe, it is necessary to start an instance of the FB_HVACPersistentDataHandling block in the MAIN program.

The behavior of the function block is as follows if everything was correct when starting:
udiStatus:= 1;
iPersistCount:= 1;
bDone:= FALSE;

If the result of the query of usiStatus is 1, this means that the persistent variables have been read from the memory. bDone only goes TRUE if the persistent variables have been written successfully.

Setting:

The following setting must be made in TwinCAT:

The option Delete invalid persistent data must be deactivated under PLC Configuration on the PLC Settings tab!!

FB_HVACPersistentDataHandling 2:

VAR_INPUT

sNETID            : T_AmsNetId; 
TMOUT             : TIME;    
ePersistentMode   : E_PersistentMode;

sNETID: AmsNetId of the TwinCAT computer on which the function should be executed. If it is to be run on the local computer, an empty string can be entered.

TMOUT: States the length of the timeout that may not be exceeded by execution of the ADS command.

ePersistentMode: Mode in which the persistent data should be written. Also see E_PersistentMode (see Tc2_Utilities library).

VAR_OUTPUT

udiStatus        : UDINT;
iPersistCount    : INT;
bDone            : BOOL;
bBusy            : BOOL;
bError           : BOOL;
udiErrorID       : UDINT;

udiStatus: 0 = No status
1 = Persistent data read successfully
2 = Backup from persistent data read
3 = Neither persistent nor backup data read

iPersistCount: Counter that is incremented by 1 after successful writing.

bDone: Will be set to TRUE if the function block is executed.

bBusy: When the function block is activated the output is set, and it remains active until execution of the command has been completed.

bError: This output is set to TRUE if an error occurs during the execution of a command.

udiErrorID: Contains the command-specific error code (see ADS Return Codes).

Requirements

Development environment

required library

required function

TwinCAT 3.1 build 4022.16 or higher

Tc2_HVAC V3.3.1.0

TF8000 | TC3 HVAC V1.0.0.0