FiFo register to store numeric values


#1

Hi,
Is there anyone who made a chart for using an FiFo register and could share the code?

Regards / Lennart


#2

Any reason not to use the built in command?
Shift Numeric Table Elements
It will FiFo the table for you, either up or down.
From the manual;

•For positive shift counts, entries shift toward the end of the table. For negative shift counts, entries shift toward the beginning (index zero) of the table.

•Entries at the beginning or end of the table are lost when shifted beyond those limits.

•Zeros are written to entries left empty by shifting.


#3

For small fixed sized queues, shifting the table is simplest. If the length of data in the queue changes, then you will need to keep track of the index for the end of the queue.

If you need a larger queue then performance would be best to use a circular buffer where you keep track of the beginning and end positions and don’t do any shifting. This method is only slightly more complex and if someone were to make a subroutine to handle a queue, this is what I would recommend.


#4

Thanks! Beno and Philp for these tips.

I’m not used to work with opto22 yet. I have done more programming with Siemens system.

But I will try this.

Regards / Lennart