Pic Pid
Pic Pid
Iraq
Abstract — The Proportional Integral Derivative (PID) controller processing applications[4]. If the PID parameters are tuned
is the most common form of feedback used in the control systems. properly they provide robust and reliable performance for most
It can be used for various Industrial functions. One of the
applications used here is to control the position of the DC motor. systems. In this paper, PID controller is used to control the
Controlling the position of a DC motor is very significant in that position of DC Motor. As PID controllers require mathematical
any small change can lead to instability of the closed loop system. models of the system to be controlled, hence mathematical
Conventional PID controllers are used to control the DC motor for models of DC motor is derived[5, 6].
various industrial processes for many years due to their simplicity
in operation. PID controllers require mathematical models to
control the plant of different control processing applications. This DC Motor’s Model
paper seeks to focus on controlling the position of DC motors using
PID controller made by PIC microcontroller. Consequently DC Motor plays a crucial role in research, industry and
hardware has been designed and produced which in practice laboratory experiments because of their low cost[6, 7]. The
worked well.
position of the motor can be controlled by three methods
Keywords- PID Controller, PIC Microcontroller, Position namely terminal voltage control method, armature rheostat
Controlling. control method and flux control method. Here in this paper
terminal voltage control method is employed. A control system
is an interconnection of components forming a system
INTRODUCTION
configuration that will provide a desired system response[2, 8].
DC machine is a highly versatile and flexible machine. It can
satisfy the demands of load requiring high starting, accelerating
and retarding torques[1]. A DC machine is also easily adaptable
for drives with range of speed control and fast reversal. They
are widely used in industrial applications. The DC motors are
used in rolling mills, in traction and in overhead cranes[2]. They
are also used in many control applications as actuators and as
speed or position sensors. In such applications, as that of
position sensors and robotics, drives performance must
precisely follow the desired performance. A number of control
schemes such as proportional (P), proportional integral (PI),
proportional derivative integral (PID), PWM, adaptive and
fuzzy logic controller (FLCs) are used for control of speed and Figure 1: Components of DC Motor
Position of DC motors. The proposed controller system uses the
PID control scheme for position control of DC motor[1, 3, 4]. In armature voltage control scheme for DC motors, voltage
PID controllers due to their simplicity are widely used in applied to armature is varied without varying the voltage
industrial applications for speed and position control of DC applied to the field[1, 4]. Equivalent model of DC motor is
motor for several years. Due to its simplicity, clear shown in following figure (Figure 2).
functionality, applicability and ease of use offered, PID
controllers are used in more than 95% of the industrial control
1st International Conference on Engineering and Innovative Technology, SU-ICEIT 2016, April 12-14, 2016, Salahaddin University-Erbil, Kurdistan, Iraq
𝑑𝑖𝑎 (𝑡)
𝑣𝑎 = 𝑅𝑎 𝑖𝑎 (𝑡) + 𝐿𝑎 + 𝐾𝑏 . 𝑤(𝑡) (5)
𝑑𝑡
𝑑𝑤(𝑡)
𝐾𝑡 . 𝑖𝑎 (𝑡) = 𝐽𝑚 + 𝐵𝑚 . 𝑤 (𝑡) (6)
𝑑𝑡
EASE OF USE
Unlike a simple proportional control algorithm, the PID A. HARDWARE
controller is able to manipulate the input processes based on the First, we describe the hardware of system and its features.
history and the rate of change of the signal. This gives a more This project will require following hardware:
accurate and stable control method [1, 5, 11]. The basic idea is
a. PIC16F876A
that the controller reads the system state by a sensor. Then it
b. PR24 Printed Circuit Board (PCB)
subtracts the measurement from a desired reference to generate
c. LCD (2x16 character)
the error value. The error will be managed in three ways, to: 1.
d. L293D Driver
Handle the present, through the proportional term, 2. Recover
e. DC Motor SPG20-50K
from the past, using the integral term, 3. Anticipate the future,
f. 22mm Precision Wire wound potentiometer
through the derivative term. In this paper we will use a basic
g. Related electronic components
open loop system and a closed loop system with PID system to
control the DC motor [8].
Interface LCD (2x 16 Characters) with PIC16F877A
To use the LCD display, users have to solder 16 pin header pin
PIC Microcontroller (PIC16F876A)
to the LCD display. LCD used in this project is JHD162A.
This powerful (200 nanosecond instruction execution) easy-to- Figure 5 is a 2*16 character LCD and table 1 is all PIN and
program (only 35 single word instructions) CMOS FLASH- connectors.
based 8-bit microcontroller packs powerful Microchips, PIC®
architecture into an 28-pin package and is upwards compatible Table 1: LCD PIN Fuction and Connection
with the PIC16C5X, PIC12CXXX and PIC16C7X devices.[12]
Pin Name Pin Function Connection
Feature of the device:
256 bytes of EEPROM data memory Self programming 1 VSS Ground GND
ICD (In Circuit Debugging function) 2 VCC Positive Supply 5V
2 Comparators
5 channels of 10-bit Analog-to-Digital (A/D) converter 3 VEE Brightness -
capture/compare/PWM functions 4 RS Select Register RB7
The synchronous serial port can be configured as either 3-wire
Serial Peripheral Interface (SPI™) or the 2-wire Inter-
5 R/W Select GND
Integrated Circuit (I²C™) bus Read/Write
Universal Asynchronous Receiver Transmitter (USART)[13]
6 E Start Read/Write RB6
All of these features make it ideal for more advanced level A/D 7 DB0 Data Bus PIN RB5
applications in automotive, industrial, appliances and consumer
8 DB1 Data Bus PIN RB4
applications. Figure 4 shows the PIC16F876A.
9 DB2 Data Bus PIN RB3
10 DB3 Data Bus PIN RB2
11 DB4 Data Bus PIN RB1
12 DB5 Data Bus PIN RC5
13 DB6 Data Bus PIN RC4
14 DB7 Data Bus PIN RC3
15 LED+ Backlight + 5V
16 LED- Backlight - GND
Figure 5: 2*16 character LCD One I/O pin (RB0) is needed for one push button as input (or
interrupt) of PIC microcontroller. Another push button is used
for RESET and connected to MCLR pin. The connections are
shown in Figure 8. The pins should be pulling up to 5V using a
Figure 6 shows the connection of LCD display. LCD
resistor (with value range 1K-10K) and this configuration will
connection pin and function of each pin is shown:
result an active-low input. When the button is being pressed,
reading of I/O pin will be in logic 0, while when the button is
not pressed, reading of that I/O pin will be logic 1.
Four analog I/O pins are needed for P, I, D and Angle value
adjuster. RA0 is responsible for Angle value, RA2 is
responsible for P value, RA3 is responsible for I value, and RA5
is responsible for D value. Figure 11 demonstrates the
connection.
//main function
TRISB =0b00000001;
TRISC =0b00000000;
Figure 15: Designed Hardware
TRISA =0b11111111;
send_config (0b00000010);
send_config (0b00000110);
send_config (0b00001100);
send_config (0b00111000);
//LCD display
lcd_clr();
lcd_goto(0);
send_string("ANGLE=");
lcd_goto (11);
send_string("P=");
lcd_goto(20);
send_string("I=");
lcd_goto(26);
kp=ai_read(2); REFERENCES
lcd_goto (13); 1. Xue, D., C. Zhao, and Y. Chen. Fractional order PID
control of a DC-motor with elastic shaft: a case study.
send_dec(kp,3); in Proceedings of American control conference. 2006.
2. Saranya, M. and D. Pamela, A real time IMC tuned
PID controller for DC motor. International Journal of
ki=ai_read(3);
Recent Technology and Engineering, 2012. 1(1): p.
lcd_goto(22); 65-70.
3. Kaya, I., IMC based automatic tuning method for PID
send_dec(ki,3); controllers in a Smith predictor configuration.
Computers & chemical engineering, 2004. 28(3): p.
kd=ai_read(4); 281-290.
lcd_goto(28);
4. Inaba, H., et al., Control apparatus for DC motor.
1978, Google Patents.
send_dec(kd,3); 5. Leonhard, W., Control of a Separately Excited DC
Machine. Control of Electrical Drives, 2001: p. 77-96.
6. Yeung, K. and J. Huang, Development of a remote-
while (!SW1); access laboratory: a dc motor control experiment.
Computers in Industry, 2003. 52(3): p. 305-311.
7. Naveenkumar, R. and D.P. Krishna, Low Cost Data
RESULTS Acquisition and Control using Arduino Prototyping
Platform and LabVIEW. International Journal of
The objective of this experiment is to design a closed-loop
control system that regulates the position of the DC motor. The Science and Research, 2013. 2(2): p. 366-369.
mathematical model of a DC motor is reviewed and its physical 8. Rubaai, A. and R. Kotaru, Online identification and
parameters are identified. Once the model is verified, it is used control of a DC motor using learning adaptation of
to design a proportional-integral-derivative (PID) controller. neural networks. Industry Applications, IEEE
Transactions on, 2000. 36(3): p. 935-942.
In this paper PID controller is designed for position control 9. Zouari, F., K.B. Saad, and M. Benrejeb, Adaptive
of DC motor. According to our analysis it is clear that PID is a Internal Model Control of a DC Motor Drive System
simple controller based on the mathematical model of the Using Dynamic Neural Network. Journal of Software
system. It successfully overcomes the drawback of proportional- Engineering and Applications, 2012. 5(03): p. 168.
derivative (PD) controller of steady-state error as steady-state
10. Rao, A.P.C., Y. Obulesu, and C.S. Babu, Robust
error is zero in PID controllers. However while reducing steady-
state error to zero, an overshoot is observed. Overshoot can be Internal Model Control Strategy based PID Controller
reduced by increasing the derivative gain but the rise time also for BLDCM. International Journal of Engineering
increases as a consequence. Hence, there is a compromise Science and Technology, 2010. 2(11): p. 6801-6811.
between overshoot and the speed of response i.e. rise time which 11. Petráš, I., Fractional-order feedback control of a DC
means we have to sacrifice one for improving another. Overall, motor. Journal of Electrical Engineering, 2009. 60(3):
PID controller gives best speed response of all the linear p. 117-128.
controllers of its class. 12. Mazidi, M.A., et al., Pic microcontroller and
embedded systems. 2005: Prentice-Hall, Inc.
Typical applications of this hardware: 13. Peatman, J.B., Design with PIC microcontrollers.
Compressors and fans in refrigerators 1997: Simon & Schuster Trade.
Fans in cooker hoods
Drums and pumps in washing machines
Robotic Arms
Surgery Robots
Fan controller
Medical Application (Electrocauter, ...)