1-second UPS (persistent variables)
Loss of data Use only TwinCAT to control the 1-second UPS and save only persistent data with a maximum size of 1 MB. Use beyond this may result in data loss or corrupt data. |
The 1-second UPS is an UltraCap capacitor that continues to supply the processor with power in the event of a power failure. During this period persistent data can be saved, which are available on switching on again.
Since the 1-second UPS is designed for the entire service life, the holding time is considerably longer with new devices. The capacitors age over the course of time and the holding time decreases. Therefore a maximum of 1 MB persistent data can be reliably saved over the entire service life. Do not save any other data and do not use any other applications to control the 1-second UPS.
Please note that the 1-second UPS does not supply power to the K-bus or the E-bus and that their data may already be invalid when the 1-second UPS is activated. Also, the fieldbus system (or Ethernet) may not work or not work properly once the 1-second UPS was activated.
Development environment | File path | File name |
---|---|---|
TwinCAT 2 | \\TwinCat\Boot\ | TCPLC_T_x.wbp The x in the file name stands for the number of the runtime system. |
TwinCAT 3 | \\TwinCat\3.1\Boot\Plc | Port_85x.bootdata The x in the file name stands for the number of the runtime system. |
Configuration of the 1-second UPS
- For the CX9020 the 1-second UPS has to be ordered ex factory (CX9020-U900).
- Declare important data such as counter values in the PLC as VAR PERSISTENT. Then call the function block FB_S_UPS_CX9020_U900 cyclically in TwinCAT in order to control the 1-second UPS (see: FB_S_UPS_CX9020_U900).
- Select the mode in the function block in order to specify what should happen in the case of a power failure. Specify, for example, whether persistent data are saved and a quick shutdown is executed (see: Data types)
- Subsequently you can check the validity of the variables and monitor whether the persistent variables are loaded without error (see: Checking the validity of the variables).
Sample project:
ups_example.pro
Saving and loading persistent data
The persistent data are saved in the Port_85x.bootdata file on the memory card. On starting the PLC the Port_85x.bootdata file is loaded from the memory card, backed up there as Port_85x.bootdata_old (backup) and then deleted.
Another current Port_85x.bootdata file is not written until the system is shut down or the 1-second UPS is activated.
If no Port_85x.bootdata file exists when starting the embedded PC, the persistent data are invalid and will be deleted (standard setting). The reason for this is that the 1-second UPS was activated before the TwinCAT PLC was started during startup of the embedded PC. In this case no persistent data were saved, since the system was unable to ensure sufficient buffer time for saving the data.
Always call the function block from the PLC and always use the fastest task to do so. In the case of a power failure Beckhoff recommends not calling the rest of the application in order to ensure that sufficient time remains for writing the data.
IF NOT FB_S_UPS_CX9020_U900.bPowerFailDetect THEN
;//Call programs and function blocks
END_IF
The rest of the application influences the CPU load and the CPU load in turn affects the period during which the persistent data are written.
Loading a backup of the persistent data
A registry setting can be used to determine whether the backup file is deleted or used. The backup file is used by default (setting 0):
[HKEY_LOCAL_MACHINE\SOFTWARE\Beckhoff\TwinCAT\Plc]"ClearInvalidPersistentData"= 0
If the backup file is to be deleted, the value of "ClearInvalidPersistentData" in the registry must be set to 1.
It is also possible in TwinCAT to specify on the left in the tree view under PLC whether the backup file is to be used or not.
The backup files will be deleted if the option Clear Invalid Persistent Data is activated. Corresponds to registry entry 1.