Top Banner
June 2004 45 0272-1708/04/$20.00©2004IEEE IEEE Control Systems Magazine T he World Wide Web has provided an opportu- nity for design and analysis of control systems through the Internet. An increasing number of Web-based software packages have been developed to enhance the teaching and design of control systems [1]. Today, one of the most popu- lar applications in control systems is Web-based educational environ- ments and laboratories. As an example, the interactive study support environment pre- sented in [2] provides course management, online exercis- es, and laboratories. Based on VCLab [3], which contains Java applets and MATLAB plug-ins, the system allows stu- dents to enter MATLAB commands on the Web page and submit these commands to the MATLAB program for exe- cution. The output generated by these commands can be displayed on the same Web page. To use this Web-based study environment, however, the MATLAB software has to be installed on the client machines. Instead of using MAT- LAB plug-ins to perform numerical computation on the client side, Java applets are sometimes used for numerical computation on the client side. For example, applications of Java applets can be found in the Web-based two-degrees-of-freedom robot manipulator simulation sys- tem [4] and the Virtual Control Lab [5]. Due to the lack of Design, implementation, and salient features By Qingcang Yu, Bo Chen, and Harry H. Cheng ©DIGITALVISION F E A T U R E F E A T U R E
13

Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

Feb 26, 2018

Download

Documents

ngomien
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

June 2004 450272-1708/04/$20.00©2004IEEE

IEEE Control Systems Magazine

The World Wide Web has provided an opportu-nity for design and analysis of control systemsthrough the Internet. An increasing number ofWeb-based software packages have beendeveloped to enhance the teaching and designof control systems

[1]. Today, one of the most popu-lar applications in control systemsis Web-based educational environ-ments and laboratories. As anexample, the interactive study support environment pre-sented in [2] provides course management, online exercis-es, and laboratories. Based on VCLab [3], which containsJava applets and MATLAB plug-ins, the system allows stu-

dents to enter MATLAB commands on the Web page andsubmit these commands to the MATLAB program for exe-cution. The output generated by these commands can bedisplayed on the same Web page. To use this Web-basedstudy environment, however, the MATLAB software has to

be installed on the clientmachines. Instead of using MAT-LAB plug-ins to perform numericalcomputation on the client side,Java applets are sometimes used

for numerical computation on the client side. For example,applications of Java applets can be found in the Web-basedtwo-degrees-of-freedom robot manipulator simulation sys-tem [4] and the Virtual Control Lab [5]. Due to the lack of

Design, implementation, and salient features

By Qingcang Yu, Bo Chen, and Harry H. Cheng

©D

IGIT

ALV

ISIO

N

F E A T U R EF E A T U R E

Page 2: Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

powerful numerical computing capabil-ities in Java and its applets, however,applications using Java applets alonein the simulation of dynamic systemsare limited.

Web-based laboratories can bedivided into two categories: virtualand remote. A virtual laboratoryallows clients to continuously access asimulation process in a remote server.The simulation engine in the servercould be MATLAB or any other controltool kit. A remote laboratory offers aphysical experimental apparatus toremote users through the network.

Most Web-based laboratories useMATLAB as the computational engine.For example, Sanchez et al. [6] pro-posed a virtual and remote laboratoryusing Java and MATLAB. In this sys-tem, a Web page with Java applets isused as the graphical user interface(GUI) for remote access of the lab. Thecomputations for controller designand analysis are performed in MAT-LAB in a separate process invoked byan application server called InternetVirtual Lab (IV-Lab). The applicationserver communicates with the Webserver using TCP/IP sockets. Theimplementation of such a virtual con-trol laboratory is complicated becauseof the inherent deficiency in interfac-ing MATLAB with external programs.Instead of writing an application serv-er on their own, other remote labora-tories [7], [8] use the MATLAB Webserver (MWS) to communicatebetween the HTTP Web server andMATLAB. However, even when usingMWS, the communication between theHTTP Web server and MATLAB is inef-ficient. In our experience, softwarebased on MWS is difficult to developand maintain.

We have developed a Web-basedinteractive control design and analysissystem (WCDAS) [9] based on Ch,which is a C/C++ interpreter [10], [11],and the Ch control systems toolkit(CCST) [12], [13]. WCDAS covers manyclassical and modern techniques forcontrol systems design and analysis.Most functions in the system support

June 200446 IEEE Control Systems Magazine

Figure 1. A partial view of the index page of the Web-based control design andanalysis system. The functions provided by the system are classified into the eightcategories shown in Table 1.

