Using NVRAM

The following table defines NVRAM area default values. 

 

Using Multitool Creator or newer or MultiTool Creator, these values can be adjusted using the General tab, in the following products:

  • 6000/X series (excluding 6505)

  • S/E series when device description includes SSeriesHardware library version 1.1.3.0 or newer

For more information, refer to Epec MultiTool Creator manual (available from Epec's extranet)

 

 

 

The table below describes typical NVRAM features in different products.

 

Feature

2040

3606, 3610

3720, 3724

4602

5050

61xx

EC44

SC52

SL84

Description

NVRAM type

Battery SRAM

FRAM

FRAM

FRAM

MRAM

MRAM

FRAM

FRAM

FRAM

NVRAM type

Total size of NVRAM

512 kB

2 kB

8 kB

8 kB

512 kB

512 kB

8 kB

8 kB

16 kB

Size of NVRAM

Fast parameter area

Not in use,

Has user SRAM area

256 bytes

+ backup area if SDK 2.7 or later (*)

256 bytes

+ backup area if SDK 2.7 or later (*)

256 bytes

+ backup area if SDK 2.7 or later (*)

Not in use,

Has user MRAM area

Not in use,

Has user MRAM area

256 bytes +
backup area (**)

256 bytes +
backup area (**)

512 bytes
+
backup area (**)

Size of the fast parameters which are saved in one saving to NVRAM. It is recommended to include in this group all parameters which are necessary to save with the fast cycle (machine hours,...).

CANopen OD
(defined in MultiTool Creator)

200 kB

1,75 or 1,5 kB

(*)

7,75 or 7,5 kB

(*)

7,75 or 7,5 kB (*)

100 kB

200 kB

7,5 kB

optional backup, default OFF
(SDK 3.9, see below for more information)

7,5 kB

7,5 kB
+
optional backup, default ON

(SDK 3.9, see below for more information)

CANopen OD parameters are parameters which are not saved very often. These are, for example, different configuration parameters. See also MultiTool Creator manual.

NVRAM init overhead to cycle time

0 ms

5-15 ms

5-15 ms

5-15 ms

0 ms

0 ms

   

 

Initializing NVRAM can cause overhead to cycle time.

NVRAM save overhead to cycle time

0 ms

5 ms (***)

5 ms (***)

5 ms (***)

0 ms

0 ms

   

 

Saving NVRAM can cause overhead to cycle time.

Undervoltage protection

No

Yes

(SW,

SDK 2.7)

Yes

(SW,

SDK 2.7)

Yes

(SW,

SDK 2.7)

Yes

(SW,

SDK 2.7)

No

Yes
(FW)

Yes
(FW)

Yes
(FW)

Internal undervoltage protection is not included in NVRAM handling. It is recommended to check that the supply voltage is above the low limit before calling NVRAM save.

Time until save of the fast parameters is completed

Not in use

Recommended 5 x program cycle

Recommended 5 x program cycle

Recommended 5 x program cycle

Not in use

Not in use

Recommended 5 x program cycle

Recommended 5 x program cycle

Recommended 5 x program cycle

Time needed from the start of the fast parameters saving until it is completed. Overlapping save function starts after the previous one is completed.

Time until save of the parameters is completed

Not limited

Recommended 5 x program cycle

Recommended 5 x program cycle

Recommended 5 x program cycle

Not limited

Not limited

   

 

Time needed from the start of the normal parameters saving until it is completed. Overlapping save function starts after the previous one is completed.

* Size depends on if 3000/4000 series fast parameter backup is in use. See also Using Fast Parameter Backup.

** Usable fast parameter area in S Series / E Series (e.g. SC52) is reduced by ParameterHandler header size (See NVMem (PRG)).

*** See notes in section Using NVRAM in 3000 series and 4602 below.

 

NVRAM handling and PLCopen libraries

For S Series / E Series

The principle in the image below applies.

 

 

The following image describes the libraries used in NVRAM handling and limitations in NVRAM saving functionality.

 

Using NVRAM in 6107Using NVRAM in 6107

6107 unit contains MRAM memory, which is used as NVRAM for code template.

This MRAM area is divided to different areas described in the table below.

 

Area name

Size [byte]

Freely used

Description

OD parameters

204800

NO

This area is used by CANopen OD parameters.

Event log

102400

NO

This are is used by Event Log system.

User data

102400

YES

This area can be used freely by user application.

GlobE

1024

NO

This area is used by GlobE library.

Included in device description 1.3.1.X or newer.

 

The following image describes memory area locations in 512 kByte MRAM:

 

Epec MultiTool Creator's code template automatically creates NVRAM related global variables:

 

Variable name

Data type

Initialization value

Description

G_NVRAM_6107_StartAddress

Pointer to data (DWORD)

Initialized in Flash Init

Pointer to the start of the NVRAM area. If initialization fails, pointers are set to zero.

G_NVRAM_6107_ODParamPointer

Pointer to data (DWORD)

Initialized in Flash Init

Pointer to the start of the OD parameter image. If initialization fails, pointers are set to zero.

G_NVRAM_6107_EventLogPointer

Pointer to data (DWORD)

Initialized in Flash Init

Pointer to the start of the EventLog NVRAM area. If initialization fails, pointers are set to zero.

G_NVRAM_6107_UserDataPointer

Pointer to data (DWORD)

Initialized in Flash Init

Pointer to the start of the user NVRAM area. If initialization fails, pointers are set to zero.

G_NVRAM_6107_GlobEDataPointer

Pointer to data (DWORD)

Initialized in Flash Init

Pointer to the start of the GlobE NVRAM area. If initialization fails, pointers are set to zero. Included in device description 1.3.1.X or newer.

G_NVRAM_6107_CODE_TEMPLATE_TOTAL

Constant DWORD

507904

Total size of NVRAM reserved for code template (IEC area 496 kB)

G_NVRAM_6107_OD_PAR_IMAGE_SIZE

Constant DWORD

204800

Size of the OD parameter area reservation.

G_NVRAM_6107_EVENT_LOG_SIZE

Constant DWORD

102400

Size of the  EventLog reservation.

G_NVRAM_6107_USER_DATA_SIZE

Constant DWORD

102400

Size of the user application NVRAM reservation.

G_NVRAM_6107_GLOBE_DATA_SIZE

Constant DWORD

1024

Size of the GlobE NVRAM reservation. Included in device description 1.3.1.X or newer.

G_NVRAM_6107_OD_PARAM_OFFSET

Constant DWORD

0

Offset for OD parameter area.

G_NVRAM_6107_EVENTLOG_OFFSET

Constant DWORD

204800

Offset of the EventLog area.

G_NVRAM_6107_USER_DATA_OFFSET

Constant DWORD

307200

Offset of the user NVRAM area.

G_NVRAM_6107_GLOBE_DATA_OFFSET

Constant DWORD

491520

Offset of the GlobE NVRAM area. Included in device description 1.3.1.X or newer.

 

 

User MRAM structure

Part of the MRAM area is reserved for user. This area is specifed by globals G_NVRAM_6107_UserDataPointer and G_NVRAM_6107_USER_DATA_SIZE. MultiTool Creator creates automatically a structure which is set to point to this area. This structure can be used by user to store own data. In the beginning of the structure is flag which tells if data is valid, possible error code and tag which is used to check validity of the MRAM pointer.

 

When MultiTool Creator creates new CODESYS 3.5 project, it adds a structure template (UserMRAMStructure). User can extend this structure by adding members in the end of the structure. Code template contains also pointer to this structure in MRAM (G_pUserMramStructure). This pointer can be used directly to change data in MRAM. Code template contains also a default structure (G_UserMramStructureDefault). If there are problems to get pointer to MRAM, pointer (G_pUserMramStructure) is set to point to this default structure. In this case the data is not saved but structure instance in RAM is used.

 

 

Structure header contains the following members.

 

Member name

Data type

Init value

Description

UserMRAMdataValid

BOOL

FALSE

Set TRUE if data pointer is initialized correctly, else set FALSE.

UserMRAMinitError

INT

0

Possible errors

0 = SUCCESS,

1 = Structure size is too big to fit in MRAM,

2 = Tag not AA55AA55h *)      

