Networked Control Systems

Similar documents
Networked Control Systems:

NOWADAYS, many control applications have some control

Chapter 5 A Modified Scheduling Algorithm for The FIP Fieldbus System

Delay compensation in packet-switching network controlled systems

Appendix A Prototypes Models

NONLINEAR CONTROL with LIMITED INFORMATION. Daniel Liberzon

Stability Analysis of Networked Linear Control Systems with Direct-Feedthrough Terms

CSE 380 Computer Operating Systems

Distributed Systems Fundamentals

Time in Distributed Systems: Clocks and Ordering of Events

Input-Output Stability with Input-to-State Stable Protocols for Quantized and Networked Control Systems

Wireless Internet Exercises

Stability of networked control systems with variable sampling and delay

STATE AND OUTPUT FEEDBACK CONTROL IN MODEL-BASED NETWORKED CONTROL SYSTEMS

requests/sec. The total channel load is requests/sec. Using slot as the time unit, the total channel load is 50 ( ) = 1

Real-time operating systems course. 6 Definitions Non real-time scheduling algorithms Real-time scheduling algorithm

Motors Automation Energy Transmission & Distribution Coatings. Servo Drive SCA06 V1.5X. Addendum to the Programming Manual SCA06 V1.

MOST control systems are designed under the assumption

Lan Performance LAB Ethernet : CSMA/CD TOKEN RING: TOKEN

Description of the ED library Basic Atoms

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

CDS 270-2: Lecture 6-1 Towards a Packet-based Control Theory

These are special traffic patterns that create more stress on a switch

NICTA Short Course. Network Analysis. Vijay Sivaraman. Day 1 Queueing Systems and Markov Chains. Network Analysis, 2008s2 1-1

Communication constraints and latency in Networked Control Systems

Session-Based Queueing Systems

How to deal with uncertainties and dynamicity?

CPU scheduling. CPU Scheduling

Discrete-event simulations

Data Gathering and Personalized Broadcasting in Radio Grids with Interferences

Computing Minimal and Maximal Allowable Transmission Intervals for Networked Control Systems using the Hybrid Systems Approach

A Novel Integral-Based Event Triggering Control for Linear Time-Invariant Systems

Lecture on Sensor Networks

Towards control over fading channels

cs/ee/ids 143 Communication Networks

Modeling and Simulation NETW 707

Overlay Transport Virtualization (OTV) Unicast-Mode Transport Infrastructure Deployment

Bounded Delay for Weighted Round Robin with Burst Crediting

Coordination. Failures and Consensus. Consensus. Consensus. Overview. Properties for Correct Consensus. Variant I: Consensus (C) P 1. v 1.

CHAPTER 4. Networks of queues. 1. Open networks Suppose that we have a network of queues as given in Figure 4.1. Arrivals

Explicit computation of the sampling period in emulation of controllers for nonlinear sampled-data systems

Networked and Quantized Control Systems with Communication Delays

FAULT-TOLERANT CONTROL OF CHEMICAL PROCESS SYSTEMS USING COMMUNICATION NETWORKS. Nael H. El-Farra, Adiwinata Gani & Panagiotis D.

Event-Triggered Decentralized Dynamic Output Feedback Control for LTI Systems

Information in Aloha Networks

Computer Networks ( Classroom Practice Booklet Solutions)

Input-Output Stability of Networked Control Systems with Stochastic Protocols and Channels

Graphical User Interfaces for Emittance and Correlation Plot. Henrik Loos

Emulated controller design for networked control systems implemented on FlexRay

Queueing Theory and Simulation. Introduction

EP2200 Course Project 2017 Project II - Mobile Computation Offloading

Zeno-free, distributed event-triggered communication and control for multi-agent average consensus

Exercises Solutions. Automation IEA, LTH. Chapter 2 Manufacturing and process systems. Chapter 5 Discrete manufacturing problems

(Refer Slide Time: 1:42)

Robust Stability and Disturbance Attenuation Analysis of a Class of Networked Control Systems

Master thesis. Multi-class Fork-Join queues & The stochastic knapsack problem

Module 5: CPU Scheduling

Methodology for Computer Science Research Lecture 4: Mathematical Modeling

QSR-Dissipativity and Passivity Analysis of Event-Triggered Networked Control Cyber-Physical Systems

Chapter 6: CPU Scheduling

Clocks in Asynchronous Systems

DISTRIBUTED COMPUTER SYSTEMS

Enhance & Explore: an Adaptive Algorithm to Maximize the Utility of Wireless Networks

CL Digital Control

2DI90 Probability & Statistics. 2DI90 Chapter 4 of MR

Estimation of DNS Source and Cache Dynamics under Interval-Censored Age Sampling

System Model. Real-Time systems. Giuseppe Lipari. Scuola Superiore Sant Anna Pisa -Italy

Distributed Systems Principles and Paradigms. Chapter 06: Synchronization

2/5/07 CSE 30341: Operating Systems Principles

Process Scheduling. Process Scheduling. CPU and I/O Bursts. CPU - I/O Burst Cycle. Variations in Bursts. Histogram of CPU Burst Times

HDR - A Hysteresis-Driven Routing Algorithm for Energy Harvesting Tag Networks

Robust Network Codes for Unicast Connections: A Case Study

Time. To do. q Physical clocks q Logical clocks

Distributed Systems Principles and Paradigms

A POMDP Framework for Cognitive MAC Based on Primary Feedback Exploitation

A model-based approach to control over packet-switching networks, with application to Industrial Ethernet

CS418 Operating Systems

DATA ROUTING WITH WIRELESS SENSOR NETWORKS

Analysis of random-access MAC schemes

Delay-independent stability via a reset loop

cs/ee/ids 143 Communication Networks

WiFi MAC Models David Malone

Broadband Internet Access Disclosure

Estimation Techniques for Monitoring and Controlling the Performance of the Computer Communication Networks

Burst Scheduling Based on Time-slotting and Fragmentation in WDM Optical Burst Switched Networks

Model Predictive Controller of Boost Converter with RLE Load

Data Gathering and Personalized Broadcasting in Radio Grids with Interferences

Solutions to COMP9334 Week 8 Sample Problems

Recap. CS514: Intermediate Course in Operating Systems. What time is it? This week. Reminder: Lamport s approach. But what does time mean?

Stability Analysis of Stochastic Networked Control Systems

Load Balancing in Distributed Service System: A Survey

Switched Systems: Mixing Logic with Differential Equations

Stability Analysis of Networked Control Systems Using a Switched Linear Systems Approach

Decentralized Control of Discrete Event Systems with Bounded or Unbounded Delay Communication

Input-to-State Stability of Networked Control Systems

CPU Scheduling. CPU Scheduler

The Weakest Failure Detector to Solve Mutual Exclusion

14 Random Variables and Simulation

Process Scheduling for RTS. RTS Scheduling Approach. Cyclic Executive Approach

CHAPTER 3 MATHEMATICAL AND SIMULATION TOOLS FOR MANET ANALYSIS

Transcription:

Networked Control Systems Simulation & Analysis J.J.C. van Schendel DCT 2008.119 Traineeship report March till June 2008 Coaches: Supervisor TU/e: Prof. Dr. D. Nesic, University of Melbourne Dr. M. Tabbara, University of Melbourne Dr. Ir. M. Heemels Eindhoven University of Technology Department of Mechanical Engineering Control Systems Technology Group Eindhoven, October 2008

Traineeship project: Networked Control Systems Simulation and Analysis Jozef (Jos) Johannes Cornelis van Schendel j.j.c.v.schendel@student.tue.nl Studentno. 0547207 Voorterweg 217 5611 TR Eindhoven The Netherlands Department of Electrical and Electronic Engineering The University of Melbourne Victoria 3010 Australia Department of Mechanical Engineering Technische Universiteit Eindhoven 5600 MB Eindhoven The Netherlands

Abstract The area of Networked Control Systems (NCS) is attracting more and more attention in recent years. The potential applications of NCS are numerous, because it makes the design and implementation of control systems possible with reduced complexity and low costs. Moreover, its flexibility is large as adding or removing network nodes can be done relatively easy. Although the area of NCS is researched extensively, most of the work only discusses the theoretical proof and analysis of stability, without much emphasis on experimental validation. Here, the theoretical results will be compared with results from simulations in Matlab and experiments with a network-in-the-loop setup. Therefore, the focus of this study will be on programming, simulating and analyzing different scheduling protocols on the NCS. This study examines stability of NCS with different protocols in a more practical way. To do this, the most important scheduling protocols are programmed in Matlab and Xcode (C language). Because the round-robin (RR) and random protocol are relatively easy to implement in real systems, they are studied in more detail and used to experiment with a physical network-in-the-loop setup. Six other protocols are only simulated in Matlab Simulink and the results are compared with the results from the literature. The particular network-in-the-loop setup at hand consists of five computers (known as nodes), which act as two sensors, two actuators and one controller that communicate over a wireless network. To validate the different models, the network-in-the-loop experiments are compared with the Simulink simulations and previous studies. In this comparison the maximum allowable transfer interval (MATI) is a key parameter. This maximum time between two arrived data transmissions at the controller node, is the parameter with respect to which the closed loop system remains stable when control and sensor signals are transmitted over the network. Using MATI makes it possible to evaluate, analyze and compare the results from theory, Matlab Simulink simulations and experiments with network-in-the-loop.

Contents 1 Introduction to Networked Control Systems 5 2 Plant model and scheduling protocols 7 2.1 Batch Reactor.................................. 8 2.2 Scheduling protocols.............................. 10 2.2.1 Round-robin protocol.......................... 10 2.2.2 Random protocol............................ 11 2.3 Introduction to MATI and MTI........................ 12 3 Networked Control System code 13 3.1 NCS code structure............................... 14 3.2 Determination of the transmission intervals.................. 16 3.3 Implementation of the system equations................... 16 3.4 Bonjour networking............................... 17 3.5 UDP broadcasting............................... 18 3.6 Network configuration............................. 19 3.6.1 Data packet collisions.......................... 19 3.6.2 Computer connected to multiple networks.............. 20 3.6.3 Wireless network host......................... 20 3.7 Contents of data packets............................ 20 3.8 Dealing with data packet dropouts...................... 21 4 Networked Control System stability 22 4.1 NCS results from theory............................ 23 4.2 Network-in-the-loop experiments....................... 24 4.2.1 Network-in-the-loop with round-robin scheduling.......... 24 4.2.2 Network-in-the-loop with random scheduling............. 27 4.2.3 Network-in-the-loop on slower network (RR)............. 29 4.3 Matlab Simulink simulation.......................... 30 4.3.1 Simulink simulation with round-robin protocol............ 30 4.3.2 Simulink simulation with random protocol.............. 31 4.3.3 Simulated protocols........................... 32 4.4 Network-in-the-loop and Simulink comparison................ 36 1

4.4.1 Network-in-the-loop and Simulink: round-robin........... 36 4.4.2 Network-in-the-loop and Simulink: random.............. 38 5 Evaluation of theoretical NCS framework 39 5.1 Round-robin protocol comparison....................... 40 5.2 Random protocol comparison......................... 40 6 Conclusion and future work 41 A Matlab and Xcode files 44 A.1 Scheduling Protocols.............................. 45 A.1.1 Round-robin scheduling Matlab file.................. 45 A.1.2 Random scheduling Matlab file.................... 45 A.1.3 Try-once-discard scheduling Matlab file................ 46 A.1.4 Modified try-once-discard scheduling Matlab file........... 46 A.1.5 Modified round-robin scheduling Matlab file............. 47 A.1.6 Constant penalty scheduling Matlab file............... 47 A.1.7 Estimated error order scheduling Matlab file............. 48 A.1.8 Lag first order scheduling Matlab file................. 49 A.2 State-space description of batch reactor.................... 50 A.3 Matlab file to run Poisson Simulink model.................. 51 A.4 Matlab files to run Gaussian Simulink model................. 52 A.5 NCS program code............................... 54 A.5.1 Main................................... 55 A.5.2 Config.................................. 55 A.5.3 Controller................................ 56 A.5.4 System.................................. 64 A.5.5 Scheduling protocol........................... 72 A.5.6 Round-robin Scheduling........................ 73 A.5.7 Random Scheduling........................... 74 2