1) Time Domain Response AnalysisStep response Impulse responseInitial response Simulation response

2) Frequency Domain Analysis Bode diagram Gain and phase margin Nichols chartNyquist diagramFrequency response

3) Analysis and Design inState SpaceControllability analysisControllability staircaseGramianLQE designLQG designLyapunov equation solversObservability analysisObservability staircasePole placement

4) Root Locus DesignRoot locus

5) Model Reduction and DynamicsBandwidthPole-zero mapDamping factors and naturalfrequenciesDC gainSort polesMinimal realizationPzacancel

6) Model Conversion State-space modelTransfer function modelZPK model

7) System ConversionCoordinate transformationContinuous time to discrete timeDiscrete time to continuous timeDiscrete time to discrete timeMap delays to poles

8) System InterconnectionSeriesParallel FeedbackAppendConnect

Table 1. WCDAS supports many commonly used functions for control systemdesign and analysis. These functions include both classical and moderncontrol methods.

Page 3: Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

both continuous-time and discrete-time linear time-invari-ant systems modeled in state space, transfer functions, orzero-pole-gain representations. Users can select a designand analysis method and specify system model type, sys-tem type, and system parameters in the Web browser.These data are transferred to theserver for numerical computation,and the simulation results are sentback to the client through the com-mon gateway interface (CGI) usingthe Ch interpretive environment.Because both CGI scripts and sim-ulation programs are written in Ch, data exchange betweenclient and server is easily achieved. The system is avail-able for use through the Web without any software instal-lation, system configuration, or programming. ThisWeb-based system is ideal for teaching as well as for solv-ing practical problems in control systems design andanalysis. The software packages Ch, CCST, and WCDAS areavailable for downloading on the Web [12]. The design,implementation, and salient features of WCDAS aredescribed in this article.

Ch and Web-BasedControl System The Ch language [10], [11] is asuperset of the C interpreter. Chsupports all features of the C lan-guage standard ratified in 1990 [14].New features such as complex num-bers, variable length arrays, IEEEfloating-point arithmetic, and type-generic mathematical functions firstimplemented in Ch were adopted inC99 [15], a new C standard ratifiedin 1999. In addition, Ch supportsclasses in C++ for object-based pro-gramming. Like other mathematicalsoftware packages such as MAT-LAB, Ch has built-in support of two-and three-dimensional graphicalplotting features and computationalarrays for matrix computation andlinear system analysis withadvanced numerical analysis func-tions based on LAPACK. The appli-cation programming interface (API)of the CGI in Ch is similar to those inactive server pages (ASP) and Javaserver pages (JSP). Four classes—CResponse, CRequest, CServer, andCCookie—are provided in the ChCGI toolkit [16]. CGI programming inCh is interpretive without compila-

tion and linking, platform independent, and easy to debugand maintain. As a superset of C, Ch can interface withC/C++ programs in both source code format and binary sta-tic or dynamical libraries. Ch can also be embedded inother application programs as a scripting engine [17].

The object-oriented CCST [12], developed in Ch, pro-vides a C++ control class to support most classical andmodern control techniques. Its member functions containmost functions and features found in the MATLAB Con-trol System Toolbox [18]. Feature comparison of CCSTand the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the sameproblems, is available on the Web [12]. CCST is conve-nient for modeling, designing, and analyzing continuous-or discrete-time linear time-invariant control systems in

June 2004 47IEEE Control Systems Magazine

Figure 2. Overview of the user interface of WCDAS. The user can select a specificfunction from the index page. The Web page Form 1 describes the selected functionand allows the user to select the system type and model type. The upper portion ofForm 2 shows a sample system. The user can also define a system in the lower por-tion of this page. The customized system parameters are submitted in Form 3. Form 4is the output page.

Result

Index Page

Step

Impulse

...

Description.

...

System Model

System Type

System Time

Input NewSystemParameters

...

Default SystemExample---------------------Define a NewSystem.

Form1

Form2

Form3

Form4

From the system developer’s point of view,WCDAS is easy to maintain and extend.

Page 4: Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

both time and frequency domains due to user-friendlygraphical representations. Control systems can be mod-eled in the form of transfer functions, zero-pole-gain rep-resentations, or state-space equations.

WCDAS is developed using Ch, Ch CGI, and CCST. UnlikeWeb-based laboratories that use the MATLAB engine, data

received by the HTTP server in our system are passed to acomputational engine directly through CGI without an extraapplication server. This approach greatly simplifies theimplementation of Web-based control systems design and

