This project implements a simple PID (Proportional-Integral-Derivative) controller in C, along with a basic simulation of a temperature control system. It serves as an educational tool to understand the principles of PID control and its application in process control systems.
pid_controller.h
: Header file containing the PID controller structure and function prototypes.pid_controller.c
: Implementation of the PID controller and simulation functions.main.c
: Main program that sets up and runs the PID controller simulation.Makefile
: Build script for compiling the project.
To compile the project, simply run:
make
This will create an executable named pid_controller
.
To run the simulation and output the results to a CSV file, use:
./pid_controller > output.csv
The output file will contain columns for Time, Temperature, and Heater Power.
To remove compiled objects and the executable, run:
make clean
You can modify the PID parameters, setpoint, and simulation parameters in the main.c
file to experiment with different control scenarios. Key parameters to adjust include:
Kp
,Ki
,Kd
: PID gainssetpoint
: Desired temperaturecurrent_temp
: Initial temperatureambient_temp
: Ambient temperaturedt
: Time stepnum_steps
: Number of simulation steps
The simulation output allows you to observe:
- How quickly the system reaches the setpoint (rise time)
- Whether the temperature overshoots the setpoint
- How long it takes for the temperature to stabilize (settling time)
- The final steady-state error (if any)
By adjusting the PID parameters, you can see how they affect the system's behavior and performance.
Possible enhancements to this project could include:
- Implementing more advanced PID algorithms (e.g., with anti-windup)
- Adding a user interface for real-time parameter adjustment
- Incorporating more complex process models
- Implementing auto-tuning algorithms for PID parameters