List of Figures 2.1 Scheduling of 2 outputs with zero-order hold ŷ update............ 10 3.1 User Interface of NCS program while master................. 13 3.2 Network with five nodes............................ 14 3.3 Flowchart of NCS code............................. 15 4.1 Results from network-in-the-loop with round-robin (0.03s time-out).... 24 4.2 Results from network-in-the-loop with round-robin (0.04s time-out).... 25 4.3 Results from network-in-the-loop with round-robin and dropouts...... 27 4.4 Results from network-in-the-loop with random (κ (0, 100/3000))..... 28 4.5 Results from network-in-the-loop with random (κ (0, 100/5000))..... 28 4.6 Results from network-in-the-loop with RR on slower network........ 29 4.7 Matlab Simulink model of the NCS...................... 30 4.8 Results from Simulink with round-robin protocol............... 31 4.9 Results from Simulink with random protocol................. 31 4.10 Compare results from RR protocol...................... 37 4.11 Compare results from random protocol.................... 38 A.1 User Interface of NCS program with node.................. 54 3

List of Tables 4.1 Summary of MATI bounds........................... 23 4.2 Results from network-in-the-loop with round-robin scheduling....... 26 4.3 Results from network-in-the-loop with random scheduling.......... 29 4.4 Results from Matlab Simulink......................... 32 4.5 Summary of MATIs for the simulated protocols............... 36 4.6 Compare RR scheduling............................ 37 4.7 Compare random scheduling.......................... 38 5.1 Compare MATIs from theory with MTI from NCS experiment (RR).... 40 5.2 Compare maximum transfer intervals from theory and experiments.... 40 4

Chapter 1 Introduction to Networked Control Systems Networked Control Systems (NCS) are a type of distributed control systems in which sensors, actuators and controllers are interconnected by a shared band-limited digital communication network. This means that the control loops are closed through a real-time network and the control and feedback signals are exchanged among the system s components in the form of information packets. A typical NCS consists of one or more of the following basic elements: sensor actuator controller communication network. The first three elements are often referred to as nodes. The most important feature of a communication network is that it enables us to connect these nodes over long distance (wireless or wired), which reduces the complexity and costs in designing and implementing the control system. Moreover, modifying or upgrading the system by adding sensors, actuators or controllers can be done relatively easy. The potential applications of NCS are numerous and cover a wide range of industries, such as the automobile, process and aeroplane industries. However, the insertion of the communication network in the feedback control loop introduces also negative effects and limitations, which can degrade the performance and even destroy the stability of the closed-loop system. For example, a network causes time-delays in control loops and possible packet losses. Depending on the application, time-delays could impose severe degradation of the performance of the system, as discussed in [10]. Also, the problem of arbitrating access of different nodes on the network becomes an issue, motivating the discussion of the scheduling of nodes and the design and analysis of scheduling protocols suitable for NCS applications. 5

In this study an experimental setup of a networked control system is designed and tested for different scheduling protocols on a wireless network. The aim is to identify and characterize properties of the network that influence the control loop and make comparisons with the existing theoretical results in the literature. To make this possible without using an actual real plant, the designed NCS is tested on a linearized model of the unstable batch reactor case study, which is discussed in many previous works, such as [1] and [8]. Moreover, this report will show a practical evaluation of NCS designs using simulations and analysis of Matlab Simulink models and network-in-the-loop experiments. Outline of report This report is divided into six chapters and an appendix. Chapter 1: An introduction to networked control systems (NCS) is presented and the challenges, limitations and possible applications for networks are outlined. Moreover, the goal of this study is described shortly. Chapter 2: The plant model and scheduling protocols used in the experiments with networkin-the-loop (real NCS), the existing theory and the set up of the Matlab Simulink simulations are described. Two scheduling protocols are considered and analyzed in detail: round-robin and random. This analysis is done using the so-called maximum allowable transfer interval (MATI) and the maximum transfer interval (MTI), which are introduced at the end of this chapter. Chapter 3: In this chapter the NCS program code used for the experiments with networkin-the-loop is clarified. First the global structure of the program is mentioned and visualized by a flowchart. After that, each program element is described in detail to clarify how it is programmed. Also some problems that were faced during the experiments with network-in-the-loop are mentioned and their solutions are given. Chapter 4: The theoretical results from the literature and the results from the experiments with network-in-the-loop and simulations in Matlab of the two different protocols are described and visualized. To do this, the resulting system state responses, system state norms and probability density functions of the time between transmissions (transfer intervals) are plotted and the performance data is collected in tables. Moreover, six other protocols are analyzed by simulations in Matlab and their algorithms and results will be presented towards the end of the chapter. This chapter ends with a comparison of the network-in-the-loop experiments and the Matlab simulations to check their resemblance. Chapter 5: In this chapter a comparison is made between the MATIs found in the theory and the MTIs from the experiments with the network-in-the-loop. To do this, both the round-robin and random protocol are treated separately. Chapter 6: The final chapter consist of conclusions from the findings and comparisons in the previous chapters. Some possible topics for future studies are mentioned as well. 6

Chapter 2 Plant model and scheduling protocols The network in a NCS is the infrastructure that allows two or more nodes to communicate with each other. The access for each node to the network is regulated by providing a set of rules for communication, called protocols. The protocol determines at each transmission time, which node gets access to the network. In this chapter, the round-robin and random scheduling protocols will be described. Also, an important network parameter called the maximum allowable transfer interval (MATI) will be clarified. This parameter plays a key role in this study, because the stability boundary of networked control systems is based on the MATI. However, it is not possible to determine the MATI for the experiments with the network-in-the-loop. That is why an other approximation of the MATI is used and is called the maximum transfer interval (MTI). But first, we will start by explaining the details of the plant model that will be controlled in the NCS, namely the batch reactor as also used in [2] and [8]. 7

2.1 Batch Reactor Instead of using an actual physical plant, we use a linearized model of an unstable batch reactor that is simulated in real-time and can be actuated and observed. The model is used in many NCS stability studies before and finds its origin in [9]. It is a two-input-two-output system that can be written as: ẋ P = A P x P + B P u y = C P x P, [ ] 1 0 1 1 where x P is the state of the system and C P =, 0 1 0 0 1.38 0.2077 6.715 5.676 A P = 0.5814 4.29 0 0.675 1.067 4.273 6.654 5.893, B P = 0.048 4.273 1.343 2.104 0 0 5.679 0 1.136 3.146 1.136 0. (2.1) The system is controlled by a proportional-integral controller which is prescribed by the following state-space equations ẋ C = A C x C + B C y u = C C x C + D C y, (2.2) where x C is the controller state and [ ] [ 0 0 0 1 A C =, B 0 0 C = 1 0 ] [ 2 0, C C = 0 8 ] [ 0 2, D C = 5 0 In the presence of a network and an associated scheduling protocol, y and u cannot be continuously transmitted between the plant and controller. The network causes the next limitations: transmissions occur only at specific transmission instants t i only one signal is allowed to be transmitted onto the network at a given transmission instant t i. Let ŷ and û denote the networked versions for y and u, respectively, which are available to and maintained by the devices that compute the control law and actuate the plant. With zero-order hold sampling, ŷ and û are held constant between transmission instants and updated with components of u and y as those become available during transmission. With this, we can rewrite (2.1) and (2.2) between transmissions as ẋ P = A P x P + B P û ẋ C = A C x C + B C ŷ y = C P x P u = C C x C + D C ŷ (2.3) ŷ = 0 û = 0 8 ].

Now, we only have to explain how ŷ and û are updated at transmission instants t i. Typically, when node j (say corresponding to signal y j ) gets access to the network, then ŷ j (t + i ) = y j(t i ) while û(t + i ) = u(t i) and ŷ l (t + i ) = y l(t i ) for l j as these nodes do not get access. This can be expressed nicely in terms of the error that a network induces compared to the network-free system, which is defined as e = ( ey e u ) = ( ŷ y û u ). (2.4) For example, let e y,j = ŷ j y j. Ignoring the effects of quantization and delay, if the jth component of y is transmitted at the ith transmission instant we have ŷ j (t i ) := y j (t i ) e y,j (t i ) := 0. (2.5) The update of ŷ with a certain scheduling protocol (round-robin, Section 2.2.1) is visualized in Figure 2.1. It is clear that components of e are reset or experience jumps at transmissions instants. Hence, in general the new value of the error e from (2.4) can be described by a jump equation, also referred to as a scheduling protocol, at each transmission instant t i and with a scheduling function h of the form e(t + i ) = h(i, e(t i)). (2.6) Assuming that only the two outputs are transmitted over the network (and thus e u = 0), the NCS with error and state equations is obtained and prescribed by (2.6) and ẋ P = A P x P + B P u y = C P x P ŷ = 0 ẋ C = A C x C + B C y + B C e y u = C C x C + D C y + D C e y (2.7) which can be written as ż = [ ẋ ė ] [ A11 A = 12 A 21 A 22 ] [ x e ], (2.8) where state x = [x p x c ] T, error e = e y, z = [x e] T and [ ] [ AP + B A 11 = P D C C P B P C C BP D, A B C C P A 12 = C C B C ], A 21 = [ C P 0 ] A 11, A 22 = [ C P 0 ] A 12. These equations are implemented in Matlab (Appendix A.2) and describe how the state x and error e evolve between transmissions. 9

Figure 2.1: Scheduling of 2 outputs with zero-order hold ŷ update 2.2 Scheduling protocols In the previous section it is assumed only the two outputs are transmitted over the network. To assign network access to the two nodes measuring these signals, a scheduling protocol is needed. For instance, the protocol determines which output ŷ j is set to its actual value and which one remains the same. There are two types of protocols that are considered in the literature: static and dynamic. For a NCS with l nodes a static protocol assigns access to the network in a predetermined and cyclic manner. In this case, access to the network does not depend on the values of the error signal at transmission times, so the scheduling function h is independent of the error ( static, if you like). On the other hand, dynamic protocols first take measurements of the error every transmission time and then use this error to compute which node gets access to the network based on an algorithm. In this study, the static round-robin (RR) protocol and a stochastic random protocol are used to experiment with the network-in-the-loop setup and are simulated in Matlab and the results are analyzed later on by using the MATI and the MTI. An introduction to these two analysis parameters will be given in Section 2.3. Moreover, to show the working principle of dynamic protocols, some dynamic schedulers will be described later on in this study. 2.2.1 Round-robin protocol An example of a static protocol is the round-robin (RR) scheduling algorithm, which is used in the Token Ring and Token Bus network protocols and is often employed as a protocol for time-sharing operating systems. Each node of the network is assigned a unique index and the nodes are scheduled in a fixed order of index. Let there be l > 1 nodes in the NCS and let the protocol grant access to the network to node i 1,..., l at t si+jl for all j N, that is e i (t + s i+jl ) = 0, where e i reflects the error corresponding to node i s signal. Thus, in terms of NCS scheduling, the protocol map h from equation (2.6) has no dependence on state and is prescribed by: h(i, e) = (I (i))e, (2.9) 10

where (i) = diagδ 1 (i)i n1,..., δ l (i)i nl, with n i the number of signals corresponding to node i and 1 if i = k + jl for some j N δ k (i) = (2.10) 0 otherwise. It was established in [2] that the round-robin protocol is a uniformly globally exponentially stable (UGES) protocol, as defined below. Definition 1 (UGES protocols): A protocol as in (2.6) is said to be UGES if there exist a Lyapunov function W : N R ne R 0, a 1, a 2 > 0 and a real number ρ [0, 1) such that for all i N and all e R ne : 2.2.2 Random protocol a 1 e W (i, e) a 2 e, (2.11) W (i + 1, h(i, e)) ρw (i, e). (2.12) An example of a protocol, where the nodes are scheduled in a stochastic manner, is the random scheduling protocol. The node to be scheduled is chosen randomly from the available nodes. This algorithm is prescribed by: where (i) = diagδ 1 (i)i n1,..., δ l (i)i nl and h(i, e) = (I (i))e, (2.13) δ k (i) = 1 if k = ki 0 otherwise. (2.14) where k i is randomly picked from 1,..., l at transmission time t i with all equal probabilities. 11

