FIFO I thought!!

PLC Pie Guy

Member
Join Date
Jun 2013
Location
Halifax
Posts
1,144
Morning all.
I'm trying to make something work here and its giving me a little challenge.

I thought I should use a FIFO but now I'm not so sure after the trial and error.

Using v21 of logix5000 in an L43.

I want to move data to element[0] of a 10 dint array tag. Then, based on conditions, I wan to move another value into element[0] and have element[0] data go to element[1]. element[1] should move to element[2]. You get the picture. the data from element[9] can simply disappear.

I simply need a kick in the *** pointing me the right direction here!

Thanks
 
FIFO is what you want. Just unload it once when it gets DONE, and it should work exactly how describe.

FFL and FFU instructions. Since you seem to only care about the array order, and not unloading it until it just gets full and tossing the old result, I think you just need to use the FFL to fill it, and use the FFU to unload one spot once the FIFO is full.
 
Unfortunately I don't think the built-in AB FIFO or LIFO instructions store data in the way you want it stored. Both variants will put the new data in the next open location in the array.

However, You could do this with two copies. Copy the whole array from the source to a buffer array. Then copy the buffer back to the source shifted up by by 1 (buffer 0 to sourse 1, buffer 1 to source 2, etc.). Finally, move the new value into element 0.

There is actually an easier way (in my mind) to do this with a head pointer and a static array but that tends to confuse people. It is basically the way the FIFO instruction stores data but with your own .POS value.

Keith
 
Guess I didn't think about the order. But seems like the order would not be as important as getting the info in the array. I would just try to use the items stored in the array in the opposite direction if the order was the issue. And then just keep the relatively simple FIFO commands.

Or if the order was an issue, using the FIFO commands than buffering the created array into a separate array, reverse order. Which would be short work even Brute Forced with an array of just 10 elements.
 
Unfortunately I don't think the built-in AB FIFO or LIFO instructions store data in the way you want it stored. Both variants will put the new data in the next open location in the array.
Keith

Correct, this is what I am seeing happen. I will go to work and "brute force" it as you say but I was just hoping for a clean, one instruction to do it kind of solution before adding a few lines of logic to the code.


I tried to keep the position of 0, I reset it each time I moved a value to the FIFO but then I just keep writing over the value already stored in element[0]. It didn't push the values through the array like I hoped. I seem to remember an exercise from a PLC course that I did just as I am describing but for the life of me I can't find that exercise in my training folder.



Thank you all for the input.
 
Yes, Modifying the FIFO position will do that. That position is how it determines what to do with the array.

You are using a RSLogix 5000, so I suppose you could "roll your own" into an AOI that does what the FIFO does, but in reverse order through the array. Then you could reuse the AOI as your "FIFO with reverse stored array" or something like that.

Then in your main logic you'd just see the one instruction.
 
Originally posted by PLC Pie Guy:

I tried to keep the position of 0, I reset it each time I moved a value to the FIFO but then I just keep writing over the value already stored in element[0]. It didn't push the values through the array like I hoped.

Being a male of the species I am genetically programmed to rail against this myself, but sometimes RTFM really is the best course of action. The in-program help for the FIFO instruction is actually pretty good at telling you what is happening and would have shown you immediately that what you were hoping to do wouldn't work.

Originally posted by PLC Pie Guy:

I seem to remember an exercise from a PLC course that I did just as I am describing but for the life of me I can't find that exercise in my training folder.

I suspect it was probably this:

Originally posted by kamenges:

However, You could do this with two copies. Copy the whole array from the source to a buffer array. Then copy the buffer back to the source shifted up by by 1 (buffer 0 to sourse 1, buffer 1 to source 2, etc.). Finally, move the new value into element 0.

Three instructions instead of one (COP, COP, MOV) but still pretty compact.

Keith
 
You can do this in one COP..... IF you can arrange the storage of your DINTs in reverse order, oldest at the "top" ([0]), and newest at the "bottom" ([9]).

COP MyDINTS[1] MyDINTS[0] 9
MOV MyData MyDINTS[9]
 
The help on screen was what I was referring myself to. I was reading it but I was kind of interpreting it a little differently than how it was acting. I have never actually had to use a FIFO in real time for myself so I guess I had a pre conceived notion of what I EXPECTED it to do VS what it actually does! That was my undoing!! I have a great understanding of it now and actually as it turns out, I didn't use it. It really wasn't what I wanted so I just created a small buffer array and move the data through with a combination of MOV, ONS and one COP instruction for my string tag.

I must say, I love having a fully functional online PLC on my desk to experiment with this kind of thing....... consequence free environment!!


Thanks for the help.


DABA:::: I like that soloution!!!! You posted at the same time as me!!!!!
I mentioned earlier about a training module I did may moons ago that I thought was pertaining to a FFL. Im looking through the sections on Arrays and I found that lab... Just as you laid it out here.

Thank you
 
Last edited:
That's It, It even like my STRING arrays!!!!

But,,,,, I had to do it like this

COP MyDINTS[1] MyDINTS[0] 9
COP MyData MyDINTS[9]


Perhaps because I am doing this with a string tag. Ill try it your way with just DINT...

Thanks
 
Last edited:
Yes, you will need to use COP instead of MOV for STRING data.

If you have any periodic or event tasks that might use data from your array, you might want to use CPS instead of COP for shifting the array.

CPS cannot be "interrupted" mid-execution like COP can be...
 

Similar Topics

I am not sure if this is possible but if there is a way, you guys would be the ones to know. I am currently working on a project where we are...
Replies
7
Views
231
Hello all, I'm using a 5069-L330ER in a project and I need to essentially capture some data that will be shown as a trend on a screen. The data...
Replies
9
Views
975
Hello! I have a network of conveyors bringing raw product to 4 machines. A sensor in the hopper of each machine calls for more product. I'm...
Replies
15
Views
5,901
Hello everyone, has anyone out there ever made a FIFO using an FFL and FFU instructions on a Micro800? I have tried setting it up just as I would...
Replies
9
Views
3,137
I have a bottle capper that is using an encoder and FIFO logic to track the free standing bottles passing through a bottle capper. I have checked...
Replies
31
Views
11,694
Back
Top Bottom