UserMRAMTag

DWORD

16#AA55AA55

Tag value must always be AA55AA55h

 

Code example:

 User structure:

 TYPE UserMRAMStructure :

 STRUCT

 ...

 bootCounter:DWORD;

 ...

 END_STRUCT

 END_TYPE

 

 

 Code:

 G_pUserMramStructure^.bootCounter := G_pUserMramStructure^.bootCounter + 1;

 

 

 

Don't change data members in the header part.

 

If you have already used user structure in the system, don't add or remove members in the middle of the structure. It is possible only to add members in the end of the structure. It is possible to change name of the members but not to change the data type in the middle of the structure.

 

Default values of the structure members have meaning only in case the default structure instance in RAM is used.

 

When new values are added to the structure, the value in the boot-up is undefined until they are set the first time. They are not automatically set to default values.

 

Using NVRAM in 5050Using NVRAM in 5050

5050 unit contains MRAM memory, which is used as NVRAM for code template. This MRAM area is divided into two areas described in the table below.

 

Area name

Size [kByte]

Freely used

Description

OD parameters

100

NO

This area is used by CANopen OD parameters.

User data

212

YES

This area can be used freely by user application.

 

Epec MultiTool Creator's code template automatically creates NVRAM related global variables:

 

Variable name

Data type

Initialization value

Description

G_MramStartAddressForUser

DWORD