analysis systems. Withour Web-based sys-tem, control systemsdesign and analysis isperformed using aWeb browser on theclient machine withoutany software installa-tion or tedious pro-gramming. The userselects a simulationmethod, system type,system model type,and other system para-

meters in the Web browser. These selections and data arethen transferred to the Web server for computation using Ch

and CCST through CGI. The text orgraphical results are sent back and dis-played in the client Web browser.

Features of the Web-Based Control SystemWCDAS makes all features and capabil-ities of CCST accessible to usersthrough the Web without need for pro-gramming. By taking advantage of theCh language environment and CCST,WCDAS provides commonly used func-tions in control systems design andanalysis such as time-domain re-sponse, frequency-domain response,system analysis, system design, modelconversion, and system conversion.Most functions can be applied to bothcontinuous- and discrete-time lineartime-invariant (LTI) systems, whichare modeled in single-input, single-out-put (SISO) and multi-input, multi-out-put (MIMO) state-space equations,transfer functions, or zero-pole-gainrepresentations. The functionalities ofWCDAS are outlined in Table 1. Figure1 gives a partial view of the index pageof the WCDAS.

All functions in WCDAS are interac-tive, and all parameters such as sys-tem types, system model types, andsystem model data are selected orentered online to solve control designand analysis problems. The user inputs

June 200448 IEEE Control Systems Magazine

Figure 3. System model type and system type selection page (Form 1). This pageallows the user to choose the desired model and system types.

With WCDAS, control system design and analysis is performed using a Web browser on the clientmachine without any software installation or tedious programming.

Page 5: Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

are validated, and an informative errormessage is displayed when the inputsare not valid.

A unique feature of WCDAS is itsability to design, analyze, and verifycontrol strategies over the Internetwithout software installation, systemconfiguration, or programming. Theuser can focus on the control systemsproblems and obtain the results inter-actively. WCDAS provides an examplefor each function to il lustrate itsusage. By following the example,entering the system parameters in theform, and clicking buttons to selectdifferent choices, the user can gainexperience in control systems designand analysis.

From the system developer’s point ofview, WCDAS is easy to maintain andextend. Each function is implementedby several independent files. The detailsof the file system of WCDAS are dis-cussed later.

User Interface for theWeb-Based Control SystemThe step-response function is selectedas an example to illustrate the userinterface (UI) of WCDAS. Figure 2 showsall Web pages related to the step-response function.

The process of using a function inWCDAS starts from the index page.Clicking the “Step response” hyperlinkon the index page shown in Figure 1brings up the page shown in Figure 3labeled “Form 1.” As the first page of thestep-response function, the functiondescription is presented at the top ofthe page. The user can select systemmodel type from state space, transferfunction, and zero-pole-gain representa-tion and select system type as continu-ous or discrete time. For a discrete-timesystem, the user can specify a sampling time for the systemon this page.

By clicking the “Continue” button in Form 1, wereach the page shown in Figure 4, labeled “Form 2.” Adefault sample system whose system type and modeltype are chosen in Form 1 is given in the upper por-tion of the page. For the step-response function, thedefault system in the state-space representation inFigure 4 is

x1 =−0.5x1 − 0.8x2 + u

x2 = 0.8x1

y = 2x1 + 6.5x2.

According to the state-space equations,

x = Ax + Bu, (1)

y = Cx + Du, (2)

June 2004 49IEEE Control Systems Magazine

Figure 4. Run a sample problem or customize a new system (Form 2). Theupper portion of this Web page gives a sample system. The user can obtain thestep response of the sample system by clicking the Run Example button. Thelower portion of the page allows the user to define a new system.

Page 6: Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

values for system matrices A, B, C, and D are

A =[−0.5 −0.8

0.8 0

]

B =[

1.00

]

C = [2 6.5]

D = [0].

The step response of this sample system is obtained byclicking the “Run Example” button.

The user can also define a system in the lower portionof Form 2. The dimensions of the system matrices, the

orders of the numerator anddenominator polynomials, or thenumber of zeros and poles can bespecified by the user. For example,the lower portion in Figure 4 asksthe user to specify dimensions ofthe system matrices for the state-space model chosen on Form 1shown in Figure 3.

By clicking the “Submit” buttonin the lower portion of Form 2, Form3 is generated as shown in Figure 5.This page asks the user to enterparameters of the customized sys-tem. The user can enter each entryof the system matrices for a state-space model; the coefficients of thenumerator and denominator polyno-mials for a transfer function model;or the zeros, poles, and gain for azero-pole-gain representation.

