Allen Bradley / RSLogix Dynamic Arrays

rocket

Member
Join Date
Jun 2007
Location
MP
Posts
29
Hello

Is there any way to manipulate the length / number of members of an array in a program in runtime? I store time-stamped events in a buffer that get cleared again depending on age of each record and I do not want to pre-define the maximum size of the buffer (array) but rather let it grow and shrink dynamically as required (within reasonable limits of course). Is this possible and, if so, how?
 
Many instructions will allow you to vary the length (number of values it uses), but those locations must be created ahead of time and can not be added to or removed from memory while the controller is running.

OG
 
Dynamic memory allocation is extremely difficult to do

Consider an array directly between two other data structures and you want to add more elements. A new array would need to be allocated of the new desired size and the data from the original array would then need to be copied to the new array. Now you have a hole that isn't used any more. This is called fragmentation. If you do this enough time the memory will not be able to allocate new data because there aren't any blocks big enough. Therefore memory would need to compressed ( garbage collection ). This would not be easy to do during a scan. Even allocating a new array would take time. Now all the code would need to be modified to point the new locations and this would need to happen on the fly.

I don't think you want your PLC slowing down like a Microsoft PC does when it gets short on memory.
 
OK thanks that is clear. BUT... I have created an AOI to do the timestamping when an input to it transitions high. In some applications, I only need say 10 timestamps, I flush out the oldest if more arrive. In other applications I need 100 or more. Now I don't particularly want to create separate AOI's for each type of use (i.e. one with an array of 10, one with 50, one with 100 etc.). I'd rather have one AOI and when calling it the first time, initialise the number of records required to buffer thereby sizing the array to the maximum required size. Is THIS possible?
 
Dynamic arrays in PLCs

Hi Rocket.

I'm having a problem understanding your reasoning. Basically,
unless you're dealing with a crippling amount of memory
allocation I don't see a reason to save the 90 (or 50) entries.
Furthermore, I agree with Peter on this one. Dynamic memory
allocation is not (and perhaps shouldn't be) in a PLC's
vocabulary. If you really need it (which I don't think you do)
you should be looking at a coprocessor.

Good Luck,

(8{)} :) .)
(Yosi)
 
I time-stamp certain events in order to calculate how many times something has happened in an hour or in a day or even in a week or month. Depending on the duration and the nature of the process for which I'm time-stamping events, I need more or less "buffer" space.

I have created an Add-On-Instruction to capture and calculate the number of events in the desired time-frame.

I don't particularly like creating multiple AOI's for each type of scenario (i.e. one AOI that can capture up to 10 events and another that can handle 50). It simply seems a bit clumsy - and I would have liked to write my AOI such that when I use it in code I can then stipulate at first-call the maximum number of events it would need to handle... It's not so much a memory issue as an "elegance" issue. Why copy and past the exact same AOI when all that is different in the AOI is the maximum "buffer" size?
 
Actually, this site

http://trutegra.com/different-array-lengths-with-one-aoi

Shows a great method of creating a dynamic array inside of an AOI. I've tested it out by creating a shift left/right AOI

I don't see how you believe this is dynamically creating arrays. The link shows how to get the size of an array passed to it by InOut reference using the SIZE instruction. That is not the same thing.
 
Hi jstolaruk. Correct, it is not equivalent to dynamically creating arrays but it at least enables one to use a single AOI for arrays of varying sizes.
 

Similar Topics

Hello all. I have been working with an SLC 5/04 system, which houses various Digital and Analog INs and OUTs, up to Slot 29. I am currently...
Replies
3
Views
2,477
1.the black switch is master start/stop switch 2. When red pushbutton is pressed once, both motor 1 and 2 should run continuously 3.if you close...
Replies
3
Views
1,739
how can i use my allen Bradley RSlogix PLC to gate triggering to a TRIAC or thyristor actually i want to gate triggering to the TRIAC or...
Replies
12
Views
6,230
Hello All, I am fairly new to PLC programming and really only know how to use the basic functions of RSlogix 5000. I have a new project I will...
Replies
14
Views
24,123
Hi All, I wonder if anyone knows the answer, or even if its a stupid question, as to whether the ALMA / ALMD blocks that rslogix uses for alarms...
Replies
5
Views
6,242
Back
Top Bottom