Skip to content

Repository files navigation

Spring Mass Damper System with PI Controller (MATLAB)

Overview

This project presents the modelling, analysis, and control of a Spring–Mass–Damper System using MATLAB and Control System Toolbox. The objective is to analyse the dynamic behaviour of the system in both the time domain and frequency domain, then design a Proportional-Integral (PI) controller to improve system performance.

The project was completed as part of the Control Systems (CNS317B) course for the Bachelor of Engineering Technology in Electrical Engineering.


Objectives

The project aims to:

  • Model a Spring–Mass–Damper system using its transfer function.
  • Analyse the uncontrolled system.
  • Evaluate system stability using multiple control engineering techniques.
  • Design and tune a PI controller.
  • Improve transient response and eliminate steady-state error.
  • Compare uncontrolled and controlled system performance.

System Model

The plant transfer function is

[ G(s)=\frac{1}{10s^2+0.4s+100} ]

where

  • Mass (m) = 10 kg
  • Spring constant (k) = 100 N/m
  • Damping coefficient (c) = 0.4 Ns/m

Control Strategy

A PI controller was implemented:

[ G_c(s)=\frac{K_ps+K_i}{s} ]

Controller gains used in the MATLAB script:

  • Kp = 10
  • Ki = 100

The controller was designed to:

  • Improve settling time
  • Eliminate steady-state error
  • Maintain system stability

Analyses Performed

Time Domain

  • Step Response (Uncontrolled)
  • Step Response (PI Controlled)

Root Locus

  • Open-loop Root Locus
  • PI Controlled Root Locus

Frequency Domain

  • Bode Plot
  • Gain Margin
  • Phase Margin
  • Nyquist Plot

MATLAB Features Used

The project makes use of the following MATLAB Control System Toolbox functions:

  • tf()
  • step()
  • stepinfo()
  • feedback()
  • pole()
  • rlocus()
  • bode()
  • margin()
  • nyquist()

Project Structure

.
├── SpringMassDamper_PI_Controller.m     # Main MATLAB simulation
├── GA4_Report.pdf                       # Technical report
├── README.md

Results

The project demonstrates that the PI controller significantly improves system performance by:

  • Reducing settling time
  • Eliminating steady-state error
  • Improving damping
  • Maintaining closed-loop stability
  • Providing improved frequency-domain stability margins

The generated plots include:

  • Step Response
  • Root Locus
  • Bode Plot
  • Nyquist Plot

How to Run

Requirements

  • MATLAB
  • Control System Toolbox

Steps

  1. Clone this repository
git clone https://github.com/yourusername/Spring-Mass-Damper-PI-Controller.git
  1. Open MATLAB.

  2. Navigate to the project folder.

  3. Run

SpringMassDamper_PI_Controller

The script will automatically generate all simulation plots and display the calculated system characteristics.


Learning Outcomes

This project demonstrates understanding of:

  • Dynamic system modelling
  • Transfer functions
  • Time-domain analysis
  • Frequency-domain analysis
  • Root Locus design
  • PI controller design
  • Closed-loop stability
  • MATLAB Control System Toolbox

Author

TG Maelane

Bachelor of Engineering Technology (Electrical Engineering)

Tshwane University of Technology


Course

Control Systems (CNS317B)

Graduation Attribute 4 (GA4)

System Modelling and Stability Analysis


License

This repository is intended for educational and academic purposes.

About

MATLAB project that models and analyses a Spring–Mass–Damper system using transfer functions, Root Locus, Bode, Nyquist and Step Response, then designs a PI controller to improve stability, settling time and steady-state accuracy.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages