PLUS+1 User Forum

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

Title: How to implement an integral or sum-up
Post 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!
Title: Re: How to implement an integral or sum-up
Post by: kdcommon on March 31, 2014, 04:24:20 AM
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.
Title: Re: How to implement an integral or sum-up
Post by: oiltronic on April 05, 2014, 08:42:43 PM
That would blow up really fast.  I think you're going to want a two-input switch before that circuit to either add your value or 0, which is then triggered by a periodic timer or some such thing.
Title: Re: How to implement an integral or sum-up
Post by: kdcommon on April 09, 2014, 08:19:29 AM
You are right.
Title: Re: How to implement an integral or sum-up
Post by: Marbek_Elektronik on April 09, 2014, 06:10:15 PM
Also look to your loop-time.

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.
Title: Re: How to implement an integral or sum-up
Post by: oiltronic on April 09, 2014, 10:06:43 PM
It is important for the integral, that your loop time is constant.
Unless, I think, you are multiplying by always-smaller 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.
Title: Re: How to implement an integral or sum-up
Post by: Marbek_Elektronik on April 10, 2014, 10:09:14 AM
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.