This project simulates a DC motor speed control system using a PID (Proportional–Integral–Derivative) controller implemented in C. It demonstrates how feedback control is used in embedded systems to achieve stable and accurate motor speed.
Figure: Motor speed response showing rise time, overshoot, and settling to the desired setpoint.
- Closed-loop motor speed control
- PID controller implementation (Kp, Ki, Kd tuning)
- Anti-windup mechanism for integral control
- PWM-like control signal limiting
- CSV data logging for analysis
- Graph visualization using Python
-
Feedback control systems
-
PID tuning (Proportional, Integral, Derivative)
-
System performance analysis:
- Rise time
- Overshoot
- Settling time
- Steady-state error
-
Embedded-style modular programming in C
motor_control_project/
│── main.c # Main simulation loop
│── motor.c # Motor model
│── motor.h
│── pid.c # PID controller
│── pid.h
│── plot.py # Graph visualization
│── output.csv # Generated data
│── graph.png # Output graph
-
The motor model simulates speed based on input voltage.
-
PID controller calculates control signal:
error = setpoint - actual_speed -
Anti-windup prevents integral saturation.
-
Control signal is limited (similar to PWM in embedded systems).
-
Motor speed updates iteratively.
-
Data is stored in
output.csvfor visualization.
gcc main.c motor.c pid.c -o motor
./motor
This generates:
output.csv
pip install matplotlib
python plot.py
This generates and displays the graph (graph.png).
Kp = 2.0
Ki = 0.5
Kd = 1.0
These values can be tuned to observe different system behaviors.
- Integral anti-windup to prevent saturation
- Modular code design using header and source files
- Data logging and visualization for performance evaluation
- Real-time plotting (live graph)
- Sensor noise simulation and filtering
- RTOS-based control loop
- Embedded hardware implementation (ARM/NXP boards)
- PWM duty cycle modeling
Simulated DC motor speed control using PID in C, implementing closed-loop feedback with anti-windup and analyzing system performance through CSV-based data logging and graphical visualization.
- Ashish Yadav NIT Jamshedpur
