Logix5000 FIFO manipulation

alexbeatle

Member
Join Date
Feb 2010
Location
San Francisco
Posts
188
Hello!
I've got data that I'm pushing/poping into a FIFO on Logix5000. Logix is also connected to the Ignition HMI for display.
Once in a while I'd need to change data in FIFO - push/pop anywhere in the FIFO data array.
Any suggestion on how-to best?

Ex. If FIFO is an array of strings strFIFO[100]. Normally, I push/pull using FFL/FFU. When needed, remove strFIFO[3], strFIFO[55], strFIFO[67] - pop string #3, #55, #67 update FIFO POS and remove blanks in-between. Similar with inserting an empty or a new string into the FIFO (anywhere in the array)

Currently I do it on HMI by selecting which string to remove. The, using while loops: copy all of the unselected strings to a temp array and then copy back into FIFO, updating the POS, accordingly. This is cumbersome and is taking relatively long time.
 
Unfortunately I can't think of a better conceptual way to do it than you currently are. You can clean it up a little by using the COP instruction. That should get rid of the while loop as you can copy the items as blocks and get rid of or create a space in two instructions. But the concept of how you are managing the strings is the best i can think of.

Keith
 
Unfortunately I can't think of a better conceptual way to do it than you currently are. You can clean it up a little by using the COP instruction. That should get rid of the while loop as you can copy the items as blocks and get rid of or create a space in two instructions. But the concept of how you are managing the strings is the best i can think of.

Keith
Thanks, Keith!
Interesting concept with the COP. Maybe better with CPS do disallow data change during copy.
 
Last edited:
See if something like this will work. It 3 rungs of logic that clears the selected entry and shifts the remaining data up and also reports the next entry position for the FIFO.

it's an exported subroutine.

I didn't look into inserting a blank entry into the middle of the array. Maybe tomorrow.
 
A few thoughts on this.
From the post to looks like you are using string data type in the FIFO array
In logix 5000 a string data type has 2 parts
An array of ASCII characters
And an INT of LEN = the number of characters in the string the max allowed is 80
If you edit the ASCII characters with an external program like an HMI, Net Studio ect.
You need to also edit the LEN part of the string type. The Logix program will read the string for the LEN value, if your string is longer than the value it will truncated, if it is shorter than it will add characters to your string to the length of LEN. This could result in unexpected actions in your PLC program.

Now for the FIFO
A FIFO Load will copy the load tag to the array at the POS ( Position of last Data ) and add one the POS.)
It will only load the FIFO if the POS is less than the Max. value
A FIFO Unload as long as the POS value is greater than 0 it will always copy the data in POS 0 to the unload tag and copy the data in pos 1 to pos 0 and the data in pos 2 to pos 1 Ect. And sub 1 from the POS value.
So understanding how a FIFO works you can read and write the data in the array for any other source
A copy command from the program or external source if you like you just need to remember and follow the rules if you change the string you must change the LEN to match the string length a LAN value of 0 is an empty string even if the array is populated with ASCII Characters it will return an empty string.
In place of removing the empty strings in the array and them copying the array to fill why not just check the unload tag after the unload copy and if it is an empty string just retrigger the unload again this way it will automatically handle any empty strings it encounters, remember you can load an empty string with the FIFO load command as well. It copies the value of the load tag to the array even if it is empty.

On other note when reading or weighting to an PLC FIFO array from an outside program you should lock out the FIFO load and unload functions until the read write is compete otherwise you risk data corruption.
It would be the same as using the SCOP to prevent the data from changing while you are reading or writing it.
 
See if something like this will work. It 3 rungs of logic that clears the selected entry and shifts the remaining data up and also reports the next entry position for the FIFO.

it's an exported subroutine.

I didn't look into inserting a blank entry into the middle of the array. Maybe tomorrow.

Thanks. Looking good! If I make the array of UDTs (1 string and 1 bool), is COP Len still =1 for the null insertion? My null UDT will be 1 blank string and a false bool.
 
Last edited:
A few thoughts on this.
From the post to looks like you are using string data type in the FIFO array
In logix 5000 a string data type has 2 parts
An array of ASCII characters
And an INT of LEN = the number of characters in the string the max allowed is 80
If you edit the ASCII characters with an external program like an HMI, Net Studio ect.
You need to also edit the LEN part of the string type. The Logix program will read the string for the LEN value, if your string is longer than the value it will truncated, if it is shorter than it will add characters to your string to the length of LEN. This could result in unexpected actions in your PLC program.

