How do I turn this Simulink model with Gain Control to Pole Placement?

31 visualizaciones (últimos 30 días)
farzad
farzad el 29 de Dic. de 2025 a las 19:13
Respondida: Sam Chak el 30 de Dic. de 2025 a las 10:17
Hi All
I have already calculated the gains for acceleration and velocity but my block is state space and gives displacement and velocity. I just dont know , what should I do with displacement, or should I leave disp and vel and only control acceleration with one gain or acc and vel ?? I have added 2 Zero pole blocks, which defined the new gains. but then It seems like State Space is not coincident with this method

Respuestas (2)

Umar
Umar el 30 de Dic. de 2025 a las 4:01

@Farzad, your state-space block outputs displacement and velocity but not acceleration, so you need to compute acceleration using the formula acceleration equals A(2,:) times your state vector plus B(2) times your control input, where A(2,:) is the second row of your A matrix. Your gains 5.0266 and 5.0268 are for velocity and acceleration feedback, so you must use both, and you also must include displacement in your feedback even though it wasn't in your original design because it affects dynamics through the A matrix. Remove the Zero-Pole blocks since they create mathematical inconsistencies when patched onto state-space models, and use direct gain blocks instead.

The MATLAB simulation demonstrates this with a mass-spring-damper system where the state-feedback gains are [20.0000, 9.0000] for displacement and velocity, and adding acceleration feedback gain of 0.50 produces effective gains of [10.0000, 5.3333]. The plots show three cases: open-loop oscillates badly with 0.14m overshoot and takes over 4 seconds to settle, state feedback reduces this to 0.03m with under 2 seconds settling, and acceleration feedback gives 0.05m settling with even smoother transients. The velocity and acceleration plots confirm both feedback methods eliminate the wild oscillations seen in open-loop, with acceleration feedback providing marginally better damping throughout the response.

For your Simulink model, you have two implementation options: Option 1 is to compute acceleration explicitly in a MATLAB function block using the formula above, then create feedback as u equals reference minus K_displacement times displacement minus K_velocity times velocity minus K_acceleration times acceleration. Option 2 is to use modified effective gains calculated as K_effective equals [K_disp plus K_acc times A(2,1), K_vel plus K_acc times A(2,2)] divided by (1 plus K_acc times B(2)), which incorporates acceleration feedback implicitly into your state gains. Either way, connect all outputs from your state-space block through appropriate gain blocks to a summing junction with negative signs for feedback, and verify your response shows quick settling with minimal overshoot like the simulation demonstrates.

Here's the complete MATLAB code that demonstrates both approaches:

% State-Space Acceleration Feedback Controller Example
% This demonstrates how to properly extract and feedback acceleration
% from a state-space system where states are [displacement; velocity]
close all;clear all;clc;
% Define a simple mass-spring-damper system
m = 1;    % mass (kg)
c = 2;    % damping coefficient (N·s/m)
k = 10;   % spring constant (N/m)
% State-space matrices: x = [displacement; velocity]
A = [0, 1; -k/m, -c/m];
B = [0; 1/m];
C = [1, 0; 0, 1];  % Output both displacement and velocity
D = [0; 0];
% Create state-space system
sys = ss(A, B, C, D);
fprintf('System matrices:\n');
disp('A ='), disp(A)
disp('B ='), disp(B)
disp('C ='), disp(C)
% Design state-feedback gains using pole placement
% Desired closed-loop poles (faster, well-damped)
desired_poles = [-5, -6];
K_state = place(A, B, desired_poles);
fprintf('State-feedback gains [K_displacement, K_velocity]:\n');
disp(K_state)
% KEY INSIGHT: To get acceleration feedback, compute it from dynamics
% acceleration = A(2,:)*x + B(2)*u
% For full feedback including acceleration:
% u = r - K1*x1 - K2*x2 - K3*acceleration
% Substituting acceleration = A(2,:)*x + B(2)*u:
% u = r - K1*x1 - K2*x2 - K3*(A(2,:)*x + B(2)*u)
% u*(1 + K3*B(2)) = r - [K1, K2]*x - K3*A(2,:)*x
% u = (r - [K1+K3*A(2,1), K2+K3*A(2,2)]*x) / (1 + K3*B(2))
% Example: Add acceleration feedback gain
K_acc = 0.5;  % Acceleration feedback gain
% Modified state-feedback gains incorporating acceleration
K1 = K_state(1);  % Displacement gain
K2 = K_state(2);  % Velocity gain
K3 = K_acc;       % Acceleration gain
% Compute effective gains after algebraic manipulation
K_eff = [K1 + K3*A(2,1), K2 + K3*A(2,2)] / (1 + K3*B(2));
fprintf('\nWith acceleration feedback gain K_acc = %.2f:\n', K_acc);
fprintf('Effective state gains: [%.4f, %.4f]\n', K_eff(1), K_eff(2));
% Simulate step response
t = 0:0.01:5;
u_step = ones(size(t));
% Original system (no feedback)
[y_open, t_out, x_open] = lsim(sys, u_step, t);
% Closed-loop with state feedback (no acceleration term)
sys_cl_state = ss(A-B*K_state, B, C, D);
[y_state, ~, x_state] = lsim(sys_cl_state, u_step, t);
% Closed-loop with acceleration feedback included
A_cl_acc = A - B*K_eff;
sys_cl_acc = ss(A_cl_acc, B, C, D);
[y_acc, ~, x_acc] = lsim(sys_cl_acc, u_step, t);
% Compute acceleration for each case
acc_open = zeros(length(t), 1);
acc_state = zeros(length(t), 1);
acc_acc = zeros(length(t), 1);
for i = 1:length(t)
  acc_open(i) = A(2,:)*x_open(i,:)' + B(2)*u_step(i);
  acc_state(i) = A(2,:)*x_state(i,:)' + B(2)*u_step(i);
  acc_acc(i) = A(2,:)*x_acc(i,:)' + B(2)*u_step(i);
end
% Plot results
figure('Position', [100, 100, 1000, 800]);
subplot(3,1,1)
plot(t, y_open(:,1), 'b--', t, y_state(:,1), 'r-', t, y_acc(:,1), 'g-', 'LineWidth', 1.5)
ylabel('Displacement (m)')
legend('Open-loop', 'State feedback', 'With accel feedback', 'Location', 'best')
title('System Response Comparison')
grid on
subplot(3,1,2)
plot(t, y_open(:,2), 'b--', t, y_state(:,2), 'r-', t, y_acc(:,2), 'g-', 'LineWidth', 1.5)
ylabel('Velocity (m/s)')
grid on
subplot(3,1,3)
plot(t, acc_open, 'b--', t, acc_state, 'r-', t, acc_acc, 'g-', 'LineWidth', 1.5)
ylabel('Acceleration (m/s²)')
xlabel('Time (s)')
grid on
% Summary for Farzad
fprintf('\n=== SUMMARY FOR YOUR SIMULINK MODEL ===\n');
fprintf('Your state-space block outputs displacement and velocity.\n');
fprintf('To feedback acceleration, you have two options:\n\n');
fprintf('Option 1: Compute acceleration algebraically\n');
fprintf('  acceleration = A(2,:)*[disp; vel] + B(2)*control_input\n');
fprintf('  Then feedback: u = reference - K1*disp - K2*vel - K3*accel\n\n');
fprintf('Option 2: Incorporate acceleration gain into state gains\n');
fprintf('  Use modified gains that account for acceleration implicitly\n');
fprintf('  Effective K = [K1+K3*A(2,1), K2+K3*A(2,2)] / (1+K3*B(2))\n\n');
fprintf('Your gains 5.0266 and 5.0268 should be applied correctly:\n');
fprintf('- If they are [K_vel, K_acc], use Option 1 above\n');
fprintf('- Remove Zero-Pole blocks and use direct gain multiplication\n');
fprintf('- Connect displacement from state-space even if not in original   
design\n');
fprintf('  (it affects the dynamics through the A matrix)\n');

Results: please see attached.

Run this code in MATLAB Mobile to see the complete simulation results and understand how to properly implement acceleration feedback in your Simulink model.

Let me know how it goes.


Sam Chak
Sam Chak el 30 de Dic. de 2025 a las 10:17
In all "mathematical" linear, time-invariant finite‑dimensional systems, particularly for an n-th order system represented in state form , the full state feedback control law, , can place the n closed‑loop poles arbitrarily (requiring only n states) if the pair (A, B) is controllable. This approach guarantees stability (negative real poles) and achieves the desired transient performance (overshoot and settling time). Achieving zero steady-state is a different story though...
For example, a motion system described by a 2nd-order differential equation in acceleration, , needs only two states: displacement (x) and velocity (), in the control law. A state-feedback controller of the form can effectively place the two desired closed-loop poles, making it unnecessary to include an acceleration term explicitly in the controller.
% desired closed-loop poles
p1 = -2+3i;
p2 = -2-3i;
% manual pole-placement using calculus-free high school algebra
k1 = p1*p2;
k2 = -(p1 + p2);
% state-feedback matrix, A - B*K
% x1 x2
ABK = [ 0, 1
-k1, -k2]; % u = - k1*x1 - k1*x2
% verify if poles are placed at the desired locations
eig(ABK)
ans =
-2.0000 + 3.0000i -2.0000 - 3.0000i

Etiquetas

Productos


Versión

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by