Infosys在阅读器中打开 / AI 翻译

TF3xxx - Measurement · 0 次阅读

Declaring and calling filters with FB_FTR_<type>

This sample shows how the individual filter function blocks of the PLC library Tc3_Filter are declared and called.

Download: Tc3_Filter_AllFilters.zip (*.tnzip)

Description:

  • The sample project consists of a TwinCAT PLC project.
  • In the MAIN PLC program, a function generator generates a harmonic signal that is used as input signal for the various filters.
  • Each filter is described in a separate function block, which is instantiated in the MAIN PLC program.
  • The MAIN PLC program is called by a task with a cycle time of 1 ms.

Implementation:

  • The declarations and calls of the filter function blocks provided in the Tc3_Filter library are shown as examples in the function blocks.
  • The variable nExampleSelector can be used to change the filter during runtime.

Basic principle:

FUNCTION_BLOCK FB_PT1
VAR_INPUT
    aBuffer    : ARRAY [1..MAIN.cChannels] OF ARRAY [1..MAIN.cOversamples] OF LREAL;
END_VAR
VAR_OUTPUT
    aOutput    : ARRAY [1..MAIN.cChannels] OF ARRAY [1..MAIN.cOversamples] OF LREAL;
END_VAR
VAR
    stParams: ST_FTR_PT1 := (fSamplingRate := 10000,
    fKp := 1,
    fT1 := 6.3661977236758134307553505349006E-4,
    nOversamples := MAIN.cOversamples,
    nChannels := MAIN.cChannels);
// fT1 correlates to fc=250 Hz
    fbFilter : FB_FTR_PT1:=(stConfig:=stParams);
END_VAR

See also: