PLUS+1 User Forum
PLUS+1 Software => Code sharing => Topic started by: power4 on March 26, 2014, 07:29:34 PM

I want to build a block to sum up all previous input and output the sum. It is a kind of numerical integral. Does anybody give an idea how to achieve that?
Thanks!

If you just want a intergral function rather tnan any other functions, the algrithem is very simple, isn't it? You can achieve that by using only one 'ADD' commponent.
If you consider Simple time factor, the Input value must multiply the sample time value before 'ADD' function.

That would blow up really fast. I think you're going to want a twoinput switch before that circuit to either add your value or 0, which is then triggered by a periodic timer or some such thing.

You are right.

Also look to your looptime.
I suggest 10ms for the most applications.
Please test if your controller don't needs more time.
It is important for the integral, that your loop time is constant.

It is important for the integral, that your loop time is constant.
Unless, I think, you are multiplying by alwayssmaller time increments of elapsed time since the last sample, such as the number of milliseconds, and summing the totals over a sufficiently large number of samples.

I think to build an integral, it is better to use constant sample times.
Of course, if sample time was to long, because of longer loop time, it is a good way to multiply with the sampling time.