dc motor speed control by pic based digital pid controller

14
DC-motor speed control by PIC-based digital PID-controller Yoshihiko Takase and George Ibrahim Department of Mechatronics Engineering, Faculty of Mechanical and Electrical Engineering, Tishreen University, Lattakia, Syria Abstract DC motor speed control was carried out by preparing a PIC based PID controller. The H-bridge motor driver was driven by the sign/magnitude PWM signal at frequency of 240Hz. The step responses of the motor speed (ω) were systematically measured to obtain optimum PID parameters. Practical steps to determine the parameters were, first to estimate the values by the Ziegler-Nichols method in medium speed region and second to tune the values in detail step by step. The PID controller exhibited notable improvements of the time constant at rising edge (e.g. 0.5 to 0.2 s) and excellent control performance to minimize the steady-state error (e.g. between -0.5 and 0.2 %) even the ω vs duty cycle curve was strongly nonlinear in discontinuous conduction mode of PWM at 240 Hz. 1 Introduction The practice project to understand the base of the process control plainly was planned for the student who studies the mechatronics engineering. The project consists of: 1. Characteristics of PIC PWM con- troller measured by USB based data acquisition system,[1] 2. Basic simulation of digital standard-PID- controller,[2] 3. DC-motor speed control by PIC-based digital PID-controller, 4. DC-motor simulation and verification of the result by experiment, 5. Locked anti-phase PWM PID-control of DC-motor speed, and 6. DC-motor position PID-control by simulation and experiment. This is the third item of the project. DC motor has a simple structure and is easy to control its speed. The simulation of it may also be relatively easy in the next step of the project. A proportional-integral-derivative controller (PID controller) is a common feedback loop component in industrial control systems. In the absence of knowledge of the underlying process, a PID controller is the best controller.[3],[4] Pulse-width modulation (PWM) is a very efficient way of providing intermediate amounts of electrical power between fully on and fully off to the motor. PWM works well with the microprocessor, which, because of its on/off nature, can easily set the needed duty cycle. Practically there are many items to utilize the PWM, for example microprocessor family, driver device (transistor, FET and their H-bridge IC), PWM frequency and operation mode (sign/magnitude PWM or locked anti-phase PWM,[5],[6] continuous or discontinuous conduction[7]). Although there are many articles which describe each principle of the motor control and simulation using commercial software, it is not easy to find an experimental procedure to perform loop tuning of the microprocessor based PID control to achieve optimum behavior of the motor speed. For example, the web site of University of Michigan is presenting many control tutorials.[8] Especially for education purpose of the present study, popular and not expensive devices are used such as microcontroller (PIC16 series[9]), small DC motor, popular H-bridge driver, I/O terminal for USB and popular PC. The purpose of the present study is to present an essential process to carry out the PID speed control of DC motor. The study process is to prepare hardware of PIC PWM controller, DC motor driver, frequency to voltage (f -v) converter, data acquisition system by using an analog I/O terminal for USB, to prepare software to perform PID control, to measure step response of the motor speed, to adjust the 1

Upload: akozy

Post on 13-Apr-2015

317 views

Category:

Documents


13 download

DESCRIPTION

DC-motor-speed-control-by-PIC-based-digital-PID-controller

TRANSCRIPT

Page 1: DC Motor Speed Control by PIC Based Digital PID Controller

DC-motor speed control by PIC-based digital PID-controller

Yoshihiko Takase and George Ibrahim

Department of Mechatronics Engineering, Faculty of Mechanical and Electrical Engineering, TishreenUniversity, Lattakia, Syria

Abstract

DC motor speed control was carried out by preparing a PIC based PID controller. The H-bridgemotor driver was driven by the sign/magnitude PWM signal at frequency of 240Hz. The stepresponses of the motor speed (ω) were systematically measured to obtain optimum PID parameters.Practical steps to determine the parameters were, first to estimate the values by the Ziegler-Nicholsmethod in medium speed region and second to tune the values in detail step by step. The PIDcontroller exhibited notable improvements of the time constant at rising edge (e.g. 0.5 to 0.2 s)and excellent control performance to minimize the steady-state error (e.g. between −0.5 and 0.2%)even the ω vs duty cycle curve was strongly nonlinear in discontinuous conduction mode of PWMat 240Hz.

1 IntroductionThe practice project to understand the base of the process control plainly was planned for the studentwho studies the mechatronics engineering. The project consists of: 1. Characteristics of PIC PWM con-troller measured by USB based data acquisition system,[1] 2. Basic simulation of digital standard-PID-controller,[2] 3. DC-motor speed control by PIC-based digital PID-controller, 4. DC-motor simulationand verification of the result by experiment, 5. Locked anti-phase PWM PID-control of DC-motor speed,and 6. DC-motor position PID-control by simulation and experiment.This is the third item of the project. DC motor has a simple structure and is easy to control its speed.

