Any other alternate of FIFO

backendcode

Member
Join Date
Aug 2017
Location
brampton
Posts
249
Hello Guys,

I am just wondering if there is any other alternative of FIFO. I am trying to record the value which changes after a couple of seconds and I want to keep the record of last 10 values. What other option do I have? Any suggestion and I will write a logic then and can show you.

Thank you,
 
A FIFO seems like the most logical choice. If you want to store a new value in the FIFO only when the value changes then proceed the FIFO rung with one that compares the present value with one stored previously. If they are unequal then turn on a bit and store the new value in the 'previous' location. Use the bit to trigger the shift/store of the FIFO with the new value as the data.
 
It all depends on what your're trying to do.

A FIFO is great when you have a variable number of data points, and/or the trigger to unload data is different from the trigger to load data.

But it sounds like you just want to smooth out a signal by averaging the last bunch of data points. For that, you don't need a FIFO, simple shift logic works.

The timer isn't strictly necessary, if you want to capture data every scan, or if the logic is in a periodic task.

The Array can be much bigger than 10; then by adjusting the value of the "Len" tag, you can set how many data points you want to collect, without having to edit the logic. (Caution: make sure that Len < the size of the array, or the PLC may fault). (Caution #2: increasing the Len on the fly makes the result unreliable until the array has gotten fully populated).

An alternative technique is, instead of shifting all the data, is to use indirect addressing, and increment a pointer each Update, resetting when it reaches the maximum sample size. It's arguably a better technique in terms of PLC speed, but I like being able to watch the data shift, rather than see new data appear somewhere in the array, and my processes generally don't need millisecond precision.

FIFO.jpg
 
10 move instructions will roll your own FIFO, but it is still technically a FIFO.

If the values were every second, you could install a mirror every 150,000km and just use those to check previous values. Either a very bright screen or operate in space. You might need a lens also.

You could also make up random values, and say they are 'close enough for what we use it for'.

I am about out of ideas.
 
It looks like you just want to store the last 10 values
a FIFO will work very well for that but with a FIFO you need to both load and unload it. So with every load you must have an unload or the array file will fill up.
try a file shift just 2 rungs of code and you don't have to unload it the old data just rolls off the top as the new data is loaded
i hope the attached pi will help to understand it
i have used this a few times and it works good.
the one shown is much larger then the 10 entries you need but with a littler modification it should work for you

File Shift.jpg
 
It all depends on what your're trying to do.

A FIFO is great when you have a variable number of data points, and/or the trigger to unload data is different from the trigger to load data.

But it sounds like you just want to smooth out a signal by averaging the last bunch of data points. For that, you don't need a FIFO, simple shift logic works.

The timer isn't strictly necessary, if you want to capture data every scan, or if the logic is in a periodic task.

The Array can be much bigger than 10; then by adjusting the value of the "Len" tag, you can set how many data points you want to collect, without having to edit the logic. (Caution: make sure that Len < the size of the array, or the PLC may fault). (Caution #2: increasing the Len on the fly makes the result unreliable until the array has gotten fully populated).

An alternative technique is, instead of shifting all the data, is to use indirect addressing, and increment a pointer each Update, resetting when it reaches the maximum sample size. It's arguably a better technique in terms of PLC speed, but I like being able to watch the data shift, rather than see new data appear somewhere in the array, and my processes generally don't need millisecond precision.
+1

This guy nailed it...
 
+1

This guy nailed it...

Yeah. One follow-up question: Why the reset immediately before the AVE instruction? While I am a fan of defensive programming, I am wondering what unintended situation this reset prevents.
 
Yeah. One follow-up question: Why the reset immediately before the AVE instruction? While I am a fan of defensive programming, I am wondering what unintended situation this reset prevents.

Yes, that part of his example is redundant. The RES would be necessary if the timer was retentive. His description of when and why to use a FIFO is spot on though.
 
A FIFO seems like the most logical choice. If you want to store a new value in the FIFO only when the value changes then proceed the FIFO rung with one that compares the present value with one stored previously. If they are unequal then turn on a bit and store the new value in the 'previous' location. Use the bit to trigger the shift/store of the FIFO with the new value as the data.

Thank you for the reply, I ended up using FIFO and I agree with you FIFO is the best solution but I was just wondering If I can learn a technique to store last 10 or whatever values of my tag.

Thank you again.
 
It all depends on what your're trying to do.

A FIFO is great when you have a variable number of data points, and/or the trigger to unload data is different from the trigger to load data.

But it sounds like you just want to smooth out a signal by averaging the last bunch of data points. For that, you don't need a FIFO, simple shift logic works.

The timer isn't strictly necessary, if you want to capture data every scan, or if the logic is in a periodic task.

The Array can be much bigger than 10; then by adjusting the value of the "Len" tag, you can set how many data points you want to collect, without having to edit the logic. (Caution: make sure that Len < the size of the array, or the PLC may fault). (Caution #2: increasing the Len on the fly makes the result unreliable until the array has gotten fully populated).

An alternative technique is, instead of shifting all the data, is to use indirect addressing, and increment a pointer each Update, resetting when it reaches the maximum sample size. It's arguably a better technique in terms of PLC speed, but I like being able to watch the data shift, rather than see new data appear somewhere in the array, and my processes generally don't need millisecond precision.

Great! Thank you! I will give it a try when I will go back to work.

Thank you again,
 
It looks like you just want to store the last 10 values
a FIFO will work very well for that but with a FIFO you need to both load and unload it. So with every load you must have an unload or the array file will fill up.
try a file shift just 2 rungs of code and you don't have to unload it the old data just rolls off the top as the new data is loaded
i hope the attached pi will help to understand it
i have used this a few times and it works good.
the one shown is much larger then the 10 entries you need but with a littler modification it should work for you

View attachment 46838

Thank you :)
 
Yeah. One follow-up question: Why the reset immediately before the AVE instruction? While I am a fan of defensive programming, I am wondering what unintended situation this reset prevents.

File instructions (FAL, FSC, AVE, etc.) set a .DN bit, and don't re-execute until the bit is reset, typically by a true-to-false transition. The timer .DN bit does that, so yes, as written, the RES is not needed.

But I also suggested that the TON could be removed if one wanted to capture data every scan, or if the code were in a periodic task. In that case, there'd be no true-to-false transition, so the RES of the AVE control word is needed.

Side note: many people don't realize that you can use an RES on file control elements ('R' data types in PLC5/SLC). They do the same thing there as in timers & counters: clear the various bits (.DN, .FD, etc.) reset the accumulator (.POS), while leaving the preset (.LEN) alone. Clean technique.
 
The alternative to the FIFO buffer is called a ring buffer or circular buffer.

It's much faster to execute for the CPU so it's the standard type of buffer for almost everything that has a CPU (PLC, computer, phone etc).
 

Similar Topics

Hello All, I want to publish my data in sql server in Excel format as daily report. And xl reported pro version seem to be much expensive which...
Replies
1
Views
483
I'm looking for alternate module that I can use in place of Rockwell 5069-IO mainly for safety output card (OBV8S). Looking at the lead time, I...
Replies
2
Views
1,172
Good morning everybody, I hope you are very well. I share with you the information of the PLC LOGO! Siemens and expansions that we have...
Replies
4
Views
1,055
Hello All, Currently I am migrating S7 300 to S7 1500 & I am unable to use DP send & receive data from Master PLC. Which instruction is...
Replies
4
Views
1,589
Hi guys Do you have some experiences with Power Analyzers such as Siemens SENTRON PAC4200?.. I have alternative analyzer installed on machine...
Replies
6
Views
2,012
Back
Top Bottom