0% found this document useful (0 votes)
23 views7 pages

MATLAB PID Control of Mass-Spring-Damper

The lab report details the modeling and simulation of a mass-spring-damper system using MATLAB and Simulink, focusing on the design and effects of PID controllers. It outlines the objectives, theoretical background, and results of simulations, demonstrating how varying PID parameters influences system performance. The report concludes that effective tuning of PID controllers significantly enhances the system's response and stability.

Uploaded by

Samrat Bhattarai
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views7 pages

MATLAB PID Control of Mass-Spring-Damper

The lab report details the modeling and simulation of a mass-spring-damper system using MATLAB and Simulink, focusing on the design and effects of PID controllers. It outlines the objectives, theoretical background, and results of simulations, demonstrating how varying PID parameters influences system performance. The report concludes that effective tuning of PID controllers significantly enhances the system's response and stability.

Uploaded by

Samrat Bhattarai
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Tribhuvan University

Institute Of Engineering

Thapathali Campus

Lab report on: MATLAB


Modeling and simulation of mass, spring, damper system and
Design of PID controller for closed loop system

Report No.:3

Submitted By: Submitted To:

Samrat Bhattarai Department Of Industrial


Engineering
078BIE023

Date Of Submission: August 6, 2024


MODELING AND SIMULATION OF MASS, SPRING, DAMPER SYSTEM

Objective
1. To learn to model mass, spring damper system in MATLAB and Simulink
2. To simulate model mass, spring damper system in MATLAB and Simulink and analyze the
response.
3. To learn the effect of the PID controllers

Theory
MATLAB Simulation is a powerful tool used for modeling, simulating, and analyzing dynamic
systems. MATLAB provides an interactive environment with a vast library of functions and toolboxes
for various engineering and scientific applications. Simulink, a graphical extension of MATLAB, is
particularly useful for simulating control systems, signal processing, and other dynamic systems.

Key features:
▪ Modeling: Create mathematical models of physical systems using blocks and connection in
Simulink
▪ Simulation: Run simulations to observe the behavior of the system over time.
▪ Analysis: Analyze the results using MATLAB’s extensive plotting and data analysis tools.

Mechanical Modeling

k
m
F
Figure 2 Mass spring & Damper system

Figure 1 FBD

Modeling Equation
𝑚𝑥̈ + 𝑏𝑥̇ + 𝑘𝑥 = 𝐹

Laplace and Transfer Function


𝑚𝑠 2 𝑋(𝑠) + 𝑏𝑠𝑋(𝑠) + 𝑘𝑋(𝑠) = 𝐹(𝑠)

𝑋(𝑠) 1
= 2
𝐹(𝑠) 𝑚𝑠 + 𝑏𝑠 + 𝑘
Feedback Control Action and PID controller Principle
Feedback Controller

e u
R Y
Controller Plant
+
-

Figure 3 System Controller

e= represents the tracking error; difference between desired input(R) and actual output(Y).
Sent to controller which computes:
derivative of e
integral of e

u= represents controller output; and is equal to:


Kp (proportional gain) times the magnitude of the error +
Ki (integral gain) times the integral of the error +
Kd (derivative gain) times the derivative of the error

Controller’s Output:
𝑑𝑒
𝑢 = 𝐾𝑝 𝑒 + 𝐾𝑖 ∫ 𝑒𝑑𝑡 + 𝐾𝑑
𝑑𝑡

Controller’s Transfer Function


𝐾𝑖 𝐾𝑑 𝑠 2 + 𝐾𝑝 𝑠 + 𝐾𝑖
𝐾𝑝 + + 𝐾𝑑 𝑠 =
𝑠 𝑠

Characteristics of PID Controllers


➢ Proportional Controller Kp
▪ Reduces the rise time
▪ Reduces but never eliminates
steady-state error
➢ Integral controller Ki
▪ Eliminates steady-state error
▪ Worsens transient response
➢ Derivative controller Kd
▪ Increases the stability of the system
▪ Reduces overshoot
▪ Improves transient response
MATLAB System Response
Assume:
m = 1kg, b = 10 Ns/m, k = 20 N/m

MATLAB code
>> m=1; b=10; k=20
k=
20
>> num=1;
>> den= [m, b, k];
>> plant=tf (num, den);
>> step(plant)

Figure 4 MATLAB code response Amplitude v/s Time(sec)

Output
Final Value = 0.05
Steady-state error = 0.95
Rise time = 0.884s
Settling time = 1.59s
PID controller should
influence (reduce) all these
parameters.

Figure 5 Simulink Simulation


