0% found this document useful (0 votes)
15 views

Lab 5 Control

Uploaded by

Osama Gaming
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Lab 5 Control

Uploaded by

Osama Gaming
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

LAB NO.

5
PI SPEED CONTROL OF DC MOTOR

OBJECTIVES: -
Implement PI (Proportional, Integral) control for DC motor to meet the reference or input speed
adjusted by
1. Set in the program,
2. Set through potentiometer.
APPARATUS: -
• Arduino board
• Laptop
• DC Encoder Motor
• Motor Driver L298N
PI CONTROL: -

The two-term controller is called a PI controller because it contains a


proportional and an integral, and a term represented by KP and KI respectively and these are
gains of the controller. The transfer function and equation of the controller can be represented
as below;

Block diagram of PI controller can be given by;

Figure Error! No text of specified style in document..1: PI Controller Block Diagram

As we can see it is a close loop feedback system and the output of the system
us compared with the input and then the error is processed through a controller. There are two
blocks for the controller in PI control. One is Proportional and the other is Integral.

The purpose of the proportional gain is straight forward and contains K P which
is proportional gain which will be multiplied with the error to amplify the magnitude of the
error and then applied to the system. Practically it is used to achieve the desired output response
or to overcome the transient error. With the increase of the proportional gain the amplitude of
the output response of the system is also increased for a given error.

The integral term contains the integral of error with respect to time and
multiplied with the integral gain K I. practically this parameter is used to overcome the steady
state error. Using the proportional gain, the value of the desired output response some ties can
never be achieved thus to minimize the steady state error and to achieve the desired response
this parameter is used int controller.

At the end both the terms i.e., proportional and integral are added using an adder
and then applied to the system. Thus, the transient error is overcome using proportional term
and the steady state error is overcome using integral term. Following flowchart is basic
algorithm to control the speed of the motor using a controller.

PI CONTROL FOR DC MOTOR: -

Now the repose of the Dc motor in close loop can be obtained. Here the target
is to give a specific speed and let the control to adjust the duty cycle so that the specified speed
reaches. For that purpose, the speed of the motor should be feedback to sense the current speed
and take some action to achieve the given specified speed.
• Connect Arduino with the PC through data cable.
• Connect 12V to the power input of encoder labeled 12V and ground of supply to ground
of driver.
• Connect ground of Arduino with the ground of driver or supply also.
• Connect the motor at the output of driver.
• Now apply logic high on IN1 and low at IN2, using Arduino and MATLAB.
• Then, create and encoder object and specify the pins on which encoder is connected
here in this case it should be connected to pin 2 and 3 of Arduino uno.
• Now input the speed of the motor which is desired.
• Apply a PWM wave to the motor so that motor starts.
• In a loop read the speed of the motor using readSpeed() function.
• Compute the error in the loop.
• Use equation of proportional controller and multiply KP with error and use this to apply
PWM.
• Use equation of integral controller and multiply integral of error with K I.
• To calculate the integral of error find cumulative error and multiply it with time interval
for one loop cycle.
• The response of the motor in close loop in shown below.

Figure 5.1: Repones of Motor with PI control, input speed = 310rpm


Figure 5.2: PI Control Output Response for input speed set though potentiometer

TASKS: -

a) Plot Step Response and Error for with PI control such that steady state error is minimum
(fix P gain and adjust I gain, fixed input speed),
Result:

b) Plot Step Response and Error for with PI control such that steady state error is minimum
(fix I gain and adjust P gain, fixed input speed),
c) Plot Step Response and Error for with PI control such that steady state error is minimum
(set PI gain from parts (a, b) for variable input speeds).

PROGRAM CHANGES
Make following changes in the program used in Lab 4:
For Task A & B
1) introduce gain ki for integral control, 2) define integral function using a variable (sum the
current and previous values of error) in the main loop, 3) store this error_sum in a variable and
make this error function of pwm (multiply error_sum with gain ki and add in the ‘kp*error’
used in previous lab.
For Task C
1) Along with above steps, read the analogue voltage at A 0 pin, 2) translate this voltage in
term of motor speed (inputSpeed = (voltage/5)*maxSpeed), 3) adjust the input speed 70, 80
and 90% of max speed and take step responses in the same plot.
Note: If you introduce any new variable, initialise at first with zero value.

Conclusion:
In conclusion, implementing PI (Proportional, Integral) control for a DC motor can improve
the motor's response and accuracy to meet a desired reference or input speed. The PI control
algorithm combines proportional control, which adjusts the motor's voltage based on the
difference between the desired speed and actual speed, and integral control, which adjusts the
voltage based on the accumulated error over time.

You might also like