Persistent data
Notice | |
Application example In the following example, changes to the loads, the power supply or even just aging components can lead to the application no longer fulfilling the desired function. Beckhoff takes no responsibility for the implementation of the example in an application. |
Normally, persistent data are only stored during the TwinCAT stop or by a function block. This chapter shows you how to store persistent data on a CX7000 without a UPS.
In the case of an Embedded PC with UPS, the function block is usually linked to the UPS. The function block becomes active as soon as a power failure is detected, writes the persistent data and then shuts down the Embedded PC. With a 1-second UPS, the Embedded PC is not shut down because there is too little time left for this.
In the case of a small controller such as the CX7000 which is delivered without a 1-second UPS, you can still use this function. All that is needed is to use a power supply unit that has enough residual energy to supply power to the CX7000 with this residual energy for a certain period of time. A small test can show you if this is possible with your power supply unit:
Testing a power supply unit
When the CX7000 is running, turn off the AC voltage of your power supply unit and measure how long the CX7000 continues to run. If it is more than three seconds, you may be able to use the power supply unit as a replacement for a 1-second UPS. Note that power supply units also age and lose capacity. You should therefore include a safety factor, such as a factor of three, so that you have enough reserve to be able to operate the power supply unit for a longer period of time as a replacement for a 1-second UPS.
Now determine how long the power supply unit maintains the supply of power. You need an EL1722 for this, which you connect to the AC side of the power supply unit. Then write a small program:
VAR
bPower230V AT %I* : BOOL; (*link to the EL1722*)
END_VAR
VAR RETAIN
Counter : INT;
END_VAR
Program:
IF NOT bPower230V THEN (*bPower230V is linked to the EL1722*)
Counter:=counter+1; (*the counter is a retain value*)
END_IF
Create a boot project and turn off the AC voltage of the power supply unit. As soon as the EL1722 no longer displays a value, the counter is incremented and the data are copied to the internal NOVRAM. Turn the AC voltage back on and log in. You must now multiply the counter value by the task time. Repeat this a few times to be sure that the power supply unit always behaves in the same way. Next, you have to insert the function block FB_WritePersistentData
. This is contained in the Tc2_Utilities library (in the "TwinCAT PLC" folder).
Then determine how long it takes to store the persistent data. Repeat this process a few times too, so that you obtain a constant value and can determine a maximum value in case of fluctuations. You can determine the time required via the Busy flag. The function block is being processed as long as the Busy flag is set. Multiply the value determined by two to incorporate a further safety factor.
Example:
Your measurement shows that the power supply unit maintains the supply of power for three seconds and that the persistent data is written in about 400 ms. With the recommended safety factors, the power supply is maintained for one second and the persistent data is written in about 800 ms.
The power supply is therefore maintained for a longer period of time than is needed to store the persistent data. Therefore you can use the example power supply unit as a replacement for the 1-second UPS.