How to solve Algebraic Loops in half car model with PID controller

6 Comments

Can you show the entire set of differential equations for the half-car model and the two PID controllers? It may be easier to identify the root cause of the algebraic loop and find a way to remove it by creating the proper mathematical equation.
If you know how, try writing the differential equations in code for the convenience of checking in MATLAB. Otherwise, if you are unable, just write the equations with standard mathematical notations (preferably in LaTeX—click the icon ).
I presume that you have derived all four second-order differential equations correctly. Since you already have the equations, it might be helpful to share the entire file or copy/paste the equations. I prefer to consolidate the equations and all parameters into a single function() file for easy troubleshooting in MATLAB (not Simulink).
I believe you created a separate parameter file for constants such as a, b, bf, ksf, ksr, etc., but you didn't show them.
clear all; close all; clc;
%model parametreleri
ti=0; ts=6; dt=0.00005;
M=1000; mr=200; mf=100; I=1600;
Ksr=32000; Ksf=28000; Ktf=400000; Ktr=400000;
br=2000; bf=2000; a=1; b=1.2; V=20;
r=(a+b)/V; % the value in the transport delay
% Kp=322000; Ti=inf; Td=0;
% Y0r=[0,0;10,0];
% Y0f=[0,0;10,0];
% sim PID_half
% figure(2)
% plot(time,Y2,'r');
Kcr=322000; Pcr=0.24;
% Kp=0.6*Kcr; Ti=Pcr/2; Td=Pcr/8;
Kp=922000; Ti=0.1600; Td=0.0300;
h=0.035;
Y0r=[0,0;0.00247,h;0.00597,h;ts,h];
Y0f=[0,0;0.00247,h;0.00597,h;ts,h];
sim PID_half
figure(1)
plot(time,Y2,'k');
hold on
plot(time,Y2r,'m');
hold on
plot(time,Y2f,'r');
xlabel('zaman(s)');
ylabel('konum(m)');
legend ('Y2', 'Y2r', 'Y2f')
Unable to find system or file 'PID_half'.
There is no algebraic loop error message when I run the Simulink file. I added a Scope to check the signals, and they are stable. Perhaps @Sulaymon Eshkabilov can also take a look.
thank you so much for your efforts. I don't use Scope, I'm using the plot code from the matlab command page. as you can see , there is a very big peak at first.when I run the code, it gives an algebraic loop error but I can get these graphs, and when I change the coefficients, it asks me to reduce the number of steps or fix the algebraic loop set parameter trust region command. i thought that if I solved the algebraic loop error, I would improve the graph more.

Sign in to comment.

Answers (2)

By glancing at your Simulink model, that looks ok without seeing f(u)'s. I can see the problem is in f(u) function definitions. I would check f(u) for acceleration calcs.
There are a couple of derivative blocks in your model that creates all instability (spikes are occuring due to derivatives at t=0, i.e., Any/0 = inf) related issue at the start of your simulation. A possible solution can be:
(1) Switch the derivative block with a some sort of transfer function, e.g., TFD(s) = s/(tau_D*s+1)
(2) Include the derivative term into the PID's transfer fucntion

Categories

Find more on General Applications in Help Center and File Exchange

Products

Release

R2018b

Tags

Asked:

on 23 Dec 2023

Community Treasure Hunt

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

Start Hunting!