The simulation of it may also be relatively easy in the next step of the project.A proportional-integral-derivative controller (PID controller) is a common feedback loop component

in industrial control systems. In the absence of knowledge of the underlying process, a PID controller isthe best controller.[3],[4]Pulse-width modulation (PWM) is a very efficient way of providing intermediate amounts of electrical

power between fully on and fully off to the motor. PWM works well with the microprocessor, which,because of its on/off nature, can easily set the needed duty cycle. Practically there are many items toutilize the PWM, for example microprocessor family, driver device (transistor, FET and their H-bridgeIC), PWM frequency and operation mode (sign/magnitude PWM or locked anti-phase PWM,[5],[6]continuous or discontinuous conduction[7]).Although there are many articles which describe each principle of the motor control and simulation

using commercial software, it is not easy to find an experimental procedure to perform loop tuning ofthe microprocessor based PID control to achieve optimum behavior of the motor speed. For example,the web site of University of Michigan is presenting many control tutorials.[8]Especially for education purpose of the present study, popular and not expensive devices are used such

as microcontroller (PIC16 series[9]), small DC motor, popular H-bridge driver, I/O terminal for USBand popular PC.The purpose of the present study is to present an essential process to carry out the PID speed control

of DC motor. The study process is to prepare hardware of PIC PWM controller, DC motor driver,frequency to voltage (f -v) converter, data acquisition system by using an analog I/O terminal for USB,to prepare software to perform PID control, to measure step response of the motor speed, to adjust the

1

Page 2: DC Motor Speed Control by PIC Based Digital PID Controller

PID parameters to the optimum values for the desired control response, and to evaluate the performanceof the PID controller under a popular operating condition using n-p-n transistor H-bridge drive andsign/magnitude PWM signal.

2 PIC based DC motor PID controller hardwareHardware consists of PIC16F88 controller board, I/O board with H-bridge motor driver, f -v converter,high-precision analog I/O terminal, RS-232C terminal (popular PC) and DC motor.DC motor of a type of DME34SMA with revolution sensor, product of Japan servo Co., Ltd. was used.

Standard specification of the motor is that power supply is 12V, output is 1.3W and current is 0.2A. Therevolution sensor is a magnetic pulse generator to provide rectangular pulse output (12 pulses/revolutionand dutycycle = 50± 20%).[10]The PIC16F88 controller board was connected to both the PC through the USB/Serial converter and

the motor driver.The output pulses of the revolution sensor was converted to analog signal by the f -v converter and

supplied to the A/D converter (10 bit) of the PIC16F88. Circuits of the PIC16F88 controller board,RS-232 to/from TTL USART, and the I/O board with H-bridge motor driver are essentially the sameas ones reported previously.[1]The voltage output of the f -v converter was captured and stored to the PC by using a high-precision

analog I/O terminal for USB 2.0, AIO-160802AY-USB, product of CONTEC Co., Ltd. It has analoginput (16 bit, 8 ch) and analog output (16 bit, 2 ch). The maximum conversion speed is 10µs.[11] Graphswere plotted by using the Excel.The block diagram of the experimental setup is shown in Figure 1.

PIC16F88

Controller

Board with A/D

Power Supply

(SW type 5 V)

USB/RS-232

Converter

Power Supply

(SW type 12 V)

Freq. to Volt.

Converter

Motor with

Rev. SensorGeneral Purpose

I/O Board

with Motor Driver

PC with USB

Interfaces

A/D Converter

with USB

Interface

M PG

Fig. 1 Block diagram of the experimental setup.

3 Standard PID controller programFor a digital implementation of a PID controller, the standard form of the PID controller has to bediscretised. The discretised PID controller is expressed, as well as the previous study,[2] as follows:

∆MVn = KP

(en − en−1 +

∆t

TIen +

TD

∆t(en − 2en−1 + en−2)

), (1)

MVn = MVn−1 +∆MVn, (2)

2

Page 3: DC Motor Speed Control by PIC Based Digital PID Controller

where MVn is the present manipulated variable, MVn−1 the previous value of MVn, en the presenterror, en−1 the previous value of en, en−2 the previous value of en−1, KP the proportional gain, TI theintegral time, and TD the derivative time, ∆t the sampling time and n the sampling number correspondingthe present time.The standard PID velocity-algorithm was implemented by the C while loop as follows. The CCS C

