Persistent data

If BACnet properties are changed via BACnet or the online dialog of server objects, the changes are initially lost when TwinCAT is restarted, since the corresponding values from the Settings dialog are used for initialization. In order to retain the data persistently during a device restart, the function Persist Server Online Data can be used in the Settings tab of the BACnet server. If this function is activated, during shutdown and perhaps cyclically the values of all BACnet properties that have changed compared with the initial configuration are saved in a file and reloaded when a configuration is loaded. The file is created in the boot folder of the TwinCAT installation ("C:\TwinCAT\Boot") and has the name "BACnetOnline_1010010.wbp". The number code identifies the server via a TwinCAT(TcCOM) object ID.

Devices with UPS can be shut down even if the supply voltage is lost, so that the storage of persistent data is ensured. For devices without UPS the data have to be stored cyclically or in the event of changes. The "Use USV" option in the Settings tab of the BACnet server can be used to specify whether data should be stored at a specified interval during operation. The "Backup Interval" dialog box can be used to specify the interval (in minutes) at which modified BACnet properties should be saved. Data are only saved if a BACnet property has been changed since the last backup.

The option "Use USV" does not result in automatic shutdown of the device in the event of a power failure. Monitoring of the UPS status and associated tasks can be implemented in the PLC with the aid of corresponding libraries. The option "Use USV" only disables periodic saving of persistent data. Writing of persistent data has to be affected manually or through the PLC via ADS or the property PersistentData. The PLC library TcBACnetRev12.lib provides functions for triggering the saving process.

Notice

Note the maximum number of write cycles

If data are cyclically saved to a flash medium, the storage medium may be damaged or destroyed if the backup intervals are too short. It is therefore important to ensure that the number of write cycles specified by the flash manufacturer is not exceeded over the expected operating period.

Persistent data 1:

Note that with this functionality all settings that were made in the "Settings" tabs of the objects after the current TwinCAT configuration has been activated become invalid, since all settings are taken from the BACnetOnline file. If a configuration has to be changed, first deactivate the function and delete the BACnetOnline file. Attention: Once the function has been disabled, the configuration is still loaded with activated persistence function, i.e. the BACnetOnline file is generated again when the system is shut down. Writing of the file is only disabled when the configuration is activated without the persistence function. With the new dialog for managing persistent data, changes can nevertheless be easily adopted. A description follows at the end of this chapter.

Dynamically generated BACnet objects are also included in the persistent data and re-generated during a restart.

When a new TwinCAT BACnet/IP configuration (or a BACnet server, to be more precise) is created, a unique Config ID is generated within the project, through which the BACnetOnline files are allocated to a configuration (CurrentConfig.xml). This is checked when the online data are loaded. If the Config ID does not match the loaded project, the online data are not applied. In this case the data from the Settings tabs are used.

Loading and saving persistent data

This section describes the procedure for loading and saving the online data. It ensures that a valid version of the persistent data is always available, even in the event of a power failure. Loading and saving of persistent data always takes place in RUN mode, and only when persistent data were activated.

Sequence: loading the BACnetOnline file

  1. If present: load the file "BACnetOnline_XXXXXXXX.wbp"
  2. After successful loading: rename the file "BACnetOnline_XXXXXXXX.wbp" to "BACnetOnline_XXXXXXXX.wb~"
  3. If "BACnetOnline_XXXXXX.wbp" does not exist: load the file "BACnetOnline_XXXXXX.wb~"

Sequence: writing the BACnetOnline file:

  1. Rename an existing file "BACnetOnline_XXXXXXXX.wbp" to "BACnetOnline_XXXXXXXX.wb~"
  2. Write the modified property and object data to the file "BACnetOnline_XXXXXXXX.wbp.tmp"
  3. After the write operation: rename the file "BACnetOnline_XXXXXXXX.wbp.tmp" to "BACnetOnline_XXXXXXXX.wbp"

Please note that the described procedure requires twice the memory on the flash memory.

Relevant changes

As already mentioned, online data are only saved if appropriate changes were made. Changes can be triggered by:

Changes in the following BACnet properties generally do not lead to persistence-relevant changes:

Manual saving of persistent data

Saving of persistent data can be triggered manually/programmatically. An acyclic (ADS) interface is available via which writing of the BACnet online data can be triggered:

IndexGroup

IndexOffset

Description

0x80C00000

always 0

Triggering saving of the persistent data. Only valid for BACnet servers if Persist Online Data is active.

Saving can be triggered via ADS with the aid of the System Manager (BACnet server Settings tab, "Save" button).

Saving of the persistent data can also be triggered via the BACnet network and the vendor-specific BACnet property PersistentData (of the device object). A state diagram for the BACnet property PersistentData is shown below.

Persistent data 2:

The BACnet property PersistentData is only visible if the persistent data are activated and the configuration is executed in RUN mode. After the initialization the property of the BACnet-data type Enumerated indicates whether a relevant BACnet property has changed or whether dynamic objects were created since the persistent data were last saved. If the data are unchanged the property PersistentData has the value NOCHANGE (2). If data are changed via BACnet (WriteProperty, WritePropertyMultiple, CreateObject, DeleteObject, WriteBDT), via ADS Write or through an object state machine, this is indicated by the property PersitentData with the value Ready (3).

If the property PersistentData has the value Ready (3), writing can be triggered via BACnet by writing the value Write (4). During writing PersitentData has the value Writing (5). After successful writing of the persistent data PersistentData enters the state NoChange (2) or Ready (3), depending on whether relevant data have changed during writing.

If persistent data is saved by manually triggering the write process, it is recommended to set the backup interval to a correspondingly high value or to deactivate the periodic backup with the function "Use USV".

Change management for persistent data

A new dialog was integrated in TwinCAT BACnet/IP to assist with the management of persistent data. This dialog can be enabled via the button "..." next to the Save button on the BACnet server "Settings" tab. The dialog can be used to deactivate or activate temporary storage of the persistent data at runtime (even if it was not active in the configuration). Temporary deactivation is reset at the next restart or when this function is temporarily activated. The transfer function can be used for (online) transfer of modified data into the Settings dialog (and therefore into the .tsm file). Attention: In contrast to the transfer function of the Property wizard, only data that were modified online are transferred. Property data that were changed in the Settings dialog, but not online, are preserved. "Delete" can be used to delete the ".wbp" files. Save triggers the saving of the peristent data.

Persistent data 3:

In a project with activated persistent data, the following procedure is recommended for loading changes, or for storing data, which were changed online after commissioning, in the .tsm file:

  1. Trigger the transfer function (changed data are transferred from Online to Settings)
  2. Deactivate writing of persistent data (Disable button)
  3. Delete the persistent data, since the changes are now in .tsm (Delete button)
  4. Save the configuration (.tsm) (optional)
  5. Activate the configuration (System Manager - Actions - Activate Configuration ...)
  6. Restart the controller

Diagnosis persistent data

The online tab of the BACnet objects shows for each BACnet property whether it has been changed compared to the Settings dialog. A * means that a BACnet property has been changed. An additional check mark means that the change was saved in the .wbp file.

Persistent data 4:

The diagnostic functions of the BACnet device enable information relating to the processing of persistent data to be viewed.

Persistent data 5:

Under ServerInfo you can find persistence specific information:

The WbpView dialog enables a more exact analysis of which property data were modified and are stored in the .wbp file. It can be activated as a wizard via the File object of the .wbp file. The wizard shows an overview of the contents of the binary wbp data in text format.