Addressable PERSISTENT Area (%R area)¶
Special Features:
Caution
:strong:Availability of %R area
The %R area is only available in combination with Control Builder version V1.2 and later and AC500 firmware version V1.2.0 and later. For the %R area the following is relevant for Control Builder V1.2: CoDeSys.exe V2.3.8.0 or higher (shown under CODESYS / Info) AC500 Target PM5xx_V12 or higher (shown under InstallTarget / Installed targets)
The addressable PERSISTENT area or %R area has the following peculiarities:
Variables declared in the %R area are always located at the same position in the PLC’s operand memory, because they have addresses assigned (like the variables in the %M area).
Variables in the %R area are declared as follows:
VAR (caution: noRETAIN or PERSISTENT option), Symbol AT %RTypeSegment.Offset : TYPE; (* Comment *), or also aSymbol AT %RTypeSegment.Offset : ARRAY[start..end] OF TYPE; (* Comment *) END_VAR
where: | Symbol | symbolic name of the variable |
Type | X=BOOL (Bit), B=BYTE, W=WORD, D=DWORD | |
Segment | 0..7 (availability depends on CPU type) | |
Offset | 0..65535 (availability depends on CPU type) | |
TYPE | BOOL, BYTE, WORD, DWORD or defined type (such as structure) | |
start | Index of the first ARRAY element | |
end | Index of the last ARRAY element |
For each segment in the %R area, an area can be set in the PLC configuration, which is buffered in case the battery is installed and fully charged. In this case, the variables behave like variables declared as VAR RETAIN PERSISTENT, i.e., they keep their values even after
Online changes (like all other variables),
Voltage OFF/ON (like VAR RETAIN), and
download (like VAR PERSISTENT).
In contrast to the variables declared as VAR PERSISTENT, these variables have the great advantage that no program code is required for dumping the variables during a download.
The buffered part of the %R area can be written to the SD Card and read from the card (see Saving the buffered data of the %R area).
Segmentation:
The addressable PERSISTENT area in the AC500 is divided into several segments with a size of 64 kbytes per segment. A maximum of 8 segments can be addressed. The availability of the segments or partial segments depends on the CPU:
Segment | Operands | Size, cumulative [kB] | CPU PM55x CPU PM56x | CPU PM57x | CPU PM58x | CPU PM59x |
---|---|---|---|---|---|---|
0 | %RB0.0…%RB0.65535 | 64 | 1 kB | 4 kB | ||
1 | %RB1.0…%RB1.65535 | 128 | - | - | - | |
2 | %RB2.0…%RB2.65535 | 192 | - | - | - | |
3 | %RB3.0…%RB3.65535 | 256 | - | - | - | |
4 | %RB4.0…%RB4.65535 | 320 | - | - | - | |
5 | %RB5.0…%RB5.65535 | 384 | - | - | - | |
6 | %RB6.0…%RB6.65535 | 448 | - | - | - | |
7 | %RB7.0…%RB7.65535 | 512 | - | - | - |
Saving the Buffered Data of the %R Area:
The buffered part of the %R area can be saved on the SD card and read from the card. This can be necessary, if, for example, the controller has to be replaced.
Copy the data from the %R area and write it to the CPU’s RAM disk as file
Save the file to the SD Card.
Load the file from the SD Card to the CPU’s RAM disk.
Copy the data from the RAM disk to the %R area.
Saving and reading the data can be done using Function Blocks in the user program or with the PLC Browser contained in the Automation Builder. The Function Blocks are contained in the library SysInt_AC500_V10.lib: CAA-Merger-6.chm::/The-internal-System-Library/Contents-Internal-System-Library.htm.
Function | PLC Browser command | Function Block |
---|---|---|
Copy from %R area to RAM disk | persistent save | PERSISTENT_SAVE |
Save file to SD Card | persistent export | PERSISTENT_EXPORT |
Read file from SD Card to RAM disk | persistent import | PERSISTENT_IMPORT |
Copy data from RAM disk to %R area | persistent restore | PERSISTENT_RESTORE |
Delete buffered data of the PERSISTENT area | persistent clear | PERSISTENT_CLEAR |
Caution
:strong:Cycle consistency for data
If cycle consistency is required for the data, this has to be implemented in the user program. That means, that the data may not be changed during copying to/from the %R area from/to the RAM disk. If saving is done using the PLC Browser, this can be easily carried out by stopping the user program.
Caution
:strong:Cycle time for copying the PERSISTENT area
Copying the PERSISTENT area takes some milliseconds (see the following table). Thus, an according cycle time has to be set in the task configuration. Please note the remarks on the task configuration!
Action | Time in ms | |||
---|---|---|---|---|
CPU PM55x CPU PM56x |
CPU PM57x | CPU PM58x | CPU PM59x | |
Restoring 1 kB (1024 bytes) | ||||
PERSISTENT_CLEAR | <1 | <1 | <1 | <1 |
PERSISTENT_SAVE | 2 | 2 | 2 | 2 |
PERSISTENT_EXPORT | 900 | 1000 | 1000 | 500 |
PERSISTENT_IMPORT | 100 | 500 | 1000 | 500 |
PERSISTENT_RESTORE | 3 | 2 | <1 | 1 |
Restoring 4 kB (4096 bytes) | ||||
PERSISTENT_CLEAR | not possible | <1 | <1 | <1 |
PERSISTENT_SAVE | not possible | 2 | 3 | 2 |
PERSISTENT_EXPORT | not possible | 1000 | 1000 | 500 |
PERSISTENT_IMPORT | not possible | 500 | 1000 | 500 |
PERSISTENT_RESTORE | not possible | 3 | 3 | 2 |
Restoring 64 kB (65536 bytes) | ||||
PERSISTENT_CLEAR | not possible | not possible | 8 | 2 |
PERSISTENT_SAVE | not possible | not possible | 11 | 6 |
PERSISTENT_EXPORT | not possible | not possible | 2500 | 1000 |
PERSISTENT_IMPORT | not possible | not possible | 2000 | 500 |
PERSISTENT_RESTORE | not possible | not possible | 12 | 5 |
Restoring max. PERSISTENT area | ||||
4 kB | 128 kB | 512 kB | ||
PERSISTENT_CLEAR | <1 | <1 | 17 | 22 |
PERSISTENT_SAVE | 2 | 2 | 22 | 35 |
PERSISTENT_EXPORT | 900 | 1000 | 4000 | 8000 |
PERSISTENT_IMPORT | 100 | 500 | 3000 | 4000 |
PERSISTENT_RESTORE | 3 | 3 | 22 | 31 |
Access to Operands in the Addressable PERSISTENT Area (%R Area):
The operands in the %R area can be accessed bit-wise, byte-wise, word-wise and double-word-wise.
Byte SINT / BYTE | Bit (byte-oriented) BOOL | Word INT / WORD | Double word DINT / DWORD |
---|---|---|---|
Segment 0 | |||
%RB0.0 | %RX0.0.0 … %RX0.0.7 | %RW0.0 | %RD0.0 |
%RB0.1 | %RX0.1.0 … %RX0.1.7 | ||
%RB0.2 | %RX0.2.0 … %RX0.2.7 | %RW0.1 | |
%RB0.3 | %RX0.3.0 … %RX0.3.7 | ||
%RB0.65532 | %RX0.65532.0…%RX0.65532.7 | %RW0.32766 | %RD0.16383 |
%RB0.65533 | %RX0.65533.0…%RX0.65533.7 | ||
%RB0.65534 | %RX0.65534.0…%RX0.65534.7 | %RW0.32767 | |
%RB0.65535 | %RX0.65535.0…%RX0.65535.7 | ||
Segment 1 | |||
%RB1.0 | %RX1.0.0…%RX1.0.7 | %RW1.0 | %RD1.0 |
%RB1.1 | %RX1.1.0…%RX1.1.7 | ||
%RB1.2 | %RX1.2.0…%RX1.2.7 | %RW1.1 | |
%RB1.3 | %RX1.3.0…%RX1.3.7 | ||
%RB1.65532 | %RX1.65532.0…%RX1.65532.7 | %RW1.32766 | %RD1.16383 |
%RB1.65533 | %RX1.65533.0…%RX1.65533.7 | ||
%RB1.65534 | %RX1.65534.0…%RX1.65534.7 | %RW1.32767 | |
%RB1.65535 | %RX1.65535.0…%RX1.65535.7 | ||
Segment 2 | |||
%RB2.0 | %RX2.0.0…%RX2.0.7 | %RW2.0 | %RD2.0 |
%RB2.1 | %RX2.1.0…%RX2.1.7 | ||
%RB2.2 | %RX2.2.0…%RX2.2.7 | %RW2.1 | |
%RB2.3 | %RX2.3.0…%RX2.3.7 | ||
%RB2.65532 | %RX2.65532.0…%RX2.65532.7 | %RW2.32766 | %RD2.16383 |
%RB2.65533 | %RX2.65533.0…%RX2.65533.7 | ||
%RB2.65534 | %RX2.65534.0…%RX2.65534.7 | %RW2.32767 | |
%RB2.65535 | %RX2.65535.0…%RX2.65535.7 | ||
Segment 7 | |||
%RB7.0 | %RX7.0.0…%RX7.0.7 | %RW7.0 | %RD7.0 |
%RB7.1 | %RX7.1.0…%RX7.1.7 | ||
%RB7.2 | %RX7.2.0…%RX7.2.7 | %RW7.1 | |
%RB7.3 | %RX7.3.0…%RX7.3.7 | ||
%RB7.65532 | %RX7.65532.0…%RX7.65532.7 | %RW7.32766 | %RD7.16383 |
%RB7.65533 | %RX7.65533.0…%RX7.65533.7 | ||
%RB7.65534 | %RX7.65534.0…%RX7.65534.7 | %RW7.32767 | |
%RB7.65535 | %RX7.65535.0…%RX7.65535.7 |
Note
Only the first 4 kB in segment 0 are available for PM57x, i.e., %RB0.0..%RB0.4095 or %RW0.0..%RW0.2047 or %RD0.0..%RD0.1023. Only the first 1 kB in segment 0 are available for PM55x and PM56x, i.e., %RB0.0..%RB0.1023 or %RW0.0..%RW0.511 or %RD0.0..%RD0.255.