SMM Posted June 20, 2013 Report Share Posted June 20, 2013 I am having a problem of figuring out a way to calculate an average for variable number of varables. That is, I receive new values to V350 once per second and I want to be able to change the averaging period without having to download new program to OPLC all the time. The Filter FB is not suitable because it has only 16 values max and the number of valuables is a constant inside the FB and cant be changed. The Vector Shift and Vector Store FB combination wont work for the same reason, the vector length is a fixed constant value. If anyone has done something like that before or has any ideas - I would be happy to hear them. Quote Link to comment Share on other sites More sharing options...
Michael_P Posted June 20, 2013 Report Share Posted June 20, 2013 HI SMM, I may have the spark you are looking for, I have written an example that uses a formula function block and a factor for division. http://forum.unitronics.com/files/file/34-%7B%3F%7D/ Quote Link to comment Share on other sites More sharing options...
SMM Posted June 21, 2013 Author Report Share Posted June 21, 2013 Hello Michael, thanks for the input! However, I think I cant adapt this example to my program as it does reset all data after some period, and I need to show average value for the last n values at all times (I should have mentioned that in the first post, sorry). I think I have actually found a solution by creating a sort of FIFO vector so I can um up all values in the vector irregardles of its length. It turned out that You actually can set vector length via a MI, I am yet to test this solution, but I believe it should work. Quote Link to comment Share on other sites More sharing options...
Michael_P Posted June 21, 2013 Report Share Posted June 21, 2013 HI SMM, You can definitely use indirect addressing to generate a FIFO Vector of your desired length. You can then set formula function blocks to control the average, using the Vector length as a factor for calculation. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.