Lcs Project Report PDF
Lcs Project Report PDF
Department of Avionics, College of Engineering, Pakistan Air Force- Karachi Institute of Economics and
Technology.
Email:
1
[email protected]
2
[email protected]
3
[email protected]
ABSTRACT
This project implements a PID-based position control system using a Nisca servo DC motor with an Nf5475e encoder,
an L298N motor driver, and a potentiometer. The objective is to control the motor's position accurately by adjusting
the output voltage based on the feedback from the encoder. The PID controller, which consists of proportional, integral,
and derivative components, helps achieve stable and precise positioning.
1
December 30, 2024 [LINEAR CONTROL SYSTEMS (115965)]
// PID Constants
float kp = 1.50; // Proportional gain
float ki = 0.09; // Integral gain
float kd = 0.01; // Derivative gain
int deadband = 5; // Deadband for control
int boostvalue = 70; // Boost value for holding
torque
// Variables
4. FRONT PANEL volatile long encoderPos = 0; // Encoder position
(updated by ISR)
long targetPos = 0; // Target position
float eintegral = 0; // Integral term accumulator
float eprev = 0; // Previous error
float error = 0; // Error
float customError = 0; // Custom error offset for
tuning
unsigned long prevT = 0; // Time of last loop
bool display_flag = false; // Debug display flag
2
December 30, 2024 [LINEAR CONTROL SYSTEMS (115965)]
3
December 30, 2024 [LINEAR CONTROL SYSTEMS (115965)]
} else if (command.startsWith("d")) {
kd = command.substring(1).toFloat();
Serial.print("kd set to: ");
Serial.println(kd);
} else if (command.startsWith("b")) {
deadband = command.substring(1).toInt();
Serial.print("Deadband set to: ");
Serial.println(deadband);
} else if (command.startsWith("u")) {
boostvalue = command.substring(1).toInt();
Serial.print("Boost set to: ");
Serial.println(boostvalue);
} else if (command.startsWith("e")) {
customError = command.substring(1).toFloat();
Serial.print("Custom Error Offset set to: ");
Serial.println(customError);
} else if (command.startsWith("o")) {
encoderPos = 0;
targetPos = 0;
error = 0;
eintegral = 0;
customError = 0;
eprev = 0;
Serial.println("Encoder and target position
reset.");
} else if (command.startsWith("f")) {
display_flag = command.substring(1).toInt() > 0;
Serial.print("Debug display ");
Serial.println(display_flag ? "enabled" :
"disabled");
}
} 8. APPLICATIONS
4
December 30, 2024 [LINEAR CONTROL SYSTEMS (115965)]
8. FUTURE RECOMMENDATION
12. REFERENCES
https://ftn.canon/en/product/motor/encoder.
html
https://forum.arduino.cc/t/position-control-
of-a-motor-using-feedback-with-encoder-
and-arduino-uno/1280945
https://nevonprojects.com/arduino-pid-
based-dc-motor-position-control-system/