Indonesian J ournal of Ele c trical Engin eering and  Computer Sci e nce   Vol. 2, No. 3,  Jun e  201 6, pp. 592 ~ 60 6   DOI: 10.115 9 1 /ijeecs.v2.i3.pp59 2-6 0 6        592     Re cei v ed Fe brua ry 28, 20 16; Re vised  April 22, 201 6; Acce pted  May 9, 201 6   Dual DC Motor Speed Control Based on Two  Independent Digital PWM Signals using  PIC16F877A Microcontroller      A y man Y  Yousef 1* , MH Mostafa 2   1 Electrical Engineer ing Dept., Facu lt y   of Engineer ing at  Shoubra, Benha Universit y , Cairo, Egy p t   2 Distributio n S e ctors, Sout h Cairo El ectrica l  Distributi on C o ., Cairo, Eg yp *Corres p o ndi n g  author, e-ma i l : A y man. yo uss e f@feng.b u .ed u .eg       A b st r a ct   In this p aper  a  dua l o pen  lo o p  spe ed c ontro system bas ed  on tw o in de pe nde nt PWM signa ls o f   sma ll p e rman ent magn et DC (PM DC) motors usin g PIC16F 87 7A mi crocontro ller ( M CU) has b e e n   desi gne d a n d  i m p l e m e n ted. T he C aptur e/Co mp are/PW M ( CCP)  mo dul es   of the MC U a r e confi gur ed  as   PW M mod e  an d the MCU is  p r ogra m me d usi ng flow cod e  so ftw are package  to gener ate tw o PW M signa ls   w i th various  du ty cycles at the  same freq uen cy. A dual  H-br idg e  cha n n e l c h ip S N 75 44 10  is use d  to driv e   the  motors. T h e vari atio n of  PW M duty cyc les is  rel a te d   directly t o  co ntrolli ng  the  DC  motors ter m i n a l   voltag e w h ich directly pr oport i on al w i th spe ed of  each  mo tor. The comp l e te  PWM control system  mo de l   has be en si mulate d usi ng p r oteus des ig n suite so ftw are packag e . T h e  devel op ment of hardw are a n d   softw are of the dual D C  motor  speed co ntrol  system h a s be en exp l ai ne d a nd clar ified.      Ke y w ords : PIC16F 8 77A, PW M, CCP1, CCP2, and PMD C         Copy right  ©  2016 In stitu t e o f  Ad van ced  En g i n eerin g and  Scien ce. All  rig h t s reser ve d .       1. Introduc tion  Direct current  (DC) motors pl ays an ef fective role  and still  found  in several industri a l   appli c ation s  such a s  toys, disk drive s , steel ro llin g mills, pape r ma chine s  and in  conj un ction with  power el ectro n ic devi c e s  [1]. The DC  motors ha many goo d chara c te risti c s in addition,  high  reliability, flexibility which  make its  sp eed contro l i s  very simpl e  and suit different ope ra ting  con d ition s . It co nvert s  el e c tri c al  p o wer into m e chan ical  po wer th roug h m u tual  effect b e twe en  two  ma gnet  fi elds. One of these   two ma gnet  fiel d s  i s   often produ ced by p e rm a nent ma gnet  in   stator el emen t [2]. The oth e r mag netic fi eld is  p r odu ced by elect r ic current pa ssi ng throu gh th rotor (a rmatu r e) wi nding.  This  mutual  intera cti on  bet wee n  the t w o  fields produ ces to rqu e  le a d to the rotor rotation.  The speed of  DC moto r ca n be co ntrolle d by two maj o r metho d s, the first is a m agneti c   field cont rol t h is meth od i s  u s ed in  se parately ex cited DC moto rs an d ca nnot  be used  with  perm ane nt magnet moto rs [3]. The second is a r matu re voltage co ntrol. In this work, the second   method is u s ed becau se the cho s e n  motor is pe rma nent magn ets DC mot o r (PMDC). The s e   motors a r e u s ed i n  ap plications th at re quire  co mpa c t size  and  fra c tional  horse power  whe r they   are m anufa c t u red  at low  cost. The r e a r e seve ral te chniqu es   of DC moto r spee d co ntrol u s e d  in  many practi cal co ntroll er  appli c ation s   su ch a s   by u s ing thy r isto r,  ch oppe circuit, Fuzzy Lo gic  Controlle r an d digital co ntrollers [4]. In  mode rn  spee d appli c ation s  the digital control te chniq u e s   provide a b e tter way to re al ize the DC m o tor sp eed  co ntrol [5].   The main p u r po se of the  pre s ent work  is to desig n  and implem ent the hard w are and  softwa r e  of o pen l oop  digit a l control  system ba se d o n  PWM  to  cont rol  dual  DC  Motor  usi ng  PIC  16F87 7A microcontroller.       2. Modeling of PMDC Mo tor   The equival e nt circuit sho w n in Figu re  1 rep r e s ent s a perm ane nt magnet DC  motor.   Evaluation Warning : The document was created with Spire.PDF for Python.
                             ISSN: 25 02-4 752    IJEECS  Vol.  2, No. 3, Jun e  2016 :  592  – 606   593     Figure 1. Modeling of PM DC moto     Whe n  the  su pply voltage  i s  a pplie d to t he terminal of a PM DC  motor, the  a r mature   cur r e n t  of  i a   flows in the  armatu re  circuit, and the indu ced b a ck emf and a  motor torque  is  develop ed to balan ce the l oad torq ue at  a certai spe ed. The termi nal voltage is  given by:    b a a a a e dt di L R i V   (1)     The ba ck e m f is given by:    m b b k e  (2)     Then:     b a a a k R i V (3)     a t m i k T (4)     m d m m B T T dt d J (5)   Whe r e:     2 60 n (6)     Whe r e V a  is terminal vol t age in volt, ia is ar m a ture  curre n t in amp, L is armatu re  indu ctan ce in  henn ery,  e b   back  emf of  motor in volt, R a  is  arm a ture re si stan ce i n  omh, di a  /dt   is  rate  of chang e of a r matu re  cu rrent in  a m p/se c,  ω m  i s  m o tor  sp ee d in  rad/ se c,  n  i s  m o tor  speed   in r.p.m,  Tm  is motor torque in  Nm,  k t  i s  torque  co nstant. Then, th sp eed  control expression  of  dc moto r is gi ven as,     b a a a b b k R i V k e   (7)     In perma nent  magnet  DC  motor, the on ly met hod u s ed to sp eed  control i s  the a r mature  voltage co ntrol method, b e ca use the p r oviding  m a g netic field by  the perma n ent magnet s is   con s tant a n d  can not alte red. Refe rri ng  to Equation   7, it is foun that t he spee d of the m o to r is  prop ortio nal t o  the a r matu re voltag e, th en by  cont rol ling this volta ge the  motor sp eed  ca n b e   controlled.           Evaluation Warning : The document was created with Spire.PDF for Python.
