Hello all, thanks for your comments, Peter/Pandiani/L D[AR2,P#0.0], it is great to have such a good community here on PLCs.net
The PLC is processing every 1ms but the data from the serial motion sensor is updated every 20ms (50Hz)
The digital filter function block has these inputs for testing:-
tTaskCycleTime : Cycle time with which the function block is called. If the block is called in every cycle this corresponds to the task cycle time of the calling task.
tCtrlCycleTime : Cycle time with which the control loop is processed. This must be greater than or equal to the TaskCycleTime. The function block uses this input variable to calculate internally whether the state and the output variables have to be updated in the current cycle.
so the task cycle time (tTaskCycleTime ) is set to 1ms and the control loop sample timer (tCtrlCycleTime) to 20ms.
To simplify for testing, I have made the function block call every 20mS therefore the function block is called when the data is updated.
Now both tTaskCycleTime and tCtrlCycleTime are 20ms.
Thanks for the code [AR2,P#0.0]. I will try that and compare. That site what derived the coefficients, 8000 sample a second is extremely high. The way it was written, I assumed this sample frequency was for the plot only and not for the coefficients calculation.
I stand corrected, filter:
simple second order digital filter would look like this:
0.2929 z^2 + 0.5858 z + 0.2929
------------------------------
z^2 + 0.1716
This means:
b1 = 0.29229
b2 = 0.5858
b3 = 0.2929
a1 = 1;
a2 = 0;
a3 = 0.1716
requires 20 Hz sampling rate and not 10 Hz.
Matt, can you provide us with feedback? Did you try this?
Hello Pandiani, yes I have tried these values and the filter is doing some filtering but only a little bit, there is still quite a lot of this high frequency noise.
I will work on this and post more results when found.
Regards
Matt