My 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+c

Thank you for reading this.

If you would like to refer to this comment somewhere else in this project, copy and paste the following link:

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.

If you would like to refer to this comment somewhere else in this project, copy and paste the following link:

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.

If you would like to refer to this comment somewhere else in this project, copy and paste the following link:

2017-09-08Originally created by:amir_aj67@yahoo.comHello Community

My 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+c

Thank you for reading this.

2017-09-16Hi.

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.

2017-09-28linear_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.