You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old October 10th, 2009, 03:07 PM   #1
rocket
Member
South Africa

rocket is offline
 
Join Date: Jun 2007
Location: MP
Posts: 27
Allen Bradley / RSLogix Dynamic Arrays

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?
  Reply With Quote
Old October 10th, 2009, 04:48 PM   #2
bernie_carlton
Lifetime Supporting Member + Moderator
United States

bernie_carlton is online now
 
bernie_carlton's Avatar
 
Join Date: Apr 2002
Location: Yakima, Washington
Posts: 5,379
As far as I know for SLC, Micrologix, ControlLogix you will have to pre-assign some area for the maximum possible entries.
__________________
Controlling outputs is the PLC's way of getting its inputs to change.

www.thePLCguy.com
  Reply With Quote
Old October 10th, 2009, 07:20 PM   #3
Operaghost
Member
United States

Operaghost is offline
 
Operaghost's Avatar
 
Join Date: Apr 2002
Location: Seattle, WA USA
Posts: 2,023
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
  Reply With Quote
Old October 10th, 2009, 09:13 PM   #4
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, UMSA, United Marxist States of America
Posts: 5,910
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.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old October 11th, 2009, 01:02 AM   #5
rocket
Member
South Africa

rocket is offline
 
Join Date: Jun 2007
Location: MP
Posts: 27
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?
  Reply With Quote
Old October 11th, 2009, 01:18 AM   #6
(8{)} ( .)
Member
Israel

(8{)} ( .) is offline
 
(8{)} ( .)'s Avatar
 
Join Date: Apr 2004
Location: Israel
Posts: 409
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)
  Reply With Quote
Old October 11th, 2009, 01:30 AM   #7
rocket
Member
South Africa

rocket is offline
 
Join Date: Jun 2007
Location: MP
Posts: 27
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?
  Reply With Quote
Old October 11th, 2009, 05:42 AM   #8
danny.michael
Lifetime Supporting Member
United States

danny.michael is offline
 
Join Date: Sep 2006
Location: Alabama
Posts: 155
Could you not have maximum buffer size and beginning buffer location as inputs to the AOI?
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
How To Enter Rslogix 5000???? sundar_scada LIVE PLC Questions And Answers 9 October 8th, 2009 11:29 AM
Rockwell Allen Bradley Programming Software, RSLogix 5, RSLogix 500, RS Linx, RSLogix vvcd LIVE PLC Questions And Answers 21 September 24th, 2009 10:04 PM
Allen bradley RSLogix 5000 to siemens simocode steven_42 LIVE PLC Questions And Answers 3 July 7th, 2009 06:27 PM
RSLogix 5000 V15 Features Samneggs LIVE PLC Questions And Answers 18 April 20th, 2006 05:45 PM
Latest Allen Bradley Guardplc & Rslogix Guard!! ckchew666 LIVE PLC Questions And Answers 1 December 1st, 2003 01:49 AM


All times are GMT -5. The time now is 09:40 AM.


.