Loading and storing of recipes

The function block fb_ReadWriteFile enables data (up to 16,000 bytes) to be stored permanently in the flash memory of the BX controller. A new program or a project reset does not affect the content of this memory. This function block is not suitable for sustained and continuous use. A maximum of 10000 write cycles are permitted. There is no limit on read operations.

Application: Saving of recipes or settings that only change rarely or not at all, for example controller parameters.

Loading and storing of recipes 1:

Note the following during writing of data

  • The voltage must not be interrupted during writing. It is therefore advisable to initiate writing via an operating panel or the navigation keys or simply via a digital input, in order to ensure that the BX Controller is not switched off during writing. Automatic writing is not recommended, since uninterrupted voltage supply during writing cannot be guaranteed.
  • Writing of data takes approx. two seconds, irrespective of the number of data that are written.
  • The data are lost if the BX controller is switched off during the write operation.
  • Only one instance of this function block is permitted.

Function block fb_ReadWriteFile

Function block for reading and writing of recipes

Function block fb_ReadWriteFile

VAR_INPUT

bRead           :BOOL;
bWrite          :BOOL;
OffsetRead      :WORD;
DataReadSize    :WORD;
DataRead        :Pointer to Byte;
OffsetWrite     :WORD;
DataWriteSize   :WORD;
DataWrite       :Pointer to Byte;

Legend

bRead: A rising edge triggers reading of the function block (bWrite must be FALSE)
bWrite: A rising edge triggers writing of the function block (bRead must be FALSE)
OffsetRead: Offset in the memory 16,000 bytes max.
DataReadSize: Size of data to be read in bytes (16,000 bytes max.)
DataRead: The pointer should be pointed to the data via ADR
OffsetWrite: Offset in the memory 16,000 bytes max.
DataWriteSize: Size of data to be written in bytes (16,000 bytes max.)
DataWrite: The pointer should be pointed to the data via ADR

VAR_OUTPUT

bBusy          :BOOL;
bError         :BOOL;
bErrorId       :UDINT

Legend

bBusy: Indicates that the function block is still active
bError: Function block error
bErrorId: Error number

Return parameter iErrorId

Meaning

0

No error

1dec

READ: Data offset and data length more than 16,000 bytes

2dec

WRITE: Data offset and data length more than 16,000 bytes

0x31440708

CRC error in the data memory

0x31470708

Writing of data is not yet complete

Required libraries:

Loading and storing of recipes 2: Download sample ST program (sample file)

readwritefile.prx