2.3 Introduction to MATI and MTI Another parameter in the stability analysis of NCS is the maximum allowable transfer interval (MATI), usually referred to as τ. Often the MATI is used in the literature as follows: as long as the transmission times are smaller than the MATI, then the NCS is stable in a suitable sense. In other words, the MATI is introduced to place an upper bound on the time between transmissions of information from sensor node to controller and controller to actuator to still guarantee stability. There are several methods to determine lower bounds on the true MATI. For instance in [2], where Nesic and Teel show that L p stability of the system is preserved if the transmission intervals are smaller than 1 L ln ( L + γ ρl + γ ), (2.15) where ρ [0, 1) characterizes the stability properties of the protocol (as in Definition 1) and it typically depends on the number of nodes l in the network. L characterizes the possible growth of the error e between the actual values of inputs and outputs and their last transmitted values over the network. Finally, γ is the L p disturbance gain that captures robustness properties of the system without the network. For more details, see [2]. The stability of NCS is largely determined by the scheduling protocol used and by the maximum transfer interval between any two transmissions in the network. That is why in the continuation of this study, the different protocols that are simulated in Matlab and used to experiment with network-in-the-loop will be analyzed on stability in terms of the MATI. However, it is not possible to determine one MATI from the experiments with network-in-the-loop. That is why we introduce a new parameter: the MTI (maximum transfer interval). The MTI is the maximal time between two succeeded transmissions that results from an experiment on the network-in-the-loop. Hence, the MTI is not the maximum allowed time between two transmissions, but the maximum time resulting from one experiment with network-in-the-loop. So, the MTI for an experiment that results in an unstable NCS forms an upper bound on the MATI. 12

Chapter 3 Networked Control System code Communication networks can be designed and programmed in many different ways and codes. In this study the used program language is Xcode, Apple s premiere development environment for Mac OS X. The Xcode suite includes most of Apple s developer documentation and a program used to construct graphical interfaces (Figure 3.1) and it supports Objective-C source code. Xcode is a flexible tool that provides different ways to customize the development process and makes it suitable for many different applications. In this chapter the NCS program structure and the most important program elements will be discussed. The complete code can be found in Appendix A.5. Figure 3.1: User Interface of NCS program while master 13

3.1 NCS code structure For this NCS study five Mac computers are available: two act as sensors and send one of the outputs y 1 or y 2, two act as actuators and receive one of the inputs u 1 or u 2 and one acts as controller (master node) and contains the plant and controller models. The network is sketched in Figure 3.2. With the five nodes, the NCS code has the following global communication structure that is clarified in the flowchart in Figure 3.3 and in the next sections of this chapter in more detail: The system state is initialized and each node starts advertising its service using Bonjour networking (as explained in Section 3.4). The master node discovers all available nodes and broadcasts to all to be ready. Each node executes the scheduling protocol (except for the random protocol, which is executed by the master only) and decides which node j gets access to the network. Node j broadcasts its data. The master node records the time between the current and the previous transmission and updates the system equations. In a real system, the computers that are sensors would be connected to sensors that measure the real plant and the computers that are actuators would be actuating the real plant. One possibility for simulating this is making sure that every computer contains a copy of the plant that is simulated and synchronized with all the other plants. The other possibility is to do what is done here: the computers do not actually send real data, but the master node runs the entire simulation and waits for the nodes on the network to send and receive messages (without real data) before resetting the components of the error to zero. This will guarantee realistic transmission times. Figure 3.2: Network with five nodes 14

Figure 3.3: Flowchart of NCS code 15

3.2 Determination of the transmission intervals In this study, one of the key parameters is the transmission interval (also known as transfer interval). This parameter is for example used to calculate the MATI and the MTI and is equal to the time between two consecutive arrivals of data packets from two consecutive scheduled nodes at the master node. Therefore, the i th transmission interval is calculated by τ i = t i+1 t i. Hence, in the setup of Figure 3.2, the transmission interval is determined by the master node that stores the time that a data packet from the scheduled node arrives and subtracts this time from the time that a packet from the next scheduled node arrives. The arrival times are determined by a standard command in Xcode. 3.3 Implementation of the system equations As discussed in [1] and Section 2.1, equations (2.8) and (2.6), the linearized model of the controlled batch reactor is described by the following system equations: ż(t) = Az(t) t [t i, t i+1 ] z(t + i ) = h(i, z(t i)), (3.1) where A is the system matrix containing the plant and controller dynamics of the batch reactor (see Appendix A.2), t is the continuous time, t i the transmission times, z is the state [x e] T and h(i, z) equals the scheduling protocol function. The set of equations in (3.1) can be solved for each discrete time step using (3.2): z(t + i+1 ) = h(i + 1, exp(a(t i+1 t i ))z(t + i )). (3.2) However, computing this numerical integration for each sampling period will take a lot of time, especially calculating the exponential term. To shorten the numerical integration time and decrease the data size and memory usage, an alternative formula is used and (3.2) is rewritten as: z(t i+1 ) = exp(aε) k z(t + i ), where ε τ i, k = τ i ε, τ i = t i+1 t i. (3.3) The exponential term exp(aε) in equation (3.3) is constant and pre-computed with parameter ε = 0.0001. When (3.3) is implemented in a loop that computes z(t i+1 ) in k steps, the computation of the exponential term and the numerical integration is faster. 16

3.4 Bonjour networking In the NCS program each node runs the same scheduling protocol that computes which node should be scheduled. But what happens if that computed node is not available, for example because it broke down? This kind of situations can be avoided by checking whether or not the node is available for scheduling. A way of introducing this is by implementing Bonjour networking (also known as zero-configuration networking). This enables automatic recovery of available computers, devices and services on Internet Protocol (IP) networks, without the need to enter IP addresses or configure Domain Name System (DNS) servers. In order to provide true zero-configuration experience, the devices must be able to: Allocate IP addresses without a Dynamic Host Configuration Protocol (DHCP) server. Translate between names and addresses without a DNS server. Locate or advertise services without using a directory server. When the Bonjour networking is implemented in the network code, each node will advertise his services (sensor or actuator) and the master node will be able to see all available and advertising nodes on the local network. These available nodes will be shown in a list, which is updated frequently. The advertising of the nodes will be done using the User Datagram Protocol (UDP, see Section 3.5). Although UDP does not guarantee reliability or ordering in the way most other protocols do (like Transmission Control Protocol (TCP)), avoiding the overhead of checking whether every packet actually arrives makes UDP faster and more efficient for applications that do not need guaranteed delivery such as these advertisements. Moreover, UDP is compatible with packet broadcast (sending to all on local network), which makes it ideal for the advertising service. But why use Bonjour? On local area networks (LANs) there are still some problems using IP. Many networks have become reliant on protocols that require no system administration. While IP has emerged as a unifying protocol for wide area networks and the internet, it is not a universal standard on local networks, especially small networks like the one used in this study. These networks do not often have dedicated address and name servers (DHCP and DNS) or a real system administrator. More and more of these small networks are being set up and most users do not want to configure subnet masks or DNS servers and need to be able to plug in a printer or such without taking too much time trying to get the configuration right. The capability that Bonjour provides is the ability to discover available services and choose one from a list, instead of having to know each service s name or IP address in advance. 17

For this application the zero-configuration networking is ideal, because the addresses of all nodes do not have to be known and as discussed above, it gives the ability to see all the advertising nodes at each moment. This information can be used for many different purposes. First of all, as soon as a node looses connection it is displayed on the screen (and an alarm signal can be introduced) so that the controller is informed and can repair it. Secondly, the number of available nodes is used in the scheduling protocol and failing nodes will not be scheduled. Finally, when a node stops advertising and disappears from the discovered list, the network should respond to this to keep system stability. How this can be done, will not be discussed in this report but can be studied in the future. 3.5 UDP broadcasting As mentioned in Section 3.4, the advertising and discovering of nodes happens using the User Datagram Protocol (UDP) principle. In this section the UDP broadcasting principle will be clarified. UDP is used to send short messages, known as datagrams, from one networked computer to another. Unlike the Transmission Control Protocol (TCP), UDP does not guarantee reliability or ordering of datagrams: they may drop out or arrive out of order. However, avoiding the checking whether every packet arrives or not makes UDP faster and more efficient for applications that do not need guaranteed delivery. Moreover, UDP is compatible to broadcast to all clients on the local network. This broadcasting is done by sending small data units, containing the actual system data and the UDP header, which consists of the following four fields: destination port, length, checksum (optional) and source port (optional). In the NCS these fields and data are: destination port is equal to the receiving port of the control node length is equal to the length of the user datagram, including the header and the data, and has a minimum value of 8 bytes checksum is used for error-checking of the header and data the actual data is a structure containing four integers and one double (24 bytes). The UDP header and data are not processed by intermediate systems in the network (like computers or network equipment which do not directly support users, but forward received data onward to the intended recipient) and are delivered to the final destination (the control node) in the same form as originally transmitted. Once delivered, the packets are checked using checksum and valid data is passed to the appropriate session layer protocol identified by the destination port number. 18

3.6 Network configuration As mentioned in the previous sections, the NCS setup consists of five different computers. The network configuration used in this study, where the master node serves as host of the wireless network, results in some problems. First of all there is a lot of communication over the wireless network, such as internet, the NCS simulation and the fact that one screen acts as interface for all computers. Because of this large amount of communication and data transport on the wireless network, the possibility that collisions occur is very high. Secondly, the fact that the host of the wireless network is also connected to the local area network of the university introduces further problems. Namely, the local area connection port is set as the main communication port of the computer (can be adjusted). As a consequence, when the Xcode program broadcasts to all nodes, the master node does not automatically broadcasts over the wireless port of the computer. Instead, the main (wired) communication port is chosen as broadcast port. This fact should be taken into account during programming and should be declared in the NCS code. The third problem is related to the fact that one computer serves as host of the wireless network in the office. As in all networks, all data transport on the network goes via this host. Hence, when this host does not send the data on to its final destination, the data packet drops out and the NCS gets into an infinitely long time-out. Summarizing, there are three network complications that have to be dealt with: collisions due to amount of communication computer/node connected to multiple networks one computer/node serves as host of wireless network. In the next three sections, these problems and the solutions will be discussed. 3.6.1 Data packet collisions The best solution to reduce the number of collisions would be the use of a separate wireless network for the NCS simulation. However, in most cases the network is used for multiple purposes, so collisions can not be avoided. Though, the introduction of a wired switch to remote the computers on one screen has a large effect on the number of dropouts. This is achieved while the wireless internet is not used. Although this change in configuration reduces the number of dropouts, the round-robin simulation was not yet stable. The usage of an other faster available wireless network (less traffic, more Mbit/s), instead of the one in the office, resulted in simulations with a very small number ( 0) of dropouts. 19

3.6.2 Computer connected to multiple networks Most computers use the wired network port as main network port. When the program is written such that the master node broadcasts to all nodes via a random communication port, this results into a failure of the NCS. Because the random command chooses automatically the main network port, the control node broadcasts over the wired local area network instead of the wireless one. Programming the master node to send the commands over the wireless network port, is quiet simple to accomplish. Because all the nodes in the network have an address of the form 10.0.2.x, the address 10.0.2.255 is the broadcast address for the wireless network. 3.6.3 Wireless network host Because one of the computers is connected to the university network, that computer also serves as host of the wireless network in the office so that wireless internet is available. However, a host of a network also serves as a distribution station and passes on all communication. So each data packet first goes to the host and then to its final destination. When a random node (not the master node) is chosen as host of the wireless network, none of the data will be passed on and the network will wait infinitely long. This can be solved by making the master also the host of the wireless network, because the master already covers the function of distribution station by broadcasting to all nodes and discovering them. 3.7 Contents of data packets In a real NCS the measurements of the sensors will be sent and received as data packets. However, because in this study the NCS is simulated with the batch reactor model from Section 2.1, other data is being sent and received, namely a structure called SystemData. This structure contains the following elements: node number magic number message type state dimension system state. The node number variable is equal to the number of the node that is scheduled by the protocol, which uses the state dimension variable to schedule the right number of available nodes. To check whether or not the sent data packet has arrived at the master node, the magic number integer is compared with a certain constant integer: when the two integers 20

