DC Motor Speed Control with PID
Back to project overview
In this project it is aimed to speed control a
standard Pololu DC motor with encoder using
software based PID controller
@ 02a Enainogiu
Description Files! Components? Logs? Instructions® Discussion ®
«Back to project details
SORT BY:
Oldest ¥
Fundementals
05/23/2016 at 12:41 + 0 comments
Standard DC motors without encoders have just two cables (terminals) to drive the motor. These
terminals are used for creating a voltage difference which is directly related to motor speed. The
shaft rotation speed is increased if the voltage difference between terminals are increased or
vice versa.
By inverting the applied voltage to these connections, itis possible to drive the motor in the
opposite direction, But unfortunately, the relation between the applied voltage and the speed is
not linear and the output of the shaft rotation is unpredictable due to various reasons such as a
torque applied to the shaft. In such case shaft rotation speed is reduced even though the voltage
stays same. So its clear that the speed of the motor doesn't only depend on the voltage but also
to the environmental conditions,
puhe
If speed control of a DC motor is desired, another sensor called encoder is required to g}
actual position and thereby speed of the shaft rotation. These information is then used to
compare and if necessary correct th:
speed of the de motor
Pololu DC motor with Encoder that i've used in this project is as shown in the picture below.
Full Nome: 30:1 Metal Gearmotor 37Dx52L mm with 64 CPR Encoder
(0:1 and a shaft with a diameter of 37 mm.
d to the motor shaft is 64 Cycles Per Revolution (CPR).
und the output of the encoder counts up to 64.
shaftis different than th shaft and as
1 these shafts is 30:1. So if motor shaft turns 30
elation is considered; the cycles per revolution of the
This motor has a metal gearbox with a ratio
Resolutl the encoder that is assemb
This means that if the motor shaft turn:
But itis important to notice that th
the ratio of rotation betw
mentioned befor
times, gearbox shaft turns just 1 time. If this
gearbox shaft can be calculated with the following formula:
and it is equal to 30 * 64 = 1920 CPR.
The gearbox output resolution (1920 CPR) is of great importance in this project because itis the
only feedback we get from the DC motor and using this feedback we shall acquire position and
speed variables to be used in PID control which will be explained in detail later:
Just like almost all complex projects, we should always prefer going through the project step by
step to prevent any unknown behaviour output from the system. For this project, the steps 1am
planning to follow are listed below.
Encoder
DC Motor + Motor Driver + Enc:
PID + DC Motor + Motor Driver + Ence
erStep 1 - Encoder
(05/23/2016 at 12:43 + 0 comments
In this step, itis aimed to co!
nd check if it is functioning pro}
Duld 1920
only one turr
motor by hand.
Luckily, pin diagram of the en¢ y ’ min the tabl
c unctio
Ri 1 motor terminal
Black > the other motor terminal
er encoder GND
Bh encoder Vec (3.5 - 20 V)
Yellow ncoder A output
White ncoder B output
Motor power pins w sed ut the other four pins are necesse
ncoder to function properly. Encoder GND and Vcc pins are used to
ncoder A and B pins a > get fi ck from the encoder. Greer
> Arc in anc
>utput whic
mportant to selec
Ifthe interrug
e pil
dbefirst and continue, After a
at that moment and g
4
ratever it's
Boare Digital Pins Usable For Inte’
Uno, Nano, Mini, other 328-based 2,3
Mega, Mega2560, MegaA\
Micro, L
MKR1000 Rev
so the pinsi
In this proje
these | preferred 18 and 19, Sol connected encoder output A
digital pin 19.
Pin connections of the encode
> terminal connections a entionally le
igure
motor power
motor power
encoder ND
encoder Vee
tncoder A output
ig encoder B Guta
Encoder
fritzingony 4
AboutUs ContactHackadayio Give Feedback Terms of Use PrivacyPolicy_ Hackaday API
) 2017 Hackaday