Simulating NCS Systems - Example
This example shows how to simulate a networked control model. The ouput a simulation consists of four plots
- State Evolution: A closed-loop NCS consists of four sets of states: the plant states, the controller states, the input network-induced error and the output network-induced error. In this first plot you can see how all four of these sets of states evolve over time.
- Network Signals: The network-induced disturbances are shown in this plot. Here is possible to see the exact transmission interval, delay and dropout sequences that were used in the simulation.
- Network Uncertainty Region: The uncertainty region for which allowable combinations of transmission intervals and delays is plotted here. This plot is useful to visualize where in the uncertainty space the network lies.
- Input/Output Signals: The input/otuput signals that are communcated via the network are also plotted. The solid-line signals
and
are the signals that are being transmitted over the network. The dotted-line signals
and
are the signals that are being received.
Contents
Define the Control System
The plant is a model of a batch reactor, which the dynamics are linearized and given in continuous-time as
where
Ap=[1.38 -0.2077 6.715 -5.676; -0.5814 -4.29 0 0.675; 1.067 4.273 -6.654 5.893; 0.048 4.273 1.343 -2.104]; Bp=[0 0; 5.679 0 ; 1.136 -3.146; 1.136 0 ]; Cp=[1 0 1 -1; 0 1 0 0];
Next we define the controller, which is given as
where
Ac=zeros(2); Bc=[0 1; 1 0]; Cc=[-2 0 ; 0 8]; Dc=[0 -2; 5 0];
Create an 'ncs' Object
Now we are ready to create a ncs object. Since we want to compare two different protocols, we must create two seperate ncs objects. To do so, we will first initialize an ncs object by specifying the number of inputs and outputs the plant has. Then we will specifiy the plant, controller and network properties using the variables defined above.
ncs1 = ncs(2,2);
ncs1 = ncs1.setPlant(Ap,Bp,Cp);
ncs1 = ncs1.setController('C-LTI uWired',Ac,Bc,Cc,Dc);
In the command above we specified 'uWired' when the controller was set. This means that the controller is directly connected to the actuators and the controller commands can be continuously applied to the plant. Next we will specify the network nodes and protocol wer are intrerested in.
txIntvls = [1e-3 0.05]; % [min,max] bounds on the sampling time delays = [0 0.02]; % [min,max] bounds on the delay ncs1 = ncs1.setNetwork('tPoly',[txIntvls delays]); ncs1 = ncs1.setNetwork('nodesU',{blkdiag(1,1),blkdiag(1,1)}); ncs1 = ncs1.setNetwork('nodesY',{blkdiag(1,0),blkdiag(0,1)}); ncs1 = ncs1.setNetwork('protocol','RR');
The network node specification above indicates that each of the plant outputs share network access. The first node contains the first plant output and the second node contains the second node output. How the nodes are granted access to the network is determined by the protcol specified.
Plot Robust Stability Regions
Finally, to generate the data for plotting the simulation results we simply plug each of the ncs variables into the following function
simOut = ncs1.simulateNcs;
Simulation Progress: 100% complete




The above simulation can also be done via the ncsEditor GUI by loading the NCS from ncsExamples.mat into the GUI and clicking on the 'Simulate NCS' button.