Transfer Function (tf)
Describes a plant or compensator with two coefficient lists.
Group: Control · Kind: {"block":"tf","kind":"control"}
When to use it
Use it when you already have a plant or filter as a function of s. Use PID Controller for a PID.
Pins
| Pin | Domain | Meaning |
|---|---|---|
in |
signal | Signal input |
out |
signal | Signal output |
Common parameters
num: Numerator coefficients, highest power first (Default: required)den: Denominator coefficients, highest power first (Default: required)
Parameters
| Key | Unit | Default | Typical range | Description |
|---|---|---|---|---|
num |
— | required | Numerator coefficients, highest power first | |
den |
— | required | Denominator coefficients, highest power first | |
y0 |
— | 0 | Output at the start; needs an integrator (last den coefficient 0) |
|
lo |
— | -1e30 | Lowest value the output can reach; an integrator stops there (anti-windup) | |
hi |
— | 1e30 | Highest value the output can reach; an integrator stops there (anti-windup) |
Parameter descriptions are in English in both languages.
Use for: Plant models · Compensators · Sensor lags
Not for: PID control → pid · Discrete filters at a sample time → ztf
Formulas
| Formula | Equation | Source |
|---|---|---|
| Transfer function | H(s) = num(s)/den(s) | Ogata, Modern Control Engineering, 5th ed. (2010), ch. 2 |
| First-order corner of k/(tau·s + 1) | fp = 1/(2π·tau) | Franklin, Powell & Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed. (2019), ch. 6 |
| Gain at f | abs(H) = k/√(1 + (2π·f·tau)²) | Franklin, Powell & Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed. (2019), ch. 6 |
| Phase at f | φ = -atan(2π·f·tau)·180/π | Franklin, Powell & Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed. (2019), ch. 6 |
Quick check
Inputs:
k: DC gain = 1 —tau: Time constant = 1m sf: Frequency = 100 Hz
Outputs:
fp: Corner frequency =1/(2*pi*tau)Hzmag: Gain at f =k/sqrt(1 + (2*pi*f*tau)^2)—ph: Phase at f =-atan(2*pi*f*tau)*180/pi°
Model logic
- Coefficients are in descending powers of s; leading zeros are dropped, both lists are divided by the first den coefficient, and the block is built in controllable canonical form.
- Each accepted step of length h advances the state by the trapezoid (Tustin); the matrices are recomputed only when h changes, and a step with h = 0 only records the input.
- The state starts at zero; a non-zero y0 is accepted only with an integrator (last den coefficient 0 and last num coefficient not 0).
- A num of the same degree as den gives direct feedthrough; an improper function, a zero den, an order above 16 or an output that is not finite stops the run.
Model
H(s) = B(s)/A(s). num and den hold the coefficients in descending powers of s, so 0.01, 1 means 0.01·s + 1. Leading zeros are dropped and both lists are divided by the first denominator coefficient. The block is realised in controllable canonical form and integrated with the trapezoidal rule over every accepted solver step. The initial state is zero. A numerator of the same degree as the denominator gives direct feedthrough (the output follows the present input), so a loop through such a block needs another block without feedthrough.
Common mistakes
- Write the coefficients from the highest power of s down, so 1, 0.01 means s + 0.01. A numerator of higher degree than the denominator, a zero denominator or an order above 16 is refused.
- An unstable denominator makes the output grow until the run stops, and a pole at 2/h (h is the step length) breaks the method. Keep maxStep several times smaller than the fastest time constant.
Problems rules: compile.error, solver.control
Datasheet and sources
There is no datasheet. The coefficients come from your model of the plant, with R, L, C and J turned into time constants in seconds, or from a compensator you designed.
Example
Open the example with the command file.openExample and the name demo:tf.
Generated by cargo xtask reference from the usage texts and parameter specs. Do not edit by hand.