Simulink Model of PID Controllers

20
Transfer Function=
𝑠2 +10 𝑠+20

Changing gain of controllers one by one


Case 1: Initial condition:
Kp = 1 Ki = 1 Kd = 1

Figure 6 Case 1
Case 2: Changing P only
Kp=300 Ki = 1 Kd = 1

Figure 7 Case 2

Case 3: Changing PI
Kp= 300 Ki=350 Kd=1

Figure 8 Case 3
Case 4: Changing PID
Kp= 300 Ki= 350 Kd=10

Figure 9 Case 4

Discussion
In this lab, we explored the modeling and simulation of a mass-spring-damper system and the design
of a PID controller for a closed-loop system. Through the simulation, we gained insights into the
dynamics of mechanical systems and the effectiveness of control strategies in achieving desired
performance. The mass-spring-damper system is a fundamental mechanical model used to understand
oscillatory behavior. By varying the parameters of mass, spring constant, and damping coefficient, we
observed how the system responds to different inputs. The natural frequency and damping ratio
significantly influence the system's transient and steady-state behavior. In particular, we noted that
increasing the damping coefficient reduced oscillations, leading to a quicker stabilization of the
system. The design of the PID controller was a critical aspect of this lab. We implemented the PID
controller to regulate the position of the mass in the mass-spring-damper system. By tuning the PID
parameters, we aimed to achieve a balance between fast response and minimal overshoot. We
observed that proper tuning of the PID controller significantly improved the system's performance.
The proportional term helped reduce the error, the integral term eliminated steady-state error, and the
derivative term provided damping, improving transient response. Overall, the lab provided a
comprehensive understanding of the principles of modeling, simulation, and control of dynamic
systems. We gained hands-on experience in designing and tuning a PID controller, which is essential
for controlling real-world systems

Conclusion
In this way we learnt to simulate mass, spring and damper system in MATLAB and Simulink and also
observed the effect of PID controllers on the system by simulation.

Common questions

Powered by AI

Increasing only the proportional gain (Kp) in a PID controller setup leads to a faster response time since it reduces the rise time, but this increased gain can also lead to increased overshoot and possibly introduce oscillations if the gain is too high, affecting the system's stability .

Using Simulink offers the advantage of providing a graphical interface to model and simulate dynamic systems easily. It supports detailed analysis with real-time visualization. However, the limitation could include the steep learning curve for beginners and the potential for oversimplification of complex systems when not adequately modelled .

The simulation provided insights into the oscillatory behavior of mechanical systems. By varying system parameters (mass, spring constant, damping coefficient), distinct responses were observed. Key insights included how natural frequency and damping ratio influence transient and steady-state behavior, with higher damping leading to reduced oscillations and quicker stabilization .

Tuning the PID controller significantly affects the performance of the mass-spring-damper system. Correct tuning optimizes the balance between a fast response and minimal overshoot, improving system performance. The proportional term reduces error, the integral term eliminates steady-state error, and the derivative term enhances damping, thus collectively improving both transient and steady-state responses .

Mastering the modeling and simulation of mass-spring-damper systems in MATLAB and Simulink has wide real-world applications, such as in automotive suspension systems, vibration analysis in building structures, and aerospace engineering for studying aircraft dynamics. Understanding these models aids in designing more efficient control systems and in predicting system responses under various conditions, thus improving engineering solutions .

MATLAB and Simulink are used for modeling and simulating mass-spring-damper systems to provide an interactive environment with a vast set of functions and toolboxes for engineering applications. Simulink, in particular, is useful for simulating control systems and observing system behavior over time, allowing for detailed analysis of the system’s dynamics .

Damping in a mass-spring-damper system reduces oscillations and aids in stabilizing the system quicker. It plays a significant role in determining the system's transient behavior. Higher damping leads to less oscillation and faster stabilization; however, excessive damping can slow the system's overall response time .

The proportional term in a PID controller reduces the rise time, which means it helps the system reach the desired value faster. However, it reduces but never eliminates the steady-state error . This means while it helps improve the speed of response, it alone cannot ensure perfect accuracy in reaching and maintaining the desired output level.

The derivative term of a PID controller contributes to the system's stability by providing predictive action—essentially damping the system's movement, thus improving transient response. It helps reduce overshoot and enhances the system's ability to settle quickly to a desired state .

The integral component of a PID controller eliminates steady-state error, which helps the system accurately reach and maintain the desired output. However, it worsens the transient response by potentially making the system slower to respond to changes and can lead to overshoot if not properly tuned .

You might also like