FB_HVACNOVRAMDataHandling

FB_HVACNOVRAMDataHandling 1:

Application

PLC variables are written fail-safe to NOVRAM with this function block. Following a power failure or a restart of the controller, the NOVRAM will be read out completely.

The behavior of the function block looks as follows if everything was correct at startup:
udiStatus:= 1;
iNovRamReadCount:= 1;
iNovRamWriteCount:= 0;
bDone:= TRUE

FB_HVACNOVRAMDataHandling 2:

Note In the case of ARM-based runtime systems, please make sure that the memory addresses of the PLC variables are divisible by 4!

Comments

The globally declared variables g_dwHVACVarConfigStart and g_dwHVACVarConfigEnd are allocated to the start address and end address of the memory area. The user must take care to ensure that there are no memory overlaps. The block size is then determined internally from the two addresses. The entire flag area is written automatically to NOVRAM in the event of changes to the flag variables.

see also application example: FB_HVACNOVRAMDataHandling 3:Example_NOVRAM.zip

VAR_INPUT

sNETID            : T_AmsNetId;     
TMOUT             : TIME;           
udiDevID          : UDINT;      
usiBlockSize      : USINT;          

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.

udiDevID : the Device ID specifies the NOVRAM of the CX90xx or CX10xx to be accessed with the function block for reading or writing. The device IDs are specified by the TwinCAT System Manager during hardware configuration.

FB_HVACNOVRAMDataHandling 4:

usiBlockSize : the block size to be accessed per read/write cycle is given in percent; e.g. 20, i.e 5 read/write cycles will be required in order to access the entire flag area.

VAR_OUTPUT

udiStatus         : UDINT;                   
iNovramReadCount  : INT;                
iNovramWriteCount : INT;                
bDone             : BOOL;                   
bBusy             : BOOL;                   
bError            : BOOL;
udiErrorID        : UDINT;                          

udiStatus : = 0 , no status

= 1, valid data at last reading of NOVRAM

= 2, invalid data at last reading of NOVRAM. Data were discarded.

iNovramReadCount : counter that is incremented by 1 when NOVRAM is read from.

iNovramWriteCount: counter that is incremented by 1 when NOVRAM is written to.

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 switched to TRUE if an error occurs during the execution of a command. The command-specific error code is contained in udiErrorID.

udiErrorID: contains the command-specific error code. Please see ADS Return Codes.

Example of handling inside TwinCAT PLC

1st step

FB_HVACNOVRAMDataHandling 5:

2nd step

3rd step

4th step

FB_HVACNOVRAMDataHandling 6:

On ARM-based platforms (e.g. CX90xx) care must be taken that the addresses of the allocated variables are divisible by 4.

5th step

6th step

FB_HVACNOVRAMDataHandling 7:

    • For reasons of performance it is useful to address the allocated variables (VAR_CONFIG Object) without gaps.
    • If the variable configuration (VAR_CONFIG) is subsequently changed, it is compulsory to load the changes to the target system via an « Online Change » and not via « Load All ». Only an « Online Change » ensures that the NOVRAM data is retained correctly. The NOVRAM data would be recognized as invalid in the case of « Load All ».

    Sample for declaration of allocated variables:

    Heizkurve.fbRealMinTemp_NOVRAM.rVar_N        AT %MB12 : REAL;
    Heizkurve.fbRealMaxTemp_NOVRAM.rVar_N        AT %MB16 : REAL;
    Heizkurve.fbRealNightSetback_NOVRAM.rVar_N       AT %MB20 : REAL;
    Heizkurve.fbRealSetpoint_Y1_NOVRAM.rVar_N        AT %MB24 : REAL;
    Heizkurve.fbRealSetpoint_Y2_NOVRAM.rVar_N        AT %MB28 : REAL;
    Heizkurve.fbRealSetpoint_Y3_NOVRAM.rVar_N        AT %MB32 : REAL;
    Heizkurve.fbRealSetpoint_Y4_NOVRAM.rVar_N        AT %MB36 : REAL;
    Heizkurve.fbRealOutsideTemp_X1_NOVRAM.rVar_N     AT %MB40 : REAL;
    Heizkurve.fbRealOutsideTemp_X2_NOVRAM.rVar_N     AT %MB44 : REAL;
    Heizkurve.fbRealOutsideTemp_X3_NOVRAM.rVar_N     AT %MB48 : REAL;
    Heizkurve.fbRealOutsideTemp_X4_NOVRAM.rVar_N     AT %MB52 : REAL;

    .g_dwHVACVarConfigStart                  AT %MB0  : DWORD;
    .g_dwHVACVarConfigEnd                AT %MB56 : DWORD;