Generated reference › Controller Blend 2D — Control Systems/Gain Scheduling
kind: generated#block#control-systems-gain-scheduling

Controller Blend 2D — Control Systems/Gain Scheduling

2D

Control_Systems/Gain_Scheduling/Controller_Blend_2D · 3 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.

2D Controller Blend

Control Systems / Gain Scheduling

The Aerospace Blockset's 2D Controller Blend: the 1D Controller Blend nested. Three controllers are blended along v1, and each of those three is itself a 1D Blend along v2 – nine self-conditioned state-space controllers, each sitting at one (v1, v2) breakpoint pair and carrying its own state. As a variable crosses a breakpoint the controllers change ROLES rather than breakpoints, so no controller's state jumps.

A controller at breakpoint pair (i, j): dx/dt = H·u + (B − H·D)·y + (A − H·C)·x,   its output C·x + D·y (every matrix that pair's), where u is the blended output fed back to all nine and H places the poles of A − H·C at Poles.

Each variable has its own copy of the 1D Blend's role machine. With a variable in [bpk, bpk+1) and fraction f, its three roles are: the breakpoint above with weight f; the one below with weight 1 − f; and a standby, weight 0, at bpk+2 when f ≥ 0.5 or bpk−1 when f < 0.5 (clamped to the table). The inner blend along v2 is formed for each of the three outer controllers, and the v1 weights blend those three. Each variable is clamped to its breakpoints at both ends.

When a variable's interval index goes up by one, its controllers move one role on (above becomes below, below becomes standby, standby becomes above); down by one, one role back. The roles start as above, below, standby. The rotation fires on a rising edge of the index change: an index that changes on two consecutive samples rotates once, and the first sample never rotates – exactly as the Simulink block's triggered subsystems behave.

Ports

  • y – the controller input, an [m,1] column, m being the column count of the B and D matrices.
  • v1 – the first scheduling variable, a scalar.
  • v2 – the second scheduling variable, a scalar.
  • u – the blended controller output, a scalar.

Parameters

  • A Matrices – the n×n A matrix for every breakpoint pair, stacked vertically with the first variable varying fastest: [P1·P2·n, n]. From a MATLAB array A(:,:,i,j) the config is reshape(permute(A,[1 3 4 2]),[],size(A,2)).
  • B Matrices – the n×m B matrices, stacked the same way.
  • C Matrices – the 1×n C rows, stacked the same way. One output only.
  • D Matrices – the 1×m D rows, stacked the same way.
  • Breakpoints v1 – the P1 values of v1, strictly increasing, at least two.
  • Breakpoints v2 – the P2 values of v2, strictly increasing, at least two.
  • Initial State – every controller's x at the start: a scalar or an [n,1] column. Default 0.
  • Poles – the n poles of A − H·C, real and distinct. Default [−5 −2], Simulink's.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

Hj is computed at the start of a run by Ackermann's formula on the observer dual. With one output that is the only gain placing the poles, so it is the one Simulink's place returns; the configuration is refused if a C row and its A leave the state unobservable, if two poles coincide, or if C has more than one row.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. The schedule, the gains H and the matrices A − HC and B − HD are baked in; the two role machines and the nine states integrate with forward Euler at the block's period. The emitted core grows with the nine controllers times the P1·P2 arms that address them. All ten are rendered from the one description of the arithmetic the block's own simulation runs.

The three HDL targets are simulation-only: the fraction divides by a signal difference, so they compute in real arithmetic and quantize only at the ports.

Simulink bridge

None (Support::None), for the 1D Controller's reason: the four matrix parameters of aerolibschedule/2D Controller Blend are four-dimensional arrays, and neither MATLAB's matrix literal syntax nor an ICore matrix config has that form. The block is reported rather than exported without its matrices; it has no parity testbench, and code export verification covers it.

Notes

  • Discrete by nature here: the roles are a per-sample state, so the block always steps at its own period. The Simulink block is continuous; at the same fixed step under its Euler solver the two agree exactly.
  • Stateful: 9n controller states plus the two role machines. Direct feedthrough always: the weights are the Prelookup fraction of v at the same instant, so the output moves with v even with every D row zero.
  • Every standby controller's state still evolves, fed the blended output, so it is ready when the roles rotate it in.
  • In the three HDL targets v1 and v2 arrive in Q16.16, so a variable within one quantum (1.5×10−5) of a breakpoint can fall in the other interval, and its roles then rotate on a different sample than a double-precision run would. The blended output is continuous across a breakpoint, but the role machine is not, so treat a red HDL cell on this block as a re-run before a diagnosis.

Code facts#

FactValue
registered typeControl_Systems/Gain_Scheduling/Controller_Blend_2D
familyControl_Systems/Gain_Scheduling
solver environment classICoreBlock_0_Control_Systems_1_Gain_Scheduling_2_Controller_Blend_2D
sourcesrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Gain_Scheduling/Controller_Blend_2D/ICoreBlock_0_Control_Systems_1_Gain_Scheduling_2_Controller_Blend_2D.cpp
headersrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Gain_Scheduling/Controller_Blend_2D/ICoreBlock_0_Control_Systems_1_Gain_Scheduling_2_Controller_Blend_2D.h
default size on canvas150 × 100 px
ports at insert3 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoubley
2inICoreDoublev1
3inICoreDoublev2
4outICoreDoubleu

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
A Matrices[0 1; -2 -3; 0 1; -3 -3.5; 0 1; -2.5 -3.2; 0 1; -3.5 -3.8]—
B Matrices[0; 1; 0; 1; 0; 1; 0; 1]—
C Matrices[1 0; 1 0; 1 0; 1 0]—
D Matrices[0; 0; 0; 0]—
Breakpoints v1[1 2]—
Breakpoints v2[1 2]—
Initial State0—
Poles[-5 -2]—

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::None
Simulink path—
port-count rulePortsParam::None
SampleTime parameteryes

Caveat (shown to the user): aerolibschedule/2D Controller Blend computes exactly what this block does -- measured to 0 under ode1, both role machines included -- but its four matrix parameters are FOUR-DIMENSIONAL arrays, one slice per breakpoint pair, and neither MATLAB's matrix literal syntax nor an ICore matrix config has that form. So the schedule cannot cross in either direction; reported rather than exported to a counterpart that would be missing its matrices

Catalog contract: src/ICoreBlocks/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).