The step response of the defaultsystem or user-defined system isshown in Form 4 in Figure 6. ThisWeb page is reached by clicking the“Run Example” button in Form 2 orthe “Run” button in Form 3. The usercan specify the final time of theresponse and select grid on or off forthe step response in Form 3.

Implementationof Web-BasedControl System

System ArchitectureThe system architecture of WCDASis shown in Figure 7. When a user(client) sends the HTTP server arequest for a hypertext markup lan-guage (HTML) page, the server can

respond to this request directly. If the user’s request is forexecuting a Ch script program in the server, the Ch scriptprogram is invoked by Ch CGI [16]. The Ch programretrieves user’s data from an HTML document throughCGI by the member function “GetForms” of the CRequestclass and returns the resulting data to CGI by class CRe-sponse. When a plot output is requested, a Ch plot pro-gram named plot.ch is called by a Ch script to generate aplot in the portable network graphics (PNG) image file for-mat. The output plot, together with the text results gener-ated by a Ch script, are assembled by member functionsof class CResponse and sent to the HTTP server via CGIand then to the user’s Web browser.

June 200450 IEEE Control Systems Magazine

Figure 5. The parameter input page (Form 3). This page allows the user to entersystem parameters.

Page 7: Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

File SystemFigure 8 shows the file system of WCDAS. Eachfunction is implemented by both HTML filesand Ch scripts. A Web browser can accessHTML files directly. Ch scripts are interpretedby the Ch language environment through CGI.For instance, the Step response on the indexpage in Figure 1 is linked to an HTML filestep.html, which creates Form 1 in Figure 3.Forms 2 and 3 and the resulting output pageForm 4 are created by a Ch script calledctk_step.ch. The handling of multiple pages inone Ch file is discussed later.

As previously described, if the output of afunction, such as a step response is a plot, thenthe Ch script plot.ch is invoked to generate thecorresponding plot. The program plot.chretrieves the required data through CGI andsends a plot stream back to CGI, as shown inFigure 7.

Data StructureMost functions in WCDAS support system mod-els in state space, transfer functions, or zero-pole-gain representations for both continuous-and discrete-time systems. To customize a sys-tem, the user has to make a suitable choice andenter all model parameters. To avoid the needfor entering all of the inputs into a single Webpage, multiple Web pages aredesigned for users to select choic-es and enter data. The user’sselections and system parametersare saved and passed from oneWeb page to another. To decreasethe complexity of handling andtransferring data, a clear and well-organized data structure isrequired.

Figure 9 shows the three-partdata structure used for state-space models. The first part isthe header, which saves the pageID, system model ID, system typeID, and sampling time for dis-crete-time systems. The page IDis used to identify different formsdescribed previously. The valueof ss for the system model sys-Model indicates state space equa-tions. The value for system typesysType can be either continuousor discrete time. The value ofTsValue specifies the sampling

June 2004 51IEEE Control Systems Magazine

Figure 7. The system architecture of WCDAS. The Ch CGI manages the communica-tion between the HTTP server and Ch programs.

Client

Internet

Client

Server

HTML

File

CGI

Ch

Program

Ch

Plot

Plot Data

PNG

Stream

Ch Language

Environment

(Server Kernel)

Figure 6. The resulting output page (Form 4). This page shows the stepresponse of the default or user-defined system.

Page 8: Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

time. The second part of the data struc-ture defines the dimension of the matri-ces A, B, C, and D in (1) and (2). Thethird part of the data structure consistsof the values of system matrices. For atransfer function or a zero-pole-gainmodel, the second part defines theorder of the numerator and denomina-tor polynomials of a transfer function orthe number of zeros and poles. Thethird part defines the coefficients of thenumerator and denominator polynomi-als or the values of zeros and poles.

To simplify the software implementa-tion and to reduce code redundancy,functions that are used to access thestructured data are implemented sepa-rately and shared by all CGI scripts. Asan example, the function read Matrix-Dim() of Table 2 reads matrix dimen-sions from the structured data. In thisprogram, the variables name and valueare the arrays of strings with names andvalues from a fill-out form. The integervariable num contains the lengths ofthese two arrays. The return value is anarray of eight integers with an indexstarting from one. The eight elements inthe returned array stand for the extent ofthe rows and columns of matrices A, B,C, and D in sequence. The function ato-iCheck() in Table 2 checks and convertsthe string of value[i] to an integer. Ifthere is any error, such as an invalidinput for an integer number, a Web pagewith an error message is generated.

