Spped Control of DC Motor Using Arduino
-
Upload
rohit-kaushik -
Category
Documents
-
view
216 -
download
2
Transcript of Spped Control of DC Motor Using Arduino
Objective: Speed Control of DC Motor using Arduino PI controller
Contents: Design Problem Description Implementation System Bring up Code Result
Design problem : a) To actuate the DC motorb) To control the speed of rotation using a switch.
Description:DC drives are less complex with a single power conversion from AC to DC. Again the speed torque characteristics of DC motors are much more superior to that of AC motors. A DC motors provide excellent control of speed for acceleration and deceleration. DC drives are normally less expensive for most horsepower ratings. DC motors have a long tradition of use as adjustable speed machines and a wide range of options have evolved for this purpose. In these applications, the motor should be precisely controlled to give the desired performance.
Block diagram of speed control of DC motor
Because the Arduino can't handle more than 40ma of current, you must have an external power source to power it. This circuit enables you to use a motor that is too big for the Arduino to handle, control direction of the motor with a relay, and control the speed of the motor with a potentiometer.
P I Controller
Digital form of PI controller is
where the error e(t), the difference between command and plant output, is the controller input, and the control variable u(t) is the controller output. The 3 parameters are K (the proportional gain), Ti(integral time), and Td (derivative time).
Performing Z transform
Converting back to discrete time form
Arduino code:
int sensorPin1 = A0;int sensorPin2 = A1;int pwm_pin = 7;double ref = 0;double feed = 0;double Kp = 20;double Ki =0.002;double Kd = 0;double e_present = 0;double e_previous = 0;double Ts = 0.01;
//double conv_factor1=1;//(5/1023);//double conv_factor2=1;//(4.06/1023);double I = 0;double I0 = 0;double d = 0;double y = 0;double y_act = 0;double d1;
void setup(){ Serial.begin(115200); pinMode(pwm_pin, OUTPUT);}
void loop(){ //(5/1023) //Reading Analog Values ref = 0.00488 * analogRead(sensorPin1); feed = 0.00391 * analogRead(sensorPin2);
//PID BLOCK e_present = ref - feed; I = 0.5 * Ts * (e_previous + e_present) + I0; y = Kp * e_present + Ki * I + Kd * (e_present - e_previous) / Ts; I0 = I; e_previous = e_present;
//Saturation and corrosponding duty cycle if (y >= 0 && y <= 100) { y_act = y; } else if(y>100) { y_act = 100; } else { y_act=0;
} d = y_act /100; d1=d; digitalWrite(pwm_pin, HIGH); delay(d1 * 10); digitalWrite(pwm_pin, LOW); delay((1 - d1) * 10); Serial.println(d1, 5);
}
IMPLEMENTATION & RESULTS:
1.Set Up
2. Speed feedback Voltage