2D Controller Blend -- the 1D Controller Blend NESTED, nine self-conditioned controllers Each controller sits at one (v1, v2) breakpoint PAIR and carries its own state: dx/dt = H_ij*u + (B_ij - H_ij*D_ij)*y + (A_ij - H_ij*C_ij)*x, its output C_ij*x + D_ij*y H_ij = place(A_ij', C_ij', Poles)' and u is the blended output, fed back to all nine.

⚠ THIS IS NOT A NEW ROLE MACHINE, AND THAT IS THE MEASUREMENT THAT MATTERS. The mask holds the 1D Blend's "Controller indices" subsystem on v1 -- block for block the same: four Memory blocks, three triggered index subsystems with a RISING trigger on |k - k_prev| and "no trigger on first evaluation", six multiport switches, the same [0, P-1] saturations, bound here to v1's breakpoint count -- choosing three OUTER controllers with weights f1, 1-f1, 0. Each outer controller is then itself a 1D Blend on v2, with its own copy of that same role machine over three inner controllers. Nine controllers, nine states; the inner blend is formed per outer controller and the outer weights blend those three. The three inner role machines all see the same v2 and start the same, so they stay identical and ICore runs one.

So the support's blend program takes a LEVEL COUNT: 3^N controllers, one role machine per scheduling variable, the blend nested from the innermost variable out. N = 1 is the 1D Blend, unchanged.

MEASURED AGAINST R2026a by simulating a reference of that reading against the real block under ode1: EXACTLY 0 over 800 samples in each of three runs -- slow sweeps of both variables past both ends of their breakpoints, WHITE NOISE on both (index changes on consecutive samples, where the rising-edge rule skips a rotation), and both variables starting mid-table.

Discrete by nature here: the role machines are per-sample state (the Simulink block keeps them in Memory blocks), so the block steps at its own period with forward Euler -- exactly what the real block computes under ode1 at that period.

NO SIMULINK BRIDGE, for the 1D Controller's reason: four FOUR-dimensional matrix parameters.

Sample results#

Controller Blend 2D — Step: 0 -> 1 at t = 1 sController Blend 2D — Step: 0 -> 1 at t = 1 s00.51012345t (s)in ICoreDouble-Out-0in ICoreDouble-Out-0in 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 … 0.02693
rampRamp: slope 1 from t = 00 … 1.376
sineSine Wave: amplitude 1, 2 rad/s, no phase, no bias-0.1618 … 0.2369
tableRepeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample-0.0795 … 0.1932

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

Category dynamic · sample time 0.1 · 60 steps · commit 4287636be · produced by docsSample --out <folder> --blocks Controller_Blend_2D Observer_Form_2D Observer_Form_3D Self_Conditioned_2D Self_Conditioned_3D --steps 60 · data docs/generated/samples/Control_Systems__Gain_Scheduling__Controller_Blend_2D.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).