Data Passing BetweenPagesAs discussed before, the user’s modeldefinition data are entered in multiplepages. Data passing between differentpages is shown in Figure 10, whereForms 1–4 are defined in the previoussection of the UI. The header of the datastructure of the system, including sys-tem model type and system type, arespecified in Form 1. This information ispassed to Form 2 when the user clicksthe “Continue” button in Form 1. If theuser selects to run the default examplein Form 2, WCDAS has all of the dataand can generate the resulting outputpage directly. If the user selects to

June 200452 IEEE Control Systems Magazine

Figure 8. The file system of WCDAS. Each function has its own HTML file andCh CGI script for easy development and maintenance. Functions shared by mul-tiple Ch scripts are treated as function files.

HTML Files Ch Files

Index HTML

step.html ctk_step.ch

Nichols.html ctk_nichols.ch

dcgain.html ctk_dcgain.ch

pplace.html ctk_pplace.ch

Plot.ch

Ch Function Files

...

...

...

...

Figure 9. The data structure for a state-space model. The data from HTML filesare passed to Ch scripts based on a predefined data structure for different sys-tem models. The data structure used to represent a system in WCDAS is com-posed of data header, dimension definitions, and data blocks.

Dimension

Routine Control ID

Name Value

Header

Definition

Data Block

Dimension

Definition

Data Block

System Model

System Type

Sampling Time

Matrix A

Matrix B

Matrix C, D

Do

sysModel

sysType

TsValue

Arow

Acol

Float

.

.

.

Brow

Bcol

Float

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Page1

ss

Continuous Time

0.25

3

3

–0.5

3

1

1.0

Page 9: Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

define a new system in Form 2, the header informationand the dimensions of the system matrices are passed toForm 3. Combining this information with the values of thesystem matrices entered in Form 3 generates a completeset of the data to represent a new system. All of the dataare passed to Form 4 to generate the output response ofthe new system.

The Ch script plot.ch is invoked to generate a PNGimage stream when a plot output is requested. The methodfor passing data to plot.ch is critical for Web-based plot-ting. If the data are passed improperly, the output mightremain the same even if the user had submitted new sys-tem parameters. In our implementation, we pass the para-meters along with the name of the CGI script. A uniquename is created each time when the script plot.ch isinvoked. Therefore, different results are generated for dif-ferent submissions. The output plot is displayed on theWeb page by the following code segment, where the mem-ber function of class Cserver CServer::URLEncode() is usedto encode the data passed to the program:printf (�<center><img src=\�/cgi-bin/chcgi/

toolkit/control/plot.ch�);

for (i=0;i<num;i++){ /* pass data to plot.ch */

putc (i==0 ? �?� : �&�, stdout);

fputs (Server.URLEncode(name[i]) ,stdout);

putc (�=�,stdout);

fputs (Server.URLEncode(value[i]),stdout);

}

Handling Multiple Pagesin One Ch ScriptForms 2–4 shown in Figure 2 are created by the same Chscript file ctk_step.ch. This Ch script program can handlethree different pages. The value of the field named Do inthe header of the data structure shown in Figure 9 informsthis Ch script as to which page it is han-dling. The value of the variable Do shouldbe one of the three values Page1, Form 2,or Result. The critical part of programctk_step.ch is shown in Table 3.

The function printFormHead inside Table3 displays the page ID, system model type,system type, and sampling time at the top ofthe form. The source code of this function isshown in Table 4. To simplify CGI program-ming, the Ch code between statementsfprintf stdout � ENDPRINT and END-PRINT is transferred verbatim to an HTMLfile. The variable inside the parentheses fol-lowing the symbol “$” is replaced by theactual value at runtime. For system inter-connections, such as series interconnectionof two subsystems, the two subsystems

need to be identified with different model IDs. This identifi-cation is handled by two global variables IDidx and modelID.Variable IDidx has the value 0 or 1. Variable modelID is anarray with two elements sysModel and sys1Model indicatingsystems 0 and 1, respectively.

Input Data ValidationFor security and robustness reasons, WCDAS can handleunintended inputs and mistakes. Although the fill-outforms on the Web pages have greatly reduced the possibil-ity of a user mistake compared to programming, we arevigilant about all inputs by checking all data passed bymeans of CGI. We try to be defensive in CGI programming.

June 2004 53IEEE Control Systems Magazine