Initialized in Flash Init

Start of the user MRAM area

G_MramEndAddressForUser

DWORD  Initialized in Flash Init  End of the user MRAM area

 

Below is the MRAM usage of the 5050 unit.

 

Area name

Size [kByte]

Access from PLCopen application

FW error log

20

RO - access. Pointer to memory area is get by function  

PLCopen log

20

RW - access. Pointer to memory area is get by function   SYSTEM_SHM_IEC_LOG_GET_AREA

Retain variables

64

Access trough variables with Retain and Retain persistent key words in PLCopen application

Reserved

8

No access

User MRAM

372

User MRAM variable. Part of this is used by CANopen OD parameters which are created to MT code template. Pointer to memory area is get by function  SYSTEM_SHM_MRAM_GET_IEC_AREA.

 

User MRAM structure

 

Structure header contains the following members.

 

Member name

Data type

Init value

Description

UserMRAMdataValid

BOOL

FALSE

Set TRUE if data pointer is initialized correctly, else set FALSE.

UserMRAMinitError

INT

0

Possible errors

0 = SUCCESS,

1 = Structure size is too big to fit in MRAM,

2 = Tag not AA55AA55h *)      

UserMRAMTag

DWORD

16#AA55AA55

Tag value must always be AA55AA55h

 

Code example:

 User structure:

 TYPE UserMRAMStructure :

 STRUCT

 ...

 bootCounter:DWORD;

 ...

 END_STRUCT

 END_TYPE

 

 

 Code:

 G_pUserMramStructure^.bootCounter := G_pUserMramStructure^.bootCounter + 1;

 

 

 

Don't change data members in header part.

 

If you have already used user structure in the system, don't add or remove members in the middle of the structure. It is possible only to add members in the end of the structure. It is possible to change name of the members but not to change the data type in the middle of the structure.

 

Default values of the structure members have meaning only in case the default structure instance in RAM is used.

 

When new values are added to structure, the value in the boot-up is undefined until they are set the first time. They are not automatically set to default values.

 

Using NVRAM in 3000 series and 4602Using NVRAM in 3000 series and 4602

3000 series and 4602 units have non-volatile memory which is used to save parameters. This memory area is divided to fast and CANopen OD parameters. Since fast parameter area is smaller than OD parameter area, also the parameter saving time is less. It is recommended to use fast parameter area for parameters that are needed to save often, such as machine hours and states. OD parameters are used for parameters that are saved more seldom.

 

Control unit's internal library (for example 3606int) contains two data arrays, one for fast and one for OD parameters (for example, G_3606_FastParamsData and G_3606_ParameterImage). These arrays are used to handle data from/to NVRAM. Fast parameters are defined directly using %M addresses.

 

Initializing the NVRAM data causes a 5 to 15 ms increase in the PLCopen application cycle.

 

Saving the NVRAM data causes an increase in the PLCopen application cycle.

The increase is typically about 5 ms, but may be up to 80 ms depending on the size of data.

 

Even if the saving of the data from RAM to NVRAM is fast, it is recommended to trigger the parameter saving and not save every program cycle.

 

It is recommended to check the supply voltage level before saving parameters. If the supply voltage is close to low limit (may depend of the control unit version), it is no recommended to trigger the saving of the parameters to NVRAM (for example, NvRam_3606_Save).

 

Normal parameters

The data array for normal parameters includes header and footer tags, two bytes long each. Tag values are increased in every saving and when the NVRAM is initialized, the data validity is checked by comparing the tags. If the values differ from each other, all the data is reset.

 

Typically parameters defined in Epec MultiTool Creator are saved to this data array.

 

 

Fast parameters

Memory area %MB10000 - 10255 is reserved for fast parameter structure. Memory area %MB10004 - 10254 is reserved for application. Fast parameter structure contains parameter checksum (G_ControlUnitType_FastParams_CRC) and a keyword (G_FileSysKeyWord). These values are checked in NVRAM initialization. If the keyword and CRC does not match with the saved values, the keyword is changed to the one given as input to NvRam_ControlUnitType_Init and the entire user data area is reset.

 

The application can use memory area %MB10004 - %MB10254 for fast parameters. After the PLCopen application is taken into use it is not possible to change the memory address for parameters.

 

See also Using Fast Parameter Backup.

 

 

Example of fast parameter definition in Epec MultiTool Creator code template:

 

Global definition:

 

G_3606_FastParamsSave:BOOL:=FALSE; (* Flag to start saving of the fast parameters. *)

 

 