are equal, the master received the packet, otherwise the packet dropped out. The message type variable is used to reset the scheduling protocol and can be equal to 0 or 1. It equals 1 when no data dropouts are detected, but when the timer threshold expires in case of the RR protocol, the integer is set to 0, the protocol is reset and the last node transmitted is asked to broadcast again. Finally, the system state variable contains the state values of all available nodes and is updated each time a data packet arrives at the master node. 3.8 Dealing with data packet dropouts In Section 3.6.1 is discussed in what way the number of dropouts is reduced. But how does the NCS deal with data packet dropouts that occur because of collisions due to the amount of communication? This depends on the scheduling protocol. When the round-robin node scheduler is used, a time-out of a certain period is applied (see Section 4.2.1). When that period expires, because of a data packet dropped out, the last transmitted node is asked to transmit again. In this way of dealing with larger transfer intervals caused by data dropouts, the RR algorithm is maintained. The random node scheduling protocol has a different working principle. In contrast to the RR scheduler, the random protocol is only executed by the master node. While the master node schedules one of the nodes in a random manner, each node is transmitting its data constantly with a random time between each transmission. The time between each transmission instant is chosen randomly from a certain set of times (see Section 4.2.2), which minimizes the probability that two or more nodes decide to transmit at the same time. In this way, not many data packets will drop out and the system s maximum time between two succeeded transmissions will never be long. 21

Chapter 4 Networked Control System stability The protocols described in Section 2.2 are tested on stability for the setup as discussed in Chapter 2 and 3. The maximum allowable transfer interval (MATI) and the maximum transfer interval (MTI) from Section 2.3 are important variables in this analysis. In this chapter the theoretical NCS results providing (conservative) lower and upper bounds on the MATI, the results from the experiments with network-in-the-loop and the Matlab Simulink simulation results will be presented. Before presenting these results, we have to make an important remark. In the literature, a NCS model with two nodes that measure the two outputs is used. However, the network-in-the-loop setup that is used in this study contains four nodes. This means that the theoretical bounds on the MATI would be smaller when a NCS with four nodes was used in the literature and the difference between the values that result from this work and the literature would be larger. The goals of this chapter are to investigate whether or not the network-in-the-loop NCS can be replaced by a reliable Matlab simulation model that is a good approximation of the real system and verify the conservative character of the theoretical MATIs. Note that during all simulations and experiments the initial state z of the system is equal to z(t 0 ) = [0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5] T. 22

4.1 NCS results from theory Much research is performed on the stability theory of NCS. In Walsh et al. [8] the lower bound τwalsh RR on the MATI on the linearized model of the batch reactor with a RR scheduler is 1.05 10 9 seconds. In other words, the results in [8] guarantee that the NCS is stable as long as the transmission intervals are smaller than 1.05 10 9 seconds. However, the computed lower bound on the transfer interval τwalsh,const RR with equidistant transfer intervals, while the system remains stable, is around 0.06 seconds. In [2], Nesic and Teel determine a theoretical bound of τnesic RR = 0.0082 seconds and an upper bound τnesic,const RR on the MATI (with equidistant τ i ) of 0.0657 seconds. Finally, in [1] an UGES system is achieved with τtabbara RR = 0.0123 seconds. Moreover, Tabbara determined a mean transfer interval bound for a networked system with the random protocol without dropouts: τtabbara rand = 0.02s. These theoretical stability bounds for the transfer interval of a NCS with the round-robin and random scheduling protocols are summarized in Table 4.1. Note that these values result from models with non-equidistant transfer intervals (except otherwise stated). Moreover, as noted before in the introduction of the chapter, the theoretical MATIs would be lower than the values given in the table below when a NCS with four nodes was used in the literature. Table 4.1: Summary of MATI bounds Theoretical MATI with round-robin protocol Definition Notation Value [seconds] lower bound from [1] lower bound from [2] lower bound from [8] computed bound from [8] (equidistant τ i ) computed bound from [2] (equidistant τ i ) τtabbara RR 0.0123 τnesic RR 0.0082 τ RR walsh 1.05 10 9 τwalsh,const RR 0.06 τnesic,const RR 0.0657 Theoretical MATI with random protocol computed bound from [1] τ rand tabbara 0.02 In Chapter 5 of this report, these results will be compared with the results obtained from the network-in-the-loop experiments and Matlab Simulink simulations. 23

4.2 Network-in-the-loop experiments Network-in-the-loop experiments with the NCS are performed with two different scheduling protocols: the static round-robin protocol and the stochastic random protocol. In this section the results obtained from experiments with the program and network discussed in the previous sections of this report, will be described. 4.2.1 Network-in-the-loop with round-robin scheduling The RR protocol is described in Section 2.2.1 and can easily be implemented in the NCS code. As discussed in Section 3.8, when a packet dropout occurs the master node waits for a certain amount of time (time-out), after asking the last transmitted node to transmit again. This time-out is the only parameter that can be varied to examine its influence on system stability. In Figures 4.1 and 4.2, the results from the network-in-the-loop experiments are plotted for two different values of the RR time-out: 0.03s and 0.04s. In the probability density function (PDF) plot of the sample times in Figure 4.2, also a normal distributed fit is plotted. The two arrows in the figure indicate the occurrence of some high transfer intervals that are caused by data packet dropouts. As can be seen, this results in a maximal transfer interval of 0.27s, which has a very low probability. 2 1.5 1 State x with RR (0.03s time out) p State x p1 State x p2 State x p3 State x p4 2.5 2 1.5 1 State x and error e with RR (0.03s time out) c State x c1 State x c2 Error e 1 Error e 2 State norm 3 2 1 Vector norm of state State x p 0.5 0 0.5 1 1.5 State x c and error e 0.5 0 0.5 1 1.5 2 Probability density 0 0 2 4 6 8 10 12 14 16 18 20 Time [s] 800 600 400 200 PDF of sampletimes 2 0 5 10 15 20 Time [s] 2.5 0 5 10 15 20 Time [s] 0 0 0.05 0.1 0.15 0.2 0.25 0.3 Transfer interval [s] Figure 4.1: Results from network-in-the-loop with round-robin (0.03s time-out) 24

State x p 2 1.5 1 0.5 0 0.5 1 1.5 State x p with RR (0.04s time out) State x p1 State x p2 State x p3 State x p4 x = 0.1 State x c and error e 3 2 1 0 1 2 State x c and error e with RR (0.04s time out) State x c1 State x c2 Error e 1 Error e 2 e = 0.1 Probability density State norm 4 3 2 1 0 100 80 60 40 20 Vector norm of state 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 Time [s] PDF of sampletimes z =0.1 NCS sampletimes Normal fit 2 0 1 2 3 4 5 Time [s] 3 0 1 2 3 Time [s] 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 Transfer interval [s] Figure 4.2: Results from network-in-the-loop with round-robin (0.04s time-out) To analyze the performance of the NCS with the RR protocol based on the network-in-theloop experiments, some characteristic parameters are introduced. These are the minimal times (in seconds) that all the states in x and e and the vector norm of state z, respectively, (see Section 3.3) are smaller than 0.1, defined as t x := mint > 0 i 1, 2, 3, 4, t T, x pi (t) 0.1 t e := mint > 0 i 1, 2, t T, e i (t) 0.1 and x ci (t) 0.1 t z := mint > 0 t T, z 0.1 (4.1) These three characteristic parameters are depicted by the dotted lines in Figure 4.2. Evaluating the results in Figures 4.1 and 4.2 gives the values that are summarized in Table 4.2. As can be concluded from the figures and table, a longer time-out (0.04s) results in smaller t x, t e and t z than the system with a smaller RR time-out of 0.03 seconds, which might be considered surprising. However, the maximum transfer interval of the system with a time-out of 0.03 seconds is relatively large in comparison with the other system, while the other characteristic values and the figures of the normal distributions are similar. Thus, the fact that the system with the smaller time-out is slower, is caused by a small number of large transfer intervals, caused by data packet dropouts. 25

Table 4.2: Results from network-in-the-loop with round-robin scheduling Results network-in-the-loop with round-robin scheduling (in seconds) Definition Time-out = 0.03s Time-out = 0.04s With dropouts maximum transfer interval (MTI) 0.2690 0.0771 2.3884 mean transfer interval 0.0394 0.0388 0.0413 minimum transfer interval 0.0091 0.0144 0.0069 t x 12 1.5 t e 12.5 1.2 t z 12.3 1.6 To examine the influence of packet dropouts on system stability, an experiment is done using ping to create dropouts. This is achieved by sending much (unimportant) data over the network, causing collisions with the important data packets and leading to packet dropouts. During this experiment the RR time-out from Section 3.8 equals 0.1 seconds and the ping data is sent as frequently as possible. In Figure 4.3 the measured distribution of the transfer intervals, the state norm and the percentage of dropouts are plotted. Again, the arrows are used to indicate large transfer intervals that are caused by data packet dropouts. As shown, the NCS becomes unstable when too many dropouts occur. Evaluating the transfer intervals in Table 4.2 shows that the maximum interval is apparently too large to maintain stability. Moreover, probably several high transfer intervals occur during the experiments, because else the stability of the system would be maintained. In Figure 4.3, the percentage of dropouts is calculated by dividing the number of dropouts by the total number of transmitted data packets at that time. As can be seen, the first serie of consecutive dropouts occur at time is 100s. Though, the system (state norm) remains stable. However, when more dropouts occur (at time 145s), the system shows a peak. Hence, the relation between dropout percentage and state norm peaks can not be clarified precisely. 26

4000 PDF of sampletimes Probability density 3000 2000 1000 0 0 0.5 1 1.5 2 2.5 Transfer interval [s] 8 x 104 Vector norm of state State norm 6 4 2 0 0 50 100 150 200 250 Dropout percentage [%] 1 0.8 0.6 0.4 0.2 Dropouts using ping 0 0 50 100 150 200 250 Time [s] Figure 4.3: Results from network-in-the-loop with round-robin and dropouts 4.2.2 Network-in-the-loop with random scheduling The stochastic random scheduling protocol is described in Section 2.2.2 and is, like the RR protocol, easy to implement in the Xcode program (see Appendix A.5). Unlike RR, the random protocol does not have a time-out period when a data packet drops out, but has a certain period between each transmission, which means that each node (scheduled or not) is sending data constantly. In that way, although a data packet might be lost, one of the next data packets sent by the same node will always arrive at the master node. Because this period between each transmission instant is randomly chosen from a time set of small values, the probability that nodes try to transmit at the same time is very low and the system s time-out will never be very large. In this section the time κ between transmissions will be varied to examine the influence of this parameter. Although the values are chosen randomly, the time set of values from which κ is picked can be chosen a priori. In Figures 4.4 and 4.5 the results from the network-inthe-loop are plotted for two different sets: κ (0, 100/3000s) and κ (0, 100/5000s). 27

State x p 1.5 1 0.5 0 0.5 1 1.5 2 2 x 105 State x p with Random (100/3000 s) State x p1 State x p2 State x p3 State x p4 2.5 0 50 100 150 Time [s] State x c and error e 4 x State x and error e with Random (100/3000 s) 105 c State x c1 3 2 1 0 1 2 State x c2 Error e 1 Error e 2 3 0 50 100 150 Time [s] Probability density State norm 5 x 105 4 3 2 1 Vector norm of state 0 0 20 40 60 80 100 120 140 600 500 400 300 200 100 PDF of sampletimes 0 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 Transfer interval [s] Figure 4.4: Results from network-in-the-loop with random (κ (0, 100/3000)) 0.5 0.4 0.3 0.2 State x with Random (100/5000 s) p State x p1 State x p2 State x p3 State x p4 1.2 1 0.8 0.6 State x and error e with Random (100/5000 s) c State x c1 State x c2 Error e 1 Error e 2 State norm 1.5 1 0.5 Vector norm of state State x p 0.1 0 0.1 0.2 0.3 0.4 0.5 State x c and error e 0.4 0.2 0 0.2 0.4 0.6 Probability density 0 0 1 2 3 4 5 6 7 8 9 10 400 300 200 100 PDF of sampletimes 0 2 4 6 8 10 Time [s] 0.8 0 1 2 3 4 5 Time [s] 0 0 0.05 0.1 0.15 0.2 0.25 0.3 Transfer interval [s] Figure 4.5: Results from network-in-the-loop with random (κ (0, 100/5000)) To analyze the performance of the random scheduling experiments with network-in-theloop, the same criteria as in Section 4.2.1 are applied to the results in Figures 4.4 and 4.5. The values are summarized in Table 4.3 and show that the distribution of the two sets of transmission intervals is not very different. Though, one of the sets (κ (0, 100/5000)) maintains system stability, while the other set from Figure 4.4 leads to instability. This might be caused by a few dropouts close after each other around time = 40s, which lead to a relatively large maximum transfer interval of 0.3663s. After that, the system converges again. Unfortunately, it is difficult to program the recording of the number of dropouts in the experiment with the random scheduling protocol, so it will not be possible to plot the percentage of dropouts. 28

