Internet PLC Forum
General => Technical support => Topic started by: tobor0216 on January 11, 2010, 03:26:52 PM
-
I am wondering how to set a DM location = to a counter. The reason I am looking to dp this I want to read my counters into a mDM location in case of a pwr failure, I can then write them back to the counters and I do not lose any information.
Thanks Paul
-
E.g. DM[10] = CTRPV[1]
or
DM[1000] = CTRPV[5]
-
This works, but the problem is when I reset the PLC or remove the power, the memory locations are cleared.
-
You can make the DM[] array act as if it is non-volatile using a couple of different methods:
- If you have the MX-RTC battery backed clock calendar option it is possible to make the DM[] behave as it is is non-volatile. This requires both the MX-RTC module and a dip-switch setting on the PLC board.
- Copy the values that you want to save into the EEPROM and reload the DM[] from EEPROM at power up/reset
I use the following code to copy the first 96 entries of DM[] into EEPROM at addresses 1 to 96:
FOR I = 1 to 96
SAVE_EEP DM,I
NEXT
I use the following code to reload DM[] when the PLC is reset:
for i = 1 to 96
dm=LOAD_EEP(i)
next