You are on page 1of 6

Control and Computing Laboratory

(EE615) Report

Sandeep Kumar S
193070019
Group 6

Department of Electrical Engineering


Indian Institute of Technology Bombay
Experiment No:1
DC Motor Position Control via Arduino Mega

AIM:
a) Design and implement an embedded (PID) feedback controller using Arduino Mega

b) Design and implement a motor driver circuit and interface the Arduino Mega with this

circuit

c) Achieve the following design specifications for the DC motor position control: For a step
command of 180 degrees, the DC motor should satisfy less than 0.5 sec rise time, 1 sec
settling time and 10% overshoot.

Components Used :
DC motor, Arduino Mega 256, Motor Driver IC: L293D,
Regulated Power supply (5V and 12V)
Peripherals :
Male-Male Jumpers, Connecting wires, USB adapter
Control Algorithm :
Digital PID controller
OBJECTIVE :
1) Record the initial position of DC motor using the value read through Potentiometer of
DC motor and define the set point(destination) (corresponds to the position 180 degree
+ initial position)

2) In case the DC motor overshoots the target position, the DC motor has to be rotated in
opposite direction and the motor has to be stabilized at its set point within 1sec.

3) use proper Kp, Ki, Kd gain to satisfy the constraints of 0.5sec rise time, 1sec settling time
and Max 10% overshoot.
The position of DC motor is available through Potentiometer of the motor and it is read through
the Arduino in the range 0-1023.
The read value is converted to a Voltage between 0-5V and the control action is performed on
setpoint voltage(static) and the voltage corresponding to motor position.

Challenges faced :
1) Erroneous reading and Control while using the analog Pin 13(PWM) and Pin 12 of
Arduino :
DC motor used to rotate 180 degrees and then settled back to its initial position and the
voltage displayed on serial monitor did not correspond to the final settled value.
After changing the pin configuration to 8 and 9, the issue was solved.
2) Higher rise time :
In order to improve the rise time, the code was modified , not to have a control action
till a predefined error is reached. Till the predefined error is reached the motor is run
with full speed (Control Voltage : 12V).
3) Integral error not getting accumulated:
Whenever the program reaches the end of execution and restarts the execution of code
defined in the Void loop, the variables are reinitialized to zero and hence the integral
error was not getting added at each cycle based on the past error.
Code modified to execute the Void loop only once.
Start

Check the full scale output provided by Potentiometer of DC motor

Create a mapping function which maps the motor position to a voltage 

set point defined as voltage corresponding to 180 deg rotation 

Define Kp, Ki, Kd values to control the motor

error = Setpoint_voltage -- Voltage

YES
Calculate  C>256 C=255
C = kp*e + ki*e +kd*e

analogWrite(9,255)   
 analogWrite(8,0)    

NO

YES YES
error > 1 or analogWrite(8,255)   
error > 0
error < -1  analogWrite(9,0)    

NO

error <=1 and YES analogWrite(8,C)   


error >0  analogWrite(9,0)    

NO

YES
error >=-1 and analogWrite(8,0)   
error <0  analogWrite(9,c)    

NO
Check if constraints
NO
of 0.5sec rise time, 1sec settling
NO error >-0.02 and time and Max 10% overshoot are
error <0.02 met

YES
YES
Motor Stops rotating, the program execution
finishes
STOP
RESULTS:
We printed the values of time and reading of POT in the serial monitor.
From those values we calculated rise time, settling time and % overshoot.
kp = 15;
ki = 5;
kd = 2;

Rise time (10% to 90% of peak value) = 0.39 sec


Settling time (time taken to settle between + or -2% of steady state value) = 0.74 sec
Overshoot =(14/180)*100= 7.7 %

200
180
160
140
POSITION (degrees)

120
100
80
60
40
20
0
0 200 400 600 800 1000 1200 1400 1600

Time (milli seconds)

Inference :
The position of DC motor can be controlled precisely using the PID controller.
Too high Control gains of Kp and Ki will saturate the control action (Max value 255).

You might also like