# Simulink: How to fix given error for a closed loop model w/ PID controller?

• Engineering
• simphys
In summary, the conversation is about a problem with a simulink model and Matlab code. The error is caused by rapidly changing values and the solution could be to check the values of all components and variables, as well as adjusting the time step or error band. The speaker also asks for updates on the solution.
simphys
Homework Statement
The question that is asked is basically to create a closed loop model with a PID controller. (if necessary more information on the picture)
The problem that I am encountering is an error which I don't understand and know how to fix?
Relevant Equations
not relevant
Could I get some input on how to fix this problem please? Thanks in advance!

The exercise for which I need the model.

The simulink model together + the error that needs to be fixed + Matlab code used:

Note: Gain 1 = 1/Ti

#### Attachments

• Screenshot from 2023-06-07 17-33-21.png
26.5 KB · Views: 76
• error.png
22.5 KB · Views: 89
• matlab_code.png
5.3 KB · Views: 78
7.4 KB · Views: 78
I'm not an expert on this, but it looks like some of the equations it is solving are changing in value so fast that further calculations make no sense.

Please check the values of all the components/variables you have supplied. For instance maybe one is missing a minus sign or a decimal point. Another common problem is that an 'm' was entered instead of 'M' (or the other way around -- one means milli-, the other Mega-).

Then try changing the time step or error band, as the Error Msg. suggested.

Good Luck,
Tom

p.s. please keep us posted on what you find that works.

## How do I address the "Algebraic Loop" error in my Simulink model with a PID controller?

The "Algebraic Loop" error occurs when there is a direct feedback loop without any delay. To fix this, you can try adding a small delay block or a unit delay block in the feedback path. This will break the algebraic loop and allow Simulink to solve the model.

## Why is my PID controller not stabilizing the closed-loop system in Simulink?

There could be several reasons for this issue. First, check if the PID gains (Kp, Ki, Kd) are appropriately tuned for your system. You can use the PID Tuner tool in Simulink for automatic tuning. Also, ensure that the plant model is correctly defined and linearized if needed. Additionally, verify that there are no issues with the sampling time or solver settings.

## How can I resolve the "Singular Matrix" error in my closed-loop model with a PID controller?

The "Singular Matrix" error usually indicates that the system matrix is not invertible. This can happen if there are dependencies between states or if the system is not properly defined. Check your model for any redundant states or improper connections. Simplifying the model or adding constraints can sometimes help resolve this issue.

## What should I do if my Simulink model with a PID controller is running very slowly?

If your model is running slowly, it could be due to a high computational load. Try reducing the simulation time, using a fixed-step solver with an appropriate step size, or simplifying the model. Additionally, ensure that the PID controller is not excessively demanding in terms of computational resources by optimizing its parameters.

## How do I fix the "Derivative of state" warning in my closed-loop Simulink model with a PID controller?

This warning indicates that the model includes a direct feedthrough from an input to a derivative of a state, which can cause numerical issues. To fix this, you can try adding a low-pass filter to the derivative term in the PID controller. This will smooth out the derivative action and reduce the likelihood of numerical instability.

• Engineering and Comp Sci Homework Help
Replies
1
Views
1K
• Engineering and Comp Sci Homework Help
Replies
2
Views
3K
• Engineering and Comp Sci Homework Help
Replies
4
Views
2K
• Engineering and Comp Sci Homework Help
Replies
2
Views
1K
• Engineering and Comp Sci Homework Help
Replies
4
Views
3K
• Engineering and Comp Sci Homework Help
Replies
3
Views
1K
• General Engineering
Replies
9
Views
2K
• Electrical Engineering
Replies
12
Views
2K
• DIY Projects
Replies
5
Views
4K
• Mechanical Engineering
Replies
6
Views
1K