Skip to content

tslime/PIDControllerSimulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PID Controller Simulator

Language: C++
Purpose: Simulates a closed-loop PID-controlled system that regulates speed toward a target value over discrete timesteps.

Description

This project implements a minimal yet functional PID (Proportional–Integral–Derivative) controller coupled with a simple system simulator to visualize dynamic feedback control.
The system models how a controller drives a simulated variable (e.g., speed) toward a defined target through iterative updates.

The program produces an exponential-like convergence curve characteristic of stable PID systems, which can be plotted directly using Gnuplot from within C++.

Components

  • PIDController — computes control signals using Kp, Ki, and Kd.
  • SystemSimulator — updates the simulated system’s state based on control input and responsiveness.
  • Unit — integrates both components into a loop and manages Gnuplot visualization.

Example Output

timestep: 0 current speed: 50 updated speed: 65.1
timestep: 10 current speed: 95.4 updated speed: 96.6
timestep: 50 current speed: 101.7 updated speed: 101.7

The resulting plot shows a smooth exponential rise with slight overshoot and fast stabilization — a hallmark of a properly tuned PID loop.


Visualization

Simulation results are plotted using Gnuplot, launched directly from the program via a pipe:

set title "PID Controller Simulation"
set xlabel "Time step"
set ylabel "Speed"
plot '-' using 1:2 with lines title 'Current Speed', \
     '-' using 1:2 with lines title 'Updated Speed'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages