CODESYS - the IEC 61131-3 automation softwarehttps://forum.codesys.com/ Linear Interpolation - Linear trendlinehttps://forum.codesys.com/viewtopic.php?f=2&t=8134 Page 1 of 1

 Author: amir_aj67@yahoo.com [ Fri Sep 08, 2017 1:20 pm ] Post subject: Linear Interpolation - Linear trendline Hello CommunityMy aim is to monitor an analogue input to my PLC, if this analogue value rate of change is higher than the defined threshold then i need to stop the machine.there are few ways to do this mathematically. The first method is to calculate the rate of change. I have tried to use the ROC in alarms group with no luck. the main problem is that i can't change the threshold online. The second and my favourite method is to save lets say up to 10 readings in an array and then do a curve fitting, after that we can find the slope of the linear trendline (like what we do in excel) and we can compare the slope of these few trendlines to understand if the analogue input ROC is higher than expected or not. I tried to use the LINEAR_INT in Oscat library but the problem with that one is it does not do a curve fitting for all the points but it cuts it up to 10 linear segments. does any one of you have any idea what is the best way to do above? is there any function that can output a linear trendline for an (x,y) array? something like equation below:y=a*x+cThank you for reading this.

 Author: Josep M. Rams [ Sat Sep 16, 2017 6:30 pm ] Post subject: Re: Linear Interpolation - Linear trendline Hi.If x is time and you capture one signal every cycle:Speed:=(analog_cyclei-analog_cyclei-1)/ cycle_time.If speed is not stable you can apply a filter.If not x nor y are time, a lineal regression could be a good solution (wikipedia). Be carefull because sometimes and if the number of samples is big could spend a lot of time.

 Author: shooter [ Thu Sep 28, 2017 7:17 pm ] Post subject: Re: Linear Interpolation - Linear trendline linear_int is to make an interpolation not a curvefitting.curve fitting is not a solution as you will need a input to check where it is on your curve.you can use a filter, and check if the ROC is too high with every sample taken or wit a filter.