12.07.2015 Views

Learning digital control systems with a low-cost educational platform

Learning digital control systems with a low-cost educational platform

Learning digital control systems with a low-cost educational platform

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Proceedings of 2005 CACS Automatic Control ConferenceTainan, Taiwan, Nov 18-19, 2005<strong>Learning</strong> <strong>digital</strong> <strong>control</strong> <strong>systems</strong> <strong>with</strong> a <strong>low</strong>-<strong>cost</strong> <strong>educational</strong> <strong>platform</strong>Chyi-Shyong Lee, Juing-Huei Su, Yu-Li Wang, Chia-Ruei Lee, and Jia-Shing FuLunghwa University of Science and Technology, Taiwan, cslee@mail.lhu.edu.twAbstractThe most critical needs for future engineeringgraduates are skills to integrate their knowledge tosolve complex engineering problems. Designs of<strong>digital</strong> <strong>control</strong> <strong>systems</strong> are such examples becausethey involve knowledge of mathematics for modeling,feedback <strong>control</strong>ler design, and knowledge ofmicro-<strong>control</strong>lers for implementation of <strong>digital</strong> <strong>control</strong>algorithms. Therefore, this paper introduces a<strong>low</strong>-<strong>cost</strong> and integrated <strong>educational</strong> <strong>platform</strong> to helpstudents learn step by step to solve the designproblems of <strong>digital</strong> <strong>control</strong> <strong>systems</strong>. Two practicalproblems about the servo <strong>control</strong> of dc-motors andtemperature <strong>control</strong> of a water-tank are used to leadstudents to get familiar <strong>with</strong> the <strong>platform</strong>, and thetheory of system modeling, identification, stabilityanalysis, feedback <strong>control</strong>ler design, and evenself-tuning adaptive <strong>control</strong>ler design <strong>with</strong> recursiveleast square identification algorithms.Key Words: <strong>digital</strong> <strong>control</strong> <strong>systems</strong>, <strong>educational</strong><strong>platform</strong>.1. IntroductionControl <strong>systems</strong> theory and design are oftenbased on abstract mathematical concepts and physics.They are used to help students get familiar <strong>with</strong> thedynamics of the system to be <strong>control</strong>led, and then findways to design a successful feedback <strong>control</strong>ler tomeet prescribed specifications. Moreover, thefeedback <strong>control</strong>ler is often constructed nowadays viasoftware algorithms in micro-<strong>control</strong>lers and analoghardware circuits for input/output of signals. This isbecause of the convenience of updating the algorithmsin software forms and the fast performanceimprovements of micro-<strong>control</strong>lers. Designs of<strong>digital</strong> <strong>control</strong> <strong>systems</strong> therefore involve knowledge ofmathematics for modeling, feedback <strong>control</strong>ler design,and knowledge of micro-<strong>control</strong>lers forimplementation of <strong>digital</strong> <strong>control</strong> algorithms. Inorder to make the education both conceptual andexperiential [1], fast development and <strong>educational</strong>tools for constructing a <strong>digital</strong> <strong>control</strong> system tovalidate the theory in textbooks and to learn practicalissues in implementation are necessary for studentsand engineers to quickly grasp the working principlesof a successful <strong>digital</strong> <strong>control</strong> system.Although the Quanser Inc. (www.quanser.com)has recently developed an <strong>educational</strong> <strong>platform</strong> thatdemonstrate <strong>control</strong> fundamentals by using a widerange of <strong>control</strong> methods, the product usually <strong>cost</strong>shigh and not affordable to students. Chen andNaughton [2] also proposed an undergraduatelaboratory <strong>platform</strong> for <strong>control</strong> system design,simulation, and implementation based on the popularMATLAB/SIMULINK environment. The <strong>platform</strong>presents an excellent environment which al<strong>low</strong>sstudents to focus all their effort on learning the <strong>control</strong>system theory when <strong>control</strong>ling real world <strong>systems</strong>.The only drawback of this <strong>platform</strong> is that studentscan not have a clear picture of how to construct the<strong>control</strong>ler in a micro-<strong>control</strong>ler and the correspondingprogramming and implementation issues. This isbecause the environment is built on top of thereal-time operating system, RTLinux, theMATLAB/SIMULINK software, and a DSP board tohandle all the necessary signal input and outputfunctions. Therefore, all the students have to do is tocode the corresponding <strong>control</strong> algorithms asMATLAB script languages (.m files) or SIMULINKmodels. The environment is easy to use for students,but difficult for teachers to maintain. Moreover, forthose schools which do not purchase theMATLAB/SIMULINK software, it is impossible forthem to adopt the approach as an <strong>educational</strong> tool. Inorder to remedy the above problems and to benefitthose undergraduate students who are in general notwealthy, this paper presents a <strong>low</strong>-<strong>cost</strong> and integrated<strong>platform</strong> to meet the needs. It is cheap and simpleenough that every student can build his own <strong>platform</strong>during the course. Two practical problems about theservo <strong>control</strong> of dc-motors and temperature <strong>control</strong> ofa water-tank are used to lead students step by step toget familiar <strong>with</strong> the <strong>digital</strong> feedback <strong>control</strong> theory,and the software and hardware developingenvironment of the <strong>platform</strong> through implementationof the corresponding <strong>control</strong> algorithms.2. System Overview2.1 Hardware moduleThe proposed <strong>educational</strong> <strong>platform</strong> whose blockdiagram is shown in figure 1 is a single boardcomputer and it <strong>cost</strong>s less than 1500 NT dollars (see


Proceedings of 2005 CACS Automatic Control ConferenceTainan, Taiwan, Nov 18-19, 2005table 1 for <strong>cost</strong> analysis). It consists of anATmega128 RISC CPU, an RS232 port tocommunicate <strong>with</strong> a PC, an in system programming(ISP) port for downloading programs from a PC to the128K byte flash memory, 6 pulse width modulation(PWM) output channels to drive power switches, 8A/D ports for accessing physical signals, an encoderinput port <strong>with</strong> resolutions being increased 4 times viaa programmable logic device (PLD), and several<strong>digital</strong> I/O ports. The reasons to choose an 8-bitmicroprocessor whose price is comparable to a <strong>digital</strong>signal processor (TMS320C24x) are threefold: 1)internal flash ROM size (128Kbyte) is larger, and canbe easily accessed via the ISP port; 2) softwaredeveloping environment can be constructed <strong>with</strong>outany additional <strong>cost</strong>, and 3) the undergraduate studentsare more familiar <strong>with</strong> 8-bit micro-<strong>control</strong>lers than<strong>digital</strong> signal processors (TMS320C24x). Thedrawback for this choice is that the computationalspeed is s<strong>low</strong>er for multiplication and division,although this does not create too much trouble in ourexperiments.To download programs into the microprocessorby using the ISP port of ATmega128, a simple andcheap hardware interface circuit connected to theprinter port of a PC is necessary(www.lancos.com/e2p/avrisp-stk200.gif). Thecorresponding software, PonyProg2000, which runs atthe PC side can also be freely downloaded from theweb page www.lancos.com/ppwin95.html. Theencoder input circuit which is capable of increasingthe resolution 4 times of the original signals comingfrom an encoder is shown in figure 2. The idea isfrom an application note [10] by Microchiptechnology, Inc., and the programming equations ofthe PLD are listed in the fol<strong>low</strong>ing table:Table 1: Programming equations of the PLD forresolution enhancementPLD programming equations;---------------------------------------MODULE ENCODEDECLARATIONSIA , IB ,CLK,Mode PIN 2,3,1,4;UP,DOWN,U_D,DIR PIN 16,17,15,14;S1 ,S3, S2, S4,X1 NODE;EQUATIONSS2 := S1;S4 := S3;S1 := IA;S3 := IB;UP =(!S1 & S2 & S3 & S4+S1 & S2 & S3 & !S4 & Mode+S1 & !S2 & !S3 & !S4 & Mode+!S1 & !S2 & !S3 & S4 & Mode );DOWN =(S1 & S2 & !S3 & S4 & Mode+!S1 & S2 & !S3 & !S4 & Mode+!S1 & !S2 & S3 & !S4+S1 & !S2 & S3 & S4 & Mode );U_D := UP + DOWN;X1:=DIR;DIR=(UP # X1) &!DOWN;ENDThe resolution enhancement circuit can not onlygenerate two separate 4 times resolution up and downcount signals, it can also give an up/down countingsignal and a direction signal to meet different needs.The entire hardware circuit is shown in figure 3.Sensor Circuits:Temperature orcurrent ...Download program via ISP 8 A/D portsPersonal computer:communication &<strong>control</strong>Figure 1.Figure 2.RS2322.2 Software moduleMicro‐<strong>control</strong>ler:AVR mega128downEncoder counter:PLD for resolutionenhancement (4x)up6 PWMchannelsPhysical variablesΦ 1Φ 2Driver Circuits:for Motor or RelayThe hardware configuration of the<strong>educational</strong> <strong>platform</strong>The encoder interface circuit that provides4 times resolutionThe programming language used in the<strong>educational</strong> <strong>platform</strong> is C, because of its portabilityand easy readability when compared <strong>with</strong> theassembly language.Thanks to the GNU project (www.gnu.org), theGNU C compiler for ATmega128 can be freelydownloaded from the web site www.avrfreaks.net, tohelp us construct the programming environment at no<strong>cost</strong>. The communication program shown in figure 4is written by using visual basic and provides functionsof loading <strong>control</strong> parameters into the microprocessor,receiving data of <strong>control</strong>led variables from themicroprocessor through the serial RS232 bus,graphical representation of data, and saving data asMATLAB m-file format. Sample software codes aregiven to students such that more sophisticated analysistools could be implemented on top of them.3. ExperimentsTwo basic <strong>control</strong> problems are devised to helpstudents turn <strong>digital</strong> <strong>control</strong> theories into workingalgorithms in the <strong>educational</strong> <strong>platform</strong>, such that all


Proceedings of 2005 CACS Automatic Control ConferenceTainan, Taiwan, Nov 18-19, 2005the theories, the practical implementation issues, andproblem solving skills can be more efficiently learnedduring the course. The first one is <strong>digital</strong> servo<strong>control</strong> of DC motors, and the second one is <strong>digital</strong>temperature <strong>control</strong> of a water tank. They are simplesingle input single output (SISO) <strong>systems</strong>, and yetprovide enough theoretical and practical issues forstudents to learn.AVR mega128LM18200 H-bridge motor driver<strong>with</strong> current sensingDC motor[3]. The mathematical models are then transformedto zero-order-hold sampled-data models [4]. Oncethe students are familiar <strong>with</strong> the modeling process,the coefficients of the corresponding discrete-timemodel for a DC motor can then be obtained by usingthe least-square estimation method [4, p.511], and thecoefficients of the corresponding analog model forheat transfer of a water tank can be found by using theon-line method proposed in [5], or the offline methodsin [9].RS232 portISP portFigure 3.PWM, ADC, and I/O portsencoder signalresolution enhancementencoder signal inputThe photograph of the entire hardwarecircuitFigure 4. The operation window of thecommunication programIn these two experiments, the H-bridge driverfrom the National semiconductor Corporation(www.national.com/pf/LM/LMD18200.html) is usedas a DC motor driver, and a solid-state relay is used todrive the heater in the <strong>digital</strong> temperature <strong>control</strong> of awater tank. The entire setup of the target <strong>systems</strong> areshown in figure 5. Both experiments consist of threeparts to lead students step by step to learn thenecessary <strong>digital</strong> <strong>control</strong> theories and to implement thecorresponding software codes. They are: 1)modeling and identification of physical <strong>systems</strong>, 2)performance and stability requirements of feedback<strong>control</strong>led <strong>systems</strong>, and 3) design of PID <strong>control</strong>lers<strong>with</strong> anti-windup function, and tuning of <strong>control</strong>parameters.3.1 Modeling and identification of physical <strong>systems</strong>Modeling of DC motors and heat transfer of awater tank can be found in text book by Franklin et al.3.2 Stability and performance requirements forfeedback <strong>control</strong>led <strong>systems</strong>Stability and performance analysis of a feedback<strong>control</strong>led system are very important skills forstudents to make sure they will not destroy thehardware circuits and implement a usable <strong>control</strong>algorithm. Closed-loop stability assured by applyingthe Routh’s and Jury’s stability criterion [3-4], theNyquist criterion, and Bode’s gain-phase relationshipare concepts that students should keep in mind duringthe course. Time-domain specifications forperformance requirements of a step response are alsointroduced such that students will try to fine tune the<strong>control</strong> parameters to meet the requirements. It isbecause our objective is to lead students to solvepractical <strong>digital</strong> <strong>control</strong> problems by using the<strong>educational</strong> <strong>platform</strong> in a semester that those moreadvanced stability theory and frequency-domainspecifications for performance requirements are notincluded in our course.Table 1. Cost analysis of the <strong>educational</strong> <strong>platform</strong>Price,Components and sub<strong>systems</strong>NTD$ATmega128_16MHz 300Resolution enhancement circuit for75encoder signalsRS232 communication circuit 30In system programming circuit 60PCB board 150LMD18200 H-bridge driver circuit fordc motors500Solid-state Relay (12A) and temperaturesensor circuits300Total 14153.3 Design of PID <strong>control</strong>lers <strong>with</strong> anti-windupfunction and tuning of <strong>control</strong> parametersWhen the model parameters are at hand, themethods in [6, 8] about PID <strong>control</strong>ler design and its<strong>digital</strong> implementation [4, p.306] and implementationof anti-windup functions [7, 4 p. 310] are used astheoretical background for <strong>digital</strong> feedback <strong>control</strong>lerdesign. This is because PID <strong>control</strong>lers are mostoften used in industrial <strong>control</strong>. After discussions ofthese theories, an initial software example code of the


Proceedings of 2005 CACS Automatic Control ConferenceTainan, Taiwan, Nov 18-19, 2005<strong>digital</strong> feedback <strong>control</strong>ler is given to students suchthat they can modify the <strong>control</strong>ler parameters andeven the <strong>control</strong>ler structure [6] to see if the responsescoincide <strong>with</strong> the theoretical predictions. If not,double check of the software codes and theories canmake them more familiar <strong>with</strong> problem-solvingtechniques. Experimental results which compare theperformances of the servo <strong>control</strong> of dc motors <strong>with</strong>and <strong>with</strong>out the anti-windup function are shown infigure 5. The robustness of the <strong>digital</strong> temperature<strong>control</strong>ler is shown via experimental results in figure 6by changing the amount of water in the water tank.Figure 5. The experimental results of <strong>digital</strong> servo<strong>control</strong> of DC motors <strong>with</strong> and <strong>with</strong>out anti-windupfunction4. ConclusionsA <strong>low</strong> <strong>cost</strong> <strong>educational</strong> <strong>platform</strong> is devised in thispaper. It can be constructed for servo <strong>control</strong> of dcmotors and temperature <strong>control</strong> of a water tank forless than USD$ 50. Two experiments are devised tohelp students become familiar <strong>with</strong> the necessary<strong>control</strong> theories and the corresponding softwareimplementation for the servo <strong>control</strong> of a dc motorand temperature <strong>control</strong> of a water tank. This canhelp encourage students to make their own<strong>educational</strong> <strong>platform</strong> and learn to solve by themselvesmore practical <strong>digital</strong> <strong>control</strong> problems. To make the<strong>educational</strong> <strong>platform</strong> more versatile, the USB portshould be used to increase the communication speedbetween the <strong>educational</strong> <strong>platform</strong> and the personalcomputer. This may be done <strong>with</strong> the help of theUSB interface device [11]. Moreover, the <strong>digital</strong>signal <strong>control</strong>ler (dsPIC) provided by the MicrochipTechnology Inc. is another affordable choice ofmicro-<strong>control</strong>ler for its fast computational speed andversatility. It is also easy to setup the developmentenvironment for the <strong>digital</strong> signal <strong>control</strong>ler (dsPIC)<strong>with</strong>out too much money.Figure 6. Robustness analysis of the <strong>digital</strong> PIDtemperature <strong>control</strong>ler <strong>with</strong> and <strong>with</strong>out anti-windupfunctionSince tuning of PID <strong>control</strong>ler parameters may betedious in practice, techniques in auto-tuning of<strong>control</strong>ler parameters [2, 4] are introduced to studentsafter they successfully apply theories to design PID<strong>control</strong>lers in both the problems. Because of thecomputational complexity, the self-tuning adaptivefeedback <strong>control</strong>ler for servo <strong>control</strong> of dc motors byusing recursive least square (RLS) estimation can onlybe demonstrated in our dSPACE real time <strong>control</strong>environment if the order of the reference model isgreater than or equal to 2. The student can stillimplement a convergent RLS algorithm on the<strong>educational</strong> <strong>platform</strong> if the sampling frequency is nottoo high and a reference model of order 1 is used.Figure 7 shows the experimental results of asuccessful self-tuning adaptive feedback <strong>control</strong>ler,whose reference model is of order 1. On the otherhand, the algorithm described in [5] for on-lineidentification of system parameters and auto-tuning ofPID <strong>control</strong>ler parameters can be successfullyimplemented in the <strong>educational</strong> <strong>platform</strong>, because thedynamics for heat transfer in the temperature <strong>control</strong>of a water tank is s<strong>low</strong>.Figure 7. The experimental results of a successfulself-tuning adaptive feedback <strong>control</strong>ler, whosereference model is of order 15. References[1] D. S. Bernstein, “Enhancing undergraduate<strong>control</strong> education,” IEEE Control SystemsMagazine, pp. 40-43, October 1999.[2] Y.-C. Chen and J. M. Naughton, “Anundergraduate laboratory <strong>platform</strong> for <strong>control</strong>system design, simulation, and implementation,”IEEE Control Systems Magazine, pp. 12-20,June 2000.[3] G. F. Franklin, J. D. Powell, and A.Mami-Naeini, Feedback <strong>control</strong> of Dynamic<strong>systems</strong>, 4 th edition, , chapter 2, Prentice-Hall,Inc., 2002.


[4] K. J. Åström and B. Wittenmark,Computer-Controlled Systems: Theory andDesign, 3 rd edition, Prentice-Hall, Inc., 1997.[5] K. J. Åström and T. Hägglund, ”Automatictuning of simple regulators <strong>with</strong> specificationson phase and amplitude margins,” Automatica,Vol. 20, No. 5, pp. 645-651, 1984.[6] R. Kelly and J. Moreno, “<strong>Learning</strong> PIDstructures in an introductory course of automatic<strong>control</strong>,” IEEE Transactions on Edcuation, Vol.44, No. 4, pp. 373-376, November 2001.[7] C. Bohn and D. P. Atherton, “An analysispackage comparing PID anti-windup strategies”IEEE Control Systems Magazine, pp. 34-40,April 1995.[8] E. Eitelberg, “A regulating and tracking PI(D)<strong>control</strong>ler,” International Journal of Control,Vol. 45, No. 1, pp. 91-95, 1987.[9] J. C. Basilio and M. V. Moreira, “State-spaceparameter identification in a second <strong>control</strong>laboratory,” IEEE Transactions on Edcuation,Vol. 47, No. 2, pp. 204-210, May 2004.[10] Microchip Technology, Inc., “Servo Control of aDC-Brush Motor,” application note AN532,1997.[11] Royal Philips Electronics, PDIUSBD12: USBinterface device <strong>with</strong> parallel bus,www.semiconductors.philips.com/pip/PDIUSBD12D.html.AcknowledgementsThe authors would like to thank National ScienceCouncil for its financial support under grantNSC-94-2613-E262-004.Proceedings of 2005 CACS Automatic Control ConferenceTainan, Taiwan, Nov 18-19, 2005

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!