(* User should define own fast parameters for this M-area 10004 - 10254. End address is defined with input parameters in init of the NvRam. Below is three example parameters. It is not possible to change address of the parameters once they are started to use. It is basically possible to replace already used parameter with new one. For example :

Before ...

  G_3606_UserParam1 AT %MB10004:BYTE; (* Example for the usage of the fast parameters. *)

  G_3606_UserParam2 AT %MB10005:BYTE; (* Example for the usage of the fast parameters. *)

Replaced ...

  G_3606_UserParamChanged AT %MB10004:WORD; (* Example for the usage of the fast parameters. *)

 

NOtice that this parameter gets values from old parameters  G_3606_UserParam1 and G_3606_UserParam2

*)

 

G_3606_FastParamsKeyword AT %MB10000:DWORD; (* Keyword which can be used to check that data and codesys project matches. *)

 

(* User defined parameters starts *)

G_3606_UserParam1 AT %MB10004:BYTE; (* Example for the usage of the fast parameters. *)

G_3606_UserParam2 AT %MB10008:DWORD; (* Example for the usage of the fast parameters. *)

G_3606_UserParam3 AT %MB10012:STRING; (* Example for the usage of the fast parameters. *)

(*....*)

G_3606_UserParam4 AT %MB10254:BYTE; (* Example for the usage of the fast parameters. *)

(* User defined parameters end. *)

 

 

G_3606_FastParams_CRC AT %MB10255:BYTE; (* CRC which is used to check data when load from NVRAM. *)

 

 

 

 

Using NVRAM in 2040Using NVRAM in 2040

Example of NVRAM parameter handling in 2040 when Epec MultiTool Creator code template is used

 

Code template global variables:

    G_NVRAM_USER_DATA_SIZE:DWORD:= 102400;   (* 100 kB *)

    G_NVRAMUserDataPointer:DWORD;

 

Data Types:

 

TYPE MyNVRAMData :

STRUCT

  BootUpTimes:DWORD;

END_STRUCT

END_TYPE

 

 

Code:

 

IF bInit THEN

  bInit := FALSE;

 

  (* Pointer to user data *)

  IF SIZEOF(pMyNVRAMData^) < G_NVRAM_USER_DATA_SIZE THEN (*Check structure size*)

    pMyNVRAMData := G_NVRAMUserDataPointer;

    pMyNVRAMData^.BootUptimes := pMyNVRAMData^.bootUptimes + 1;

  ELSE

  (* Error - user defined structure is bigger than available size *)

    ;

  END_IF

END_IF

 

IF pMyNVRAMData <> 0 THEN

  ;(*Handle application NVRAM data*)

END_IF

 

 

 

 

Using NVRAM in S SeriesUsing NVRAM in S Series

S series control units (e.g. SC52) have non-volatile memory which is used to save parameters. This memory area is divided into fast and CANopen OD parameters.

 

Since the fast parameter area is smaller than the OD parameter area, it also means that the parameter saving time is less. It is recommended to use the fast parameter area for parameters that need to be saved often, such as machine hours and states. OD parameters are used for parameters that are saved more seldom.

 

The application shall synchronize saving of the Fast and OD parameters and direct NVRAM library usage by limiting the access to one NVRAM access at a time. NVRAM can handle only one transfer session at a time.

 

Code template's NVRAM handling is implemented with SSeriesHardware library using NVMem (PRG).

 

Using fast parameters and OD parameters is described in How to use & save parameters in Safety Control Unit.

 

OD parameter backup

 

SSeriesHardware library's version 1.1.3.0 or later includes optional OD backup functionality. Functionality requires device description using required library version.

 

Backup can be taken in use at MultiTool Creator with library parameter G_PARAM_BACKUP_IN_USE. Default value depends on control unit.

Code template is automatically generated utilizing the parameter selection.

 

See NVMem (PRG) for more information on NVRAM memory layout.

 

Using NVRAM in E SeriesUsing NVRAM in E Series

E Series control units (e.g. EC44) have non-volatile memory which is used to save parameters. This memory area is divided into fast and CANopen OD parameters.

 

Since the fast parameter area is smaller than the OD parameter area, it also means that the parameter saving time is less. It is recommended to use the fast parameter area for parameters that need to be saved often, such as machine hours and states. OD parameters are used for parameters that are saved more seldom.

 

Code template's NVRAM handling is implemented with SSeriesHardware library using NVMem (PRG).

 

Using fast parameters and OD parameters is described in How to use & save parameters in a Control Unit

 

OD parameter backup

 

SSeriesHardware library's version 1.1.3.0 or later includes optional OD backup functionality. Functionality requires device description using required library version.

 

Backup can be taken in use in MultiTool Creator with library parameter G_PARAM_BACKUP_IN_USE. Default value depends on control unit.

Code template is automatically generated utilizing the parameter selection.

 

See NVMem (PRG) for more information on NVRAM memory layout.

 

In EC44 OD backup is OFF by default for backward compatibility.

OD image size needs to be reduced by half if OD backup is taken in use to have space for backup image.

 

 

 

Source file Topic100310.htm

Last updated 19-Dec-2024