Author Topic: How to implement an integral or sum-up  (Read 13889 times)

power4

  • Guest
How to implement an integral or sum-up
« 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!

kdcommon

  • Guest
Re: How to implement an integral or sum-up
« Reply #1 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.

Offline oiltronic

  • PLUS+1 Guru
  • *****
  • Posts: 170
  • Karma: +15/-0
Re: How to implement an integral or sum-up
« Reply #2 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.

kdcommon

  • Guest
Re: How to implement an integral or sum-up
« Reply #3 on: April 09, 2014, 08:19:29 AM »
You are right.

Offline Marbek_Elektronik

  • PLUS+1 Guru
  • *****
  • Posts: 352
  • Karma: +8/-0
    • Marbek Elektronik
Re: How to implement an integral or sum-up
« Reply #4 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.
Marbek Elektronik, Dipl.-Ing. Bernd Konrad
Dienstleistung, Entwicklung, Herstellung

Offline oiltronic

  • PLUS+1 Guru
  • *****
  • Posts: 170
  • Karma: +15/-0
Re: How to implement an integral or sum-up
« Reply #5 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.

Offline Marbek_Elektronik

  • PLUS+1 Guru
  • *****
  • Posts: 352
  • Karma: +8/-0
    • Marbek Elektronik
Re: How to implement an integral or sum-up
« Reply #6 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.
Marbek Elektronik, Dipl.-Ing. Bernd Konrad
Dienstleistung, Entwicklung, Herstellung