Generated reference › Transfer Fcn Lead Or Lag — Control Systems/Discrete
kind: generated#block#control-systems-discrete

Transfer Fcn Lead Or Lag — Control Systems/Discrete

z-Z z-P

Control_Systems/Discrete/Transfer_Fcn_Lead_Or_Lag · 1 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Description#

The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.

Transfer Fcn Lead or Lag

Control Systems / Discrete

A first-order compensator with both singularities given directly in the z plane:

H(z) = (z − Z) / (z − P)

realized as the one-line recursion y[k] = P·y[k−1] + u[k] − Z·u[k−1]. Numerator and denominator are both monic, so the instantaneous gain is 1 and the DC gain is H(1) = (1 − Z) / (1 − P). Which of lead and lag you get follows from the pair rather than from a mode setting: Z > P leads (phase advance, DC gain below one), Z < P lags.

Before the first sample there is neither a previous output nor a previous input, so the two configured initial conditions stand in for them.

Ports

  • Input – the signal u to compensate, of any size [p,m].
  • Output – the compensated signal y, the SAME size [p,m] as the input.

The compensator is scalar, but it is applied independently to every entry of the input signal, each entry carrying its own memory.

Parameters

  • Pole (in Z Plane) – a scalar P, the denominator's root. Defaults to 0.95, Simulink's own default. |P| < 1 is stable, and the closer to 1 the longer the compensator's memory. Any real value is accepted here, but see the Simulink bridge below before using one outside 0 < P < 1.
  • Zero (in Z Plane) – a scalar Z, the numerator's root. Defaults to 0.75. Setting Z equal to P cancels the pole and leaves a plain wire, which is accepted rather than rejected – it is a legitimate way to switch a compensator out of a loop. As with the pole, any real value runs here; 0 < Z ≤ 1 is what crosses to Simulink.
  • Initial Condition (Previous Output) – a scalar standing in for y[−1] on the first sample, broadcast to every entry. Defaults to 0.
  • Initial Condition (Previous Input) – a scalar standing in for u[−1] on the first sample, broadcast to every entry. Defaults to 0.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text, all from the shared realization every linear Control Systems / Discrete block uses. The pole, the zero and both initial conditions are baked into the generated core at export time rather than exposed as tunable parameters: the singularities are folded into the A/B/C/D coefficients, and the two initial conditions are combined into the single state seed P·y[−1] − Z·u[−1] that a first-order section actually needs.

Simulink bridge

Import and export, mapped to simulink/Discrete/Transfer Fcn Lead or Lag. "Pole (in Z Plane)" to PoleZ, "Zero (in Z Plane)" to ZeroZ, "Initial Condition (Previous Output)" to ICPrevOutput, "Initial Condition (Previous Input)" to ICPrevInput. All four cross as plain numbers, so the mapping is lossless in either direction.

Simulink restricts the pole and the zero; this block does not. Its block is masked, and the mask rejects anything outside 0 < P < 1 and 0 < Z ≤ 1 – "Pole position must be a positive number less than 1", "Zero position must be a positive number less than or equal to 1". So a compensator configured here with a negative or unstable singularity is perfectly valid in ICore and simulates and exports normally, but the generated Simulink script will stop on it rather than build a block that behaves differently. Keep both inside that box if the model has to cross. The two initial conditions carry no such restriction, and either may be negative.

"Sampling Time (s)" does not cross, unusually: Simulink's block is a masked subsystem with no SampleTime parameter at all, so the rate stays on the ICore side and a block configured with an explicit positive rate reports that it did not carry over. In Simulink it simply inherits the rate of whatever drives it.

Simulink's RndMeth and DoSatur are left at their defaults and have no ICore counterpart: they select a rounding mode and an overflow policy that only bite on fixed-point or integer signals, and ICore's signal path is double precision throughout.

Notes

  • Discrete only, and stateful: one state per entry, not two. The block has to remember two past values but only one number – the part of y[k] this step's input does not supply – which is what keeps the realization the same order as the transfer function.
  • Being linear, the block is directly usable by the model reduction and linear-analysis commands.
  • Lead or Lag vs. First Order. Transfer Fcn First Order is this block with the zero at the origin and the gain normalized to H(1) = 1. Reach for it when all you want is a lag with unity DC gain; reach for this one when the numerator needs a zero of its own.

