FIFO in connected component workbench Help

keristos

Member
Join Date
Aug 2011
Location
Malta
Posts
65
Hey,

I am trying to implement a FIFO as a sort of memory option when I am trying to log the last 30 values of a variable.

Due to the lack of FIFO or Memory option on CCW (as far as I am aware) I tried using the COP function as follows:

Source: Test_1
SRC_OFFSET: 0
Dest: Test_1
DEST_OFFSET: 1
Length: 29
SWAP: 0

Where Test_1 is an array of dimension 30.

The way i reasoned this out is to grab the first 29 [0 - 29] values of the array and copy them onto the [1 - 30] positions of the same array.

The issue I encountered is that the COP function seems to perform the copy in a step-by-step manner, copying only one element at a time. This therefore caused the first element in the array to be copied throughout the array.

This diagram might explain it better. From what I've concluded it function like this:
Grab [0] and copy to [1] ==== Value 1 is copied to [1]
Grab [1] and copy to [2] ==== Value 1 is copied to [2]

[0]1 ----> [0] 1 ----> [0] 1
[1]2 ----> [1] 1 ----> [1] 1
[2]3 ----> [2] 3 ----> [2] 1
[3]4 ----> [3] 4 ----> [3] 4
[4]5 ----> [4] 5 ----> [4] 5
[5]6 ----> [5] 6 ----> [5] 6
[6]7 ----> [6] 7 ----> [6] 7
[7]8 ----> [7] 8 ----> [7] 8
[8]9 ----> [8] 9 ----> [8] 9

Were this to happen simultaneously or inversely (starting from the bottom) I wouldn't have this issue.

Maybe someone out there smarter than me has a better idea?
 
I have not used CCW, but in the SLC world, it will do the same thing. However, if you copy from element 1 to element 0, the FIFO effect can be achieved. You then have to just look at it from the other end... put the new data at the "top" and have the old data "fall out the bottom".
 
It is possible to move data the way you wish but it takes another temporary array.

COP array1, 0-28 to temp_array, 0-28

then

COP temp_array, 0-28 to array1 1-29
 
Did you get this to work??

I realize this is an old thread, butttt;
I have been using CCW and the micro800 series controllers for a few years, and up until just now, the combo has worked well for me and I've always managed to get all of my projects done perfectly with it.

My Current Problem:
I have a timer running upon starting of machine (.PT set for t#24h) and am trying to store the TON.ET into an element of a large array on each triggered event. Every time the event is triggered I want to store the current ET (elapsed time) in the array and push the previously stored values forward in the elements within the array (or backwards, doesn't matter to me). I'm also using a BSL instruction for other tracking reasons in my program and that function works perfectly and as it should. I literally want to do the same exact thing in this other array, but with the TIME data type rather than a bit.

For two whole days I have been trying to accomplish it with FFL/FFU and with COP, but no matter how i configure them i get nothing but problems. The FFL/FFU is super buggy and just does not seem to work right. I can load the stack in perfect order as I want to, but it eventually gets .FULL (TRUE), and when I begin to use the FFU to try and unloadit, it just gets all screwed up. I've tried it with every possible length and FF_LF_CON configuration combination possible for both the FFL and the FFU.

The COP function method isn't working for me either. I'm beginning to think I may have to end up doing it in structured text. Any help to avoid using ST would be much appreciated. I literally want to trigger an event and push the TON.ET into element[0] and push the previous values forward up to element[80] at which point they can just get pushed out of the array after [80], but it doesn't seem like there's a simple way even in the most recent CCW version 11. Thanks in advance!
 
A simple (if very tedious) way to do this would be to move each element forward in reverse order. First step would be to move array[79] to array[80]. Next would be to move array[78] to array[79]. Rinse and repeat until you've moved array[0] into array[1], then copy the new information into array[0].

To save a bit in time and sanity, you could use a pair of counter .ACCs that you count down each time you copy with indirect addressing.

Would loosely follow this procedure:

1. Copy new TON.ET to a holding tag.
2. move value "79" into CounterA.ACC and value "80" into CounterB.ACC
3. move Array[CounterA.ACC] into Array[CounterB.ACC]
4. SUBTRACT "1" from both counter's .ACC
5. Repeat steps 3-4 until all information has shifted (CounterB.ACC would reach 0 after you moved Array[0] into Array[1])
6. Stop the loop once CounterB.ACC EQU 0
7. COP the new TON.ET from your holding tag into Array[0]
8. Reset process for next copy.

May be a clunky way of doing it, but it's likely possible to do it this way in CCW (I've never used it, so I'm not sure)
 
Why avoid ST?

Code:
IF bEvent AND NOT bEventOld THEN

  FOR i := 80 TO 1 BY -1 DO
    myArray[i] := myArray[i-1];
  END_FOR

  myArray[0] := Timer.ET;

END_IF
bEventOld := bEvent;
I get mean looks if I use anything but ST.
 
I appreciate the help guys. I did not really want to include ST within this project. I have used ST in CoDesys projects, but for this one, I was trying to keep it in simple ladder, which would totally be "simple ladder" if the FIFO stack or COP functions worked normally. Again, thanks for the help. I may try those alternatives and see how they work, as the two days of frustration so far on this issue have pushed me to having to accept it MUST be done differently :ROFLMAO:
 
Why avoid ST?

Code:
IF bEvent AND NOT bEventOld THEN

  FOR i := 80 TO 1 BY -1 DO
    myArray[i] := myArray[i-1];
  END_FOR

  myArray[0] := Timer.ET;

END_IF
bEventOld := bEvent;
I get mean looks if I use anything but ST.

CommisioningMan, many thanks! Your reply was very prompt and helpful. I made a very small tweak to your example and it works perfectly. Also, I managed to write it as a function block in ST and then call the function block in the ladder program. I still have more to learn in ST. Thanks again! (y)

ST_FB.JPG Ladder.JPG Array.JPG
 

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
184
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
942
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,689
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,066
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,603
Back
Top Bottom