Table 4.3: Results from network-in-the-loop with random scheduling Results network-in-the-loop with random scheduling (in seconds) Definition κ (0, 0.033) κ (0, 0.020) maximum transfer interval (MTI) 0.3663 0.2552 mean transfer interval 0.0392 0.0388 minimum transfer interval 0.0105 0.0135 t x 2 t e 0.7 t z 2.1 4.2.3 Network-in-the-loop on slower network (RR) The stability of the systems in Sections 4.2.1 and 4.2.2 is mainly influenced by the number of dropouts, thus large maximum transfer intervals. To show what the system does when it is used to experiment with the network-in-the-loop over a slower network with more traffic, thus more data packet collisions, the local wireless network in the office is used. In the experiments with network-in-the-loop the round-robin protocol is used as scheduler and the time-out period equals 0.03s (as used to obtain the results in Figure 4.1). In Figure 4.6 it is shown that the percentage of dropouts lies between 0 and 7%. This relatively high number of dropouts leads to system instability as shown in the state and error figures. 1.5 x 1033 State x p with slower network 2.5 x 1033 State x c and error e with slower network 200 Probability density function of sampletimes State x p 1 0.5 0 State x p1 0.5 State x p2 State x p3 State x p4 1 0 20 40 60 80 Time [s] State x c and error e 2 1.5 1 0.5 0 0.5 1 State x c1 1.5 State x c2 2 Error e 1 Error e 2 2.5 0 20 40 60 80 Time [s] PDF State norm Dropouts [%] 150 100 50 0 0 0.05 0.1 0.15 0.2 0.25 0.3 Transfer interval [s] 3 x 1033 2 1 Vector norm of state 0 0 10 20 30 40 50 60 70 10 5 Percentage of dropouts using other network 0 0 10 20 30 40 50 60 70 Time [s] Figure 4.6: Results from network-in-the-loop with RR on slower network 29

4.3 Matlab Simulink simulation To validate the results from the experiments with network-in-the-loop from the previous sections, a model is designed using Matlab Simulink to simulate and analyze the NCS. Both system elements (batch reactor model and scheduling protocol from Chapter 2) are implemented in the total system in Simulink. The resulting simulation model is shown in Figure 4.7, where the Matlab function block f(x) (upper block) contains the linearized batch reactor model and h(x) (lower block) the scheduling algorithm (RR or random). To apply a sampling time that is comparable with the probability density functions in Figures 4.1 to 4.4, a Gaussian distributed pulse signal is used to approximate the transfer intervals from the experiments and to reset the integrator. The model in Figure 4.7 is simulated for the RR and random protocols and the results are discussed in this section and summarized in Table 4.4. Figure 4.7: Matlab Simulink model of the NCS 4.3.1 Simulink simulation with round-robin protocol The round-robin algorithm from Section 2.2.1 is implemented in a m-file, given in Appendix A.1.1. This m-file is inserted in the Simulink model from Figure 4.7, together with an approximation of the Gaussian distribution from Figure 4.2 (RR with a time-out of 0.04s). With this configuration, the round-robin simulation of the NCS gives the results shown in Figure 4.8 and the performance data is summarized in Table 4.4. In Figure 4.8 the absolute responses of the states are plotted versus the time and show stable and smooth behavior, without any disturbances (dropouts are not modeled). 30

0.6 Simulink RR state x p State x p1 0.2 Simulink RR state x c and error e State x c1 1.5 Vector norm of state State x p 0.5 0.4 0.3 0.2 0.1 State x p2 State x p3 State x p4 State x c and error e 0.18 0.16 0.14 0.12 0.1 0.08 0.06 0.04 0.02 State x c2 Error e 1 Error e 2 State norm Probability density 1 0.5 0 0 1 2 3 4 5 6 7 8 9 10 Time [s] 150 100 50 PDF of sampletimes 0 0 2 4 6 8 10 Time [sec] 0 0 0.1 0.2 0.3 0.4 0.5 Time [sec] 0 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 Sampling time [s] Figure 4.8: Results from Simulink with round-robin protocol 4.3.2 Simulink simulation with random protocol The implementation of the random algorithm from Section 2.2.2 in Matlab is given in Appendix A.1.2. This m-file is inserted in the h(x) function block from Figure 4.7 and the Gaussian distribution from Figure 4.5 is approximated and applied as an integrator reset signal. Note that the high transfer intervals, due to dropouts, from the experiments with network-in-the-loop from Figure 4.5 are not taken into account in the Gaussian distribution. The simulation of the NCS with the random protocol gives the results in Figure 4.9 and Table 4.4. 0.6 Simulink random state x p State x p1 0.2 Simulink random state x c and error e State x c1 1.5 Vector norm of state State x p 0.5 0.4 0.3 0.2 0.1 State x p2 State x p3 State x p4 State x c and error e 0.18 0.16 0.14 0.12 0.1 0.08 0.06 0.04 0.02 State x c2 Error e 1 Error e 2 State norm Probability density 1 0.5 0 0 1 2 3 4 5 6 7 8 9 10 Time [s] 100 80 60 40 20 PDF of sampletimes 0 0 2 4 6 8 10 Time [sec] 0 0 0.1 0.2 0.3 0.4 0.5 Time [sec] 0 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 Sampling time [s] Figure 4.9: Results from Simulink with random protocol 31

Table 4.4: Results from Matlab Simulink Results from simulations (in seconds) Definition Round-robin Random maximum transfer interval 0.0721 0.0736 mean transfer interval 0.0389 0.0387 minimum transfer interval 0.0065 0.0085 t x 2.5 2.6 t e 0.034 0.035 t z 3.0 3.0 In the table above, the performance results from the Simulink simulations are given. The same criteria are used as in Sections 4.2.1 and 4.2.2. As shown in the table, the results of the two different protocols are similar and the performances are almost equal. Although the protocols are different (RR and random), for such small and perfect normal distributed transfer intervals the Simulink model apparently gives the same results. 4.3.3 Simulated protocols In [2], [3] and [7] several other protocols are proposed. Nesic and Teel discuss the modified round-robin, Try-Once-Discard (TOD) and the modified TOD protocols in [2] and [3]. Walsh et al. propose the Constant Penalty, Estimated Error Order and Lag First Order scheduling protocols in [7] (all with TOD as underlying scheduler). These protocols from Walsh are dynamic schedulers as explained in Section 2.2 and use an estimation of the error. These methods are relatively easy to implement, as long as no dropouts occur. As soon as that happens, it becomes difficult to program a mechanism that reacts on this to maintain the right scheduling order. That is why the scheduling protocols mentioned in this section are less robust than the RR and random schedulers. Moreover, the RR and random protocols are easier to implement. This is why only the RR and random scheduling protocols are used in the experiments with network-in-the-loop. The other protocols have been simulated in Matlab Simulink only (see Appendix A.1) and are discussed in this section and their results are summarized in Table 4.5. Let us first introduce the other protocols. Try-Once-Discard In [2], Nesic and Teel describe the UGES try-once-discard (TOD) protocol which operates as follows. Suppose that there are l nodes competing for access to the network, with error vector e = (e T 1 e T 2... e T l )T. The node i with the greatest error at time t sj will be granted access to the network at t + s j and hence the error will be reset to e i (t + s j ) = 0 while 32

the others stay the same. If a data packet fails to gain access to the network, it is discarded and thus e i (t + s j ) = e i (t s j ) as the error remains the same. If two or more nodes have equal priority, a pre-specified ordering of the nodes is used to resolve the collision. The protocol model is described by: h(e) = (I Ψ(e))e, (4.2) where Ψ(e) := diagψ 1 (e)i n1, ψ 2 (e)i n2,..., ψ l (e)i nl. I nj are identity matrices of dimension n j with l j=1 n j = n e and 1 if j = min(arg maxi e ψ j (e) := i ) 0 otherwise. (4.3) Modified try-once-discard The modified TOD protocol is described in [3] and behaves like TOD for large e and for small e it makes the error jumps smaller, because it is transmitting less information. It is described by e(i + 1) = h(i, e(i)), where h(e) = (I Ψ(e))e as in equation (4.2), and a modified version of equation (4.3), given by: sat( ej ) if j = min(arg max ψ j (e) := i e i ) 0 otherwise, (4.4) where sat( e j ) is a saturation function that is given in Appendix A.1.4, bounded by a given parameter. In [3] is showed that the modified TOD scheduling protocol is uniformly globally asymptotically stable (UGAS) as in Definition 3 below. Definition 3 (Lyapunov UGAS protocols): A protocol as in Section 4.3.3 is said to be Lyapunov UGAS if there exist a Lyapunov function W : R 0 R n R 0, α 1, α 2 K and a real number λ [0, 1) such that for all i N and all e R n : Modified round-robin α 1 ( e ) W (i, e) α 2 ( e ), (4.5) W (i + 1, h(i, e)) λw (i, e). (4.6) Like the modified TOD protocol, the UGAS modified RR is described in [3] and has a similar structure as the normal RR: it behaves exactly like round-robin for e > 1 and 2 for small e it transmits less frequently (e.g. for e ( 1, 1 ] the protocol transmits at a 10 11 frequency that is 10 times smaller than that of the RR protocol). Consider the protocol in equation (2.9), where (i) = diagδ 1 (i)i s1,..., δ l (i)i sl and 1 1 if e > 0, i = (k + jl), j N δ k (i) = sat( e ) (4.7) 0 otherwise. 33

Constant penalty Walsh et al. describe in [7] the UGAS constant penalty (CP) scheduling protocol in the following way: ê i (t + ) = e i (t ) = ẽ(t) ê j (t + ) = ê j (t (4.8) ) + θ, where i represents the transmitted node, j the silent nodes, j i and θ (0, ) is a prespecified constant. When this is written in a discrete way, the following equations result: e + = (I Φ(r, ê))e ê + = (I Φ(r, ê))(ê + θ) + Φ(r, ê) e (4.9) r + = (I Φ(r, ê))(r + 1), where θ is the penalty vector, 1 = [1...1] T, the scheduling function Φ is given by Φ(r, ê) = diagϕ j (r, ê)i sj, j [1,..., l] and 1 if [n =min(arg max ê )] ϕ n (r, ê) = [n =minm : r m M] (4.10) 0 otherwise. In these equations ê is the estimation of the error and M is the threshold for the transmission counter r. This scheduling scheme ensures that every node is visited at least once during any kpt time interval. If r j M, no matter how big ê i is at that instant, node j will be transmitted. If there are two or more nodes for which this applies, the first of those nodes will be transmitted. Estimated error order The UGAS estimated error order (EEO) scheduling algorithm is described in [7] by the next equations, where at every transmission instant the true error equals e i (t + i j ) = 0 and node i keeps silent where its growth rate and error amplitude are estimated by: ˆė i (t) = k i (t) = e i (t i j )/(t ij t ij 1 ) ê i (t) = θ 0 + k i (t) (t t ij ), (4.11) where θ 0 [0, ) is a prespecified small constant. This set of estimated error equations can be rewritten as: e + = (I Φ(r, ê))e ê + = θ 0 + k T, where k = e (4.12) T r + = (I Φ(r, ê))(r + 1), where T is the sampling period and Φ and 1 are given in the CP section. The scheduling scheme is based on the continuity of the plant output and small interval between two consecutive transmissions and the true error of every node is assumed to be piecewise linear. So, the difference with the Constant Penalty scheduler is that the estimated error ê + is updated by using its error growth rate and error amplitude. 34