compiler was used to develop the program.

MVn_1 = en_1 = en_2 = 0.0;

dt = 0.0041;

// Processing loop of the standard PID controller of velocity algorithm

while (TRUE) {

// Error signal = setpoint - process variable

e = SP - PV;

// Equation (1)

dMV = Kp*(e-en_1) + Kp*DT/Ti*e + Kp*Td/DT*(e-2*en_1+en_2);

// Equation (2)

MV = MVn_1 + dMV;

// Process variable from measurement

PV = inport();

// Update previous value to current value

MVn_1 = MV;

en_2 = en_1;

en_1 = e;

}

The above essential part of the program is the same as the previous one written for Windows operatingsystem.[2] The executable program, however, has some difference between for Windows and for PIC,which is practically important. PIC16 series does not have hardware for number multiplication andfloating point number processing, which are always included in CPUs used for Windows operating system.Program memory size of the PIC16F88 is 7168 bytes (internal flash memory) which is much smaller thanexternal memory size of Windows system. In conclusion, floating point number was used only forparameters KP , TI and TD. Other variables such as setpoint, process variable and error signal weredefined as singed long integer. The executable program occupied about 95% of the program memorysize. In the present experiment the sampling time ∆t was set to inverse value of the PWM frequency(e.g. 4.1ms for 240Hz).

4 Experimental

4.1 Speed vs PWM duty cycle characteristics

First, it is necessary to know the relation between DC-motor angular-speed (ω) and PWM duty cycle.The ω vs duty cycle characteristics were measured for two kinds of DC motors and two kinds of motordrivers. PWM frequency dependence was also measured.Figure 2 shows the ω vs duty cycle characteristic. The PWM frequency was 61Hz. Power supply of

the motor was 12V. The characteristic showed strong nonlinearity, then additional measurement wascarried out for DC motor of a different product (TG-47C, Tsukasa Denko Co., Ltd.) to make sure of thecharacteristic.Figure 3 shows the ω vs duty cycle characteristic for two kinds of motor drivers, n-channel MOS FET

driver (IRF830) and n-p-n transistor H-bridge driver IC (L298). PWM frequency was 61Hz. Powersupply of the motor was 12V.Figure 4 shows the ω vs duty cycle characteristics for fPWM= 0.061, 0.240, 0.980, 3.91, 7.81 and

3

Page 4: DC Motor Speed Control by PIC Based Digital PID Controller

DC-Motor Speed vs Duty Cycle Characteristic

0

1000

2000

3000

4000

5000

0 20 40 60 80 100Duty cycle [%]

Spe

ed [r

pm]

DME34S TG-47C

Fig. 2 The ω vs duty cycle characteristic for two kinds of DC motors, DME34S and TG-47C.fPWM = 61Hz. Power supply of the motor was 12V.

DC-Motor Speed vs Duty Cycle Characteristic

0

1000

2000

3000

4000

5000

6000

0 20 40 60 80 100Duty cycle [%]

Spe

ed [r

pm]

IRF830 L298

Fig. 3 The ω vs duty cycle characteristic for two kinds of motor drivers, MOS FET (IRF830) andn-p-n transistor H-bridge IC (L298). The PWM frequency was 61Hz. Power supply of the motorwas 12V.

15.6 kHz. The driver device was L298.The ω vs duty cycle characteristics shown in Figures 2 - 4 showed strong nonlinear relations, then the

measurement was carried out twice. The characteristic was not unstable but reproducible. In addition,DC power supply vs ω characteristic of the same motor was also measured using DC power supply insteadof the PWM signal. The characteristic showed linear relation as shown in Figure 5. Both characteristicsin Figures 4 and 5 show that there is a dead region where ω stays zero. The threshold value of the deadregion strongly depends on the PWM frequency.Figure 6 shows the output voltage vs ω characteristic of the f -v converter. The linearity is excellent.

The straight line is expressed by the equation

VOUT = 0.934ω + 5.0, (3)

where VOUT is the output voltage in mV unit of the f -v converter and ω is the angular speed in rpmunit.Figure 7 shows the output voltage vs power voltage characteristic of the f -v converter. The linearity is

excellent when the power voltage is equal to or larger than 5V. In the present experiment, power voltageof 5V was used for compatibility with the A/D converter of the PIC.

4

Page 5: DC Motor Speed Control by PIC Based Digital PID Controller

DC-Motor Speed vs Duty Cycle Characteristic

0

500

1000

1500

2000

2500

3000

3500

4000

4500

0 20 40 60 80 100Duty cycle [%]

