1/25/2016 4:10 PM  
Joined: 3/5/2013 Last visit: 9/26/2022 Posts: 21 Rating: (0) 
Hello all, I am trying to populate a vector of tank level every minute for 60 minutes. Now I can do this using 60 moves first moving vector.[60] to vector.[59] all the way to vector.[0] where I move the current tank level every minute. Is there an easier way to move a vector with real data type? The only thing I can think of is to multiply my REAL value by 10 and convert to a DINT, use a Shift Left block to move everything to the left, populate the right most bits with the current tank level, and then divide by 10 to get back to a real value with accuracy to the tenths. However this seems like a real workaround and I am hoping there is an easier way. Any help is appreciated. Thanks!!! 
1/25/2016 6:52 PM  
Joined: 7/7/2010 Last visit: 1/27/2023 Posts: 13080 Rating: (2123)

To me it would make more sense to simply use a circular buffer and just keep track of the last and first items in the buffer. Then as you add elements to the buffer, you update the last. If the last = first, you add one to first (mod with size of buffer so it wraps around). In this way, you do the least amount of moves each data update and it turns out to be really fast.

science guy 

1/25/2016 6:55 PM  
Joined: 4/28/2015 Last visit: 1/28/2023 Posts: 9011 Rating: (716) 
Hello, really maybe don't understand your situation, but isn't enough create array of Real containing 60 indexies and with some time interrupt (checking your right index to write) fill your array with real value? No one shift moves... Or maybe missunderstanding all ? 
With best regards... 

1/25/2016 9:10 PM  
Posts: 5225 Rating: (1160)

..maybe as explanation of what the two gentlemen The original discussion: 
This contribution was helpful to1 thankful Users 
7/21/2017 8:44 AM  
Joined: 6/19/2017 Last visit: 1/27/2023 Posts: 6401 Rating: (125) 
New question published by Antony_BR is split to a separate thread with the subject Need help to move values. Best regards 
My Forum is the place to personalize your profile, 

Follow us on