Now for the FIFO
A FIFO Load will copy the load tag to the array at the POS ( Position of last Data ) and add one the POS.)
It will only load the FIFO if the POS is less than the Max. value
A FIFO Unload as long as the POS value is greater than 0 it will always copy the data in POS 0 to the unload tag and copy the data in pos 1 to pos 0 and the data in pos 2 to pos 1 Ect. And sub 1 from the POS value.
So understanding how a FIFO works you can read and write the data in the array for any other source
A copy command from the program or external source if you like you just need to remember and follow the rules if you change the string you must change the LEN to match the string length a LAN value of 0 is an empty string even if the array is populated with ASCII Characters it will return an empty string.
In place of removing the empty strings in the array and them copying the array to fill why not just check the unload tag after the unload copy and if it is an empty string just retrigger the unload again this way it will automatically handle any empty strings it encounters, remember you can load an empty string with the FIFO load command as well. It copies the value of the load tag to the array even if it is empty.

On other note when reading or weighting to an PLC FIFO array from an outside program you should lock out the FIFO load and unload functions until the read write is compete otherwise you risk data corruption.
It would be the same as using the SCOP to prevent the data from changing while you are reading or writing it.

Great points! I missed on the .LEN since all of my strings are of the same length, but if I want to introduce an edit or if I insert blank, I definitely need to take care of this.
 
Thanks. Looking good! If I make the array of UDTs (1 string and 1 bool), is COP Len still =1 for the null insertion? My null UDT will be 1 blank string and a false bool.

Yes, As long as the Nulls are made from the same UDT.
 
It looks like it's pretty easy to insert a null entry into the Array using the FFL instruction. If you don't use a one shot the FIFO position will stay on the Entry position.

insert null.PNG
 
It looks like it's pretty easy to insert a null entry into the Array using the FFL instruction. If you don't use a one shot the FIFO position will stay on the Entry position.
The requirement is to be able to insert at any position of the array, not just at the begining.
 
Also, I see that you put a NULL at he end of the array and then search for it to establish .POS for the FIFO. Why not simply subtract the .POS by one, as we only remove one array record.

If your talking about the FFL.POS then yes that should work.


Also, I overlooked the fact that the insert null rung over wrote the position and did not shift existing down and insert the null position.
 
It looks like you are making things more complex then it has to be. Without knowing the exact application it’s hard to say but you may not need a FIFO at all
Just an array or strings data type
The can be more easily addressed by the index
Copy string A to string array[6] length of 1
It will copy the charterers and the .LEN to the indexed location
You don’t need do anything with the .POS of the FIFO
If you just want to show a string based on an index value then just use an array and forget the overhead that you need with the FIFO
 
Do over on the insert Null.

This shifts data down and inserts null. The only thing I did was make the Storage Array 1 Element larger than the FIFO Array.

insert null.PNG
 
It looks like you are making things more complex then it has to be. Without knowing the exact application it’s hard to say but you may not need a FIFO at all
Just an array or strings data type
The can be more easily addressed by the index
Copy string A to string array[6] length of 1
It will copy the charterers and the .LEN to the indexed location
You don’t need do anything with the .POS of the FIFO
If you just want to show a string based on an index value then just use an array and forget the overhead that you need with the FIFO

As mentioned in the original post, normally (90% of the time) FFL/FFU works for me. But once in a while (10%) I'd need to edit it - remove or insert record(s).
 
Last edited:

Similar Topics

Hello Friends I need to save 2 tags (String and DINT) in a FIFO of 10 elements. When a programmed condition is true, this 2 tags should enter...
Replies
3
Views
4,558
Anyone know of an easy way to program a FIFO in function block for RSLOGIX500. There appears to be no instruction for this. I'm sure I can put...
Replies
4
Views
2,807
How do I make sure that I only push Unique elements into my FIFO (or I guess into an array)? Should I just write an AOI that loops through the...
Replies
2
Views
1,827
Hi! So my problem is a little funky, I had Studio 5000 v 24 and 30 installed, but forgot to install RSLogix (which I cannot go without). Is there...
Replies
2
Views
89
So I had an odd request from a customer for the above. I have written the logic and tested it all in one PLC with only using 7 outputs and 7...
Replies
15
Views
423
Back
Top Bottom