#### Abstract

This paper investigates a modified modeling of networked control systems (NCSs) with programmable logic controller (PLC). First, the controller-to-actuator and sensor-to-controller network-induced delays are investigated by a modeling tactics based on hierarchical coloured petri net (HCPN) in a structure-conserving way. Comparing with the recent result, the signal transmission delay is set in a random interval instead of a fixed mode; moreover, the data packet drop out and disorder are also taken into consideration. Second, delays captured form CPN tools are analyzed with a strategy based on Baum–Welch algorithm and statistics science. Besides, time delays are modeled as a Markov chain and the transition probabilities is calculated using the consequent from the previous operation. Finally, a comparison verification illustrates the equivalence property between proposed models.

#### 1. Introduction

As a kind of control system [1–6], NCSs have motivated a lot of research studies in the control field during recent years [7–10] by many advantages it shares; for example, reduced weight, high flexibility, simple installation and maintenance, and low cost. Because of those practical characteristics, more and more efforts have been devoted to these systems [11–13]. Admired for past achievements, NCSs have been found in widespread applications such as feedback control systems [14, 15], stabilization of linear systems [16], control of nonlinear systems [17], and adaptive tracking control of nonlinear multiagent systems [18–20]. Compared with traditional point-to-point hardwiring system, typical NCSs is a young generation of control architectures which has a feedback control structure consisting with the controller, sensor, and actuator through network communication. The insertion of this performance condition, with a finite bandwidth, brings serial challenging and undesirable issues on account of data packet loss, scheduling, and latency in the process of communication signal’s transmission to remote analog input/output unit. Affected by these cases, the communication channel, which takes the place of traditional signal transmission technologies, brings hard-to-solve problems in the stability analysis and controller synthesis because of transmission time delays. As a result, this issue received increasing interests in this field [21–23]. Traditional time-delay analysis usually assumes that the time delay is constant, time-varying or obeys some random distribution, and rarely analyzes it from the perspective of system operation mechanism. Modeling from the perspective of operation mechanism can effectively show various state changes that may occur in the system and the relationship between changes. This prompts us to adopt HCPN to carry out structural reservation modeling and then analyze the time-delay characteristics.

In 1992, Petri nets were introduced by Petri [24] firstly as a net-theoretic approach to implement a particular purpose. The relationships between departments could be represented by a net, and it is a good approximation to imitate the appearance and character of asynchronous and concurrent operation in discrete event systems. Petri nets is a kind of mathematical structures which is a bipartite-directed graph consisting of two kinds of compositions; one is drawn as a circle which is called Place, and another drown as a rectangles named Transition. These two nodes combine with each other with arcs which are drawn as arrows. Coloured Petri net (CPN) [25–28], in which groups of objects is thus distinguished by colour, inherits all the advantages of classical Petri net. The wide practical application distributes on the direction of distributed control systems [29] and domains environments [30]. Recently, a novel of theoretical results has been done on the application of Petri nets for NCSs [31, 32]. Regarding the execution of the NCSs practical operational fundamental principle, the CPN has been chosen to build a formalism model [31]. With the rapid development of scientific technologies, the process in large-scale systems is more and more complicated, which makes it hard to solve problems in modeling. Therefore, to solve the problem of state explosion during formal verification, HCPN is invented [33–35] which is a new type of Petri net for creating large-scale and complex systems. Its main purpose is to summarize the system model with simple network model and to expand and fill it with substitution change. This method is not only beneficial to the excessive number of reservoirs, transitions, and arcs in the model but also beneficial to avoid the explosion of system state space and simplify the analysis of the model. In [31], a mapping from the established hypothetical delays in Ethernet of NCSs to entities of a CPN model was defined, and the simulation analysis of network induced delays was tested and verified in a simple way. Following a similar way, in [32], a two-step approach was included in the estimation of delays in the modeling of NCSs. However, the Ethernet model in the proposed model was studied in a hypothesis, in which time delays were not interrelating with network bandwidth-limited bit limit and packet dropouts. Further investigation and analysis is in [36, 37] and the references therein.