Spe

ed [r

pm]

61 Hz

240 Hz

980 Hz

3.91 kHz

7.81 kHz

15.6 kHz

Fig. 4 The ω vs duty cycle characteristic for fPWM= 0.061, 0.240, 0.980, 3.91, 7.81 and 15.6 kHz.Motor driver was n-p-n transistor H-bridge IC (L298). Power supply of the motor was 12V.

DC-Motor Speed vs Power Voltage Characteristic

y = 385.13x - 717.81

0

500

1000

1500

2000

2500

3000

3500

4000

4500

0 5 10 15Power voltage [V]

Spe

ed [r

pm]

Fig. 5 The ω vs DC power voltage characteristic of the motor.

Output Voltage vs Speed of F-V Converter

y = 0.9341x + 5.0212

0

500

1000

1500

2000

2500

3000

3500

4000

0 1000 2000 3000 4000Speed [rpm]

Out

put v

olta

ge [m

V]

Fig. 6 Output voltage vs ω characteristic of the f -v converter.

5

Page 6: DC Motor Speed Control by PIC Based Digital PID Controller

Output Voltage vs Power Voltage of F-VConverter

y = 0.5435x - 0.1199

0

1

2

3

4

5

6

7

8

9

0 2 4 6 8 10 12 14 16

Power voltage [V]

Out

put v

olta

ge [V

]

Fig. 7 Output voltage vs power voltage characteristic of the f -v converter.

4.2 Open-loop step-response of speed

Figure 8 shows the open loop step responses of ω. The duty cycle was changed from 0% to 12, 17, 25,50, 75 and 100%. The envelope of the step PWM-excitation is referred to as Vstep in the figure. ThePWM frequency was 240Hz on which the dead region was comparatively small as seen in Figure 4.

Open-Loop Step Response of DC-Motor Speed

0

500

1000

1500

2000

2500

3000

3500

4000

4500

0 2 4 6 8 10Time [s]

Spee

d [rp

m]

Vstep

Duty= 12%

Duty= 17%

Duty= 25%

Duty= 50%

Duty= 75%

Duty=100%

Fig. 8 Open-loop step response of ω with dutycycle =12, 17, 25, 50, 75 and 100%. fPWM = 240Hz.

4.3 Closed-loop step-response of speed under the P control

Closed loop step response of ω under the proportional (P) control was examined by changing KP andsetting integral and derivative contributions zero. Step responses of ω are shown in Figure 9 for KP=1,2, 4, 6, 10 and 50, and fPWM=240Hz. The setpoint started from 659 rpm (SP=12) and rose to 2666 rpm(SP=511). The high level value continued for 5 sec then fell back to 659 rpm. The middle two thin linesindicate these setpoints.

6

Page 7: DC Motor Speed Control by PIC Based Digital PID Controller

P-Controller Step Response of DC-Motor Speed

0

500

1000

1500

2000

2500

3000

3500

0 2 4 6 8 10Time [s]

Spe

ed [r

pm]

Vstep

Kp=1.0

Kp=2.0

Kp=4.0

Kp=6.0

Kp=10

Kp=50

659 rpm

2666 rpm

Fig. 9 P-controller step response of ω with KP = 1, 2, 4, 6, 10 and 50. fPWM = 240Hz.

4.4 Closed loop step response of speed under the PI control

Effect of KP on the step response of ω under the PI control was examined by changing KP and settingTI constant and TD zero. Step responses of ω are shown in Figure 10 for KP = 0.6, 0.8, 1.4, 1.8 and 2.6.fPWM = 240Hz. No control curve (No ctrl) is also shown. The value of TI was set to 0.3.

PI-Controller Step Response of DC-Motor Speed

0

500

1000

1500

2000

2500

3000

3500

0 2 4 6 8 10Time [s]

Spe

ed [r

pm]

Vstep

No ctrl

Kp=0.6

Kp=0.8

Kp=1.4

Kp=1.8

Kp=2.6

659 rpm

2666 rpm

Fig. 10 PI-controller step response of ω with KP = 0.6, 0.8, 1.4, 1.8 and 2.6. TI = 0.3. fPWM = 240Hz.

Effect of TI on the step response of ω under the PI control was examined by changing TI and settingKP constant and TD zero. Step responses of ω are shown in Figure 11 for TI = 0.8, 0.5, 0.3, 0.2 and 0.1.fPWM = 240Hz. No control curve (No ctrl) is also shown. The value of KP was set to 1.4.

4.5 Closed loop step response of speed under the PID control