Figure 10. Data passing between pages. The data in Figure 9 are passed tothe next page.

Form1

Form2

Form3

Form4

Only the Headerof the DataStructure

Full Data Structure

Full DataStructure

Header +New SystemDimensionDefinition

array int readMatrixDim(int num, chstrarray

name, chstrarray value) [1:8] {

array int nvar[1:8];

int i;

for (i=0; i<num; i++) {

if(strcmp(name[i],"Arow")==0)

nvar[1]= atoiCheck(value[i]);

if(strcmp(name[i],"Acol")==0)

nvar[2]= atoiCheck(value[i]);

if(strcmp(name[i],"Brow")==0)

nvar[3]= atoiCheck(value[i]);

...

}

return nvar;

}

Table 2. Read matrix dimensions from the structureddata. This function reads the dimensions of the systemmatrices. The function is shared by all CGI scripts thatneed the dimension information of system matrices.

Page 10: Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

June 200454 IEEE Control Systems Magazine

/* generate Form1 */

int processFirstPage(chstrarray name, chstrarray value) {

/* part I: show default example */

printFormHead("ctk\_step", "Result", value); /* setup <Form> information */

...

printRunButton("Run Example");

/* part II: show user defined system input box */

printFormHead("ctk\_step", "Form2", value); /* setup <Form> information */

...

}

/* generate a fill-out form ---Form3, for user to input each element for new system */

int processForm(int num, chstrarray name, chstrarray value) {

printFormHead("ctk\_step", "Result", value); /* setup <Form> information */

...

}

/* calculate and show result ---- Form4, plot if necessary. */

int processResult(int num, chstrarray name, chstrarray value) {

...

}

int main() {

num =Request.getFormNameValue(name, value); // get CGI value

/* value[0] contains variable Do value */

...

/* "Page1" was passed from Form1 -- step.html */

if(strcmp(value[0],"Page1")==0) {

processFirstPage(name, value); // show Form2

}

/* "Form2" was passed from function processFirstPage() . */

else if(strcmp(value[0],"Form2")==0) {

processForm(num, name, value); // show Form3

}

/* "Result" was passed from both processFirstPage() and processForm() . */

else if(strcmp(value[0],"Result")==0) {

processResult(num, name, value); // get result, show Form4

}

...

}

Table 3. The code segments of program ctk_step.ch. This program handles Web pages Form 2 to Form 4.Each form is processed by the corresponding function as shown below.

Page 11: Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

June 2004 55IEEE Control Systems Magazine

int printFormHead(char *chFileName, char *doWhat, chstrarray value) {

fprintf stdout << ENDPRINT

<FORM method="POST" action="/cgi-bin/chcgi/toolkit/control/$(chFileName).ch">

<INPUT type="hidden" name="Do" value="$(doWhat)">

<INPUT type="hidden" name="$(modelID[IDidx])" value="$(value[1])">

<INPUT type="hidden" name="sysTypeStr" value="$(value[2])">

<INPUT type="hidden" name="TsValue" value="$(value[3])">

ENDPRINT

return 0;

}

If an input value is not valid, an informative error messageis displayed. As discussed in the section on data struc-tures, the values of name fields for each element in thedata structure indicate which type of data this elementshould be. The values of Int, Float, and Complex corre-spond to the int, double, and double complex data types inC. Passed data that cannot be converted to these datatypes are considered not to be valid.

Besides data type checking, additional validationchecks are implemented. For example, if a user submits amodel such that A is 3 × 3 and B is 2 × 1, the system givesan error message indicating that the dimensions of A andB do not match.

Application ExamplesIn this section, two sample applications are used to illus-trate how control problems are solved using WCDAS.

Example 1Consider the linear time-invariant, state-space control sys-tems (1) and (2) with matrices

A =−0.5 −0.8 0.53

0.8 0.12 0.7−0.53 −0.7 −1.1

B = 1.0

0.8−1.5

C = [2 6.5 − 2]

D = [1.2].

To plot the step response of the system, we first click the“Step response” hyperlink in the index page shown in Figure 1. Then we select the system model for the state

space equation and system type of continuous time in Figure 3. By clicking the “Continue” button, Form 2 is gen-erated as shown in Figure 4. Next, we define a new systemwith matrix dimensions of 3 × 3 for A, 3 × 1 for B, 1 × 3 forC, and 1 × 1 for D. Next, by clicking the “Submit” button in Figure 4, Form 3 is brought up as shown in Figure 5, and wefill out each element with the given data. Finally, click the“Run” button to display the result as shown in Figure 6.