Lag first order The third and last scheduling algorithm Walsh et al. describe in [7] is the UGAS lag first order (LFO) scheme. Actually, this algorithm is a autoregressive filter and uses a time-varying penalty θ(t) which is updated according to the following law: θ(t k+1 ) = (1 1/m)θ(t k ) + ẽ(t k+1 ) /m + θ 0 /m, (4.13) where m [1, ) and θ 0 (0, ) are two prespecified constants. Assume at t k instant, node i is transmitted and all other nodes keep silent, then ê i (t + k ) = e i(t k ) = ẽ k, ê j (t + k ) = ê j(t k ) + θ(t k) for all j i, where θ(t k ) is updated as above in (7). Writing this time-varying scheme in a discrete way, results in the next set of equations: e + = (I Φ(r, ê))e ê + = (I Φ(r, ê))(ê + θ) + Φ(r, ê) e, r + = (I Φ(r, ê))(r + 1), (4.14) where the penalty is updated by θ = (1 1/m)θ+ e /m+θ 0 /m and m and θ 0 are constants. See Section 4.3.3 for the definition of the other parameters Φ and 1. Summary of simulated protocols The protocols described in this section are implemented in Matlab files (Appendix A.1) and simulated with the Simulink model in Figure 4.7. However, instead of using the Gaussian time distribution as integrator reset input, Poisson distributed transmission intervals are used as in [1] and [7]. The simulation results in Table 4.5 represent the maximal mean values of the Poisson distributed transfer intervals, while the simulations remain stable. This mean value of the Poisson distribution is a parameter that can be varied in Simulink. These results are obtained by running the simulation model for different values of the mean of the Poisson distribution and determine for which mean value the system gets unstable. Note that these values are not equal to the MATI. Based on the Simulink simulations and literature results, the maximal mean transfer intervals and the estimations of the real MATIs are summarized in Table 4.5. Note again that the simulation model uses a NCS with four nodes, whereas the model in the literature uses a NCS with two nodes and the MATIs would be lower than the theoretical values in the table when four nodes were used. 35

Table 4.5: Summary of MATIs for the simulated protocols MATI and MMTI results of simulated protocols (in seconds) Used protocol Literature Simulation try-once-discard 0.010 [1] 0.090 modified try-once-discard not available 0.059 modified round-robin not available 0.053 constant penalty 0.030 [7] 0.077 estimated error order 0.040 [7] 0.091 lag first order 0.035 [7] 0.063 4.4 Network-in-the-loop and Simulink comparison Because simulation is much faster and cheaper than doing experiments on the real system, it would be desirable that the Matlab Simulink simulations are close to the network-inthe-loop experiments. In the following two sections the Simulink results from Section 4.3 will be compared with the NCS experiment results from Section 4.2 to examine this. 4.4.1 Network-in-the-loop and Simulink: round-robin A model that predicts the behavior of the real system would be ideal. To check whether the Matlab Simulink model of the NCS in Figure 4.7 is a good approximation of the real system, the resulting states of the simulation will be compared with the results from the network-in-the-loop experiments. In this section, RR with a time-out of 0.04 seconds is the scheduling protocol, as shown in Figures 4.2 and 4.8. Moreover, in the Simulink simulations the Gaussian fit of the transfer intervals from Figure 4.2 is used, instead of the exact transfer intervals from the experiments. All states x i and e i and the vector norms display similar results. That is why only x p3 and e y1 = ŷ 1 y 1 are plotted in Figure 4.10 for both the network-in-the-loop experiment and the Simulink simulation. The conclusions on performance that can be drawn from Figure 4.10 are summarized in Table 4.6, where t i is defined in equation (4.1). 36

1.5 1 State x p3 Simulink NCS 4 3 2 Error state e 1 Simulink NCS 3.5 3 2.5 Vector norm of both states Simulink NCS State x p 0.5 0 0.5 Error e 1 0 1 State norm z 2 1.5 1 0.5 1 2 0 1.5 0 1 2 3 4 5 Time [s] 3 0 0.5 1 1.5 2 Time [s] 0.5 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 Time [s] Figure 4.10: Compare results from RR protocol Table 4.6: Compare RR scheduling Compare RR scheduling (in seconds) Definition Simulink NCS mean transfer interval 0.0387 0.0388 transfer interval variance 8.24 10 5 8.41 10 5 t x 1.5 1.2 t e 0.03 0.7 t z 3.0 1.6 As shown in the figure and table, the Matlab simulation results in different behavior than the experiment with network-in-the-loop. It is obvious that the normal distribution of the transfer intervals is alike, because in the Matlab simulation a comparable transfer interval distribution is used as in the experiment. Though, we do not use the exact same transfer intervals as in the experiments, especially the sequence of transfer intervals is probably totally different. This might clarify the differences between the network-in-theloop experiments and the Matlab simulations. Also, the performance of both results is quite different. This might be caused by the fact that dropouts occur (and thus large transfer intervals) during the experiments, but are not taken into account in the Simulink model, which results in the smooth response of the simulation plots. Though, the performance results of the experiment and simulation are of the same order (except the error). 37

4.4.2 Network-in-the-loop and Simulink: random In this section the results from the experiments with the network-in-the-loop and Matlab Simulink simulations with the random scheduling protocol will be compared. The results from the network-in-the-loop experiments are shown in Section 4.2.2, Figure 4.5 (κ 0 : 100/5000s), and are used to examine the similarity of the Simulink results from Figure 4.9 and the experiments with the network-in-the-loop. As in the RR comparison above, a Gaussian approximation of the transfer intervals is used and all states show similar results. That is why in Figure 4.11 only states x p4 and e y2 = ŷ 2 y 2 are plotted together with the vector norms of both the network-in-the-loop and Simulink state results. 0.6 0.5 State x p4 Simulink NCS 0.8 0.6 Error state e 2 Simulink NCS 1.5 Vector norm of both states Simulink NCS 0.4 0.4 1 0.2 State x p 0.3 0.2 Error e 0 0.2 State norm 0.5 0.1 0.4 0 0.6 0.1 0 2 4 6 8 10 Time [s] 0.8 0 0.5 1 1.5 2 2.5 3 Time [s] 0 0 1 2 3 4 5 6 7 8 Time [s] Figure 4.11: Compare results from random protocol Table 4.7: Compare random scheduling Compare random scheduling (in seconds) Definition Simulink NCS mean transfer interval 0.0391 0.0388 transfer interval variance 8.81 10 5 8.60 10 5 t x 2.5 2 t e 0.04 0.7 t z 3.0 2.1 As in the RR comparison in Section 4.4.1, the Simulink model with random scheduling gives different behavior and performance results than the experiments with the network-inthe-loop. The Simulink model shows less disturbances, which is expectable because there are no side effects (such as data packet dropouts) in Simulink, while these are present in the experiments with the network-in-the-loop. Again, the differences might be caused by the usage of a Gaussian approximation of the transfer intervals instead of the exact intervals and sequence from the experiments. 38

Chapter 5 Evaluation of theoretical NCS framework In this chapter a comparison is made between the results from previous research, as in [1] and [7], and the network-in-the-loop experiments using the MATI and MTI from Section 2.3. This is done to verify the conservative character of the lower bounds presented in the literature. As shown in Chapter 4 and in the network-in-the-loop experiments, the stability of the NCS is mainly influenced by the number of data packet dropouts and thus by large transmission intervals. These factors are dependent of the used scheduling protocol (time-outs) and, as least as important, of the characteristics of the used (wireless) network. To make a good comparison, it is important to realize that two different wireless networks are available for the network-in-the-loop experiments that are discussed in this study: one that is able to transport data packets with very few dropouts and one with relatively many dropouts because of the increased amount of other traffic. Of course, for applications it is desired to use a network that transports data with as few dropouts as possible. 39

5.1 Round-robin protocol comparison In Section 4.1 the results from previous studies on the RR and random protocols are summarized. In Table 5.1 these MATIs for the RR protocol are compared with the MTI obtained from the NCS with network-in-the-loop resulting in stable behavior, which is equal to the one obtained from the NCS experiment with a RR time-out of 0.04s and no dropouts from Table 4.2 and Figure 4.2. This MTI is denoted by τncs,0.04. RR Table 5.1: Compare MATIs from theory with MTI from NCS experiment (RR) MATIs from theory and MTI from NCS (RR, in seconds) τtabbara RR = 0.0123 τnesic RR = 0.0082 τ RR walsh = 1.05 10 9 τ RR ncs,0.04 = 0.0771 As shown in Table 5.1, the MTI obtained from the stable NCS experiment is higher than the MATIs obtained by theoretical calculations. In the literature a lower bound on the MATI is calculated, while in the NCS experiment this lower bound is actually conservative and the MTI results to be higher before the system becomes unstable. Though, doing a new experiment with τncs,0.04 RR = 0.0771 might result in unstable behavior, depending on the number of large transfer intervals. Moreover, the sequence of the transfer intervals might influence the system s stability, while τ i is not exactly Gaussian distributed. Comparing the resulting MTI with the MATIs from the theory, makes clear that in this study an other approximation is determined than in the theory: the authors of previous studies determined conservative lower bounds on the MATI, while the MTIs determined in this study are typically much larger than these lower bounds on the MATI. 5.2 Random protocol comparison In [1], Tabbara determines an average MATI for a NCS system with a random scheduling protocol for different percentages of dropouts. For non-equidistant transmission rates and a network without dropouts, this value τtabbara rand equals 0.02s as displayed in Table 4.1. In Section 4.2.2 the MTI τncs rand from the stable network-in-the-loop experiment (κ 0 : 100/5000s) is determined and this value is shown in Table 5.2. Table 5.2: Compare maximum transfer intervals from theory and experiments Maximum (allowable) transfer interval (random, in seconds) τ rand tabbara = 0.02 τ rand ncs = 0.2552 40

Chapter 6 Conclusion and future work In this study different scheduling protocols are simulated using Matlab Simulink and using a network-in-the-loop setup. The results from the simulations and experiments are compared with each other in Chapter 4 and with previous studies in Chapter 5. These comparisons were done for two reasons: to compare the theoretical bounds from the theory with the ones obtained from experiments with a real network-in-the-loop and say something about the conservative character of the theoretical MATI to design a Matlab Simulink model of the NCS that is a good approximation of the network-in-the-loop setup (real NCS). As concluded in the previous chapters, most studies from the literature compute theoretical lower bounds on the MATI. However, from the experiments with the network-in-the-loop that are performed in this research, with a standard wireless network, it can be concluded that the values of the MATI in the literature are typically much smaller than the MTIs obtained from the network-in-the-loop experiments. An important note here is that the studies in the literature analyse a NCS with two nodes and that in this study a NCS with four nodes is examined. This means that the theoretical lower bounds on the MATI that are given in this work would be even smaller when a NCS with four nodes was analyzed in the literature. Moreover, the MATI might not be such a relevant parameter to analyze the NCS stability. From the network-in-the-loop experiments it seems that the transfer intervals are often having a normal (Gaussian) distribution. This means that the maximum transfer interval has a very low probability and might not be a good parameter in this case. Here, the average transfer interval might be a better parameter to analyze NCS stability. To study this in more detail, we recommend to formulate a stability theory in terms of distributions with certain parameters, such as the average transfer interval and/or the standard deviation, instead of using the MATI. This new stability theory might give better and less conservative results. 41

