CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Sat Dec 07, 2019 3:07 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Jan 18, 2017 5:38 pm 
Offline

Joined: Tue Dec 06, 2016 7:13 pm
Posts: 3
Hello,
can you advice an efective way to do a memory FIFO buffer to temporarily store data on an array of structures.
Thank you!


Top
   
PostPosted: Sat Mar 18, 2017 3:30 pm 
Offline
Frequent User
Frequent User

Joined: Fri Sep 02, 2011 8:02 pm
Posts: 309
By the age of the question you may already have solved, but here is my suggestion:

First, you will need to use a byte copy scheme to copy a structure into another location (strut1 := struct2 doesn't work). Be sure to use SIZEOF for your pointer arithmetic.

I created a scheme to avoid shifting data but still give a history array output for visualizations. It requires copying the entry to two locations and an array that is twice as big as the number of entries you are trying to buffer. For example, if you wanted the last 100 entries, you need an array that is 200 entries big.

For the last 100, you need to:

Start index at 99.
Save entry at index and index + 100.
Shift index to 98.
Etc, etc

Give an output of this FB a type POINTER TO ARRAY[0..99] OF structure;

Set the pointer to index

_________________
Scott Cunningham
KEB America, Inc.
www.kebblog.com
www.kebamerica.com


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited