FB_FirstOrderPlant (Function Block)
Simulates a first-order linear plant using Euler’s backward (implicit) discretisation.
The continuous-time transfer function is:
which discretises to:
where \(K\) is Gain, \(\tau\) is Tau in seconds, and
\(\Delta t\) is the task cycle time, measured automatically on the first call.
Note
The block is FINAL and must be instantiated, not extended.
Use FB_init to set fGain and fTau at declaration time.
Extends: FB_SisoComponent
Properties
Gain
Type: LREAL
Gets or sets the steady-state gain.
This is the factor by which a constant input is scaled to produce the output once the plant has fully settled. For example, a gain of 2 with a constant input of 5 will eventually produce an output of 10.
Tau
Type: LTIME
Gets or sets the time constant (τ).
This controls how quickly the plant responds to a change in input. A larger value means a slower response. It is the time taken for the output to reach 63.2% of its final value after a step change in input.
Methods
FB_init
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
if TRUE, the retain variables are initialized (warm start / cold start) |
|
|
if TRUE, the instance afterwards gets moved into the copy code (online change) |
|
|
Steady-state gain (K). Ratio of output to input once the plant has fully settled. |
|
|
Time constant (τ). Time for the step response to reach 63.2% of its final value. |
Reset
Sets the output to zero, returning the plant to its initial state.
Run
Advances the plant by one time step.
Note
Must be called once per cycle on a single PLC task. This is because on the first call, the cycle time is measured and stored for use in all subsequent calls.
If the measured cycle time is zero the method returns early without updating the output, guarding against a divide-by-zero.