The primary contributions of this paper are as follows:(i)First, considering the potential cause for the deteriorating performance or instability on NCSs, this paper sets network band delay in an interval instead of the definite transmission delay in [32] to make the model more realistic. In this method, it is supported by the HCPN model to simulate some challenging issues on account of network information propagation.(ii)Second, the CPN model in [31, 32] is not considered data packet latency and dropout in the Ethernet CPN model of NCSs. Focusing on those challenges in network transmission, this paper has some alterations on the base of the model in [32]; close to the reality, data packets’ dropout and packet out-of-order are taken into consideration in the proposed model of data transmission on the network.(iii)Third, the exploration and research of random time delays existing in the sensor-to-controller and controller-to-actuator in discrete time networked control systems are acquiescence with random Markovian delays in recent literature [38–40]. However, it is not clear if this theoretical acquiescence can be put into practice. This paper makes a certification of equivalence between time delays and Markov model [41].

This paper is organized as follows. Section 2 is the conceptual framework of Petri net. Section 3 is the HCPN model of NCSs-PLC. Section 4 analyzes the time delay extracted from the HCPN model. Section 5 is the equivalence analysis of the time delay of both the Markov model and the HCPN model.

#### 2. Basic Conception

*Definition 1. *A ordinary non-HCPN can be defined as a nine elements’ tuple [42],satisfying the requirements below:(i) is called colour set which is a finite set describing nonempty types.(ii) is Place representing a ellipse which interprets a passive component with discrete status.(iii) is Transition establishing with a rectangle which explains an active component; tokens can consume, produce, and change the carrying information in Transitions.(iv) is arcs which connects Places and Transitions in the model. It can be represented by arrows, and it is a finite set which meets the expectations with .(v) is defined as a map into arcs. It is defined from into which has two elements, the first element means arcs’ source and the second element means arcs’ destination.(vi) is defined a map in places. It is defined from into which means that every token on every has a corresponding colour set type.(vii) is the guard function which is defined a map in transitions. is the type appertain to , and the binding must perform every Boolean expressions. It is can be shown as .(viii) is called arc expression which maps every element in to an expression, and the type of it can be written as ; it can be shown aswhere is defined as the place of .(ix) illustrates a map between and the type It is the initialization function which can be shown as

*Definition 2. *A HCPN can be defined as a nine elements-tuple satisfying the requirements below [42]:(i) is a congregations for nonhierarchical pages in the model, and each page does not have collaborative net elements. It can be shown as(ii) is substitution nodes.(iii) is called page assignment, and every page must not be the subpage of itself; it is satisfied by the following conditions:(iv) is defined as a set of place nodes or transition nodes.(v) is a function of port type, and it has four types, in type, out type, in/out type, and general.(vi) is port assignment. It is binary relations such that(vii) is a finite set of fusion sets such that(viii) is a function of the fusion type. It is defined from fusion into , such that(ix) is a multiset of the prime page.

#### 3. The CPN Model for NCSs

##### 3.1. The Top Model

The integrated model can be divided into two levels, one is top level which simulates the relationship between the controller, the sensor, and the actuator with a cursory method, as shown in Figure 1. The other level is the detailed function description of the controller, the sensor, and the actuator. In the proposed top-level model, the sensor and the actuator connect with PLC Remote IO. PLC-CPU sends packets from the controller to PLC Remote IO through Ethernet; then, PLC Remote IO sends acknowledgments from the sensor and the actuator back to PLC-CPU. There are three subpages and one top page in the whole model. After some introductions of time delay in PLC-CPU, those pages are explained one by one in detail.

##### 3.2. The Analysis of the Time Delays in PLC-NCSs

Figure 2 is a representative of traditional NCSs with the PLC controller. The sensor and actuator are connected to digital/analog I/O section through Ethernet. Before entering or leaving network, data packets will enter into a transmission queue to wait for the scan cycle of I/O.

