How to add an s+1 block on simulink?

82 views (last 30 days)
Julian
Julian on 22 Nov 2024 at 4:00
Edited: Sam Chak about 11 hours ago
Hi everyone, I'm new to Simulink and had a quick question.
How do I add a block that says "s+1" on Simulink? I tried adding a transfer function with numerator [1 1] and denominator [1] but it won't let me do that. I understand s+1 is a lead/lag filter, but Simulink's transfer function lead/lag doesn't seem to match what I need. Any pointers would be much appreciated. Thanks!
  4 Comments
Mathieu NOE
Mathieu NOE on 22 Nov 2024 at 10:52
s is a derivation, so s + 1 can be replaced by a derivative block in parallel to a unitary gain block , followed by a sum block
Paul
Paul about 13 hours ago
If using the Derivative block, be sure to read the doc page first and carefully review its recommendations and warnings.

Sign in to comment.

Answers (2)

Sam Chak
Sam Chak on 22 Nov 2024 at 11:03
Edited: Sam Chak about 11 hours ago
Since you are unable to clearly define the control objective and performance requirements, I can only advise you to use the PD controller as a substitute for the '' (in the frequency domain), with a proportional gain and Derivative gain . However, there is a caveat in your design: it will only function properly as long as . No mathematical proof is provided in my response though.
Note: Please remember to disable the zero-crossing detection in the Sign block. This is a software technical issue, not a sliding mode control mathematics issue.
  2 Comments
Paul
Paul about 24 hours ago
Hi Sam,
Any recommendation on how to select the "Filter Coefficient (N)" in the PID controller block?
Also, why disable zero-crossing detection in the Sign block? Wouldn't it be important to accurately model the switch in this type of application?
Sam Chak
Sam Chak 23 minutes ago
In my run, I had to disable the zero-crossing detection; otherwise, it would throw an error message upon reaching the sliding manifold (x + x' = 0) due to rapid zero-crossing caused by the very high switching frequency from the Sign function block. I seldom use Simulink nowadays. Do you have a solution for this issue?
In determining the value for the 'Filter Coefficient (N)' in the PID controller block, I chose N = 1000 (without using a formula), which is a sufficiently high value to produce a stabilizing result. In the past, I used the Derivative block, similar to @Mathieu NOE's suggestion, to render the improper transfer functions. However, I prefer to use workarounds to substitute for or approximate certain control conditions.
Phase Portrait:
Error message:
I typically do not naively follow or construct models similar to those depicted in control block diagrams, as much information is often omitted from these diagrams in published papers to save space. Since @Julian did not provide additional information, I would likely design the following configuration, which allows for flexibility in tuning four control parameters and setting the initial values of the plant, without the need to design a state observer.
Unlike the solution depicted above, in the absence of external disturbances, the proposed controller will ensure global stability.
Control Block Diagram:
Phase Portrait:
Time response of the state x:

Sign in to comment.


Rahul
Rahul on 22 Nov 2024 at 11:53
I understand that you are trying to implement a continuous transfer function ‘s+1’ in Simulink, where you are getting an error stating the given transfer function is an improper transfer function. the order of the transfer function numerator polynomial must be smaller than the degree of the denominator polynomial
You can try to add a MATLAB function to simulate the effect of (s) as a derivative and add 1, since Simulink operates in the time domain.
function y = transfer_func(u)
% Transfer function implementation: (s + 1)
persistent prev_u prev_y
if isempty(prev_u)
prev_u = 0;
prev_y = 0;
end
% Compute derivative term (approximation)
sample_time = 0.01; % Replace with your Simulink fixed-step size if known
du = (u - prev_u) / sample_time;
% Compute output
y = du + u; % s * u + 1 * u
% Update persistent states
prev_u = u;
end
I tried to simulate the given MATLAB function on a model containing a signal generator block, like sine wave, and then visualized the output in a scope block. Here’s the model structure along with the final output waveform:
This approach simulates the (s) operation by computing a numerical derivative using a simple difference quotient, and then adds 1 to the result. You can adjust the ‘dt value to match your system's sample time for accurate results.
To know more about the usage of ‘persistent’ variables, enter the following command in MATLAB:
>> doc persistent
Hope this helps!

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!