FIFO in RSLogix 5000, help needed

4 posts in this topic

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 to the FIFO and the last element should go out (garbage). So, just 10 element should be in the FIFO.

I have done some tries with FFL and FFU instructions but without sucess.

Also, I have try to save just a tag (DINT), but without sucess. I have could save the values in the FIFO, but I am not sure how to displace the elements.

Somebody could help me?

Thanks in advance.







Edited by asteroidehk

Share this post

Link to post
Share on other sites

I am not sure where to start with an answer.  I would first create a UDDT with string and dint members (like UDDT_MyDatatype).

Define a tag array of that type (MyData[10])

Then you use the .dn bit of the FIFO to determine if there are 10 elements in the array or not.  use the .em bit to determine if it is empty (to FFU it).

I use the logic in the attached image to "log" recent data placed into a different queue.  This queue will fill up and store the last 20 values placed into a different queue which is the one being "processed" by the system.

In this logic, I check if the FIFO is full (.dn bit set), if it is I unload the head element making room for the newest member which is done in the second rung branch.  I have come accustomed to OTU the .en bit because the FFL instruction only allows one addition per scan and I sometimes need to add multiple values in a single scan.  The same with a FFU (except there I OTU THE .eu bit).



FIFO Logging.JPG

Share this post

Link to post
Share on other sites

I haven't done much with FFL or FFU, but what you're trying to do with the data once it's in the array may impact how you store it.  Here's an option to use instead of FFU/FFL: you could create an array of your UDT (with a DINT and a STRING) or simply use a DINT array and a STRING array. Then use an index tag to indicate the offset of the last thing stored.  When your conditions were true, you would increment the index, test for out of bounds, then write to the arrays using that index.

For example (I just typed this in, it's not from a PLC):
If conditions are true:

ADD Array_Index 1 Array_Index    //increment the index

GRT Array_Index 9 MOV 0 Array_Index  //limit check, wrap it back to 0 if it's past the end

COP DINT_Source DINT_Array[Array_Index]  COP STRING_Source STRING_Array[Array_Index]   //store the data


With something like these instructions, your array would always include the 10 most recent DINTs and STRINGs, with Array_Index always pointing to the most recent (and Array_Index + 1, adjusted for wraparounds is always the oldest data).


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now