Ffl ffu

Mellis is right - for the most part, I just use COP on anything other than asynchronous data, as CPS is a whole lot more CPU intensive, but if it's possible that your instruction could be interrupted halfway through, and that the half-finished data could be used somewhere else, and if that would cause a problem, then you're best to use CPS.
 
The fastest and most elegant solution when you have large arrays is to NOT shift any values at all, but to use a ring buffer.

It's very easy really. It's just an array. All you need to keep track of is where the first (oldest) value and the last (newest) value is. No moving of any data required. As you come to the end of the array you start at the beginning.

It's perfect for keeping track of things moving on conveyers or keeping a history of things.

https://en.wikipedia.org/wiki/Circular_buffer

So to put a new value in
Code:
Newest=Newest+1
If Newest>=100 then Newest=0
Array[Newest]=value

Ta take the oldest value out
Code:
value=Array[Oldest]
Oldest=Oldest+1
If Oldest>=100 then Oldest=0

Look at the ten newest value
Code:
x=Newest-10
if x<0 then x=x+100
value=Array[x]

If you're lazy you just put 256 values in the array and use an unsigned byte to keep track. Then you can skip the check if you are outisde the array becuase the byte will take care of that by itself.
 
Last edited:
Mellis is right - for the most part, I just use COP on anything other than asynchronous data, as CPS is a whole lot more CPU intensive, but if it's possible that your instruction could be interrupted halfway through, and that the half-finished data could be used somewhere else, and if that would cause a problem, then you're best to use CPS.

I disagree, CPS is no more CPU intensive than COP, they do exactly the same job in the same way. CPS just prevents "interrupts" from higher priority tasks while it is executing, so guarantees a valid "data-set". This disabling and re-enabling of interrupts adds a tad to the execution time, but I certainly would not call it "a whole lot more CPU intensive".

CPS is the equivalent of UID COP UIE

I use CPS by default, unless I can think of a good reason not to.....
 
I disagree, CPS is no more CPU intensive than COP, they do exactly the same job in the same way. CPS just prevents "interrupts" from higher priority tasks while it is executing, so guarantees a valid "data-set". This disabling and re-enabling of interrupts adds a tad to the execution time, but I certainly would not call it "a whole lot more CPU intensive".

The knowledge base disagrees...have a look at Technote 50235 (techconnect required), and the attached Word document. It's quite detailed and interesting, but the upshot of it all that I'm referring to is on page 2:
When compared to the COP instruction which only performs step 4, you can see there is a tremendous amount of overhead for the CPS instruction. Because of this it should only be used when dealing with I/O and Produce/Consume data.

There's also another technote (Technote 46251, Techconnect required) which details how to choose between COP and CPS - ultimately it ends up with "in this very specific situation, use CPS; otherwise use COP".

I mean in 99% of applications it's probably all academic with the processing power of modern controllers :)
 
The knowledge base disagrees...have a look at Technote 50235 (techconnect required), and the attached Word document. It's quite detailed and interesting, but the upshot of it all that I'm referring to is on page 2:


There's also another technote (Technote 46251, Techconnect required) which details how to choose between COP and CPS - ultimately it ends up with "in this very specific situation, use CPS; otherwise use COP".

I mean in 99% of applications it's probably all academic with the processing power of modern controllers :)

I stand corrected....
 

Similar Topics

For those who may recall I had posted previously about the FSC instruction, and while I have a better understanding of how to use it I find myself...
Replies
1
Views
1,381
A couple of questions with RS500 FFL-FFU instruction set. 1-Does the stack load from the bottom or the top, My stack is #N7:50 with a length of...
Replies
7
Views
1,596
Hey guys, I came across one question about the FIFO, FFL & FFU instruction. I want to measure the wheel speed, so I use the RPM encoder as the...
Replies
8
Views
4,001
When executing a FFU to unload the oldest value the data in the file is shifted down and the position value is changed. Does this shifting take...
Replies
12
Views
3,386
Hello, I'm currently programming a MicroLogix 1400 in RSLogix Micro, and I'm trying to put data into FIFO queues. Would you know how to use the...
Replies
4
Views
5,084
Back
Top Bottom