You are on page 1of 6
FUZZY LOGIC MICROCONTROLLER IMPLEMENTATION FOR DC MOTOR SPEED CONTROL Yodyium Tipsuwan IEEE Student Member ripsw@uniy suede Mo-Yuen Chow TEE Seair Member Department of Electrical and Computer Engineering Bax 7911, North Carolina Sate University ‘Raleigh, NC 27685-7911, USA ABSTRACT: This paper described an elterative method fo ‘implement a fuzzy logic speed conrller for a DC motor sing @ fizzy lie microcowroller The design ‘implementation, and experimental results on load and no- load conditions are presented. The controler can be implemented by using only a small amount of components and easily improved to be an adapive fzzyconiroler. The Controller also provides high performance vith compact se and low cost. L INTRODUCTION DC motors used in many applications such as ste! rolling mills, electric uains, and robotic manipulators require speed coriolis to perform tasks. Major problems in applying. @ conventional cont algoitn in 2 speed contol are the effect of nonlinearity in a DC motor. The nonlinear characteristics of « DC motor such a saturation nd friction could degrade the performance of conventional contolless (1-31. Many advanced: model-based contol methods such a8 vanable-ructre control [4) and model reference adaptive control {5} have been developed 10 reduce these eflects However, the performance of these methods depends on the accuracy of sysem models and parameters. Generally, an accurate nonlinear model of an Seta! DC motor i difficl to find, and parameter values ‘bisined from system identification may be only spproximated values. ‘Emerging intligen techniques have been developed and extensively used to improve oro replace conventional ‘consol techniques because these techniques donot require 2 precise model. Oe of intelligent techniques, fuzzy logie ‘developed by Zades (6, 7] is applied for consoles design in many applications (8,9). A fuzzy logic conller (FLO) ‘was proved analytically to be equivalent to 2 nonlinear PL ‘conroller when a nonlinear defuzification method is used (10). Also, the results from the comparisons of ‘conventional and fazzy logic cantol techniques in the form of a FLC (11, 12) and fuzzy compensator (13, 14} showed fuzzy logic can reduce the efecs of nonlinearity in a DC ‘motor and improve the performance of a controle, ‘A FLC has been implemented on many platforms such as dpa signal processor (DSP) (15), PC [1}, oF ofFthe- shelf microconrller (17). These platforms have different vantages and disadvantages. The FLC developed on DSP fr PC can quickly process fuzzy computation to generate contol eff, but the physical size of the system may £00 big and quite expensive fora small DC motor application, 0-7803-5735-3/99/510.00 ©1999 IEEE 27 (nthe other hands, using an offtbe-shelf microncontoller to implementa FLC is inexpensive ad the physical size of the sytem is small, but the FLC requires longer processing time. One way to improve the response. time in mmeroconuoller implementation approach is 0 use a Took- up table, but this method needs much more memory t0 store a able ‘An alterative method to implement 2 FLC is using 2 {unzy lope ehip. The fuzzy loge chip is fist developed in 1985 by Togal and Watanabe [18]. It has been developed and improved continuously to be a commer fuzzy logic ricrocontroller by many companies. The main feature of this chip is its capability in hardware level to execute fuzzy computation. Fuzzy rules and membership functions are efined and stored in RAM or ROM by specific formats ‘hat make a designers job easier. Tis feature could reduce eveloping time and bypass the need of a high speed yet expensive system t9 develop 2 FLC. The designer can also ltllze other features included ina fuzzy logic ‘microcontroller to reduce the size and to improve the system performance In this paper, a FLC is implemented for DC motor speed contol on'a fuzzy logic microcontroller. Heuristic Knowledge is applied to deine fuzzy membership functions and rules. The membership functions and les are ‘modified afer intally borowing the knowledge from a PL controler developed fom a simple linear mode! (11, 14]. ‘The hardware interface circuit and software algorithm are described. The results from real-time experiments with load and no-load conditions ae also included in this paper. 1, SYSTEM DESCRIPTION [A simple DC motor linear model i fisly used forthe ‘motor controller design as shown in equation (1). o where contol Wis the armature voltage of the de motor, sate varible x=[i, @]', where i,and © ae the ‘amature exrent and shaft rotational speed, respectively, 4s the disturbance on the DC motor syst, All motor parameters in this paper are obtained by standard system entificaion as shown in Table TABLE DC MOTOR PARAMETERS Tae Desi % | Pema Twa a TSH | Were ee gg Vics ion oie —[ 4) ee rg se Wee Lo es Vasc ‘An experiment, a shown in Fig I is sat up to identify the characteristic of te motor by measuring the realtime ata of shaft rotational speed and amature volage by Gecreasng the armature voltage from the rated volage 10 2ero. The experimental result shows the actual motor inthis per has several nonlinear charactersice including eadzone, fiction, and saturation, as shown in Fig 1. The lowest armature voluge to overcome deadzone and static friction for starting the motor is 4.5 V, while at leas 4 V armature voltage can sustain the rotation. The effect of saturation obviously happens when the armature voltage is higher than 11.3 V. The method to reduce these effect will be discused in section I Fig LDC motor steady-state input-output relationship. Experimental setup ‘The armature voltage for driving the motor spans beeen -15 Vand +15V. When the motor rotates, the tachometer atached onthe motor will generate the velocity signal in ¥- 13.5 V range. The limited maximum and ‘minimum volage levels represent the highest angular velocity at 500 raisin diferent cretion. ML CONTROLLER DESIGN ‘While conventional controllers depend on the accuracy of the sytem model and parameters, FLCS use a diferent ‘approach to contol the DC motor speed Instead of using a ‘system model, the operation ofa FLC is based on heuristic Inowiedge and linguist description to perform a task, The effects ffom inaccurate parameters and models ae reduced bocause a FLC does no require a system model. However, ‘building 2 FLC from the ground-up may not provide good resuls or sometime even a wore rest than conventional controller if tere isnot enough knowledge ofthe system. ‘Therefore in this paper, the result fom a PI contllr is. 172 inilly borrowed a8 apron Knowledge in the design process. The performance of the FLC is then improved by adjusting the rules and membership functions, These design procedures ae described as follows. Procedure 1: Defining inputs, outputs, and universe of discourse ‘To apply heuristic knowledge in the FLC, inpus, outputs and universe of discourse are defined fist. The ipus are the eror (E) between the reference (w) and actual speed (a), and the change in eror (CE). The output is the change in armature voltage (CU). The inputs and output illustrated in Fig 2, are described by: E=ek)=0,(k)-0,(k) 2 CE =e(t) ek -1) ° cu = u(t)~ u(t -1) ® ‘where kis the time inde. er Fig 2. Block diagram ofthe FLC. [As mentioned in section I, the maximum range ofthe DC motor angular velocity chat will noc damage the motor |s H- 500 rad. The possible eror inthe range is between 1000 rad/s and 1000 rads. Therefore, the universe of discourse of B is defined to span between -1000 rad/s and +1000 rad/s. The universe of discourse of the change in errors based onthe experiment data from the PI controller Assign included in procedure 2which gives the range of fevor change is +- 5.5 rads. For the change in armature voltage, the minimum and maximum defined value ae 1.5 V and +1.5V respectively Procedure 2: Defining fuzzy membership functions and rules ‘To perform fuzzy computation, the inputs and outputs rust be converted from numerical o¢ “esp” valve into linguistic forms. The terms such a8 “Seal” and “Big” are ‘sed to quantize the inputs and outputs values to linguistic values. Tn this paper, the linguistic tems that used 10 represent the input and output values are defined by seven fuzzy variables as shown in Table 2. Fuzzy membership functions are used 2s tools wo convert esp. valves to linguist terms. A fuzzy ‘membership fonction can contain. several fuzzy set depending on how many linguistic tems are used. Each fuzzy set represents one linguistic term. In this pape, seven fuzzy sets are oblaned by applying the seven linguistic tenms. The number for indicating how much a eisp value an be a member in each fuzzy set is called a degree of ‘membership. One crisp value can be converted t0 be “parly” in many fuzzy sets, but the membership degree in cach fuzy set may be different Tn order to define fuzzy membership fonction, designers can choose many diferent shapes based on ther preference fr experience. ‘The popular shapes are tiangular and TABLE2 ‘As observed from the PI contol surface, the iia ules Fuzzy LINGUISTIC TERMS sre oonstucted af showed in Table 3. Because the FLC 7 ‘Saas Uses the knowledge from the PI contller, the performance ne — eae ‘obtaining from the FLC is similar othe Pl conwoller. The Pe eficieney can be improved by adjusting the membership re Tra a functions and rls in procedure 3 38 —[ nope Se TABLES — INITIAL RULES ENB [NT] NS] Ze] PS | PM] oe trapezoidal because these shapes are easy 10 represent ce designer's ideas and require low computation tie. For re | | Ps | eM | PB | PB | P| Pe performing fne-uning to improve the efficient of te Pa [Ns [ze [ps [pw [re | pe | po. onteller, the adjacene of each fuzzy set value should PST NALS Lae Les bee eT ‘overap about 25% [19]. The inal membership functions FE NST eR NS TET see |B se illustated in Fig 3. EN er eee 4 NM[NB_[NB_[NB [NM NS [ze | Ps NBL NBD NB NB] NBL NM] NS DZ a Fig 3 Intl membership factions aaa a eect oo saa ete se ors ce Ce tlt ecerccere cat smemaee eaestes engenasees ae a ees at assent one aes Spang eateries tee le lee ce be ere ae Negcgeerestees ec raceees ee Stee pg ae i oe re a ents eeeesien iy suse Sates eae eee at ee om TOs acorns ee -06) © ale) ale whore K,=0.12 and K,=0264 173 ‘To send out the armature voltage ouput, the outpt in the form of fuzzy sets must be converted to a crisp value "This process is called defuzification. In this paper, the center of gravity method is chosen. The formula of this mato is dse o Le where 2s the ouput from defuzificaton, isthe specific Poston at th fuzzy set, and Fis the membership degree at the postion (10), Procedure 3: Adjusting fuzzy membership functions snd rales In order to improve the performance of the FLC, the rules. and membership functions ae adjusted. ‘The ‘membership functions are adjusted by making the area of ‘membership function near ZE region narrower to produce finer control resolution. On the othr hands, making the sea far from ZF region wider gives faster conical response ‘Also, he performance can be improved by changing the ‘eveity ofthe rules [11]. After adjusting the membership functions and rules, the final membership functions and rules are biained as shown in Fig 4, and Table 4, respectively IV. CONTROLLER IMPLEMENTATION A. Hardware Aspects ‘The furay microcontroller, Motorola GBHCBI2A4 used forthe implementation is 16-bit microcontoller with ull 4, Final membership functions TABLES FINAL RULES E] NB [RM] NS] Ze] S| PM] Pe cE PB[ Aw | NS NS | NB | PB | Pe] Pw PAT | NM [NM |-NS [NB | Po | PB | PB. Ps_[-NB[NM | NM Ze | Po] PB | PD. Ze NB | NB NM | Ze | Pw | po | Po NS_[NB-[ NB [NB [Ze | eM | PM | Po Fe NB [NB LNG NB NB LPS _| Ps [Pw 16-bit data paths, $-channel 16 bil timer, 8-channe 8-bit snag to digital convener (A/D), 4K EEPROM, IK RAM, nd mokipleinpuvoutpt ports. In this paper, BHCBIZAG rns at am intemal eloek speed of 8 MHz wits an extemal 1G Mitz osiluor. The special feature of 68HCBI2A4 is the fuzzy logic instruction set which ean perform a fuzzy logic task, "The complete contaler st is composed of Kevin Rost (BHC8I2A4 microcontroller board, input condition circuit, LUCD display, and power supply. The block diagram ofthe controle, microcontroller board, and the complete sup coniroller box are shown in Fig 5(@), 50), and 5(c), respectively =] fete (= eS io Fig (a) Hardware block diagram. The controller receives the actual motor speed input in voltage form fiom the tachometer attached on the DC rotor. This input is preprocesed by the input condition reuit for adjusting volage offset and gain before 1274 i Fig 5), Miroconoller board By actual see Fig 5(¢) Complete FLC. converted to digital data and computing B and CE. After the controller exceutes fuzzy computation, it provides the ‘TTL level PWM output signal to adjust the shat angular velocity and detion to the reference speed that can be changed by using the Keypad. The reference speed and speed eror are deplayed on LCD display, Optex DMC- 16204. The PWM. signal is 3ime amplified by a level shifter circuit before seat to the motor diver. The Schematic dagram of input condition and level shifter are shown in Fig 62nd 7 respectively Fig 6. Input coniition ciruit. ‘The input condition circuit is comprised of four sages Op-Amp Using the +-15 V reference voltage. The fit ‘tage, voltage follower presents a high-impedance input to the tachometer and low impedance ouput tothe inverting amplifier atthe next tage by remain the same volage from Fig 7. Level shifter circuit. the tachometer. The inverting amplitier is used fr sealing the +H135V signal fom the fst stage wo the +425 signal. This signals buffered by the dd stage buffer. This ‘buffer works similarly to the fst stage bufer, but input is ffom the second sage and the output i sent tothe fourth stage Finally, the signal is adjusted tothe O-SV signal that ould be applied for A/D uni on the 6SHCSI2AM. In hs ‘cit, the Burr Brown OPA132 Op-Amp is chosen forthe first and second stage cause of its ability to handle high volage. For the dhrd and fourth sage, the Bur-Brown (OPA is seteced because it provides low noise level and inherently low offset voltage "The level shifter shifts the PWM signals at port F ofthe ricrocoatller from the TTL level to the +/- 15 level ‘hat is the motor driver input level. For this propose, 1CL7661 MOSFET drivers selected. B. Software Aspects ‘A. speed contro and direction conuol of the motor is used inthis paper co illustrate the FLC design. In this implementation, the controller software program is separated to two part, The fist parti the rain program running as an ifrite loop. This loop contains procedures performing diffeent tasks, To setup the reference speed nd direcion, the program hus to monitor ie keypad. When the reference speed and direction are assigned via ‘keypad, the program obtains the cuent speed frm the “AWD unit and computes E and CE to apply with the fzzy ‘compustion routine. Afr the dfuzaieation proces, the uty cycle of dhe PWM signal and the dreton are set via the interop service routines, and then the current speed and ewor shown onthe LCD display are updated. “The second prt is composed of two timer interps. ‘The timers are set to perform as counter. The first timer represents the frequency ofthe PWM signal and remains constant 145 EH since initlized, When the timer i expired, the frst interop service routine is ivoked to set the drction ofthe DC motor and 9 reload inal value ox Second timer to st the duty cycle ofthe PWM signal. The duty cycle and direction of the PWM signal hive been etermined by the fuzzy loge sequence in the main (rogram. When second timer is expired, the second Inmet service routine Is called t tum off the PWM. futput for staring the next cycle. The flowehart of the ‘peration is shown in Fig ‘To perform these tasks efficiently, the implemented program on FLC has to operate at highspeed to minimize {he response time andthe size of the program rust be sal enough to store in on-chip memory. Therefore, the program {is coded by using assembly language. The membership functions and rules are stored with the programs on ROM, and then the membership functions ae transfered (0 the RAM or easy mewifiestio i Future research, 1275 aia ee —— x a Pe ss ee a eS] a mee —— | [enews comets [Sou = | = aa] | Fig 8. Flowchac ofthe algorithms running onthe FLC. \V. EXPERIMENTAL RESULTS In is secon, an experiment is setup to demonstrate the performance of the FLC. The conrllr is teed on diferent velocity tcacking performance both load and no- Tod conditions with a given epecd. The motor load is generated by applying a magnetic load on the rotational fdsk attached on the moor shaft This procedure is equivalent to adding friction load to the motor. In this piper, the motor is operated at 93 ads. The voltage signal from the tachometer witout Toad in forward direction is shown in Fig 9(a) and the real-time PWM signal is ilustated in Fig 90), respectively ‘The results show the FLC could regulate the angular velocity of the DC moter in no-load condition by adspting the duty eycle of the PWM signal. The results ofthe DC ‘motor operated at the same sped under lsd condition are shown in Fig 9(6) and 9(@- These results shows even the Toad is applied, the DC motor can be regulated by the ‘controler and sil rotates at the same speed withthe duty ‘yee ofthe PWM signal extended to mainain the required speed ‘VLCONCLUSION ‘This paper has demonstrated the implementation of FLC for the velocity contol of a DC motor by using 2 fuzzy microcontroller. The FLC is eaty to implement std requires @ small amount of inexpensive components in compact size The controller showed good velocity tracking perfomance unde load and no-load condition. The sizeof {he FLC can be reduced for a smaller application by removing. some redundant components such as LCD a a Ie ia pj cool ete © @ i (© Tachometer oupt from (a), (©) Shifted positive PWM. ‘output with load, (d) Tchomter output from (). splay oc redesigning the boerd layout, Becanse the ‘memberships ae sored ina small sae of RAM, the controller performance could also be easly improved by adding the feature of neuro-fuzzy or adeptive fuzzy logic algorithm ACKNOWLEDGMENT ‘The auhars are grateful 10 Seot Ellit, Jeff Sang, Daniel Wang and Kevin Ros for thei help in ths project. REFERENCES (0) B. J. Chalmers, “Influence of saturation in brushless Dermaneat-magnet motor drives” IEE Proc. B, Elect Power Appl, vol. 139, no. I, p. 51-52, 1992. (21 CT. Jonson and RD. Lorenz, “Experimental ‘denfcstion of friction and its compensation in precise, position conuolled mechanisms,” IEEE Trans. Ind Applicat, vol. 28, no 6, pp. 1392-1398, 1992. (3) C. Canadas, K. J. Astrom, and K. Braun, “Adaptive fiction compensation in DC-motor drives," IEEE Robot, Automat, vol. RA-3, no. 6, pp. 681-685, 1987 (414. Y. Hung, W. Gao, and JC. Hung, “Variable stuctre ‘control: A survey" IEEE Trans. Ind. Eiectom, vo. 40, no spp. 2-22, 1993. (5) H. Butler, G. Hondent, and J. V. Amerongen, “Model Feference adaptive conwol of a directive DC motor.” IEEE Mag. Cont. Sys, vol. 9, n0. 1 p. 80-84, 1989. (6)L. A. Zadeh, “Puzey ses" Informat, Conte, vol. 8, pp. 338.353, 1965. [7VLA. Zadeh, “Outline ofa new approach tothe analysis complex systems and decision processes," (BEE Trans Syst Man Cyber, vol. SMC-3, p. 28-46, 1973. 1276 (81M. Chow and H, Tram, “Applicaton of fuzzy logic {echnology for spatial load forecasting,” IEEE ‘Trans. Power Syst, vol. 12, . 3, pp. 1360-1366, 1997, (91 M. Chow, J. Zia and H, Tram, “Applistion of fuzay muli-objecive decision making in spatial_Toad forecasting.” IEEE Trans. Power Syst, vol 13, 90 3, pp 1185 ~ 1190, 1998, (10) H. Ying. W. Siler, and J.J. Buckley, "Fuzzy contro theory: A nonlinear ease" Automatica, vl. 26, no. 3, pp. 513-520, 1990, (11) M. Chow and A. Menozzi, “On the comparison of emerging and convestional techniques for DC. motor «contr, Proc. IECON, pp. 1008-1013, 1992. [12] 5-H. Kir, 1-H. Pak, S.-W. Leo, and E. K.P, Chong, A two-layered fuzzy logic contller for systems with eadzones." TEBE Trans. Ind. Electron, vol. 4, 0.2, pp. 155-162, 1994 (13) 1-46 Kim, K-C. Kim, and EK. P. Chong, "Fuzzy precompensted PID controllers,” IEEE Trans. Cnt. Sys. Tech, vol. 2,n0. 4, pp. 406-41, 1994 [14] J. 7, Teeter, M. Chow, and J.J. Brickley Je, "A novel Tuzay fiction compensation approach 10. improve the performance of a DC moor contol system,” IEEE Trans. Ind. Electron, vol. 43,10 1, pp. 113-120, 196, 15] C-S. Liu, 1-C. Yang and J-S. Chea, "A normalized Smoothing control scheme based on fuzzy modeling for the contol of DC brushless servo drives” Pros. AMC '96- MIE, vol. 1 pp. 29-34, 1996, 116] PL Lin and C. llsworh, "Design and implementation of a PC-based. universal fizzy logic controler system,” Tat. Cont. IEEEJIAS, pp. 399-408, 1985. [07] P. Guilemin, “Fuzzy logic applied 10 motor contol” TEBE Trans Ind. Applicat, vol. 32,0. 1, pp. 51-56, 1996. [18] M. Togai and H. Watanabe, “Expert system ona chip: ‘An engine for realtime approximation reasoning,” IEEE Expert Syst Mag, vo. 1, pp. 55-62, 1986, [19] B. Kosko, Neural networks and fuzzy systems, Prentice Hall, 1991

You might also like