Example 2A feedback system is shown in Figure 11, where the plantsystem 1 has two inputs and two outputs. The state-spacematrices of systems 1 and 2 are given by

A1 =[−1.2 −2

2 1

]

B1 =[−1 −1

0 2

]

C1 =[−1.7 4

1 2

]

D1 =[

0 1−1 0

]

A2 = 2 2 −0.5

2 0 00 1 0

B2 = 1

00

C2 = [0 0.5 − 0.5]

D2 = [0].

To find the state-space matrices of the feedback system wego to the index page shown in Figure 1 and click the

Table 4. Print header of forms. In Ch CGI, the Ch code between statementsfprintf stdout << ENDPRINT and ENDPRINT is printed out verbatim through the standard output stream.

Page 12: Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

“Feedback” hyperlink in the“System Interconnection”section. On the “FeedbackInterconnection” Web page,the user selects system 1and system 2 to be state-space models and specifiesthe dimensions of the state-space matrices. After enter-ing the inputs and outputs ofsystem 1, which are involvedin the feedback loop, clickthe “Continue” button. Onthe next page, the userenters all values that arerequired for computationand clicks the “Run” buttonat the bottom of the page.The state space matrices ofthe feedback system are dis-played as shown in Figure 12.

Conclusions A Web-based control designand analysis system calledWCDAS has been designed

and implemented using the Ch lan-guage environment (a C/C++ inter-preter), CCST, and CGI toolkit. Manycommonly used functions of controlsystems design and analysis havebeen implemented in WCDAS. Thesefunctions can be applied to both con-tinuous- and discrete-time linear time-invariant control systems modeled bystate-space equations, transfer func-tions, or zero-pole-gain representa-tions. WCDAS is easy to use andmaintain. The design, implementation,and operation of the system were dis-cussed. The user can access WCDAS[9] without any software installation,system configuration, or program-ming. The user can submit systemparameters and receive the text orgraphical results through a Webbrowser. This Web-based controldesign and analysis system is ideal forrapid prototyping, instructional use,and student learning, as well as forpractical engineering applications.The feedback from users has beenquite positive, and the convenienceand ease of use of the system have

June 200456 IEEE Control Systems Magazine

Figure 12. The state space matrices of the feedback system shown in Figure 11.The feedback system is a MIMO system with two inputs and two outputs. The sys-tem has five state variables.

Figure 11. A feedback system involving two subsystems. The plant subsystem is a MIMOsystem. The feedback controller is a SISO system.

u1 y1

y2u2 +

System

System 1

System 2

A1 =

C1 =

A2 =

B1 =

D1 =

C2 =

B2 =

D2 =

–1.2 –2

2 1

–1.7 4

21

–1 –1

0 2

0 1

–1 0

2

2

2

0

0

0

1 0

0

1

0

0

00.5 –0.5

–0.5

Page 13: Feature - Michigan Technological · PDF fileIEEE Control Systems Magazine T ... and the MATLAB Control System Toolbox, including sam-ple code in both Ch and MATLAB for solving the

been universally appreciated. Ch, Ch Control SystemToolkit, Ch CGI Toolkit, and WCDAS described in this arti-cle are freely available for academic use and can be down-loaded from the Web [12]. Users can set up WCDAS ontheir own Web servers to avoid network traffic. TheWCDAS and Ch Control System Toolkit, which has similarcapabilities as the MATLAB Control System Toolbox, areopen source. The ideas and principles presented in thisarticle are applicable to many other areas of control sys-tems. Users can examine the source code to extend thesystem with new features such as nonlinear control, ran-dom white noise analysis, and system identification.

References[1] S.E. Poindexter and B.S. Heck, “Using the Web in your courses:What can you do? What should you do?” IEEE Contr. Syst. Mag., vol. 1,pp. 83–92, Feb. 1999.

[2] G.J.C. Copinga, M.H.G. Verhaegen, and M.J.J.M. van de Ven,“Toward a web-based study support environment for teachingautomatic control,” IEEE Contr. Syst. Mag., vol. 20, pp. 8–19, Aug.2000.

[3] Virtual Control Lab, 2002. Available: http://www.esr.ruhr-uni-bochum.de/VCLab/

[4] J.C. Martinez-Garcia, G.H. Salazar-Silva, and R. Garrido, “Web-basedobject-oriented control system design,” in Proc. IEEE Int. Conf. ControlApplicat., Mexico City, Mexico, Sept. 2001, pp. 111–116.

