In my application I am receiving continuous data representing either velocity or acceleration. The data is at 10 samples per second. I keep a buffer of 10 seconds of data.
I would like to use either integration or differentiation to convert from one to the other.
I did calculus some time ago at school, but have hardly used it since and can't think how to implement it in software.
If I want to calculate acceleration from velocity, I use differentiation and if I want to calculate velocity from acceleration I use Integration. Am I right?
Differentiation: a(t) = dv(t) / dt
So, to calculate acceleration I just get the (absolute?) difference between the most recent velocity value and divide it by the time difference (0.1 s). Am I right?
Integration: v(t) = t0 to t a(T) dT + v(t0) (the underlined bit represents the stylised "s" or "f" thing).
Is this, like differentiation, done just on a pair of values?
Thanks for your help. Any answers, advice, comments or links to (simple-ish) sites welcome.
That is more or less right, except that when differentiating you use the difference, not the absolute difference.
The calculation will go easier if you choose your units so that you can use integer arithmetic throughout.
Note that you will inevitably have some rounding errors in your calculation so your calculated integrals will gradually accumulate errors over time. You need to either keep the duration short, or have some way to detect and correct these cumulative errors.