Figure 3 gives detailed instructions of time delays in NCSs with the PLC controller, in which different samples were shown as different length arrows. In the upper part of the whole figure, there are some samples which are received in the sensor with periodic sampling. In the middle part, there are three kinds of axis showing the PLC controller. Before data packets arrive at execute program, it has to wait for the scan cycle so that it can be read into PLC. Both of the reading scan cycle and writing scan cycle in PLC communication are . Another primary scan cycle is which means that only at scan cycles data packets can be captured into PLC-CPU to execute the programme. After a few execution time , the communication module sends result data to the actuator node. During the process of the data packets’ transmission, two network-induced delays are produced. One is called backward time delay and another is called forward time delay. The execution time delay in the controller is included in backward time delay which is the time costing in the transmission from the controller to the sensor, and is forward time delay which is from CPU which received the sample to the actuator which received the same sample.

##### 3.3. The Controller Model

The module of controller is divided into two parts. One is the communication module part, which is used to sending and receiving data with scan cycles, such as left part in Figure 4. The another part is the PLC-CPU model, which simulates functions of CPU reading(input), CPU executing, and CPU writing(output), such as right part in Figure 4. The transition and the transition complete data packets’ sending and receiving, respectively. transition, transition, and transition complete simulation of reading, executing, and writing in the PLC-CPU. The definition of token elements in the model is shown in Table 1.

##### 3.4. The Ethernet Model

Figure 5 is the Ethernet model which is the primary part for whole NCSs’ system. There are two modified points contrasting with the model which has been designed by Ghanaim et al. [32]. When the data packets transmit in Ethernet, transmission will be influenced by a lot of uncertainties. In consideration of these cases, the transmission time is set into a random time with an interval time varying rather than a fix data. In the proposed model, time delays of this portion are discrete uniform distributions between 1000 and 2000 when packet data passed from the sensor to the controller or from the controller to the actuator. In addition, in the actual network transmission, the data packets’ transmission is unstable because of some uncertain factors, such as packets lost and packets out of order. In this model, packets will be lost in ten percent probability, and this function is realized by . Data packets will be retransmitted based on Transmission Control Protocol/Internet Protocol if those transmission mistakes occurred. The mathematic presentation of this model is a tuple:

By the definition of , those elements in this tuple can be used to describe the Ethernet model, as shown in Figure 6.

is the Token colour set in Figure 5. is finite set of places and is finite set of transitions. is arc, and means that this arc is from place to transition . is the node function. is guard, for example, means that when transition is or , the guard of transition is ; otherwise, transition guards are true. is the colour definition of Place. Place , , , and are mean the colour. is the initialization set if the place is or , and the initial token is integer nine. means the arc expression in the Ethernet model, means when the arc is from , and , and the arc expression on those arc is .

#### 4. Time-Delay Analysis

##### 4.1. Transmission Delay in Ethernet

Network transmission is an important element in the analysis of and . Besides, it also can help to analyze the system state and performance. Data packets may be lost at a probability such as ten percent in the model of network transmission. With reference to Transmission Control Protocol/Internet Protocol (TCP/IP), data packets would be retransmitted if it is lost in the network transmission. Figure 7 is network transmission latency which is collected in the proposed HCPN model running 5050 steps. From Figure 7, it can be clearly see that, in time delay and , network transmission time delays are almost greater than 1000 and less than 2000; however, there are still ten percent points out of scope, Figure 7 shows several peak points, for example A, B, and C, which mean that, in this time, data packets are dropped out in network transmission. It will be retransmitted according to TCP/IP so that the value of it becomes very bigger than others. The network transmission latency was the transmission time and the retransmission time and other time spent on extracting data packets.

##### 4.2. The Time Delay Tca and Tsc

There are three scan cycles which play important roles in the calculation of backward time delay and forward time delay. The first one is periodic scan for program, the second one is periodic scan for the communication module, and the last one is the periodic sampling for the sensor. There exists another important data to calculate: network transmission delay. Table 2 is the parameters defined in the model which can be used to simulate and analyze the efficiency of the difference system with the HCPN model.