[5] The Virtual Control Lab for the ECOSSE Control HyperCourse.Available: http://www.chemeng.ed.ac.uk/ecosse/control/course/map/index.html

[6] J. Sanchez, F. Morilla, S. Dormido, J. Aranda, and P. Ruiperez, “Vir-tual and remote control labs using Java: A qualitative approach,” IEEEContr. Syst. Mag., vol. 22, no. 2, pp. 8–10, Apr. 2002.

[7] R.P. Manchon, O.R. Garcia, R.P.N. Garcia, N.G. Aracil, and L.M.J.Garcia, “Remote lab for control applications using MATLAB,” in Proc.IFAC Workshop Internet-Based Control Educ., Madrid, Spain, Dec. 2001,pp. 121–126.

[8] J.L. Diez, M. Valles, A. Valera, and J.L. Navarro, “Remote industrialprocess control with MATLAB web server,” in Proc. IFAC WorkshopInternet-Based Control Educ., Madrid, Spain, Dec. 2001, pp. 139–143.

[9] Web-Based Control Design and Analysis System, Softintegration, Inc.,2003 [Online]. Available: http://www.softintegration.com/webser-vices/control

[10] H.H. Cheng, “Scientific computing in the Ch programming lan-guage,” Sci. Prog., vol. 2, no. 3, pp. 49–75, 1993.

[11] Ch Language Environment User’s Guide, Softintegration, Inc., 2003[Online]. Available: http://www.softintegration.com

[12] Ch Control System Toolkit User’s Guide, Softintegration, Inc., 2003[Online]. Available: http://www.softintegration.com/products/toolkit/control

[13] Y. Zhu, B. Chen, and H.H. Cheng, “An object-based softwarepackage for interactive control system design and analysis,” ASMETrans. J. Computing Inform. Sci. Eng., vol. 3, no. 4, pp. 366–371, Dec.2003.

[14] International Standard: Programming Languages—C, ISO/IEC, 1990.

[15] International Standard: Programming Languages—C, ISO/IEC, 1999.

[16] The Ch Language Environment CGI ToolKit User’s Guide, Softinte-gration, Inc., 2003 [Online]. Available: http://www.softintegration.com/products/toolkit/cgi/

[17] Embedded Ch, Softintegration, Inc., 2003 [Online]. Available: http://www.softintegration.com/products/sdk/embedch/

[18] Control System Toolbox User’s Guide. Natick, MA: MathWorks,1998.

Qingcang Yu received his M.S. degree in electrical engi-neering from Zhejiang University, China, in 1990. From2001 to 2003, he was a visiting scholar in the Department ofMechanical and Aeronautical Engineering, University ofCalifornia, Davis. He is currently an associate professor inthe Information and Electronics Department at the Zhe-jiang Institute of Science and Technology, China. He is alsoa Ph.D. candidate in computer analysis and comprehen-sion at Zhejiang University. His research interests includeCh, computer-aided design and analysis, image processingand analysis, stereo vision, and mobile robot navigation.

Bo Chen received her M.S. degree in electrical engineeringfrom the Zhejiang Institute of Science and Technology(ZIST) in China and joined the Department of ElectricalEngineering at ZIST. She was an associate professor andthe vice chair of the Department of Electrical Engineeringwhen she left ZIST in 1999 and began working as a visitingscholar in the Integration Engineering Laboratory at theUniversity of California, Davis. Currently, she is a Ph.D.candidate in the department of Mechanical and Aeronauti-cal Engineering at the University of California, Davis. Herresearch focuses on computer-aided design and analysis,real-time and embedded control, multiagent systems, andWeb technologies.

Harry H. Cheng ([email protected]) is a profes-sor and director of the Integration Engineering Labora-tory in the department of Mechanical and AeronauticalEngineering at the University of California, Davis. Hiscurrent research interests include engineering softwaredesign, Web technology and its applications in designand manufacturing, open-architecture mechatronic sys-tem integration, and intelligent transportation systems.He is the chief architect of Ch, a C/C++ interpreter forscript computing. He has published over 90 technicalpapers and has one U.S. patent. He received his M.S.degree in mathematics in 1986 and his Ph.D. degree inmechanical engineering in 1989 from the University ofIllinois at Chicago. He can be contacted at the Integra-tion Engineering Laboratory, Department of Mechanicaland Aeronautical Engineering, University of California.Davis, CA 95616 USA.

June 2004 57IEEE Control Systems Magazine