Effect of TD on the step response of ω under the PID control was examined by changing TD and settingKP and TI constant. Step responses of ω are shown in Figure 12 for TD = 0.00, 0.02, 0.06, 0.10 and0.14. fPWM = 240Hz. No control curve (No ctrl) is also shown. The values of KP and TI were set to1.4 and 0.3, respectively.

7

Page 8: DC Motor Speed Control by PIC Based Digital PID Controller

PI-Controller Step Response of DC-Motor Speed

0

500

1000

1500

2000

2500

3000

3500

0 2 4 6 8 10Time [s]

Spe

ed [r

pm]

Vstep

No ctrl

Ti=0.8

Ti=0.5

Ti=0.3

Ti=0.2

Ti=0.1

659 rpm

2666 rpm

Fig. 11 PI-controller step response of ω with TI = 0.8, 0.5, 0.3, 0.2 and 0.1. KP = 1.4. fPWM = 240Hz.

PID-Controller Step Response of DC-Motor Speed

0

500

1000

1500

2000

2500

3000

3500

0 2 4 6 8 10Time [s]

Spe

ed [r

pm]

Vstep

No ctrl

Td=0.00

Td=0.02

Td=0.06

Td=0.10

Td=0.14

659 rpm

2666 rpm

Fig. 12 PID-controller step response of ω with TI = 0.8, 0.5, 0.3, 0.2 and 0.1. KP = 1.4. fPWM = 240Hz.

5 DiscussionZiegler-Nichols ultimate sensitivity method is hard to execute, then the second method, Ziegler-Nicholsstep response method, is tried to determine the PID parameters. Figure 8 indicates that the timeconstant of the step response of ω changes as the duty cycle changes. The PID parameters for six curvesin Figure 8 are to be determined. Table 1 shows equations to determine PID parameters KP , TI and TD

proposed by Ziegler-Nichols.[3]

KP TI TD

P controller T/(KL)PI controller 0.9T/(KL) 3.3LPID controller 1.2T/(KL) 2.0L 0.5L

Table. 1 Ziegler-Nichols step response method to determine PID parameters KP , TI and TD. Tis the time constant, K is the equivalent gain and L is the dead time.

The steps to determine the PID parameters are as follows.[12]

8

Page 9: DC Motor Speed Control by PIC Based Digital PID Controller

A) Measurement of step response of motor speedB) Determination of time constant and dead timeC) Determination of equivalent gainD) Determination of PID parameters

A) Measurement of step response of motor speedFine time resolution (10ms interval) characteristics of the data in Figure 8 are shown in Figure 13.

Lines of tangent at the rising edge are determined as shown in the figure by thin lines. The equations ofthe lines of tangent are

ω = 1.55t− 632 for dutycycle = 12%,

ω = 2.19t− 742 for dutycycle = 17%,

ω = 3.80t− 1113 for dutycycle = 25%,

ω = 9.49t− 2612 for dutycycle = 50%,

ω = 13.2t− 3612 for dutycycle = 75%,

ω = 18.2t− 4829 for dutycycle = 100%,

where ω is the angular speed in rpm unit and t is the time in ms unit.

Open-Loop Step Response of DC-Motor Speed

-500

0

500

1000

1500

2000

2500

3000

3500

4000

4500

0 500 1000 1500 2000

Time [ms]

Spe

ed [r

pm]

Vstep

Duty= 12%

Duty= 17%

Duty= 25%

Duty= 50%

Duty= 75%

Duty=100%

Fig. 13 Open-loop step response of ω with dutycycle =12, 17, 25, 50, 75 and 100%. fPWM = 240Hz.

B) Determination of time constant and dead timeThe dead time L is determined by the intercept t1 of the line of tangent at ω = 0. The dead time

L = t1 − t0 = 157, 89.0, 42.8, 25.2, 22.8 and 15.7ms for the duty cycle of 12, 17, 25, 50, 75 and 100%,respectively, where t0 is the rising edge time of the setpoint. The dead time reduces as the duty cycleincreases and becomes about 10% of the maximum value.The time constant T is determined by the intercept t2 of the line of tangent at the high steady state

value of ω. The steady state values of ω are 368, 1117, 2105, 3311, 3661 and 3877 rpm (10 points average),then the time constant T = t2 − t0 − L = 237, 511, 554, 349, 276 and 213ms for the duty cycle of 12,17, 25, 50, 75 and 100%, respectively. The time constant reduces to about half of the maximum value.

C) Determination of equivalent gainThe equivalent gain K is determined by the following equation.[12]

9

Page 10: DC Motor Speed Control by PIC Based Digital PID Controller

K =∆PV [%]

∆MV [%], (4)

where ∆PV is the change of the process variable and ∆MV the change of the manipulated variable.In the present case, the value of K for each curve becomes

K = ((368− 0)/3877)/(127/1024) = 0.77 for dutycycle = 12%,

K = ((1117− 0)/3877)/(175/1024) = 1.7 for dutycycle = 17%,

K = ((2105− 0)/3877)/(255/1024) = 2.2 for dutycycle = 25%,

K = ((3311− 0)/3877)/(511/1024) = 1.7 for dutycycle = 50%,

K = ((13661− 0)/3877)/(767/1024) = 1.3 for dutycycle = 75%,

K = ((3877− 0)/3877)/(1023/1024) = 1.0 for dutycycle = 100%,

D) Determination of PID parametersTable 2 shows the values of KP , TI and TD calculated by using equations in Table 1 and the time

constant and dead time determined above. These obtained values are not constant but change dependingon the duty cycle, then it is necessary to test if these values are suitable or not.

Controller KP TI TD

P controller 1.97Duty cycle = 12% PI controller 1.78 0.52

PID controller 2.37 0.31 0.08P controller 3.40

Duty cycle = 17% PI controller 3.06 0.29PID controller 4.08 0.18 0.04P controller 5.93

Duty cycle = 25% PI controller 5.34 0.14PID controller 7.12 0.09 0.02P controller 8.09

Duty cycle = 50% PI controller 7.28 0.08PID controller 9.70 0.05 0.01P controller 9.63

Duty cycle = 75% PI controller 8.67 0.08PID controller 11.6 0.05 0.01P controller 13.6

Duty cycle = 100% PI controller 12.2 0.05PID controller 16.3 0.03 0.01

Table. 2 PID parameters KP , TI and TD calculated by the Ziegler-Nichols method using thepresent experimental data.

Figure 14 shows the step response of ω for P controller with KP in Table 2. The setpoints were71, 215, 404, 634, 701 and 743. These values were obtained from the steady state ω in Figure 8. Certaingood step responses are seen for all setpoints though overshoot may by a little too big. The steady statevalues do not reach the setpoint which are shown by the thin lines. This is the well known steady-stateerror problem of the P controller.[8]Figure 15 shows the step response of ω for PI controller with KP and TI in Table 2. The setpoints

were 71, 215, 404, 634, 701 and 743. In a medium ω region the step response may be better than Pcontroller because the steady-state error of ω is much smaller. Less steady-state error is a direct resultof the integral contribution of the PI controller. In a high ω region the response exhibits continuous

10

Page 11: DC Motor Speed Control by PIC Based Digital PID Controller

P-Controller Step Response of DC-Motor Speed

0

500

1000

1500

2000

2500

3000

3500

4000

4500

0 2 4 6 8 10Time [s]

Spe

ed [r

pm]

Vstep

SP= 71

SP=215

SP=404

SP=634

SP=701

SP=743

368 rpm

1117 rpm

2105 rpm

3311 rpm

3661 rpm

3877 rpm

Fig. 14 P-controller step response of ω with SP = 71, 215, 404, 634, 701 and 743. fPWM = 240Hz.

oscillation. This indicates the PI parameters should be readjusted so as to a tendency to decrease KP

and to increase TI .

PI-Controller Step Response of DC-Motor Speed

0

500

1000

1500

2000

2500

3000

3500

4000

4500

0 2 4 6 8 10Time [s]

Spe

ed [r

pm]

Vstep

SP= 71

SP=215

SP=404

SP=634

SP=701

SP=743

368 rpm

1117 rpm

2105 rpm

3311 rpm

3661 rpm

3877 rpm

Fig. 15 PI-controller step response of ω with SP = 71, 215, 404, 634, 701 and 743. fPWM = 240Hz.

Figure 16 shows the step response of ω for PID controller with KP , TI and TD in Table 2. Thesetpoints were 71, 215, 404, 634, 701 and 743. In a medium ω region the step response may be betterthan both of P and PI controller because both of the steady-state error of ω and overshoot are smaller.The small steady-state error comes from the integral contribution. The suppression of the overshootcomes from the derivative contribution. The derivative term slows the rate of change of the manipulatedvariable and this effect is most noticeable close to the controller set point. Hence, derivative control isused to reduce the magnitude of the overshoot produced by the integral contribution and improve thecombined controller-process stability.[4] In a high ω region the response exhibits continuous oscillation.This indicates the PID parameters should be readjusted so as to a tendency to decrease KP , to increaseTI and to decrease TD.The PID parameters can be estimated by Ziegler-Nichols method from the step response of ω measured

in a middle ω region. It is, however, necessary to readjust experimentally especially in a high ω region.The readjustment of the PID parameters is the main purpose of the present experiment. The step

responses of ω measured under P, PI or PID control are already shown in Figures 9 - 12. In thesemeasurements setpoint started from SP = 127 not zero to see both characteristics in low and high ω

11

Page 12: DC Motor Speed Control by PIC Based Digital PID Controller

Dynamical Response of Revolution with PID Controller

(500)

0

500

1000

1500

2000

2500

3000

3500

4000

4500

5000

0 2 4 6 8 10

Time [s]

Rev

olut

ion

[rpm

]Vstep

SP= 71

SP=215

SP=404

SP=634

SP=701

SP=743

368 rpm

1117 rpm

2105 rpm

3311 rpm

3661 rpm

PID-Controller Step Response of DC-Motor Speed

0

500

1000

1500

2000

2500

3000

3500

4000

4500

0 2 4 6 8 10Time [s]

Spe

ed [r

pm]

Vstep

SP= 71

SP=215

SP=404

SP=634

SP=701

SP=743

368 rpm

1117 rpm

2105 rpm

3311 rpm

3661 rpm

3877 rpm

Fig. 16 PID-controller step response of ω with SP = 71, 215, 404, 634, 701 and 743. fPWM = 240Hz.

regions.The step response of ω in Figure 9 shows the steady-state error problem of the P controller. As

the KP increases the steady-state error decreases. However, the KP cannot be too high because thecharacteristic becomes unstable and oscillatory as indicated by the curve for KP = 50. From the datain Figures 9 and 14, the P controller is a good choice for applications in which the steady-state error isnot a big problem. In this case, the parameter KP determined by the Ziegler-Nichols method may bedirectly applicable.The KP dependence on the step response of ω in Figure 10 shows high control performance of the

PI controller when KP is in between 0.6 and 2.6 at TI = 0.3. As the value of KP increases rising edgebecomes steeper and exhibits a little overshoot. All curves tend to focus to a steady value close to thesetpoint. There is a little steady-state error especially when the ω is low. The curve for KP = 0.8 (noovershoot) or for KP = 1.4 (slight overshoot) may be the best tuning when TI = 0.3.The TI dependence on the step response of ω in Figure 11 shows high control performance of the PI

controller when TI is in between 0.5 and 0.2 at KP = 1.4. As the value of TI decreases rising edgebecomes steeper and exhibits a little overshoot. When TI is less than 0.1 the curve becomes oscillatory.All curves except TI = 0.8 tend to focus to a steady value close to the setpoint. When TI = 0.2 thesteady-state error from the setpoint 2666 rpm (SP = 511) is almost zero showing excellent controlperformance. The curve for TI is in between 0.3 and 0.2 may be the best tuning when KP = 1.4.It is worth while noticing that experimentally determined best tuning values of KP in between 0.8 and

1.4, and TI in between 0.3 and 0.2 are close to those obtained by the Ziegler-Nichols method using dataof low and medium ω regions.The PI controller reduced the time constant at the rising edge from 535ms (no control curve) to

226ms (KP = 1.4 and TI = 0.3 curve). The curves around the falling edge, however, show certainamount of undershoot. As a result, the time to reach steady state for the PI controller is almost thesame as that of the no control curve. The larger undershoot than overshoot is consistent with the strongnonlinear concave curve shown in Figures 2, 3 and 4. As the duty cycle decreases the ω decreases almostexponentially.As shown in Figure 4, the ω - duty cycle characteristics show strong nonlinearity and frequency

dependence when fPWM = 61, 240 and 980Hz. In this frequency range the PWM is considered to bein discontinuous conduction mode. The motor goes into free or unlocked state during off-duty cyclein a PWM period. A relatively poor ω - t characteristic found in high to low transition of ω forfPWM = 240Hz can be attributed to this unlocked state. The discontinuous conduction mode, on theother hand, has some advantage for such purposes: cheep switch can be utilized since fPWM is low andrelatively high torque is utilized during low to high transition of ω.In the present experiment, the ’L’ setpoint was 659 rpm. The present DC motor is not recommended

12

Page 13: DC Motor Speed Control by PIC Based Digital PID Controller

to use in such a low ω region. As a matter of fact the step response becomes much better on smalltransition in high ω region. Figure 17 shows an example of the transition from SP = 634 (3311 rpm) toSP = 701 (3661 rpm) with KP = 5.0, TI = 0.12 and TD = 0.0.

