Reconfiguration with and without reset
This sample shows how a filter can be reconfigured during runtime and which options exist to suppress a reset.
Download: Tc3_Filter_bReset.zip (*.tnzip)
Description:
- The sample project consists of a TwinCAT PLC project and a measurement project
- Two output signals and a counter variable are configured in the measurement project.
- A signal generator generates a harmonic signal with a frequency of 700 Hz. The signal is processed by two filters with identical filter coefficients.
- During runtime, the system alternates between two filter configurations (parameterization of the filter coefficients). For one filter instance (
fbFilterReset)
, in contrast to the other filter instance (fbFilterNoReset
), theReset()
method is called when the filter is reconfigured to reset the internal status of the filter. - The MAIN PLC program is called by a task with a cycle time of 1 ms.
Implementation:
- The parameter
bReset
of the configuration structure ST_FTR_IIRCoeff can be used to control whether a reset is executed when theConfigure()
method is executed (default value isTRUE
).
stParams : ST_FTR_IIRCoeff := ( … )
stParams.bReset := FALSE;
fbFilterNoReset.Configure(stConfig := stParams);
Observation:
If you activate the project, you can observe the output signals of the two filter instances in the measurement project. The red signal shows the output signal of the function block instance fbFilterNoReset
. The time curve of the signal shows no jump through the reconfiguration. The output signal of the function block instance fbFilterReset
, on the other hand, jumps when the reconfiguration is executed, since the filter returns to zero at the time of the reconfiguration (blue signal).
See also: