A Laboratory Testbed for Embedded Computer ... - Semantic Scholar

2 downloads 70748 Views 389KB Size Report
modern embedded computers in control and other applications in the past few ... programming languages, there exist few courses that focus on integrating these .... vides facilities to implement embedded programs using coop- ..... [Online]. Available: www.control.lth.se/ kursdr/ifac.pdf. [9] Z* World, Inc., Davis, CA. (2003 ...
340

IEEE TRANSACTIONS ON EDUCATION, VOL. 47, NO. 3, AUGUST 2004

A Laboratory Testbed for Embedded Computer Control Mehrdad Moallem, Member, IEEE

Abstract—There has been a tremendous growth in the use of modern embedded computers in control and other applications in the past few years. While courses offered in the electrical and computer engineering disciplines cover such topics as microprocessors, digital and analog hardware, control theory, and programming languages, there exist few courses that focus on integrating these subjects for designing embedded systems. On the other hand, there is a growing need in industry for engineers who can perform software design and system integration for various applications in embedded control. Toward filling this gap, this paper describes a laboratory testbed developed for a new course on Embedded Computer Control offered at the University of Western Ontario, London, ON, Canada. An outline of the course structure, laboratory setup, and the design aspects for implementing a modern embedded control application are presented. The embedded controller performs command, control, and user interface tasks required to operate a low-cost prototype of a thermal system. Furthermore, its network connectivity allows users to tune system parameters, start and stop running the system, and observe the status of the plant via the Internet. Index Terms—Computer control, embedded computing, modular design, real-time control.

I. INTRODUCTION

E

MBEDDED computing is an enabling technology dealing with the engineering of computer systems used in such areas as command and control, communications and multimedia, and information systems. Emerging technologies, such as microelectromechanical systems (MEMS), wireless ad-hoc networks, smart homes and work spaces, intelligent highways, and medical mechatronic devices, would require use of even more embedded computers. The opportunities seem to be endless and limited only by creative designs and novel technologies. Certain challenges exist in developing efficient embedded computer systems. First, because of their nature, the design of embedded applications often require multidisciplinary and cross-disciplinary skills. Second, many embedded applications are real time, meaning that the correctness of computations is as important as their timeliness. In this regard, a computer-controlled system under closed-loop feedback can be considered as real time because the control algorithm has to be computed within each sampling period and the system could become unstable if the period is too long. Third, modern embedded applications have sophisticated functionality, requiring execution Manuscript received February 19, 2003; revised June 15, 2003. The author is with the Department of Electrical and Computer Engineering, University of Western Ontario, London, ON N6A 5B9, Canada (e-mail: [email protected]). Digital Object Identifier 10.1109/TE.2004.825054

of concurrent tasks and intensive algorithms. The design of an embedded computer system involves compromises between memory usage of the application code, power consumption of the module, processor speed, algorithm complexity, use of modern sensor and actuator technologies, and cost of hardware and software components. As mentioned by Wolf and Madsen [1], early microprocessor applications emphasized input and output (I/O), and not computations. Today’s microprocessors have large computing power, which facilitate implementation of structured design methodologies. Wolf and Madsen [1] have discussed why the next generation of courses in embedded computing should move away from components toward analysis and design of systems. With regard to control systems, Boasson [2] analyzed software design issues for complex control systems, emphasizing the need for highly modular and expandable software architectures. Stewart et al. [3], [4] developed a real-time operating system, called Chimera, for reconfigurable, sensor-based control systems and introduced the concept of port-based objects (PBOs)—a software framework that supports the design and implementation of sensor-based control systems. Real-time operating systems (RTOSs) have been utilized in several control applications to implement modular architectures [5], [6]. With the ever-increasing role of embedded computing in today’s applications, the introduction of new courses in electrical, computer, and software engineering disciplines are needed. In this regard, such courses should focus on integrating design techniques with concepts introduced in previous courses. In this paper, details of a laboratory project designed to accompany a course on embedded and real-time computer control are presented. The project is designed to provide an opportunity for students to integrate topics covered in the course with previously taken courses in programming and computer science, signal processing, controls, microprocessors, and electronics. This paper is organized as follows. Section II describes the course structure, the laboratory setup, and the capstone project. Section III discusses design issues in developing software for the system. In Section IV, some results on incorporating the system into a course project and feedback received from students are presented. II. COURSE STRUCTURE AND LABORATORY SETUP Because of the growing importance of embedded computer systems, a new undergraduate–graduate course was recently introduced in the Department of Electrical and Computer Engineering, University of Western Ontario, London, ON, Canada.

0018-9359/04$20.00 © 2004 IEEE

Authorized licensed use limited to: Rajamangala Univ of Tech Phra Nakhon. Downloaded on June 7, 2009 at 02:55 from IEEE Xplore. Restrictions apply.

MOALLEM: LABORATORY TESTBED FOR EMBEDDED COMPUTER CONTROL

Fig. 1.

341

Components of the temperature control system.

Fig. 2. Circuit diagram of the I/O panel board.

The objective of the course is to introduce procedures for designing embedded computer-controlled systems. The underlying lecture material covers embedded computer systems with a special focus on control applications. Two main references were selected for this purpose, i.e., the textbook by Wolf [7], and a technical report by Wittenmark et al. [8]. While the latter reference discusses practical issues, such as discretization, anti-aliasing filters, selection of sampling rates, and integrator wind-up with regard to implementation of control algorithms, the former one is useful from an embedded-systems-design point of view. The textbook covers such topics as design procedure using the unified modeling language (UML) for system specification, high-performance microprocessor architectures, high-level language programming and its relationship

to assembly code, optimization for power, speed, and memory size, and embedded systems networking. A. Laboratory Setup The students are required to design the software and build a sensor-based feedback control system, using a proportional– integral–derivative (PID) controller with existing components. Although the students need to understand how the hardware in an embedded system works, the decision was made to provide the students with prebuilt hardware modules. The system is depicted in Fig. 1 and is comprised of a tube, consisting of a dc fan (used for cooling the tube), a lamp (for heating the tube), a 10–k thermistor for measuring temperature, an I/O panel consisting of four push-button switches, a

Authorized licensed use limited to: Rajamangala Univ of Tech Phra Nakhon. Downloaded on June 7, 2009 at 02:55 from IEEE Xplore. Restrictions apply.

342

IEEE TRANSACTIONS ON EDUCATION, VOL. 47, NO. 3, AUGUST 2004

Fig. 3.

BL2000 microcontroller unit (MCU) pinout (from Z World, Inc.).

buzzer, a potentiometer, and a microcontroller development kit (BL2000 from Z World, Inc. [9]) comprised of a Rabbit 2000 processor running at 22.1 MHz. The microprocessor is interconnected with analog and digital (A/D) I/O chips, and 256 kB of Flash Memory and 128 Kb SRAM. A development workstation is connected by a serial port to the embedded microcontroller unit. Fig. 2 illustrates the circuit diagram of the I/O panel, consisting of push-button switches, light-emitting diodes (LEDs), a buzzer, and a potentiometer. The potentiometer can be used for different purposes. It can be used as a set point for temperature or can be combined with push-button switches for tuning the PID controller gains. The push-button keys are used as digital inputs. Using these keys, the user may turn the system ON or OFF, set the maximum speed of the fan, or change the PID gains. Similarly, the LED outputs may be used to display the status of switches, and the buzzer can be used to inform the user if the temperature has gone above or below certain limits. Fig. 3 illustrates the pinout of the BL2000 microcontroller unit (MCU) from Z World, Inc. [9]. The MCU provides A/D I/O and an Ethernet port on a single-board computer unit. The Ethernet model was selected for remote monitoring and supervisory control. The programming environment uses Dynamic C, which is an integrated C compiler, editor loader, and debugger for embedded control and communication applications. It provides facilities to implement embedded programs using cooperative multitasking and can be extended to support a real-time kernel [9]. In Fig. 1, the motor and lamp are driven by pulsewidth-modulated signals to control the temperature in the tube. The drive

electronics consist of two buffers and two complementary metal–oxide–semiconductor (CMOS) transistors working as ON/OFF switches. Fig. 4 shows different hardware components of the system put together. The capstone project requires students to design the software for a network-enabled control system for regulating the temperature inside the tube. The temperature is regulated by turning on either the fan or the lamp based on the voltage developed across the thermistor. The I/O panel and a Web browser provide user interfaces to the system and can be used to monitor the temperature of the system, tune PID controller gains, and start or stop operation of the system from either the I/O panel or a Web browser. The 10Base-T Ethernet port streams data directly through an RJ-45 connector. The available transmission control protocol/Internet protocol (TCP/IP) libraries allow for Ethernet communications and include libraries for sending email and running http servers. As a requirement of the project, the system should send e-mail messages to a user under certain conditions, e.g., to report a failure condition, such as a high tube temperature. Fig. 5 shows the system under control from an Internet browser. III. DESIGN OF THE CONTROL SYSTEM SOFTWARE Software plays a critical role in modern embedded computer control systems. Coding a feedback control algorithm that works properly is often not sufficient. Software design must also take into account such issues as functionality, user interface, safety and reliability, upgradability, power consumption, and system costs. In this regard, the importance of modular

Authorized licensed use limited to: Rajamangala Univ of Tech Phra Nakhon. Downloaded on June 7, 2009 at 02:55 from IEEE Xplore. Restrictions apply.

MOALLEM: LABORATORY TESTBED FOR EMBEDDED COMPUTER CONTROL

343

modulation (PWM) controller software classes. Special classes representing hardware components are denoted by asterisks. The main module, i.e., the temperature controller, is responsible for initializing other modules, establishing links between modules, and running the system tasks. In the following, the design of some of the main system components are discussed. 1) Pid Controller: The simplest form of PID control algorithm is given by (1)

Fig. 4. Embedded system hardware components.

where is the error term and is the control signal (Fig. 7). When obtained from (1) is positive, the lamp is operated, and when it is negative, the fan is operated. The system features in terms of these two inputs are of course different, but proper PID feedback would desensitize the system performance as a result of these changes. From a practical point of view, implementation of the previously mentioned algorithm has certain limitations [8]. First, because of actuator saturation, the integrator can wind up leading to a sluggish transient response. Second, the pure differentiation term amplifies noise that can lead to deterioration of the control command. Finally, the differentiation term acts on the error signal, taking the derivative of the command signal as well. This procedure can lead to spikes in the command signal when the user abruptly changes the set point. Following [8], a modified PID control algorithm that overcomes these problems is given in the Laplace domain by

Fig. 5. Embedded system controlled and monitored using an Internet browser.

design is emphasized from the outset in the course. Case studies in embedded systems are presented from [7] that follow the software engineering design life cycle: requirements, specifications, architecture design, components design, and system integration. Problem decomposition in the form of top-down, bottom-up design, and use of software design diagrams (e.g., class, state, and sequence diagrams) are discussed. A. Design Guidelines In the author’s experience, some guidance should be provided to the students as how to design the system to allow them to better grasp the concepts discussed in the course and integrate them with material learned in previous courses. Toward this end, some class sessions are devoted to discussing the design procedure as described in the following. The first step in the design process is to have a set of requirements as summarized in Table I. The requirements phase is needed to understand the nature of the project and identify the function and performance of the module to be designed. Since some components of the system are already given, the design steps involving specifications and architecture (in particular, hardware architecture) can be performed quickly. The class diagram illustrated in Fig. 6 shows components of the software architecture in UML form. The temperature controller class is comprised of the user interface, PID controller, and pulsewidth

(2) where , , , , and are controller parameters, and , , and denote the Laplace transforms of , , and , respectively. In order to implement the control algorithm on an embedded computer, (2) has to be discretized. Denoting the sampling period by , and using backward differences to discretize the derivative term and forward differences for the integral term, one has (3) where

denotes the -th sampling instant and

(4) Having obtained the discretized control algorithm, the focus lannow is on modular implementation of the algorithm. guage is probably the most widely used language for embedded

Authorized licensed use limited to: Rajamangala Univ of Tech Phra Nakhon. Downloaded on June 7, 2009 at 02:55 from IEEE Xplore. Restrictions apply.

344

IEEE TRANSACTIONS ON EDUCATION, VOL. 47, NO. 3, AUGUST 2004

TABLE I REQUIREMENTS FORM FOR TEMPERATURE CONTROLLER

Fig. 6. UML class diagram showing composition of subsystems.

Fig. 7. Block diagram of the temperature feedback control system.

systems, including the environment used in the laboratory. In order to develop modular embedded software in , one has to use abstact data types (ADTs). An ADT is a precursor to objects

and consists of a data structure and a set of methods that operate on the structure. Toward this end, an appropriate data type for the PID controller module in Fig. 6 is as follows.

Authorized licensed use limited to: Rajamangala Univ of Tech Phra Nakhon. Downloaded on June 7, 2009 at 02:55 from IEEE Xplore. Restrictions apply.

MOALLEM: LABORATORY TESTBED FOR EMBEDDED COMPUTER CONTROL

345

3) User Interface: The user interface module in Fig. 6 is comprised of two modules: 1) the I/O panel module, which scans the I/O panel for new inputs from the push-button switches and the potentiometer and provides outputs to the LEDs and the buzzer and 2) the I/O network module, which provides an interface to the network port. The I/O panel module can be defined as follows.

; The routines that operate on the data type are used for initializing, updating, and calculating the PID controller and take the following general form.

The PID controller module interacts with the temperature sensor, PWM controller, user interface, and PWM controller modules. Thus, appropriate parameters (indicated by …) have to be passed to the above routines from these modules. 2) PWM Controller: The PWM controller obtains its data from the PID controller and sends PWM pulses to either the fan or the lamp. The PWM controller is implemented through software by sending high and low digital values to a digital output channel. The corresponding data type for this module can be defined as follows:

In addition, the following routines operate on the type.

data

The TCP/IP protocol suite allows application layer protocols for sending e-mail, transferring files, using the file transfer protocol (FTP), and displaying Web pages, using the hypertext transfer protocol (HTTP). The simple mail transfer protocol (SMTP) is used to send e-mail messages from a client to a mail transfer agent (MTA) [10]. As a requirement of the course project, the embedded system should send emergency messages to a user if the temperature sensor reads values above or below some critical limits. Another interesting application is control and monitoring the system from an Internet browser. Toward this end, the software suite has an http library that facilitates implementing a Web-server task on the embedded system. A typical interface to the http server task running on the embedded processor is shown in Fig. 8. Using an Internet browser, a user can monitor the tube’s temperature, start and stop the system, change the set-point temperature, and tune the PID controller gains. 4) Temperature Sensor: This module consists of a thermistor in series with a resistor, as shown in Fig. 1. The voltage across the thermistor is read by an A/D input channel. The is a function of temperature resistance of the thermistor given by (5)

with the following routines that operate on the type:

data

where is a known resistance at temperature , and is a constant. in Fig. 1 can be used to The measured voltage across obtain the temperature of the thermistor, which can be obtained from (5) as (6)

Authorized licensed use limited to: Rajamangala Univ of Tech Phra Nakhon. Downloaded on June 7, 2009 at 02:55 from IEEE Xplore. Restrictions apply.

346

IEEE TRANSACTIONS ON EDUCATION, VOL. 47, NO. 3, AUGUST 2004

Thus, (6) can be used to obtain the temperature (in degrees Kelvin) based on the voltage read by the A/D converter. B. Execution of Tasks Concurrent programming allows for separation of modules into separate tasks and is a key element in modular software development. The tasks can be executed on a processor using cooperative or preemptive multitasking. In the latter case, tasks can preempt one another based on their priorities, while in the former case, each separate task voluntarily relinquishes the processor when it does not need to perform any more activity immediately. Thus, a given task can suspend itself and let other tasks run in its idle time. Unlike preemptive multitasking, variables can be shared between different tasks without having to take precautions for shared variables. The software environment allows for both schemes to be implemented. Analysis of schedulability of tasks is helpful in evaluating performance of the system and can provide guidelines for maximal utilization of the processor. For a priority-based preemptive kernel, the rate monotonic analysis [11] and its modifications [12] can be used to determine the schedulability of a task set. For the case where a nonpreemptive kernel is used, one has to consider the structure of the code. The cooperative multitasking kernel is used to implement periodic tasks using the following construct [9].

Fig. 8. Web browser interface to the embedded system.

it takes seconds to execute the interrupt code. Denote the loop to be executed maximum time it takes for a for (; ;) by . Then, can be obtained by solving (7) Taking the deadline of each task equal to its period, a necessary condition for all tasks to meet their deadlines is that the period of each task be greater than the worst case execution time of the loop, i.e.,

(8) The schedulability condition (8) can be used as a guideline to guarantee that all tasks meet their deadlines. Qualitatively, reducing the execution times and increasing the periods would help satisfy the inequality condition given by (8). Students are required to measure execution times of the tasks, perform a quantitative analysis of the schedulability of the task set, and take appropriate measures if the schedulability test fails, e.g., by changing the tasks’ periods or optimizing code for speed. IV. DISCUSSION OF RESULTS

In the construct, costates are blocks of code that can suspend themselves by executing waitfor( ) statements, yield execution to other tasks, or abort their execution. In order to provide a timing analysis for the system, denote the periods and the , and worst case execution times of the tasks by , respectively. A timer interrupt is used to update a global variable that keeps track of the time. The delay() functions in the code listing above use this global variable to identify whether or not the corresponding task has to be executed. seconds, and Suppose that the timer interrupt runs every

In general, the students’ responses to the project were quite positive. Some students from the Electrical Engineering option, who had less background in programming and were not paired with students in the Computer Engineering option, had some difficulty in developing code and testing their programs. However, the majority of students maintained that the material for doing the project was well laid out and that the project had made the course interesting by integrating concepts from microprocessors, programming, control, and electronics. All the groups managed to finish their projects after six laboratory hours (two lab sessions). The preliminary laboratory exercises were helpful in this regard as they were designed to guide the students toward implementing the building blocks required

Authorized licensed use limited to: Rajamangala Univ of Tech Phra Nakhon. Downloaded on June 7, 2009 at 02:55 from IEEE Xplore. Restrictions apply.

MOALLEM: LABORATORY TESTBED FOR EMBEDDED COMPUTER CONTROL

347

ACKNOWLEDGMENT The author would like to acknowledge help provided by teaching assistants K. Kang, H. Bassan, and P. Yuan, in developing several of the laboratory experiments, and B. Kettlewell, G. Aarsten, and E. Porter of the Electronic Shop at the University of Western Ontario, London, ON, Canada, for building the electronic components of the system. The feedback and constructive comments by students has also been valuable in developing the laboratory. REFERENCES

Fig. 9.

Flowchart of preparatory experiments.

by the project. A flowchart for these experiments is shown in Fig. 9 which includes writing simple programs to perform cooperative multitasking, perform A/D I/O, obtain characteristics of the temperature sensor, and run the motor and lamp using PWM. A typical size of the code developed by students was 160 to 200 lines, excluding the system functions and libraries. The graduate students taking the course were required to implement the more challenging network interface and e-mail programs. Figs. 4, 5, and 8 illustrate systems implemented by students. Other recommended projects could focus on adding an FTP server task for streaming sensor data to a host workstation and the use of wireless technology for remote control and monitoring. V. CONCLUSION Control systems are one of the main application domains for embedded computing. With the complexity of applications growing rapidly, it is very important that engineers designing control systems be educated so that they are aware of the design procedures and challenges in embedded computing technology. An experimental testbed for design and implementation of embedded control software was developed to serve as the laboratory component of an undergraduate–graduate course on Embedded Computer Control. The course material and project integrate concepts taught in several other courses, including microprocessors, control systems, programming and software development, and electronics. The low-cost temperature control platform provides students with a hands-on environment to develop fundamental skills in the design and implementation of embedded computer systems. The opportunity for students to experiment with a network-enabled system allows them to get familiar with state-of-the-art technologies, such as network appliances and their potential applications in industrial measurement and control.

[1] W. Wolf and J. Madsen, “Embedded systems education for the future,” Proc. IEEE, vol. 88, pp. 23–30, Jan. 2000. [2] M. Boasson, “Control systems software,” IEEE Trans. Automat. Contr., vol. 38, pp. 1094–1106, July 1993. [3] D. B. Stewart, D. E. Schmitz, and P. K. Khosla, “The Chimera II real-time operating system for advanced sensor-based robotic applications,” IEEE Trans. Syst., Man, Cybern., vol. 22, pp. 1282–1295, Nov.–Dec. 1992. [4] D. B. Stewart, R. A. Volpe, and P. K. Khosla, “Design of dynamically reconfigurable real-time software using port-based objects,” IEEE Trans. Softw. Eng., vol. 23, pp. 759–776, Dec. 1997. [5] M. Moallem, R. V. Patel, and K. Khorasani, “Nonlinear tip-position tracking control of a flexible-link manipulator: Theory and experiments,” Automatica, vol. 37, pp. 1825–1834, 2001. [6] M. Moallem, “Electron beam position monitoring and feedback control in duke free-electron laser facility,” IEEE Trans. Ind. Electron., vol. 49, pp. 423–432, Apr. 2002. [7] W. Wolf, Computers as Components: Principles of Embedded Computing System Design. San Francisco, CA: Morgan Kaufmann, 2001. [8] B. Wittenmark, K. J. Astrom, and K.-E. Arzen. (2003) “Computer Control: An Overview”. Department of Automatic Control, Lund Institute of Technology, Sweden. [Online]. Available: www.control.lth.se/ kursdr/ifac.pdf [9] Z* World, Inc., Davis, CA. (2003, April). [Online]. Available: http://www.zworld.com/company/ [10] M. T. Jones, “Embed with the mailman,” Embedded Systems Programming, pp. 45–52, Oct. 2001. [11] C. L. Liu and J. W. Layland, “Scheduling algorithms for multiprogramming in a hard real-time environment,” J. Assoc. Comput. Mach., vol. 20, no. 1, pp. 46–61, 1973. [12] L. Sha, R. Rajkumar, and S. S. Sathaye, Proc. IEEE (Special Issue on Real-Time Systems), vol. 82, no. 1, pp. 68–82, 1994.

Mehrdad Moallem (S’95–M’97) received the B.Sc. degree in electronic engineering (with highest ranking) from Shiraz University, Iran, the M.Sc. degree in electronic engineering from Sharif University of Technology, Tehran, Iran, and the Ph.D. degree in electrical and computer engineering from Concordia University, Montreal, QC, Canada, in 1997. He has held postdoctoral and research positions at Concordia University, Montreal, QC, Canada, and Duke University, Durham, NC. He is currently an Assistant Professor at the Department of Electrical and Computer Engineering, University of Western Ontario, London, ON, Canada. His research interests include real-time and embedded computer control systems, flexure control, and algorithm and software development for mechatronic applications. Dr. Moallem is a registered Professional Engineer in the province of Ontario, Canada.

Authorized licensed use limited to: Rajamangala Univ of Tech Phra Nakhon. Downloaded on June 7, 2009 at 02:55 from IEEE Xplore. Restrictions apply.

Suggest Documents