PI-Controller Step Response of DC-Motor Speed

3000

3100

3200

3300

3400

3500

3600

3700

3800

0 1 2 3 4 5 6 7 8 9 10Time [s]

Spe

ed [r

pm]

Kp=5.0Ti=0.12

3311 rpm

3661 rpm

Fig. 17 PI-controller step response of ω with SP =634 (3311 rpm) and 701 (3661 rpm). fPWM = 240Hz.

Table 3 shows error evaluation of the step response in Figure 17. In ’L’ region the error (ω−SP )/SPis in between −0.51 to 0.19%. In ’H’ region the error is in between −0.45 to 0.20%. Overshoot is1.2% and undershoot is −4.6%. These data indicate excellent control performance of the PI controllerconsidering that the present DC motor is a product not for industrial use.

Time region [s] Item Data [rpm] Set point [rpm] Error [%]Average 3305 3311 -0.17

0.0 ≤ t ≤ 1.5 Maximum 3317 3311 0.19Minimum 3294 3311 -0.51Average 3658 3661 -0.08

2.5 ≤ t ≤ 6.6 Maximum 3668 3661 0.20Minimum 3644 3661 -0.45

t = 2.0 Overshoot 3706 3661 1.2t = 7.0 Undershoot 3159 3311 -4.6

Table. 3 Error evaluation of the step response of ω with PI controller. The PID parameters wereKP = 5.0, TI = 0.12 and TD = 0.0.

The ω - t characteristic with PID controller shown in Figure 12 shows a little complicated result.As the value of TD increases the overshoot on the rising edge is suppressed as same as that in Figure16. All curves, however, do not tend to focus to a certain steady value close to the setpoint. Thesteady-state error from the setpoint looks random and not small especially in a low ω region. Furtherexperiments indicated that the instability was mainly attributed to the motor which was running underthe discontinuous conduction mode of PWM signal. Detailed results will be presented in the next partof the study.

6 ConclusionDC motor speed control was carried out by preparing a PIC based PID controller. The H-bridge motordriver was driven by the sign/magnitude PWM signal at frequency of 240Hz. The step responses of themotor speed (ω) were systematically measured to obtain optimum PID parameters. Practical steps todetermine the parameters were, first to estimate the values by the Ziegler-Nichols method in medium

13

Page 14: DC Motor Speed Control by PIC Based Digital PID Controller

speed region and second to tune the values in detail step by step. The PID controller exhibited notableimprovements of the time constant at rising edge (e.g. 0.5 to 0.2 s) and excellent control performanceto minimize the steady-state error (e.g. between −0.5 and 0.2%) even the ω vs duty cycle curve wasstrongly nonlinear in discontinuous conduction mode of PWM at 240Hz.

References[1] Y. Takase and G. Ibrahim: Characteristics of PIC PWM controller measured by USB based Data

acquisition system, The Forth Report of Senior Volunteer of JICA (April 16, 2008).[2] Y. Takase and G. Ibrahim: Basic simulation of digital ideal-PID-controller, The Forth Report of

Senior Volunteer of JICA (April 16, 2008).[3] M. Araki: CONTROL SYSTEMS, ROBOTICS, AND AUTOMATION - Vol. II - PID Control,

Encyclopedia of Life Support Systems (Copyright 2002-2010).[4] Wikipedia: PID controller (last modified on 6 November 2010), http://en.wikipedia.org/wiki/

PID controller.[5] National Semiconductor: LMD18200 data sheet (September 1996), http://www.national.com/

jpn/.[6] D. Clark and M. Owings: Building robot drive trains, The McGraw-Hill Companies, Inc. (2003).[7] W. Shepherd, L. N. Hulley and D. T. W. Liang: Power electronics and motor control, Cambridge

University Press (1987).[8] University of Michigan: Control Tutorials for Matlab, PID Tutorial, (August 1997), http://www.

engin.umich.edu/group/ctm/PID/PID.html.[9] Microchip Technology Incorporated: PICmicro Mid-Range MCU Family Reference Manual

DS31014A-page 14-8 (1997).[10] JAPAN SERVO Co., Ltd.: Standard specification of DME34SA (November 2007), http://www.

japanservo.co.jp/digital/english/general/pdf/DME34 2.pdf.[11] CONTEC Co., Ltd.: AIO-160802AY-USB Manual (Copyright 2006), http://www2.contec.co.jp/

prod data/aio160802ayusb/c01e.pdf.[12] K. Hiroi and A. Miyata: Introduction to Control Engineering using Simulation System (in Japanese),

CQ Publishing Co., Ltd. (October 2004).

14