In addition, in the communication module, periodic scan cycle is a summation of reading time, executing time, and writing time. The periodic scan for program is set to 17,000 and the periodic sampling for the is 1000. When network transmission latency was obtained, such as in Figure 7, and can be calculated under the rule of scan cycles, as shown in Figure 8. Before the calculation of and , it is necessary to obtain the network latency, which are produced in network transmission and waiting time for the scan cycle. Contrasting with delays obtained from the HCPN model in [32], it can be clearly see that because of the indeterminacy transmission phenomenon and the random transmission time delay the periodicity of and is broken.

#### 5. Verification and Analysis

##### 5.1. Markov Modeling

A Hidden Markov Model is a statistical Markov lain with hidden states which cannot be directly visible, but the sequence of observations can give some information of . The sequence of observations alphabet is set to , and a hidden states’ alphabet sequence can be cached from . and are shown below:where is the observation state at time and is the corresponding state at observation .

The formal definition of a hidden Markov model is as follows:where is the state transition probability matrix form one state to another state, which can be written as is the observation probability matrix which can be written asand is the initial state probability which can be written as

##### 5.2. Markov Model Results

By the definition of and the algorithm, the algorithm steps are as follows.Step 1: for a given observation sequence and HMM model, the probability variables of the hidden state arewhere is called forward probability, whereand is called backward probability, whereStep 2: define the probability between the hidden state and the hidden state as follows:Step 3: the formula between and isStep 4: find the corresponding expected values of the above two variables and .Step 5: the new HMM parameters are estimated by using the two variables defined above and their expected values:

The Markov model can be built based on time delay and obtained from . In order to make analyzing more clear, data will be managed with the rounding method. From Figure 8, it two time delays can be obtained as follows:

can be divided into two categories: one category is the low delay which includes the value . The other category is high delay which includes the value

The time delay can be written as

The same procedure can be easily adapted to which can be divided into two categories: one category is the low delay which includes the value and the other category is high delay , and . The time delay can be written as

Figures 9 and 10 show the probability distribute of time delay and which are the experimental data in , respectively.

The parameters in the model can be calculated with Baum–Welch algorithm and maximum likelihood estimate, and the system with 2-state and 15-observations, and the matrix can be calculated by Matlab:

In the similar way, the system with 2-state and 19-observations can be calculated with

##### 5.3. Validation Results

From the above section, the important matrixes can be obtained as

Using the data from those two matrices, the stationary distribution of the Markov model and can be estimated by those two time delays ( and ) with the Matlab statics toolbox. The probability density function can be calculated by sample arrays which can be obtained from consecutive time delay sequence. The is the distribution of the time delay which can be compared with the stationary distribution of the Markov model.

Figures 11 and 12 are the stationary distribution of the Hidden Markov Model building above, and every observation probability value is similar to the probability density function of the time-delay sequence. The figures show that the Markov stationary distribution of both the time delay and the time delay are approximately equivalent to the probability density function of HCPN. It is clearly seen that building a Markov modeling of is feasible and time delays conform to Markov lain.

#### 6. Conclusion

In this paper, we have investigated a novel HCPN model approach for the network control system with PLC. The modified structure-conserving model has been accomplished to calculate sequences of delays under the control of scan cycles for PLC-CPU. Besides, a series of special phenomenon has been taken into consideration based on the traditional mode, such as data packets drop and data packets out of order. Time delays in network transmission have been calculated to observe the transmission data packet state in Ethernet. Finally, Markov analytical models have been built for analyzing time delays which can be obtained from the forward step mathematically.

#### Data Availability

The data used to support the findings of this study are included within the article.

#### Conflicts of Interest

The authors declare that they have no conflicts of interest.

#### Acknowledgments

This work was supported by National Natural Science Foundation of China (Grant nos. 61403278 and 61503280).