Although eight protocols are mentioned and described in this paper, only two protocols are implemented in the network-in-the-loop setup: the round-robin and random protocols. These two static schedulers are much easier to implement in the program code, because unlike the dynamic schedulers, random and RR do not use the state error to schedule the nodes, which means that the error does not need to be transmitted over the network. This makes them to operate faster and with less calculations. Moreover, the random protocol does not need a certain method for dealing with dropouts, because it is not important which node is scheduled (stochastic) and data is available at any time. The six dynamic protocols are only simulated in Simulink. The best scheduling protocol to use in the real system seems to be the random protocol. Because it is stochastic, the probability that two or more nodes decide to transmit at the same time is very low and therefore the probability that collisions and dropouts occur is very low. Moreover, the random protocol does not have a waiting time when dropouts occur, like RR (Section 3.8), which makes the maximal transfer intervals smaller and thus the NCS faster and faster stable. Finally, as shown in Section 4.4 the results from the Simulink simulations and the networkin-the-loop experiments are comparable. The used performance parameters t x, t e and t z of the simulations and experiments are of the same order. Unfortunately, in the current Simulink model the possibility of dropouts is not implemented, which should be done in future work. Moreover, instead of using the Gaussian distributed approximation of the transfer intervals, we recommend to implement the measured realization of τ i in the Simulink model to see if this results in same behavior of the simulations and experiments. Also, the current NCS program should be tested on a real plant. In this work, a linearized model of a batch reactor is used to simulate a plant that can be actuated and observed. The results show that the NCS simulations with this plant model are stable, so experimenting with a real plant would be a reasonable next step. When this is done, the dropout of a node can be examined as well, because this is not researched in this study. A final note to finish this report. The used model of the NCS with the batch reactor does not contain communication delays. Because each real NCS contains communication delays to deal with, it would be a good idea to implement a model of a network with communication delays in the current Simulink and network-in-the-loop models to examine the effects of communication delays on system stability as well. 42

Bibliography [1] M. Tabbara, Networked Control Systems, Analysis & Design, Department of Electrical and Electronic Engineering, The University of Melbourne, 2007. [2] D. Nesic, A.R. Teel, Input-output stability properties of networked control systems, IEEE Trans. Automat. Contr., 49(10): 1650-1667, 2004. [3] D. Nesic, A.R. Teel, Input-to-state stability of networked control systems, Automatica, 40(12): 2121-2128, 2004. [4] D. Nesic, A.R. Teel, L p stability of networked control systems, Proc. 42nd IEEE, Hawaii USA, 2003. [5] D. Nesic, A.R. Teel, M. Tabbara, Stability of wireless and wireline networked control systems, IEEE Trans. Autom. Cont., vol.52, no.9, 2007. [6] D. Nesic, M. Tabbara, Stability of networked control systems with stochastic protocols, Proc. 2007 American Cont. Conf., New York City, 2007. [7] G.C. Walsh, Hong Ye, L.G. Bushnell, Real-time mixed-traffic wireless networks, IEEE Trans. Ind. Elec., vol.48, no.5, 2001. [8] G.C. Walsh, Hong Ye, L.G. Bushnell, Stability analysis of networked control systems, IEEE Trans. Cont. Sys. Techn., vol.10, no.3, 2002. [9] H.H. Rosenbrock, Computer-aided control system design, Academic Press, New York, 1974. [10] M. Cloosterman, N. van de Wouw, M. Heemels, H. Nijmeijer, Robust stability of networked control systems with time-varying network- induced delays, IEEE CDC, San Diego, 2006. 43

Appendix A Matlab and Xcode files 44

A.1 Scheduling Protocols A.1.1 Round-robin scheduling Matlab file The mathematical description of the round-robin scheduling protocol in Section 2.2.1 is implemented in Matlab as shown in the m-file below. f u n c t i o n out = h ( x ) ; % Round Robin s c h e d u l i n g p r o t o c o l with s t a t e x = [ 8 x1 ] g l o b a l i ; % g l o b a l count v a r i a b l e g l o b a l x0 ; % i n i t i a l s t a t e c o n d i t i o n i = i +1; % each sampling i n s t a n t i i s r a i s e d by 1 i f i == 1 % at time = 0, i e q u a l s 1 out = x0 ; % the output o f h ( x ) e q u a l s the i n i t i a l c o n d i t i o n x0 return end e = [ x ( 5 ) ; x ( 6 ) ; x ( 7 ) ; x ( 8 ) ] ; % e r r o r e e q u a l s the f i f t h t i l l e i g h t h s t a t e nodetoreset = mod( i, 4 ) ; % e q u a l s 0 to 3 i n a f i x e d o r d e r ( 1, 2, 3, 0, 1,.. ) e (1 + nodetoreset ) = 0 ; % s e t s 1 s t t i l l 4 th element o f e to 0 i n a f i x e d o r d e r out = [ x ( 1 ) x ( 2 ) x ( 3 ) x ( 4 ) e ] ; % output o f h ( x ) e q u a l s s t a t e x A.1.2 Random scheduling Matlab file The mathematical description of the random scheduling protocol in Section 2.2.2 is implemented in Matlab as shown in the m-file below. f u n c t i o n out = h ( x ) ; g l o b a l i ; g l o b a l x0 ; % I n i t i a l c o n d i t i o n i = i +1; i f i == 1 out = x0 ; % I n i t i a l c o n d i t i o n return end e = [ x ( 5 ) ; x ( 6 ) ; x ( 7 ) ; x ( 8 ) ] ; randomnumber = c e i l (4 rand ( 1, 1 ) ) ; % node i s chosen randomly e ( randomnumber ) = 0 ; out = [ x ( 1 ) x ( 2 ) x ( 3 ) x ( 4 ) e ] ; 45

A.1.3 Try-once-discard scheduling Matlab file The mathematical description of the try-once-discard scheduling protocol in Section 4.3.3 is implemented in Matlab as shown in the m-file below. f u n c t i o n out = htod( x ) ; g l o b a l i ; g l o b a l x0 ; % I n i t i a l c o n d i t i o n i = i +1; i f i == 1 out = x0 ; % I n i t i a l c o n d i t i o n return end e = [ x ( 5 ) ; x ( 6 ) ; x ( 7 ) ; x ( 8 ) ] ; [ maxerror e r r o r ] = max( abs ( e ) ) ; e ( e r r o r ) = 0 ; out = [ x ( 1 ) x ( 2 ) x ( 3 ) x ( 4 ) e ] ; A.1.4 Modified try-once-discard scheduling Matlab file The mathematical description of the modified try-once-discard scheduling protocol in Section 4.3.3 is implemented in Matlab as shown in the m-file below. f u n c t i o n out = hmodifiedtod ( x ) ; g l o b a l i ; g l o b a l x0 ; i = i +1; i f i == 1 out = x0 ; return end e = [ x ( 5 ) ; x ( 6 ) ; x ( 7 ) ; x ( 8 ) ] ; [ maxerror e r r o r ] = max( abs ( e ) ) ; e ( e r r o r ) = s a t u r a t i o n 2 ( e ( e r r o r ), 1 ) ; out = [ x ( 1 ) x ( 2 ) x ( 3 ) x ( 4 ) e ] ; In this modified TOD m-file, the saturation2 function is calculated by the file below. f u n c t i o n out = s a t u r a t i o n 2 ( e, a ) i f abs ( e ) < a out = e ; return else out = s i g n ( e ) a ; return end 46

A.1.5 Modified round-robin scheduling Matlab file The mathematical description of the modified round-robin scheduling protocol in Section 4.3.3 is implemented in Matlab as shown in the m-file below. f u n c t i o n out = h ( x ) ; g l o b a l i ; g l o b a l x0 ; i = i +1; i f i == 1 out = x0 ; return end e = [ x ( 5 ) ; x ( 6 ) ; x ( 7 ) ; x ( 8 ) ] ; a = f l o o r (1/ s a t u r a t i o n 2 ( norm ( e ), 1 ) ) ; for j = 1 : 4 i f mod( i, 4 a ) == a ( j 1) e ( j ) = 0 ; end end out = [ x ( 1 ) x ( 2 ) x ( 3 ) x ( 4 ) e ] ; A.1.6 Constant penalty scheduling Matlab file The mathematical description of the constant penalty scheduling protocol in Section 4.3.3 is implemented in Matlab as shown in the m-file below. f u n c t i o n out = hcp( x ) ; % Function h ( x ) for the Constant Penalty p r o t o c o l g l o b a l i ; % Counter g l o b a l r ; % Link t r a n s m i s s i o n counter g l o b a l M; % Threshold for t r a n s m i s s i o n counter r g l o b a l T; % Sampling time g l o b a l eh ; % Estimated e r r o r e ( hat ) g l o b a l x0 ; % I n i t i a l c o n d i t i o n s t a t e x g l o b a l t h e t a ; % I n t e g r a t i o n c o n s t a n t i = i +1; % Counter+1 i f i == 1 % S t a r t out = x0 ; % I n i t i a l c o n d i t i o n s t a t e x eh = z e r o s ( 4, 1 ) ; % I n i t i a l estimated e r r o r e ( hat ) return end e = [ x ( 5 ) ; x ( 6 ) ; x ( 7 ) ; x ( 8 ) ] ; % Error e q u a l s s t a t e 5 to 8 [ maxerror n ] = max( abs ( eh ) ) ; % Maximum o f e r r o r, nth l i n k [ maxr j ] = max( r ) ; % Maximum o f counter r, j t h l i n k i f maxr < M % I f r i s s m a l l e r than M, nth l i n k t r a n s m i t t e d eh = eh+t h e t a ; % Error growth = growth r a t e sampling time + int const eh ( n ) = norm ( e ( n ) ) ; % Transmitted maximal e r r o r e ( hat ) ( n ) = the norm o f e e ( n ) = 0 ; % Transmitted e r r o r i s s e t to 0 47

r = r +1; % Counter i s updated with 1 r ( n ) = 0 ; % Transmitted counter i s s e t to 0 e l s e i f maxr >= M; % I f r i s g r e a t e r than M, j t h l i n k t r a n s m i t t e d eh = eh+t h e t a ; % Error growth = growth r a t e sampling time + int const eh ( j ) = norm ( e ( j ) ) ; % Transmitted maximal s i l e n t time e ( hat ) ( j ) = o f e e ( j ) = 0 ; % Phi = 1, so e ( n)+ = 0 r = r +1; % Counter i s updated with 1 r ( j ) = 0 ; % Transmitted counter i s s e t to 0 end out = [ x ( 1 ) x ( 2 ) x ( 3 ) x ( 4 ) e ] ; % The output e q u a l s the whole s t a t e A.1.7 Estimated error order scheduling Matlab file The mathematical description of the estimated error order scheduling protocol in Section 4.3.3 is implemented in Matlab as shown in the m-file below. f u n c t i o n out = heeo( x ) ; % Function h ( x ) for the Estimated Error Order p r o t o c o l g l o b a l i ; % Counter g l o b a l r ; % Link t r a n s m i s s i o n counter g l o b a l M; % Threshold for t r a n s m i s s i o n counter r g l o b a l T; % Sampling time g l o b a l eh ; % Estimated e r r o r e ( hat ) g l o b a l x0 ; % I n i t i a l c o n d i t i o n s t a t e x g l o b a l t h e t a ; % I n t e g r a t i o n c o n s t a n t i = i +1; % Counter+1 i f i == 1 % S t a r t out = x0 ; % I n i t i a l c o n d i t i o n s t a t e x eh = z e r o s ( 4, 1 ) ; % I n i t i a l estimated e r r o r e ( hat ) return end e = [ x ( 5 ) ; x ( 6 ) ; x ( 7 ) ; x ( 8 ) ] ; % Error e q u a l s s t a t e 5 to 8 [ maxerror n ] = max( abs ( eh ) ) ; % Maximum o f e r r o r, nth l i n k [ maxr j ] = max( r ) ; % Maximum o f counter r, j t h l i n k i f maxr < M % I f r i s s m a l l e r than M, nth l i n k t r a n s m i t t e d for z = 1 : 4 % For each l i n k k ( z ) = e ( z ) T; % Error growth r a t e = e r r o r / sampling time ( eq 4 i n [ 7 ] ) eh ( z ) = t h e t a+norm ( k ( z ) ) /T; % Error growth = growth r a t e sampling time + int const end e ( n ) = 0 ; % Transmitted e r r o r i s s e t to 0 r = r +1; % Counter i s updated with 1 r ( n ) = 0 ; % Transmitted counter i s s e t to 0 e l s e i f maxr >= M; % I f r i s g r e a t e r than M, j t h l i n k t r a n s m i t t e d for z = 1 : 4 k ( z ) = e ( z ) T; % Error growth r a t e = e r r o r / by sampling time eh ( z ) = t h e t a+norm ( k ( z ) ) /T; % Error growth = growth r a t e sampling time + int const end e ( j ) = 0 ; % Phi = 1, so e ( n)+ = 0 r = r +1; % Counter i s updated with 1 r ( j ) = 0 ; % Transmitted counter i s s e t to 0 end out = [ x ( 1 ) x ( 2 ) x ( 3 ) x ( 4 ) e ] ; % The output e q u a l s the whole s t a t e 48

