Please note that I do not ask for the code, but for insight, possibly from someone who as already encountered a similar issue.
I am mantaining code that runs in real time in an embedded system. For safety reasons a new check must be implemented.
This check is based on the integrated value of a certain variable. The integral must span the last "T_s" seconds, i.e. at each new cycle I have to remove the value that the variable had T_s seconds ago and add the current one.
The naive approach would be to store in an array the last T_s*frequency floating point values.
Running at 62.5Hz, this rapidly wastes lots of precious and limited memory.
Are there known approaches that, at the obvious expense of accuracy, significantly reduce the memory footprint of such a check?
The value is a measurement coming from a real system, it is not generated by a function.
I thought about storing N averages, each of M points and then integrate the N averages, this would reduce the memory requirement to N+M numbers, that can be made significantly smaller than T_s*frequency, but I wonder:
if this has been studied and an "optimal" point has been found (as a function of M, for example). I serached, but apparently my google-fu is broken, as searching anything including "numerical integration" does not lead to what I look for.
if there is a better approach
I tagged this post with C because that is the official language of the project, any solution that does not work in ANSI-C is not viable for me, unfortunately.