Rate Limiter — Control Systems/Discontinuities
Control_Systems/Discontinuities/Rate_Limiter · 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.
Rate Limiter
Control Systems / Discontinuities
Caps how fast the output is allowed to follow the input – an actuator that cannot slew instantly, a ramp-limited setpoint. With y the previously held output and dt the block's sampling period:
and d = u − y the step the input is asking for:
- d > rising·dt → y = y + rising·dt
- d < falling·dt → y = y + falling·dt
- otherwise → y = u, the demanded step already fits
So the output climbs by at most rising units per second and falls by at most |falling| units per second, and passes the input straight through whenever the step is inside the band. Applied entry by entry.
Ports
- Input – the demanded signal u, of any size [m,n].
- Output – the rate-limited signal y, of the SAME size [m,n]. The block never reshapes a signal.
Parameters
- Rising Slew Rate – scalar, the maximum upward rate in units per second. Defaults to 1, as in Simulink.
- Falling Slew Rate – scalar, the maximum downward rate, and therefore negative. Defaults to −1. It must not exceed the rising rate, which would leave an empty band; that is reported rather than silently reordered.
- Initial Condition – scalar, where the held output starts. Defaults to 0. This is a real seed: the first sample is already clamped against it, so a block starting at 0.4 with a zero input walks down at the falling rate rather than jumping.
- Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period. It multiplies both rates into the per-sample step, so halving the rate halves the step and the block is only as smooth as its sampling. ICore-side only – see the bridge note below.
All three parameters are scalars; per-entry vectors are not implemented and are reported rather than broadcast from their first entry.
Code export
All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. The two rates are baked in already multiplied by the sampling period, so the generated core carries one constant per direction and never divides by a time step. The exported state is the held output itself, one value per entry, seeded with the initial condition – so a generated core starts where the in-app block does. The three HDL targets are fully fixed-point: the whole step is an add, a compare and a clamp, with no real arithmetic.
Simulink bridge
Import and export, mapped to
simulink/Discontinuities/Rate Limiter. "Rising Slew Rate" to
RisingSlewLimit, "Falling Slew Rate" to
FallingSlewLimit and "Initial Condition" to
InitialCondition, all as plain pass-through values, so the round
trip is lossless. SampleTimeMode is always written as
inherited, which is the mode this block implements.
"Sampling Time (s)" does NOT cross: this Simulink block has no
SampleTime parameter, so the rate stays on the ICore side and an
explicitly set one is reported rather than written. That matters more here than
on most blocks, because the sampling period is part of the arithmetic – a
rig whose two sides step differently produces genuinely different slew steps.
Notes
- Stateful: one held output per input entry.
- Discrete by nature – the band is a step per sample, so the block always runs at its own rate rather than being pushed through a continuous solver's stages.
- Setting either rate to zero freezes the output in that direction; both at zero holds it at the initial condition forever.
- Not linear, and so deliberately carries no state space – the clamp is a genuine nonlinearity that no A/B/C/D can express.
Code facts#
| Fact | Value |
|---|---|
| registered type | Control_Systems/Discontinuities/Rate_Limiter |
| family | Control_Systems/Discontinuities |
| solver environment class | ICoreBlock_0_Control_Systems_1_Discontinuities_2_Rate_Limiter |
| source | src/ICoreSDK/ICoreBlockLibrary/Blocks/Control_Systems/Discontinuities/Rate_Limiter/ICoreBlock_0_Control_Systems_1_Discontinuities_2_Rate_Limiter.cpp |
| header | src/ICoreSDK/ICoreBlockLibrary/Blocks/Control_Systems/Discontinuities/Rate_Limiter/ICoreBlock_0_Control_Systems_1_Discontinuities_2_Rate_Limiter.h |
| default size on canvas | 70 × 70 px |
| ports at insert | 1 in, 1 out |
| code generators implemented | Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text |
Ports#
| # | Direction | Signal type | Description label |
|---|---|---|---|
| 1 | in | ICoreDouble | — |
| 2 | out | ICoreDouble | — |
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 variable | Default | Simulink parameter |
|---|---|---|
Rising Slew Rate | 1 | RisingSlewLimit |
Falling Slew Rate | -1 | FallingSlewLimit |
Initial Condition | 0 | InitialCondition |
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.
Simulink bridge#
| support | Support::Both |
| Simulink path | simulink/Discontinuities/Rate Limiter |
| port-count rule | PortsParam::None |
SampleTime parameter | no — the counterpart defines none; the rate stays on the ICore side |
| always set | SampleTimeMode = inherited |
| ICore config | Simulink parameter | Value translation |
|---|---|---|
Rising Slew Rate | RisingSlewLimit | passes through |
Falling Slew Rate | FallingSlewLimit | passes through |
Initial Condition | InitialCondition | passes through |
Caveat (shown to the user): the block runs at the surrounding Simulink rate; "Sampling Time (s)" does not cross, and it scales the per-sample slew step
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).
Rate Limiter block — caps how fast the output may follow the input With d = u - y: a step beyond rising*dt or falling*dt moves y by that limit, and anything inside the band ASSIGNS u outright (y + (u - y) is not exactly u in floating point, and Simulink's own form is y = u there). Entry by entry, with y seeded from "Initial Condition"; the falling limit is NEGATIVE, as in Simulink, and the first sample is already clamped against the seed -- verified against the R2026a block.
Stateful: the held output IS the state. Same per-language state contract as Backlash. Discrete by nature -- the band is a step per SAMPLE, so dt is the block's own rate.
Code export: rising*dt and falling*dt are inlined as export-time constants, so the generated core never divides by a time step and carries no rate arithmetic at all.
Sample results#
The same rig also ran:
| Stimulus | What it is | Output range |
|---|---|---|
impulse | Impulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair) | 0 … 0.1 |
ramp | Ramp: slope 1 from t = 0 | 0 … 5.8 |
sine | Sine Wave: amplitude 1, 2 rad/s, no phase, no bias | -0.7728 … 0.9093 |
table | Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample | -0.3 … 0.4 |
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__Discontinuities__Rate_Limiter.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).