A.1.8 Lag first order scheduling Matlab file The mathematical description of the lag first order scheduling protocol in Section 4.3.3 is implemented in Matlab as shown in the m-file below. f u n c t i o n out = hlfo( x ) ; % Function h ( x ) for the Lag F i r s t Order p r o t o c o l g l o b a l i ; % Counter g l o b a l r ; % Link t r a n s m i s s i o n counter g l o b a l m; % Constant g l o b a l M; % Threshold for t r a n s m i s s i o n counter r g l o b a l T; % Sampling time g l o b a l eh ; % Estimated e r r o r e ( hat ) g l o b a l x0 ; % I n i t i a l c o n d i t i o n s t a t e x g l o b a l t h e t a ; % I n t e g r a t i o n c o n s t a n t g l o b a l t h e t a 0 ; % I n i t i a l p e n a l t y i = i +1; % Counter+1 i f i == 1 % S t a r t out = x0 ; % I n i t i a l c o n d i t i o n s t a t e x t h e t a = t h e t a 0 ; % I n i t i a l e s timated e r r o r e ( hat ) return end e = [ x ( 5 ) ; x ( 6 ) ; x ( 7 ) ; x ( 8 ) ] ; % Error e q u a l s s t a t e 5 to 8 [ maxerror n ] = max( abs ( eh ) ) ; % Maximum o f e r r o r, nth l i n k [ maxr j ] = max( r ) ; % Maximum o f counter r, j t h l i n k t h e t a = (1 1/m) t h e t a+norm ( e )/m+t h e t a 0 /m; % Estimation o f the e r r o r i f maxr < M % I f r i s s m a l l e r than M, nth l i n k t r a n s m i t t e d for z = 1 : 4 % For each l i n k eh ( z ) = e ( z)+ t h e t a ; % Error growth = growth r a t e sampling time + int const end eh ( n ) = norm ( e ( n ) ) ; % Transmitted maximal e r r o r e ( hat ) ( n ) = norm o f e e ( n ) = 0 ; % Transmitted e r r o r i s s e t to 0 r = r +1; % Counter i s updated with 1 r ( n ) = 0 ; % Transmitted counter i s s e t to 0 e l s e i f maxr >= M; % I f r i s g r e a t e r than M, j t h l i n k t r a n s m i t t e d for z = 1 : 4 eh ( z ) = e ( z)+ t h e t a ; % Error growth = growth r a t e sampling time + int const end eh ( j ) = norm ( e ( j ) ) ; % Transmitted maximal s i l e n t time e ( hat ) ( j ) = norm o f e e ( j ) = 0 ; % Phi = 1, so e ( n)+ = 0 r = r +1; % Counter i s updated with 1 r ( j ) = 0 ; % Transmitted counter i s s e t to 0 end out = [ x ( 1 ) x ( 2 ) x ( 3 ) x ( 4 ) e ] ; % The output e q u a l s the whole s t a t e 49

A.2 State-space description of batch reactor The linearized model of the batch reactor from Section 2.1 is implemented in Matlab with the following m-file. f u n c t i o n out = f ( x ) ; % State space l i n e a r i z a t i o n o f batch r e a c t o r % Plant Ap = [ 1. 3 8 0.2077 6. 7 1 5 5.676 0.5814 4.29 0 0. 6 7 5 1. 0 6 7 4. 2 7 3 6.654 5. 8 9 3 0. 0 4 8 4. 2 7 3 1. 3 4 3 2. 1 0 4 ] ; Bp = [ 0 0 5. 6 7 9 0 1. 1 3 6 3.146 1. 1 3 6 0 ] ; Cp = [ 1 0 1 1 0 1 0 0 ] ; Dp = [ 0 0 0 0 ] ; % C o n t r o l l e r Ac = [ 0 0 0 0 ] ; Bc = [ 0 1 1 0 ] ; Cc = [2 0 0 8]; Dc = [0 2 5 0 ] ; % Total ( page 81) A11 = [ Ap+Bp Dc Cp Bp Cc ; Bc Cp Ac ] ; A12 = [ Bp Dc ; Bc ] ; A21 = [Cp [ 0 0 ; 0 0 ] ] A11 ; A22 = [Cp [ 0 0 ; 0 0 ] ] A12 ; % f u n c t i o n xdot = [ A11 A12 ; A21 A22 ] x ; out = xdot ; 50

A.3 Matlab file to run Poisson Simulink model To simulate the Simulink model with Poisson time distribution, the next m-file has to be evaluated. %% Simulate Simulink f i l e Poisson c l e a r a l l ; c l c ; c l o s e a l l g l o b a l i ; % Counter g l o b a l r ; % Link t r a n s m i s s i o n counter g l o b a l M; % Threshold for t r a n s m i s s i o n counter r g l o b a l T; % Sampling time g l o b a l eh ; % Estimated e r r o r e ( hat ) g l o b a l x0 ; % I n i t i a l c o n d i t i o n s t a t e x g l o b a l t h e t a ; % I n t e g r a t i o n c o n s t a n t % I n i t i a l c o n d i t i o n s x0 = 0. 5 diag ( eye ( 8 ) ) ; % Counter t h r e s h o l d and i n t e g r a t i o n c o n s t a n t M = 1 0 ; t h e t a =. 1 ; % Poisson parameters T = 1 / 1 0 ; % Sampling time lambda = 1 ; % Poisson d e n s i t y IS = 1 0 ; % I n i t i a l seed % Counters i = 0 ; r = z e r o s ( 1, 4 ) ; % Run s i m u l a t i o n sim ( BatchReactor, 1 0 ) % Simulate for 10 seconds %% P l o t s % Plot s t a t e x f i g u r e ( 1 ) p l o t ( t, s t a t e ( 1, : ), LineWidth, 2 ) hold on p l o t ( t, s t a t e ( 2, : ), r, LineWidth, 2 ) p l o t ( t, s t a t e ( 3, : ), g, l i n e w i d t h, 2 ) p l o t ( t, s t a t e ( 4, : ), k, l i n e w i d t h, 2 ) t i t l e ( EEO s t a t e s x ) x l a b e l ( Time [ s e c ] ) y l a b e l ( S t a t e x ) l e g e n d ( x1, x2, x3, x4 ) g r i d on % Plot e r r o r e f i g u r e ( 2 ) p l o t ( t, s t a t e ( 5, : ), LineWidth, 2 ) hold on p l o t ( t, s t a t e ( 6, : ), r, LineWidth, 2 ) p l o t ( t, s t a t e ( 7, : ), g, l i n e w i d t h, 2 ) p l o t ( t, s t a t e ( 8, : ), k, l i n e w i d t h, 2 ) t i t l e ( EEO s t a t e s e ) x l a b e l ( Time [ s e c ] ) y l a b e l ( Error e ) l e g e n d ( e1, e2, e3, e4 ) g r i d on 51

A.4 Matlab files to run Gaussian Simulink model To simulate the Simulink model with normal time distribution, the next m-file has to be evaluated. %% Simulate Simulink f i l e with Gaussian d i s t r i b u t i o n c l e a r a l l ; c l c ; c l o s e a l l g l o b a l i ; g l o b a l x0 ; % I n i t i a l c o n d i t i o n g l o b a l m; g l o b a l v ; % I n i t i a l s t a t e c o n d i t i o n s x0 =. 5 0 diag ( eye ( 8 ) ) ; % Import mean and v a r i a n c e ( normal d i s t r i b u t i o n ) n o r m a l D i s t r i b u t i o n ; % Counter i = 0 ; % S t a r t s i m u l a t i o n sim ( BatchReactor gaussian, 1 0 ) % P l o t s f i g u r e ( 1 ) s u b p l o t ( 1, 2, 1 ) p l o t ( t, s t a t e ( 1, : ), LineWidth, 2 ) hold on p l o t ( t, s t a t e ( 2, : ), r, LineWidth, 2 ) p l o t ( t, s t a t e ( 3, : ), g, l i n e w i d t h, 2 ) p l o t ( t, s t a t e ( 4, : ), k, l i n e w i d t h, 2 ) t i t l e ( Simulink RR s t a t e x ) x l a b e l ( Time [ s e c ] ) y l a b e l ( S t a t e x ) l e g e n d ( x 1, x 2, x 3, x 4 ) g r i d on s u b p l o t ( 1, 2, 2 ) p l o t ( t, s t a t e ( 5, : ), LineWidth, 2 ) hold on p l o t ( t, s t a t e ( 6, : ), r, LineWidth, 2 ) p l o t ( t, s t a t e ( 7, : ), g, l i n e w i d t h, 2 ) p l o t ( t, s t a t e ( 8, : ), k, l i n e w i d t h, 2 ) t i t l e ( Simulink RR e r r o r s t a t e e ) x l a b e l ( Time [ s e c ] ) y l a b e l ( Error e ) l e g e n d ( e 1, e 2, e 3, e 4 ) g r i d on N = [ ] ; [ a b ] = s i z e ( s t a t e ) ; for i = 1 : b n = norm ( s t a t e ( :, i ) ) ; N = [N; n ] ; end f i g u r e ( 2 ) s u b p l o t ( 2, 1, 1 ) p l o t ( t,n, l i n e w i d t h, 2 ) 52

x l a b e l ( Time [ s ] ) y l a b e l ( S t a t e norm ) t i t l e ( Vector norm o f s t a t e ) g r i d on % a x i s ( [ 0 5 0 3. 5 ] ) ; s u b p l o t ( 2, 1, 2 ) h i s t ( fake, 1 0 0 ) x l a b e l ( Sampling time [ s ] ) y l a b e l ( P r o b a b i l i t y d e n s i t y ) t i t l e ( PDF o f sampletimes ) g r i d on The file above contains the m-file that determines the normal distribution and is given below. %% Make a normal d i s t r i b u t i o n % Load s t a b l e RR data f i l e ( network with 0% dropouts ) load r o u n d r o b i n t i m e o u t 0. 0 4. l o g f i l e = r o u n d r o b i n t i m e o u t 0 ; % Read column with sampletimes sampletimes = f i l e ( :, 3 ) ; % t h i r d column c o n t a i n s a l l t r a n s f e r t i m e s % C a l c u l a t e mean and v a r i a n c e m = mean ( sampletimes ) ; % c a l c u l a t e the average t r a n s f e r t i m e v = var ( sampletimes ) ; % c a l c u l a t e the v a r i a n c e i n the t r a n s f e r t i m e s [ row column ] = s i z e ( sampletimes ) ; % Make normal d i s t r i b u t i o n f a k e = abs (m + s q r t ( v ) randn ( row, 1 ) ) ; % make a normal d i s t r i b u t i o n with mean m and v a r i a n c e v % that approaches the r e a l t r a n s f e r t i m e s 53

A.5 NCS program code In this appendix the NCS program code is given. As discussed before, it is written in Xcode with the C language. These twelve files are the entire code, but the program also has a user interface. How this interface looks like, depends on what kind of node is selected: when the master is selected the interface is shown in Figure 3.1; selecting one of the other nodes will result in the interface shown below in Figure A.1. Note that the.h files are used to declare (global) parameters and properties. The actual commands are written in the.m files. Another note, in this study no quantization is used, although it is shown in the UI. Figure A.1: User Interface of NCS program with node To clarify the working principle of the code, a brief instruction is given. Starting program Controller.m: (void)awakefromnib with (IBAction)refreshGraph, (void)setuplabelsforaxiswithrange and (void)setuplabelsforaxiswithrangex make the graph view; (id)init makes drop down menus for protocols and declares parameters. System.m: systemmatrix is initialized; socketcallback declares communication parameters; (id)init initializes parameters and makes sockets. Selecting scheduling protocol Controller.m: in (id)init the selected scheduling protocol is assigned to self.currentschedulingprotocol. Selecting node Controller.m: (IBAction)setNode updates UI to correspond with the right selected node (Figure 3.1 or A.1); if the master is selected, it starts discovering for searchforservicesoftype using (void)readallthedata and (void)netservicebrowser; if a normal node is selected, it starts advertising on the netservice using NSApplicationTerminateReply, (void)netservicewillpublish, (void)netservice and (void)netservicedidstop. 54