News:

  • September 24, 2026, 11:49:23 AM

Login with username, password and session length

Author Topic: Edge memory resource allocation error  (Read 12038 times)

Watermark_JS

  • Sr. Member
  • ****
  • Posts: 53
Edge memory resource allocation error
« on: August 02, 2023, 09:19:42 AM »
We have started getting Edge memory resource allocation errors and can no longer write the program we are working on to our development CPU.

The first error was:
Edge memory resource allocation error on STRDLT at CtrlPRGC1@1261.

We deleted and rewrote the relevant rung, just to see if it would change anything.

Now we are getting:
Edge memory resource allocation error on ORDLT at CtrlPRGC1@1429.  :-\
« Last Edit: August 02, 2023, 09:41:30 AM by Watermark_JS »
If you don't make mistakes, you aren't doing anything.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Edge memory resource allocation error
« Reply #1 on: August 02, 2023, 09:59:12 AM »
Well, that is a first.

Edge memory was originally designed just for edge contacts (1 bit per) and the region size was selected with that in mind. We later came up with the idea of delta contacts and chose to use edge memory for it because it was convenient, but didn't increase the memory allocated to edges. Since deltas can be on DWORD elements, it burns edge at up to 32 bits per contact, much faster than originally planned. As of now there isn't a way to increase the edge allocation, but obviously we'll need to look into that. In the meantime, you'll need to roll your own delta check with comparative contact and a previous state variable.

STRNE R0 R1
MOVE R0 R1
...delta logic here...

"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Watermark_JS

  • Sr. Member
  • ****
  • Posts: 53
Re: Edge memory resource allocation error
« Reply #2 on: August 02, 2023, 10:05:13 AM »
Thanks for the usual insanely fast response.

We had also noticed that downloads to the PLC were taking longer than usual.

We cleared the PLC memory (everything except System Settings) and the problem appears to have been resolved.

 :P
If you don't make mistakes, you aren't doing anything.

Watermark_JS

  • Sr. Member
  • ****
  • Posts: 53
Re: Edge memory resource allocation error
« Reply #3 on: August 02, 2023, 10:08:32 AM »
Also, we are using the Delta instruction, extensively, on Unsigned Word elements.  I assume that's -- as you said -- burning a ton of bits.
If you don't make mistakes, you aren't doing anything.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Edge memory resource allocation error
« Reply #4 on: August 02, 2023, 10:09:47 AM »
Also, we are using the Delta instruction, extensively, on Unsigned Word elements.  I assume that's -- as you said -- burning a ton of bits.

Yep, that's the culprit. Just a go easy(er) on the deltas and you will be fine. We'll look into increasing the allocation.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Edge memory resource allocation error
« Reply #5 on: August 02, 2023, 10:26:42 AM »
There is an upper limit, and it appears you are utilizing a ton of edge bits (edge contacts, edge triggered certain boxes, and delta contacts).  Delta contacts burn 32 edge bits of edge memory at a time - and delta contact edge bits must be DWORD aligned.

OPTION 1:
If you can put your PLC into program mode (rare applications require 100% RUN mode), you could try is to export your project, then re-import it.  This will re-assign and pack all your edge bits when you write it back to the PLC, hopefully making more contiguous blocks of 32 bits on DWORD boundary for your DELTA contacts.  However, it is a limited resource (32K bits).

OPTION 2:
If you re-use the same delta contact element across multiple rungs, (e.g. 5 places where you use DELTA D42), it would be better to have ONE delta contact of D42 in a stand-alone rung, store that bit result in an OUT C bit, then re-use that C bit as a Normally Open contact in the other 4 rungs that had the DELTA D42 contact, instead of burning 5x32 Edge bits for the identical logic.

OPTION 3:
Another alternative, you may need to write your own "delta" logic for your delta contacts, where you burn non-edge memory to store the "previous" value.  Probably best to create a 32 bit int data block DeltaD (32 bit int), and a block of bits DeltaBit.  It gets ugly, but it's do-able.

// emulate D42 Delta contact
STRE D42 DeltaD5  // DeltaD5 contains the "previous scan" value, so compare it against the "current" value in D42
ANDN ST0  // and not first scan - technically no "previous" value on first scan, so make sure on first scan the delta bit is OFF
OUT MyDeltaBit5  // write that compare to a bit that we now use wherever we would need a Delta D42 contact

// after the "delta" rung, in this next rung, ALWAYS write D42 state into its "previous scan" register that will be utilized in the next scan of the logic above
STR ST1
MOVE D42 MyDeltaD5

Then utilize MyDeltaBit5 Contact wherever you would have had a DELTA D42 contact.

This solution emulates the behavior of a delta contact that is privately utilizing edge bit memory for the "previous scan value".

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Edge memory resource allocation error
« Reply #6 on: August 02, 2023, 10:39:20 AM »
I just realized OPTION 1 may not work as I originally thought.  Since a runtime edit must be a SUPERSET of the USED edge bits in the DESIGNER CURRENT project and the ONE in the PLC.

This would work as I originally thought if the PLC program was CLEARED (JUST THE PROGRAM - not memory, not sysconfig).  If you are comfortable with that, you could try that.  DO NOT CLEAR DATA NOR SYSCONFIG - THAT IS THE DEFAULT BEHAVIOR - SO YOU MUST UNCHECK those options in the Clear PLC dialog.

After you write the Project to the PLC, remember to SAVE it to DISK (because the edge bits got re-assigned and you really need those new values ON DISK).

Watermark_JS

  • Sr. Member
  • ****
  • Posts: 53
Re: Edge memory resource allocation error
« Reply #7 on: August 02, 2023, 02:19:15 PM »
Thanks for the details.  We see now how we can reduce the impact of the deltas, if necessary.  I think we're about done adding them, so have our fingers crossed for now.

If we need to roll our own, we can.  Much appreciated!
If you don't make mistakes, you aren't doing anything.