Author Topic: Setting a DM location = to a counter value  (Read 10845 times)

tobor0216

  • Newbie
  • Posts: 24
  • I'm a llama!
    • View Profile
Setting a DM location = to a counter value
« 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

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Setting a DM location = to a counter value
« Reply #1 on: January 11, 2010, 07:18:50 PM »
E.g. DM[10] = CTRPV[1]

or

DM[1000] = CTRPV[5]
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

tobor0216

  • Newbie
  • Posts: 24
  • I'm a llama!
    • View Profile
Re:Setting a DM location = to a counter value
« Reply #2 on: January 12, 2010, 02:46:54 PM »
This works, but the problem is when I reset the PLC or remove the power, the memory locations are cleared.

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Setting a DM location = to a counter value
« Reply #3 on: January 12, 2010, 03:40:18 PM »
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