Code facts#

FactValue
registered typeControl_Systems/Discrete/Transfer_Fcn_Lead_Or_Lag
familyControl_Systems/Discrete
solver environment classICoreBlock_0_Control_Systems_1_Discrete_2_Transfer_Fcn_Lead_Or_Lag
sourcesrc/ICoreSDK/ICoreBlockLibrary/Blocks/Control_Systems/Discrete/Transfer_Fcn_Lead_Or_Lag/ICoreBlock_0_Control_Systems_1_Discrete_2_Transfer_Fcn_Lead_Or_Lag.cpp
headersrc/ICoreSDK/ICoreBlockLibrary/Blocks/Control_Systems/Discrete/Transfer_Fcn_Lead_Or_Lag/ICoreBlock_0_Control_Systems_1_Discrete_2_Transfer_Fcn_Lead_Or_Lag.h
default size on canvas120 × 80 px
ports at insert1 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDouble
2outICoreDouble

Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.

Configuration variables#

Config variableDefaultSimulink parameter
Pole (in Z Plane)0.95PoleZ
Zero (in Z Plane)0.75ZeroZ
Initial Condition (Previous Output)0ICPrevOutput
Initial Condition (Previous Input)0ICPrevInput

Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.

supportSupport::Both
Simulink pathsimulink/Discrete/Transfer Fcn Lead or Lag
port-count rulePortsParam::None
SampleTime parameterno — the counterpart defines none; the rate stays on the ICore side
ICore configSimulink parameterValue translation
Pole (in Z Plane)PoleZpasses through
Zero (in Z Plane)ZeroZpasses through
Initial Condition (Previous Output)ICPrevOutputpasses through
Initial Condition (Previous Input)ICPrevInputpasses through

Caveat (shown to the user): the sampling time does not cross: Simulink's Transfer Fcn Lead or Lag is a masked subsystem with no SampleTime parameter, and inherits the rate of whatever drives it. Its mask also REJECTS a pole outside 0 < P < 1 or a zero outside 0 < Z <= 1, which ICore itself accepts - a compensator configured outside that box runs and exports here, but the generated Simulink script stops on it

Catalog contract: src/ICoreSDK/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h

Description vs code#

The lists agree. check_block_descriptions.py finds no disagreement between the description's Ports, Parameters, Code export and Simulink bridge lists and the code's.

The verdict above is tools/docs/check_block_descriptions.py (P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.

File banner (developer view)#

The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).

Transfer Fcn Lead or Lag block — y[k] = P*y[k-1] + u[k] - Z*u[k-1], element-wise One state for a first-order transfer function, holding the combination P*y[k-1] - Z*u[k-1] rather than either past value on its own — which is what lets BOTH initial conditions seed it exactly, with no division and no special case at P == Z. See the header for the A/B/C/D. Everything below the matrices comes from ICoreDiscreteLinearBlockBase.

Sample results#

Transfer Fcn Lead Or Lag — Step: 0 -> 1 at t = 1 sTransfer Fcn Lead Or Lag — Step: 0 -> 1 at t = 1 s024012345t (s)in ICoreDouble-Out-0out ICoreDouble-Out-0

The same rig also ran:

StimulusWhat it isOutput range
impulseImpulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair)0 … 1
rampRamp: slope 1 from t = 00 … 21.41
sineSine Wave: amplitude 1, 2 rad/s, no phase, no bias-1.454 … 2.068
tableRepeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample-2 … 4.559

Plotted: step — Step: 0 -> 1 at t = 1 s

Category dynamic · sample time 0.1 · 60 steps · commit ccf005c8 · produced by docsSample --out <folder> --steps 60 · data docs/generated/samples/Control_Systems__Discrete__Transfer_Fcn_Lead_Or_Lag.json · the SVG is generated from those numbers by tools/docs/plot_svg.py, so it is a run and not a drawing (R-D10).