IJEECS   ISSN:  2502-4 752     Dual  DC Mot o r Spee d Co ntrol Based o n  Two Inde pe ndent Di gital PWM …   (A ym an Y Yousef)  594 3. Pulse Width Modula t io n (PWM The Pulse  wi dth modulatio n techniq ue i s  the  simple st and most efficient way for spe ed  control of  DC motor [6]. It con s id ere d  a s  on e of the v a riou s m e tho d s u s e d  to  co ntrol d c  mot o r by  gene rate an a l og voltage u s ing di gital si gnal s. It used  also in ma ny application s  su ch a s  co ntrol  of delivered  p o we r to  a l o a d , gen eratio n  of  sine  wave forms,  and  a nalog  voltage  level g ene rat i on  [7]. The PWM Taniqu e d epen ds o n  d e riving the d c  motor by p u lse d  wavefo rm (su c cessi v e   pulses) with “ON-OFF  logi c situatio ns a s  sh own in Figure 2.         Figure 2. Pulse wi dth mod u lation techni que       In this meth o d , the avera g e  value of th e motor  appli ed voltage i s  cha nge d by  varying   the pulse  wid t h of the driving sign al. Co nse que ntly, the motor spe ed can b e  varied by cha n g i ng  the ratio  bet ween th e p u lse  width  or the  ON time  T on  and peri od  ti me  T period  of the a pplied  si gnal   whi c h is  calle d duty cycle a nd given by:     Time Period width Pulse cycle Duty   (8)     period ON T T cycle Duty   (9)     Then, the dut y cycle ca n b e  defined a s  the fra c tion of time perio d for whi c h the  si gnal is  ON to total time peri od [8]. The avera g e  value of the motor ap plied  voltage V av  is given by:    T m period ON rated av V T T dt t V T V 0 ) ( 1 (10 )     m av V cycle Duty V   (11 )     Whe r e: T period  = T ON  + T OFF , Dut y  cy cle =  T ON  / T pe r i o d , and V m  = ampli t ude of the motor  rated voltage.    The ave r ag e power a nd re spe c tively the  spe ed of d c   motor  can  be  varied by  ch angin g   the duty cycl e of the si gna l whi c h i s  call ed pul se  widt h modul ation  PWM. In this  control meth o d the po we r in put to the  m o tor i s   swit ch ed on  an d of f quickly with  high  switchi ng rate  whi c h is  enou gh to ma ke the switchi ng effects a r e  negligible a n d  unnoti c ed.        3. Microcontroller PWM Gener a tion  Techniqu e   The g ene rati on of P W M u s ing PI C16F 8 77A MCU  de pend s o n  its  built in  CCP  module s   whi c h a r e  m ean Captu r e/Comp are/PWM. Th e PIC16F 877A  M C U ha s two  (CCP)  Modul es,  CCP1  an d CCP2 at pi ns  RC2 an d RC1 of Port  C resp ectively a s  sho w n in   Figure 3. Ea ch   module  (CCP1 and CCP 2 ) contain s  a  16 bit regi ster  (two 8-bit regi sters) [8].  The two P W regi sters  CCPR1 a nd  CCPR2  are b e long to   CCP1 and  CCP2 modul es re spe c tively. The   regi ster CCP R 1 i s   co nsi s t s  of  CCPR1 L  (lo w   byte) and  CCPR1 H   (high  byte ). Similarly, t h e   Evaluation Warning : The document was created with Spire.PDF for Python.
                             ISSN: 25 02-4 752    IJEECS  Vol.  2, No. 3, Jun e  2016 :  592  – 606   595 regi ster CCP R ha CCP R2L  (lo w   byte)  and  CCP R 2 H  (high  b y te) [9]. The  CCP1CON  and  CCP2 C O N  registe r controls th e o p e r a t ion of  CCP 1 and  CCP2  re spe c tively. T he  spe c ial  ev ent  trigge r is ge n e rated by a  compa r e mat c h and will  re set Timer1 a n d  start an A/ D co nversion  ( i the A/D mo d u le is en able d )[10]. Th e b l ock di a g ram  of the  CCP 1 and  CCP2  modul es  an d its  asso ciated re gisters is  sho w n Figu re 4.           Figure 3. Microco n trolle r Pic16F 877A pi assignm ent.      Figure 4. CCP module s   asso ciated regi sters.       These t w m odule s   ca n b e  configu r ed  t o  ge ne rate t w o sepa rate  a nd in dep end e n t PWM  sign als  with  different duty  cycle. Th e two PW M fre quen cie s  is t he sa me for  CCP1  and  CCP2   becau se it use Time r2 a s  a time base .  More  detail s  abo ut the operation of  CCP mo dule s  in   PWM mode a nd timer re so urces a r e fou nd in [8] [9]  [1 0]. The PWM function al blo c ks is  sho w in  Figure 5 and  the corre s p o n d ing PWM  waveform timin g  can b e  se e n  in Figure 6 [11].          Figure 5. PWM module bl o ck di agram   Figure 6. PWM waveform  sho w in g peri od and  dut y  cy cle       The  duty cy cle an d p e rio d  definitio ns  are  cle a r fro m  the fig u re  (6 ) itself. T he P W Period, Duty Cycle a nd Re solutio n  are  calcul ated by these formul a s  [9]:    Period  = [(PR2) + 1] × 4  × Tosc × (TMR2 Prescal e  Value)  (12 )     Duty Cycle  = (CCPR1L:CCP1CO N <5:4>) ×  To sc  × (T MR2 P r e s cal e  v a lue)   (13 )     Res o lution =   [log (FOS C /FPWM)] / [log(2)] bits  (14)  Evaluation Warning : The document was created with Spire.PDF for Python.
IJEECS   ISSN:  2502-4 752     Dual  DC Mot o r Spee d Co ntrol Based o n  Two Inde pe ndent Di gital PWM …   (A ym an Y Yousef)  596 4. Dual DC Motor Driv er a nd Control Strateg y   The SN75 44 10 driver  chip  shown in Fig u re 7 whi c h i s  the quad Hal f -H-B ridg e ch annel is  cho s e n  to dri v e the dc motors in two direction s  an d p r ovide them b y  sufficient cu rre nt. It can be  driving hi gh voltage moto rs (from 4.5V  to 36V) u s ing  TTL logi c le vels +5V and  sup p ly enou gh   contin uou s o u tput cu rrent  up to  1A [12].  The pi n a ssi gnment s a nd  con n e c tion d e scriptio n of t he  SN754 410 d r i v er chip  whe n  it used to drive t he two DC motors is  shown in Figu re 8.        Figure 7. SN7544 10 drive r   chip     Figure 8. SN7544 10 Pin a ssi gnme n ts a nd co nne ctio n diagram       The SN754 4 10 chip h a s t w control in puts, on e en able in put an d one  output  per e a ch  cha nnel. The  pins 1,2E N, 1A, 2A, 1Y an d 2Y contro l the first moto r on the left sid e  while the pi ns  3,4EN, 3A, 4A, 3Y and 4Y control the o t her moto r o n  the right side . The Control  inputs (1A, 2 A )   and (3A, 4A) are   u s ed   to control   the rot a tion  di re ct io (clo ckwi se  or anti clo c kwise)  for  the first  motor a nd  se con d  respe c tively. The ena ble inp u ts  (1, 2 EN a nd 3,4 E N) a r used  to turn th e t w o   H-b r id ge O N   or OFF. T he  pins V CC1  an d V CC2   are used to p o wer the driver  ch ip as follo w: pin  V CC1  is use d  t o  po we r the l ogic  gate s  in side th chip  by (+5V) lo gi c supply volta ge an d pin  V CC2   is u s e d  to p o w er the m o to rs  by their rated volt age a nd thi s  pin  ca n re ceive  up  to 36V. T he pi ns  4,5,13, and  1 2  must  be  co nne cted to th e gro und  (0V )  and  used a s  a h eat si nk. The propo sed  control st rate gy based o n  PWM te chniqu e by  g enerating two indep end e n t sign als u s ing  PIC16F8 77A microcontroll er and the S N 75 441 0 driv er chi p  is sho w n in Figu re  9.          Figure 9. Pro posed PWM  control strate gy      The dual con t rol strate gy depe nding u p on the oper ation of the H-Bridge is fairl y  simple  by identifying  the logi c stat e (High  or L o w of t he en a b le an d inp u t pins. T he lo gic state  of the s control pin s  i s  dete r min e d  by mean s of  the logi c val ues  se nt fro m  micro c ontroller [8]. Ta ble 1   sho w  the be h a vior of the two DC moto r for different in put con d ition s           Evaluation Warning : The document was created with Spire.PDF for Python.
                             ISSN: 25 02-4 752    IJEECS  Vol.  2, No. 3, Jun e  2016 :  592  – 606   597 Table 1. DC Motors beh aviour with diffe rent input con d itions  Enable  1,2EN   3,4EN   Inputs  1A, 3A  Inputs  2A, 4A  DC motor 1  and  DC motor 2   Functions  Runs counter clockw ise  (left direction)  Runs counter clockw ise  (right dir e ction)  Fast Motor Stop   or brake   Fast Motor Stop   or brake   Regardless   Regardless   Fast Motor Stops  or brake       4. Dual DC motor driv s y stem Desc ription   The sche mati c diag ram of  the prop osed  dual DC motor sp eed  con t rol is de sign ed and   simulate d by  Proteus  7.10 de sign  suite softwa r e packa ge.  The main  element of  the   impleme n ted  control  syste m  is the  PIC16F87 7A mi crocontroller is use d   with ot her  ele c tric a n d   electroni c de vices a s  sho w n in Figu re  10.          Figure 10. Schematic di ag ram of the Du al PW M co ntrol of DC moto r desi gne d by Proteus  s o ftware       The mi cro c on troller read  th e an alog  valu e of  th e volta ge a c ro ss two vari able  re sistan ce (potentio mete rs) which a r e  con n e c ted  with two   ADC (A N0  and  AN1)  at pin s  (RA0  and  RA1).    The ch ang e in these an alo g  values of in put  voltage will chang e the  duty  cycle of the generate d   PWM  sign als whi c h  directl y  linke d to th e DC m o tors sp eed s. A f our fixed  spe ed p u sh b u ttons  and th e two  potentiomete rs  can  be  varying the  s p e ed of th e t w o  DC m o tors  according  to  the  function of e a ch el eme n t. The pote n tiometers give  broa d ra nge  of spee d co ntrol from  0 %  to   100% of the maximum mo tor sp eed. Th e four pu sh buttons can be  adju s ted manually  to give  more  fixed v a lue s  of  sp e ed  whi c h u s e d  u s ually  su ch a s  5 0 % an d 10 0%. The s e fe w val u e s  of  fixed spee d can be chan ge d  in the future by  editing a nd upd ating the micro c ontroller p r og ram .     The motors d r iver chi p  SC7544 10 is int e rfaced  with  PIC micro c o n t roller pin s  RC6, RE1,    RC4,  a nd  RC5 th rou gh t he o u tputs IN1, IN2, IN3,  and  IN4  of t w dou ble p o les rel a ys  (DP  relay1  and   DP relay2 at it s in put te rmin als A 1 , A2, A 3 , and  A4  re spectively. Th e two  pi ns RC6  and RE1   are alway s   at HI GH  l ogi c state  but RC4  an d RC5  a r e fo rever at L O W logi state. T h e   Enable pin s   1,2EN an d 3,4EN are co n necte d to  the  gene rated t w o PWM  sig nals at pin s   RC2   and  RC1. T he o u tput pi ns Y1, Y 2 Y3, and Y 4   of SN75 441 0  chi p , ea ch t w of them  are  Evaluation Warning : The document was created with Spire.PDF for Python.
IJEECS   ISSN:  2502-4 752     Dual  DC Mot o r Spee d Co ntrol Based o n  Two Inde pe ndent Di gital PWM …   (A ym an Y Yousef)  598 con n e c ted to  one of the two DC moto rs re sp ec tivel y . The two double p o le s relays (DP rel a y1   and DP relay 2 ) are used to reverse the  rotation dire ction (clo ckwi se or anticl o ckwise) of the two   DC moto rs when the pin  RC3 sen d  si gnal with Hi g h   logic state i f  the directio n swit ch is tu rned   on. A digital  LCD (4x16)  pins  are con necte to p o r t B and  a 4 - digit 7 - Segm ent multiplex ed  displ a y unit p i ns a r con n e cted to  port  D to di splay the detail s  of  DC m o tors  control m ode s o f   operation. A 5V/12V DC p o we r su ppl y consi s ts of AC step do wn transfo rme r  22 0v/12v, full wave   rectifie r bri d g e , voltage reg u lator, an d rip p le filt er wa s i m pleme n ted [13]. PIC microco n trolle r an d   SN754 410  driver chi p  are  sup p lied by 5 V  logic le vel,  and the  DC  motors fed b y  12V as a  ra ted  voltage.      5. Soft w a r e   Algorithm Implementa tion   The  softwa r e  impleme n tation an cont rol algo rithm  of the impl e m ented  dual  dc m o tor  control syste m   wa s devel oped   u s ing F l owcod e   software p a cka g e . Flowco de i s  a  graphi cal  tool  use d  to prog rammin g  the  PIC micro c ontrolle r o n ce dra w in g th e pro g ram flowcha r t [8]. The  flowchart of the PWM cont rol algo rithm i s  sh own in Figure 1 1         Figure 11. Flowcha r t of the  develop ed control  algo rit h     The si mulatio n  of two mot o rs  ba sed P W signal usin g flowco de software  at medium   and maxim u m spe e d s  wi th duty cycle  equal s 5 0 % and 1 00% resp ectively, in two di re ction s   (anticl o ckwise and cl ockwi s e) u s in g pu sh bu tton switches a r e sho w n in Figure 12   Evaluation Warning : The document was created with Spire.PDF for Python.
                             ISSN: 25 02-4 752    IJEECS  Vol.  2, No. 3, Jun e  2016 :  592  – 606   599   Figure 12a. T w o moto rs at  starting  (PWM  module s  CCP1 and CCP2  have   Dut y  cy cle  = 0)     Figure 12b. T w o moto rs  ru ns in anti c lo ckwi se  dire ction (CCP1 and CCP2  module s  at Duty  cycle e qual 5 0 % and 100 % resp ectivel y           Figure 12 c. Two moto rs  ru ns in cl ockwise dire ction    (CCP1 an d CCP2 mod u le s at Duty cycle    equal s 10 0% and 50% respectively)      Also the  sim u lation at very low , low, equal, hig h , and very hig h  spe e d s  in  different   dire ction s  wit h  duty cycl e  equal s 1 0 %, 25%,  65%, 75% and  9 0 % usin g po tentiometers  are   sho w n in Fig u re 13.         Figure 13a. T w o moto rs  ru ns in anti c lo ckwi se  dire ction (CCP1 and CCP2  module s  at Duty  cycle e qual 9 0 % and 10%  respe c tively)      Figure 13b. T w o moto rs  ru ns in cl ockwise  dire ction (CCP1 and CCP2  module s  at Duty  cycle e qual 25% and 75 % resp ectivel y     Evaluation Warning : The document was created with Spire.PDF for Python.
IJEECS   ISSN:  2502-4 752     Dual  DC Mot o r Spee d Co ntrol Based o n  Two Inde pe ndent Di gital PWM …   (A ym an Y Yousef)  600     Figure 13 c. Two moto rs  ru ns in anti c lo ckwi se di re ctio n at the equal  spee d   (CCP1 an d CCP2 mod u le s at same Duty cycle equ al 65%)      6. Hard w a re  Setup and E x perimental Resul t     6.1. Hard w a r e  implementation   The ha rd ware developm e n t setup of the im pleme n t ed dual dc  motor control  system  (rate d voltag e V =  12V  and  rated  curre n t I =  0.5A) control  system  usi ng  PIC1 6F8 77A  microcontroll er ba sed o n  two ind epen d ent PWM sig nals i s  sh own  in Figure 1 4         Figure 14. Photogra ph of h a rd wa re setu p con n e c tion  of PIC16F87 7A MCU  based du al DC motor P W M control system      6.2. Simulati on Results  The si mulatio n  re sults  of the gen erated  PW M sig nal s wa s a c com p lish ed with  perio d of  4ms an d fre quen cy of 244 Hz u s ing  proteu suite  software pa ckage. The  output two PWM  sign als  of the  two mo dule s  CCP1  and  CCP2 at pin s   RC2 an d RC1 for different  values  of du ty  cycle a r e sho w n in Figu re  15. The sam e  duty  cycle values of 5% , 25%, 50%,  75%, and 10 0%    wa cho s en  for the  two  PWM  sign als i n  orde r to  rot a te the t w motor  at the  same  spee d. The   oscillo scope  uppe r tra c e is PWM1 si gna l while the lo wer trace is P W M2  sign al a nd Ho rizontal : 1   ms ec /div. Vertic al; 2 volt/div.      Evaluation Warning : The document was created with Spire.PDF for Python.
                             ISSN: 25 02-4 752    IJEECS  Vol.  2, No. 3, Jun e  2016 :  592  – 606   601   Figure 15a. O u tput two PWM signal s at duty  c y c l e 5%. (The two motors   rotates   at the s a me  very low sp ee d)    Figure 15b. O u tput two PWM signal s at duty  c y c l e 25%. (The two motors  rotates  at the  same lo w spe ed)        Figure 15 c. Output two PWM signal s at duty  c y c l e 50%. (The two motors  rotates  at the  same M ediu m  spee d)    Figure 15d. O u tput two PWM signal s at duty  c y c l e 75%. (The two motors  rotates  at the  same ve ry high sp eed         Figure 15e. O u tput two PWM  signal s at duty cycle 10 0%.  (The two mot o rs   rotates  at the s a me Maximum s p eed)        The sim u latio n  of the outp u t two PWM  sign als a nd the co rrespon ding termi nal  voltages  of the two  DC moto rs for  variou s valu e s  of d u ty cycl e with  oscillo scope  (Hori z ontal: 2 m s e c /div.  Vertical; 5 vol t/div) are sh o w n in Figu re  16.    Evaluation Warning : The document was created with Spire.PDF for Python.