# The Function of Remote Monitoring System of a Robot Inverter Based on PLC and Cloud Platform

Authors: Mengqi Yu
Journal: Journal of Sensors
 (2022)

---

## Abstract

In order to improve the communication efficiency of the CAN bus application layer communication protocol of the inverter network monitoring system, this paper proposes a TTCAN scheduling optimization algorithm for the robot inverter remote monitoring system based on PLC and cloud platform. According to the analysis of the communication requirements of the frequency converter monitoring system, this paper designs the application layer protocol of the nodes in the system and establishes the system scheduling matrix. The time triggered can bus protocol (TTCAN) combines the event triggered mechanism with the time triggered mechanism. The hybrid scheduling strategy is used to optimize the system matrix of TTCAN; that is, the hybrid particle swarm optimization algorithm is used for periodic messages. For nonperiodic messages, uniform scheduling strategy and dynamic scheduling algorithm are adopted. The simulation is carried out by MATLAB tools. The simulation results show that the sum of partial minimum transmission time is 1928 and there are multiple optimal individuals through the hybrid particle swarm optimization algorithm. Compared with the traditional genetic algorithm and single particle swarm optimization algorithm, the hybrid algorithm is better than the traditional genetic algorithm and particle swarm optimization algorithm in terms of iteration times and average fitness value.In conclusion, the optimized TTCAN protocol improves the real-time performance, reliability, and bandwidth utilization of the communication network.


---

## Body

## 1. Introduction

In recent years, with the rapid development of modern industrial control technology, the scale of industrial monitoring system is growing, the speed of data exchange and the amount of communication of the monitoring system have become more demanding, and the real time and reliability of the network system have become more and more important. With the continuous development, popularization, and application of frequency converter, it is applied in metallurgy, petroleum, chemical industry, textile, electric power, building materials, coal, and other industries. At the same time, the demand for the development of frequency converter to information network is becoming stronger and stronger. More and more occasions require network communication and monitoring of frequency converter, as shown in Figure1 [1]. Realizing message interconnection and standby switching between multiple frequency converters is the basic requirement of the frequency converter network monitoring system. Moreover, the electromagnetic interference on the application site of the frequency converter is large, and the distance between different frequency converters is nearly 100 meters. In order to meet the needs of the application, an industrial field bus with strong anti-interference is selected, which has the characteristics of reliable transmission and high real time, so as to ensure the reliable transmission of communication messages. In addition, because key messages are very sensitive to delay, it is necessary to study a scheduling strategy to ensure that a large number of messages are transmitted to obtain the minimum response delay [2]. The Internet of things is regarded as the application expansion of the Internet, and it is another technological revolution in the field of information technology after the computer and the Internet. It can connect any object to the Internet and exchange and communicate information and data, so as to realize the tracking, positioning, automatic identification, and remote monitoring of objects, and allow information exchange between objects at any time [3]. Its main characteristics are comprehensive perception, reliable transmission, and intelligent processing.Figure 1
Monitoring system.


## 2. Literature Review

Sundararajan and others designed a remote monitoring system for small and medium-sized coal mines based on arm. MMS information technology combined with relevant software and hardware was used to connect each module of the system for testing. The results showed that the development idea of the system was correct, the data transmission was correct, and it was suitable for promotion in small and medium-sized coal mines [4]. Brown and others designed a wireless and limited openable data communication network to meet the working conditions of the oil field. Finally, the function design, implementation method, and software development of the monitoring system are introduced. After the completion of the system, it was tested in the laboratory to prove that the data communication can be carried out normally [5]. Qian and others designed a frequency converter remote monitoring system based on a GPRS communication network in combination with oil field production. The system uses LabVIEW software to program the upper computer software. The system mainly focuses on frequency converter voltage, current and temperature data acquisition, GPRS wireless transmission, real-time display, and storage [6]. Gnanadesikan and others described in detail the main functions of the system based on the monitoring of the scraper conveyor in the fully mechanized mining face. The fault diagnosis system is developed based on the monitoring data, and the technical indicators are defined. According to the system requirements, the hardware design is combined with software programming, and the fault diagnosis method is based on the D-S basic theory. The feasibility of the fault diagnosis method is verified by an example [7]. Okyem and others used PLC control technology and CAN communication technology and took KingSCADA KingView software as the development platform to design and implement PLC-based remote monitoring platform for air compressor [8]. The remote monitoring platform of the air compressor displays the operation status, parameter information, sensor data information, and fault information of the frequency converter air compressor unit in real time. The models and application scope of PLC, frequency converter, air compressor, pressure sensor, and temperature sensor are given in detail. The experimental results show that the platform is safe, stable, and effective. As one of the most widely used field buses in the world, CAN bus is widely used in industrial control systems. At the same time, with the continuous development and application of frequency converter, the demand for its development towards informatization and networking becomes stronger. Therefore, the design of an efficient and reliable CAN bus application layer communication protocol is a necessary condition for its application in frequency converter network monitoring system [9]. This paper mainly studies the scheduling strategy and optimization design of TTCAN, designs the TTCAN application layer protocol according to the requirements of frequency converter system, and generates the message scheduling system matrix. According to the different characteristics of periodic messages and aperiodic messages, scheduling strategies are designed, respectively. Different hybrid particle swarm optimization algorithms and dynamic priority uniform scheduling are used to optimize the objective function, so as to minimize the response delay of messages and ensure the reliable transmission of hard real-time messages.


## 3. Research Methods

### 3.1. Design Method Based on TTCAN System

The core of TTCAN protocol is its unique system matrix period MC, which includes multiple basic periods BC. A BC starts with a reference message and is composed of multiple time windows, corresponding to one row of the matrix cycle. The time windows in the same column constitute the columns of the matrix cycle [10]. The time interval between the two reference messages of the matrix period is a basic period BC, and its length is the maximum common divisor of all task times in the task set. Refer to Figure 2.Figure 2
System matrix period MC of TTCAN.Suppose there aren periodic messages in the network, the message instance set M=M1,M2,⋯,MN−1,MN, and each message has two attributes: transmission time tcm and period Tm. Determine the message sending period T=T1,T2,⋯,TN−1,TN of each node, and take the maximum common divisor of all messages as the basic period BCT [11]. Take the least common multiple of all message transmission cycles or its integer multiple as MCT, and the multiple depends on whether the system cycle can complete the transmission of all messages.The number of basic cycles is shown in(1)R=MCTBCT.The number of columns of matrix period(2)C=∑i=1NMCT/TiMCT/BCT,where Ti is the transmission period of each node, BCT is the basic cycle, and MCT is the matrix period.The essence of message scheduling table generation is to collect messages [12].


### 3.2. Scheduling Requirements and Problem Description

#### 3.2.1. Overall Structure of Frequency Converter Monitoring System

For the application of frequency converter monitoring network, communication messages are divided into two categories: periodic and accidental. Periodic messages are mainly analog quantities and status quantities used for system control and monitoring, which must be triggered in strict accordance with the communication cycle to ensure the stability and rapidity of system control and the real-time monitoring of the system. Sporadic messages are mainly alarm signals and other signals sensitive to time delay. On the one hand, sporadic messages cannot affect the transmission of periodic messages. On the other hand, it is also necessary to minimize the response delay of sporadic messages to ensure the safe operation of the system [13]. Therefore, the TTCAN design method is used to schedule the bus messages, corresponding to the specific time window and the competitive time window in the TTCAN scheduling matrix, respectively.In order to illustrate the design method of TTCAN scheduling optimization algorithm in frequency converter monitoring system, the algorithm design is carried out with the simplified networking model as the object, as shown in Figure3. The CAN network of the frequency converter monitoring system has five nodes, including frequency converter nodes A and B (master node), load nodes C and D (slave node) and monitoring node E. The scheduling of periodic messages and occasional messages among five nodes is the research object of TTCAN scheduling optimization algorithm in this paper.Figure 3
Network topology of frequency converter monitoring system.Classify the messages, establish the scheduling time and transmission mechanism of the messages, and list the message attributes and communication task set shown in Table1.Table 1
Communication task set of electrical system.
Message typeMessage numberTrigger period (ms)Deadline (ms)Communication duration (μs)Recurring messagesM155368M255484M355484M41010444M52020444M61010444M72020444M81010520M92020520M101010520M112020520M122020404M132020484M144040520Aperiodic messageM15Episodic20328M16Episodic10328M17Episodic5328The bus message includes 14 periodic messages and 3 nonperiodic messages.T=5,5,5,10,20,10,20,10,20,10,20,20,20,40 is arranged in ascending order according to the sending cycle of periodic messages to determine BCT=5ms and MCT=40ms, and the number of matrix rows R is 8. The number of periodic message columns C of the basic cycle is 7, and the last column serves as an arbitration window for the scheduling of nonperiodic messages.


#### 3.2.2. Establishment of Initial System Matrix

PartSM0 and P1 of the initialization matrix are exclusive windows with a message period equal to BCT, including M1,M2,M3 messages. Part P2 is the exclusive window whose message period is greater than BCT. Part 3 is the arbitration window for aperiodic messages [14]. The matrix is a matrix with 8 rows and 8 columns (the last column is the arbitration window). The window marked with f is a free window, and the window marked with ARB is an arbitration window, which is used to transmit event type trigger messages. According to the initial scheduling matrix SM0, the transmission time series of each column of messages Tc0=368,484,484,444,520,520,520,1660, in which the occupation width of periodic messages is 3340 μs and the available width of the arbitration window is 1660 μs.


#### 3.2.3. Optimization Objectives of Message Scheduling

The protocol of TTCAN system matrix requires that the window width of the same column in each basic cycle should be consistent, which is determined by the message with the longest transmission time in this column. For PartP2, the optimization goal is how to arrange n messages into m columns, so that each column of Part P2 occupies the minimum time, and the arbitration window can reach the maximum time in the same basic cycle [15]. In order to improve the real-time performance of messages, the system matrix needs to meet the following conditions to minimize the sum of the maximum transmission time of each column of messages, which means that the bus time occupied by periodic messages is the minimum, as shown in the following equations.
(3)min∑i=1mmaxCjxijj=1,n(4)s.t.∑j=1nwjxij⩽Wii=1,m(5)∑i=1mxij=1j=1,n∀i,jmakexij∈0,1,(6)wj=MCTTjj=1,n,(7)Wi=MCTBCTi=1,m,where j is the message sequence number; i is the column number of time window SM; xij is the serial number of the corresponding j message; i whether the message of the time window column number exists, represented by 0 or 1; m is the number of columns of periodic trigger message; n is the number of messages; wj is the number of the j-th message in the SM matrix; Tj is the period of the j-th message; Cj is the transmission time of the j-th message; and Wi is the total number of rows in the time window in column i of the SM matrix.If thej-th message is placed in column i of SM, xij=1; otherwise, xij=0, and the same message can only be placed in one column; that is, there is at most one message in each row, and this message can only be stored in the current column.The bus utilization of periodic messages is shown in the following equation:(8)U=∑j=1NMCT×Cj/Tj∑i=1RLjmi,where Lj is the window width of column j, mi is the number of messages in column i, and the free window is not occupied by the bus during calculation.The optimization problem of the frequency conversion monitoring system can be transformed into a multidimensional knapsack problem, that is, a NP (nondeterministic polynomial) problem; that is, each periodic message is reasonably placed in the system matrix to minimize the occupation time of the exclusive window, so as to increase the time of the arbitration window to ensure the timely response of nonperiodic messages [16].


### 3.3. Message Scheduling Optimization Algorithm

#### 3.3.1. Periodic Message Scheduling Optimization Based on Hybrid Particle Swarm Optimization

For periodic messages, it is necessary to reasonably arrange the messages in the P2 time window to achieve effective scheduling.The basic particle swarm optimization algorithm can be used to optimize the system matrix and determine the optimal value in the process of continuously tracking the extreme value, which is easy to realize and has fast convergence speed. However, due to the single optimization method, the optimal solution often cannot break through its own limitations [17, 18]. The hybrid particle swarm optimization algorithm proposed in this paper uses genetic algorithm for reference; that is, genetic algorithm is introduced into particle swarm optimization algorithm to make particles reach the optimal value in the cross mutation with individual extreme value and population extreme value, so as to solve the problem that particle similarity cannot jump out of the boundary of local optimal solution when the population converges.(1) Individual Code. Firstly, the scheduling table is coded, and the particle individual coding adopts integer coding. Each particle represents the specific allocation of n messages to a column. The Part B messages to be optimized are M4~M14, a total of 11 messages. These 11 messages need to be reasonably allocated to 4 columns to minimize the total column width. The initial coding vector of individual particles is defined according to the initial system matrix, where the number of vector elements is 11, representing the 11 messages M4~M14, and the vector value is the value of the column in which the message is located is 1,2,3,4. A total of 4 columns need to be optimized, so the column numbers are allocated from 1 to 4. Therefore, in this numbering method, the initial vector is [1–4], representing that the 11 messages M4~M14 are allocated to the first, third, first, and fourth columns, respectively. Use the same numbering method to generate any individual particle.(2) Design Fitness Function and Calculate Individual Fitness. The fitness function is divided into two parts: one is the cost of the whole; the other part is the penalty function of illegal particles. The overall cost is calculated through the objective function, and the bus utilization is used as the evaluation standard. The overall cost of the k-th particle is as follows:
(9)fkvk=∑i=1mmaxCjxijk∣j=1,⋯,n,k=1,2,⋯,M,where vk is the position of the k-th particle, and xijk is the corresponding decision variable, and the particle swarm size is M.Since the total weight of each column of messages cannot exceed the current column capacity, in order to prevent the coding of some particles from exceeding this limit during the optimization process, a penalty function is introduced to deal with the problem that particles violate constraints. The penalty function factorpk is shown in the following formulas:
(10)pk=∑i=1mpik=1,2,⋯,M,pi=0,if∑i=1mxij=1j=1,⋯,n,α0∑j=1nwjxij−Wi,otherwise.If the formula∑i=1mxij=1,j=1,⋯,n is satisfied, then Pi is 0. Otherwise, a large positive number α0 is introduced to reduce the fitness. The fitness formula consists of an evaluation function and a penalty function. The evaluation function is expressed in the following formula:
(11)evalvk=1fkvk+pkk=1,2,⋯,M.(3) Crossover Operation. Individuals are updated by crossing with individual extremum and group extremum, and the cross method is a certificate cross method. First, a crossover position is randomly selected, and then individuals and individual extremum or individual and group extremum are crossed [19].(4) Mutation Operation. The mutation method is to randomly select a mutation position for each individual and then randomly change the value of the position into other values within a range.(5) Judge Whether the Termination Conditions Are Met. If the conditions are met, the optimal individual is selected and the number of iterations is given. If not, the particle swarm location is updated to continue the calculation.


#### 3.3.2. Nonperiodic Message Dynamic Scheduling Optimization Based on Uniform Strategy

For nonperiodic messages, it is also necessary to ensure a certain real-time performance. They are transmitted in the arbitration window of the matrix cycle. The message transmission cannot be interrupted, which will affect the transmission of periodic messages [20]. The occurrence time of the message shall be recorded, and the arbitration window shall be dynamically allocated to the message according to the priority, transmission time, and waiting time of the message. Only when the nonperiodic message is reliably transmitted in the arbitration window can the stable transmission of periodic messages be guaranteed. The start sending time of acquiring bus right for aperiodic messages can be expressed as the following equation:
(12)Sm=Tp+Wm,where Tp is the time waiting for the transmission of periodic scheduling message to end and Wm is the waiting time from c competing with other aperiodic messages for the bus to obtaining the bus in the arbitration window.It can be seen from equation (7) that Sm can be realized by reducing Tp and Wm. In order to achieve higher real-time performance of aperiodic messages, the following is to reduce the time for messages to wait for arbitration by reducing Tp through the uniform distribution algorithm. The dynamic identifier priority mechanism of delay priority is introduced to ensure the transmission of some nonperiodic messages with low priority.(1) Uniformly Distributed Scheduling Strategy. Uniform distribution scheduling is to adopt the idea of uniform, distribute the arbitration time evenly according to the number of exclusive windows in the basic cycle of the system matrix, and add an equally distributed arbitration window after each exclusive window [21]. In addition, in order to prevent node identification confusion caused by the transmission of adjacent periodic messages, a time interval window tgap shall be introduced between adjacent periodic messages. The length of uniformly distributed arbitration window is calculated as follows:
(13)tw=BCT−TCPNw−tgap,where tw is the width of each arbitration window equally divided; BCT is the basic cycle; TCP is the time occupied by periodic messages in a basic cycle; Nw is the number of exclusive windows, which is consistent with the number of arbitration windows after equal distribution; and tgap is the reasonable interval set between messages. For the convenience of analysis, tgap=0 is taken.Of course, the average width of each arbitration window can guarantee the transmission of the longest non periodic message transmission timetm. If tw<tm, it indicates that the uniform distribution time is insufficient. You can consider merging some uniformly distributed arbitration windows, so as to reduce the number of arbitration windows in the basic cycle to tw>tm.After the design according to the above principles, the last arbitration window of the system optimization matrix is divided into four subwindowsArb1,Arb2,Arb3,Arb4, with window widths of [360,360,360,656], respectively, to ensure the longest transmission time of nonperiodic messages of 328μs, so as to reduce the response delay of nonperiodic messages.(2) Dynamic Priority Scheduling Policy. Due to the arbitration mechanism of CAN bus, in order to avoid that messages with low priority cannot get the bus control right for a long time, a dynamic priority scheduling mechanism is introduced, and the delay priority is taken as an indicator of priority [22]. Delay priority is the number of message frames that have been transmitted during the waiting period of the arbitration window.


## 3.1. Design Method Based on TTCAN System

The core of TTCAN protocol is its unique system matrix period MC, which includes multiple basic periods BC. A BC starts with a reference message and is composed of multiple time windows, corresponding to one row of the matrix cycle. The time windows in the same column constitute the columns of the matrix cycle [10]. The time interval between the two reference messages of the matrix period is a basic period BC, and its length is the maximum common divisor of all task times in the task set. Refer to Figure 2.Figure 2
System matrix period MC of TTCAN.Suppose there aren periodic messages in the network, the message instance set M=M1,M2,⋯,MN−1,MN, and each message has two attributes: transmission time tcm and period Tm. Determine the message sending period T=T1,T2,⋯,TN−1,TN of each node, and take the maximum common divisor of all messages as the basic period BCT [11]. Take the least common multiple of all message transmission cycles or its integer multiple as MCT, and the multiple depends on whether the system cycle can complete the transmission of all messages.The number of basic cycles is shown in(1)R=MCTBCT.The number of columns of matrix period(2)C=∑i=1NMCT/TiMCT/BCT,where Ti is the transmission period of each node, BCT is the basic cycle, and MCT is the matrix period.The essence of message scheduling table generation is to collect messages [12].


## 3.2. Scheduling Requirements and Problem Description

### 3.2.1. Overall Structure of Frequency Converter Monitoring System

For the application of frequency converter monitoring network, communication messages are divided into two categories: periodic and accidental. Periodic messages are mainly analog quantities and status quantities used for system control and monitoring, which must be triggered in strict accordance with the communication cycle to ensure the stability and rapidity of system control and the real-time monitoring of the system. Sporadic messages are mainly alarm signals and other signals sensitive to time delay. On the one hand, sporadic messages cannot affect the transmission of periodic messages. On the other hand, it is also necessary to minimize the response delay of sporadic messages to ensure the safe operation of the system [13]. Therefore, the TTCAN design method is used to schedule the bus messages, corresponding to the specific time window and the competitive time window in the TTCAN scheduling matrix, respectively.In order to illustrate the design method of TTCAN scheduling optimization algorithm in frequency converter monitoring system, the algorithm design is carried out with the simplified networking model as the object, as shown in Figure3. The CAN network of the frequency converter monitoring system has five nodes, including frequency converter nodes A and B (master node), load nodes C and D (slave node) and monitoring node E. The scheduling of periodic messages and occasional messages among five nodes is the research object of TTCAN scheduling optimization algorithm in this paper.Figure 3
Network topology of frequency converter monitoring system.Classify the messages, establish the scheduling time and transmission mechanism of the messages, and list the message attributes and communication task set shown in Table1.Table 1
Communication task set of electrical system.
Message typeMessage numberTrigger period (ms)Deadline (ms)Communication duration (μs)Recurring messagesM155368M255484M355484M41010444M52020444M61010444M72020444M81010520M92020520M101010520M112020520M122020404M132020484M144040520Aperiodic messageM15Episodic20328M16Episodic10328M17Episodic5328The bus message includes 14 periodic messages and 3 nonperiodic messages.T=5,5,5,10,20,10,20,10,20,10,20,20,20,40 is arranged in ascending order according to the sending cycle of periodic messages to determine BCT=5ms and MCT=40ms, and the number of matrix rows R is 8. The number of periodic message columns C of the basic cycle is 7, and the last column serves as an arbitration window for the scheduling of nonperiodic messages.


### 3.2.2. Establishment of Initial System Matrix

PartSM0 and P1 of the initialization matrix are exclusive windows with a message period equal to BCT, including M1,M2,M3 messages. Part P2 is the exclusive window whose message period is greater than BCT. Part 3 is the arbitration window for aperiodic messages [14]. The matrix is a matrix with 8 rows and 8 columns (the last column is the arbitration window). The window marked with f is a free window, and the window marked with ARB is an arbitration window, which is used to transmit event type trigger messages. According to the initial scheduling matrix SM0, the transmission time series of each column of messages Tc0=368,484,484,444,520,520,520,1660, in which the occupation width of periodic messages is 3340 μs and the available width of the arbitration window is 1660 μs.


### 3.2.3. Optimization Objectives of Message Scheduling

The protocol of TTCAN system matrix requires that the window width of the same column in each basic cycle should be consistent, which is determined by the message with the longest transmission time in this column. For PartP2, the optimization goal is how to arrange n messages into m columns, so that each column of Part P2 occupies the minimum time, and the arbitration window can reach the maximum time in the same basic cycle [15]. In order to improve the real-time performance of messages, the system matrix needs to meet the following conditions to minimize the sum of the maximum transmission time of each column of messages, which means that the bus time occupied by periodic messages is the minimum, as shown in the following equations.
(3)min∑i=1mmaxCjxijj=1,n(4)s.t.∑j=1nwjxij⩽Wii=1,m(5)∑i=1mxij=1j=1,n∀i,jmakexij∈0,1,(6)wj=MCTTjj=1,n,(7)Wi=MCTBCTi=1,m,where j is the message sequence number; i is the column number of time window SM; xij is the serial number of the corresponding j message; i whether the message of the time window column number exists, represented by 0 or 1; m is the number of columns of periodic trigger message; n is the number of messages; wj is the number of the j-th message in the SM matrix; Tj is the period of the j-th message; Cj is the transmission time of the j-th message; and Wi is the total number of rows in the time window in column i of the SM matrix.If thej-th message is placed in column i of SM, xij=1; otherwise, xij=0, and the same message can only be placed in one column; that is, there is at most one message in each row, and this message can only be stored in the current column.The bus utilization of periodic messages is shown in the following equation:(8)U=∑j=1NMCT×Cj/Tj∑i=1RLjmi,where Lj is the window width of column j, mi is the number of messages in column i, and the free window is not occupied by the bus during calculation.The optimization problem of the frequency conversion monitoring system can be transformed into a multidimensional knapsack problem, that is, a NP (nondeterministic polynomial) problem; that is, each periodic message is reasonably placed in the system matrix to minimize the occupation time of the exclusive window, so as to increase the time of the arbitration window to ensure the timely response of nonperiodic messages [16].


## 3.2.1. Overall Structure of Frequency Converter Monitoring System

For the application of frequency converter monitoring network, communication messages are divided into two categories: periodic and accidental. Periodic messages are mainly analog quantities and status quantities used for system control and monitoring, which must be triggered in strict accordance with the communication cycle to ensure the stability and rapidity of system control and the real-time monitoring of the system. Sporadic messages are mainly alarm signals and other signals sensitive to time delay. On the one hand, sporadic messages cannot affect the transmission of periodic messages. On the other hand, it is also necessary to minimize the response delay of sporadic messages to ensure the safe operation of the system [13]. Therefore, the TTCAN design method is used to schedule the bus messages, corresponding to the specific time window and the competitive time window in the TTCAN scheduling matrix, respectively.In order to illustrate the design method of TTCAN scheduling optimization algorithm in frequency converter monitoring system, the algorithm design is carried out with the simplified networking model as the object, as shown in Figure3. The CAN network of the frequency converter monitoring system has five nodes, including frequency converter nodes A and B (master node), load nodes C and D (slave node) and monitoring node E. The scheduling of periodic messages and occasional messages among five nodes is the research object of TTCAN scheduling optimization algorithm in this paper.Figure 3
Network topology of frequency converter monitoring system.Classify the messages, establish the scheduling time and transmission mechanism of the messages, and list the message attributes and communication task set shown in Table1.Table 1
Communication task set of electrical system.
Message typeMessage numberTrigger period (ms)Deadline (ms)Communication duration (μs)Recurring messagesM155368M255484M355484M41010444M52020444M61010444M72020444M81010520M92020520M101010520M112020520M122020404M132020484M144040520Aperiodic messageM15Episodic20328M16Episodic10328M17Episodic5328The bus message includes 14 periodic messages and 3 nonperiodic messages.T=5,5,5,10,20,10,20,10,20,10,20,20,20,40 is arranged in ascending order according to the sending cycle of periodic messages to determine BCT=5ms and MCT=40ms, and the number of matrix rows R is 8. The number of periodic message columns C of the basic cycle is 7, and the last column serves as an arbitration window for the scheduling of nonperiodic messages.


## 3.2.2. Establishment of Initial System Matrix

PartSM0 and P1 of the initialization matrix are exclusive windows with a message period equal to BCT, including M1,M2,M3 messages. Part P2 is the exclusive window whose message period is greater than BCT. Part 3 is the arbitration window for aperiodic messages [14]. The matrix is a matrix with 8 rows and 8 columns (the last column is the arbitration window). The window marked with f is a free window, and the window marked with ARB is an arbitration window, which is used to transmit event type trigger messages. According to the initial scheduling matrix SM0, the transmission time series of each column of messages Tc0=368,484,484,444,520,520,520,1660, in which the occupation width of periodic messages is 3340 μs and the available width of the arbitration window is 1660 μs.


## 3.2.3. Optimization Objectives of Message Scheduling

The protocol of TTCAN system matrix requires that the window width of the same column in each basic cycle should be consistent, which is determined by the message with the longest transmission time in this column. For PartP2, the optimization goal is how to arrange n messages into m columns, so that each column of Part P2 occupies the minimum time, and the arbitration window can reach the maximum time in the same basic cycle [15]. In order to improve the real-time performance of messages, the system matrix needs to meet the following conditions to minimize the sum of the maximum transmission time of each column of messages, which means that the bus time occupied by periodic messages is the minimum, as shown in the following equations.
(3)min∑i=1mmaxCjxijj=1,n(4)s.t.∑j=1nwjxij⩽Wii=1,m(5)∑i=1mxij=1j=1,n∀i,jmakexij∈0,1,(6)wj=MCTTjj=1,n,(7)Wi=MCTBCTi=1,m,where j is the message sequence number; i is the column number of time window SM; xij is the serial number of the corresponding j message; i whether the message of the time window column number exists, represented by 0 or 1; m is the number of columns of periodic trigger message; n is the number of messages; wj is the number of the j-th message in the SM matrix; Tj is the period of the j-th message; Cj is the transmission time of the j-th message; and Wi is the total number of rows in the time window in column i of the SM matrix.If thej-th message is placed in column i of SM, xij=1; otherwise, xij=0, and the same message can only be placed in one column; that is, there is at most one message in each row, and this message can only be stored in the current column.The bus utilization of periodic messages is shown in the following equation:(8)U=∑j=1NMCT×Cj/Tj∑i=1RLjmi,where Lj is the window width of column j, mi is the number of messages in column i, and the free window is not occupied by the bus during calculation.The optimization problem of the frequency conversion monitoring system can be transformed into a multidimensional knapsack problem, that is, a NP (nondeterministic polynomial) problem; that is, each periodic message is reasonably placed in the system matrix to minimize the occupation time of the exclusive window, so as to increase the time of the arbitration window to ensure the timely response of nonperiodic messages [16].


## 3.3. Message Scheduling Optimization Algorithm

### 3.3.1. Periodic Message Scheduling Optimization Based on Hybrid Particle Swarm Optimization

For periodic messages, it is necessary to reasonably arrange the messages in the P2 time window to achieve effective scheduling.The basic particle swarm optimization algorithm can be used to optimize the system matrix and determine the optimal value in the process of continuously tracking the extreme value, which is easy to realize and has fast convergence speed. However, due to the single optimization method, the optimal solution often cannot break through its own limitations [17, 18]. The hybrid particle swarm optimization algorithm proposed in this paper uses genetic algorithm for reference; that is, genetic algorithm is introduced into particle swarm optimization algorithm to make particles reach the optimal value in the cross mutation with individual extreme value and population extreme value, so as to solve the problem that particle similarity cannot jump out of the boundary of local optimal solution when the population converges.(1) Individual Code. Firstly, the scheduling table is coded, and the particle individual coding adopts integer coding. Each particle represents the specific allocation of n messages to a column. The Part B messages to be optimized are M4~M14, a total of 11 messages. These 11 messages need to be reasonably allocated to 4 columns to minimize the total column width. The initial coding vector of individual particles is defined according to the initial system matrix, where the number of vector elements is 11, representing the 11 messages M4~M14, and the vector value is the value of the column in which the message is located is 1,2,3,4. A total of 4 columns need to be optimized, so the column numbers are allocated from 1 to 4. Therefore, in this numbering method, the initial vector is [1–4], representing that the 11 messages M4~M14 are allocated to the first, third, first, and fourth columns, respectively. Use the same numbering method to generate any individual particle.(2) Design Fitness Function and Calculate Individual Fitness. The fitness function is divided into two parts: one is the cost of the whole; the other part is the penalty function of illegal particles. The overall cost is calculated through the objective function, and the bus utilization is used as the evaluation standard. The overall cost of the k-th particle is as follows:
(9)fkvk=∑i=1mmaxCjxijk∣j=1,⋯,n,k=1,2,⋯,M,where vk is the position of the k-th particle, and xijk is the corresponding decision variable, and the particle swarm size is M.Since the total weight of each column of messages cannot exceed the current column capacity, in order to prevent the coding of some particles from exceeding this limit during the optimization process, a penalty function is introduced to deal with the problem that particles violate constraints. The penalty function factorpk is shown in the following formulas:
(10)pk=∑i=1mpik=1,2,⋯,M,pi=0,if∑i=1mxij=1j=1,⋯,n,α0∑j=1nwjxij−Wi,otherwise.If the formula∑i=1mxij=1,j=1,⋯,n is satisfied, then Pi is 0. Otherwise, a large positive number α0 is introduced to reduce the fitness. The fitness formula consists of an evaluation function and a penalty function. The evaluation function is expressed in the following formula:
(11)evalvk=1fkvk+pkk=1,2,⋯,M.(3) Crossover Operation. Individuals are updated by crossing with individual extremum and group extremum, and the cross method is a certificate cross method. First, a crossover position is randomly selected, and then individuals and individual extremum or individual and group extremum are crossed [19].(4) Mutation Operation. The mutation method is to randomly select a mutation position for each individual and then randomly change the value of the position into other values within a range.(5) Judge Whether the Termination Conditions Are Met. If the conditions are met, the optimal individual is selected and the number of iterations is given. If not, the particle swarm location is updated to continue the calculation.


### 3.3.2. Nonperiodic Message Dynamic Scheduling Optimization Based on Uniform Strategy

For nonperiodic messages, it is also necessary to ensure a certain real-time performance. They are transmitted in the arbitration window of the matrix cycle. The message transmission cannot be interrupted, which will affect the transmission of periodic messages [20]. The occurrence time of the message shall be recorded, and the arbitration window shall be dynamically allocated to the message according to the priority, transmission time, and waiting time of the message. Only when the nonperiodic message is reliably transmitted in the arbitration window can the stable transmission of periodic messages be guaranteed. The start sending time of acquiring bus right for aperiodic messages can be expressed as the following equation:
(12)Sm=Tp+Wm,where Tp is the time waiting for the transmission of periodic scheduling message to end and Wm is the waiting time from c competing with other aperiodic messages for the bus to obtaining the bus in the arbitration window.It can be seen from equation (7) that Sm can be realized by reducing Tp and Wm. In order to achieve higher real-time performance of aperiodic messages, the following is to reduce the time for messages to wait for arbitration by reducing Tp through the uniform distribution algorithm. The dynamic identifier priority mechanism of delay priority is introduced to ensure the transmission of some nonperiodic messages with low priority.(1) Uniformly Distributed Scheduling Strategy. Uniform distribution scheduling is to adopt the idea of uniform, distribute the arbitration time evenly according to the number of exclusive windows in the basic cycle of the system matrix, and add an equally distributed arbitration window after each exclusive window [21]. In addition, in order to prevent node identification confusion caused by the transmission of adjacent periodic messages, a time interval window tgap shall be introduced between adjacent periodic messages. The length of uniformly distributed arbitration window is calculated as follows:
(13)tw=BCT−TCPNw−tgap,where tw is the width of each arbitration window equally divided; BCT is the basic cycle; TCP is the time occupied by periodic messages in a basic cycle; Nw is the number of exclusive windows, which is consistent with the number of arbitration windows after equal distribution; and tgap is the reasonable interval set between messages. For the convenience of analysis, tgap=0 is taken.Of course, the average width of each arbitration window can guarantee the transmission of the longest non periodic message transmission timetm. If tw<tm, it indicates that the uniform distribution time is insufficient. You can consider merging some uniformly distributed arbitration windows, so as to reduce the number of arbitration windows in the basic cycle to tw>tm.After the design according to the above principles, the last arbitration window of the system optimization matrix is divided into four subwindowsArb1,Arb2,Arb3,Arb4, with window widths of [360,360,360,656], respectively, to ensure the longest transmission time of nonperiodic messages of 328μs, so as to reduce the response delay of nonperiodic messages.(2) Dynamic Priority Scheduling Policy. Due to the arbitration mechanism of CAN bus, in order to avoid that messages with low priority cannot get the bus control right for a long time, a dynamic priority scheduling mechanism is introduced, and the delay priority is taken as an indicator of priority [22]. Delay priority is the number of message frames that have been transmitted during the waiting period of the arbitration window.


## 3.3.1. Periodic Message Scheduling Optimization Based on Hybrid Particle Swarm Optimization

For periodic messages, it is necessary to reasonably arrange the messages in the P2 time window to achieve effective scheduling.The basic particle swarm optimization algorithm can be used to optimize the system matrix and determine the optimal value in the process of continuously tracking the extreme value, which is easy to realize and has fast convergence speed. However, due to the single optimization method, the optimal solution often cannot break through its own limitations [17, 18]. The hybrid particle swarm optimization algorithm proposed in this paper uses genetic algorithm for reference; that is, genetic algorithm is introduced into particle swarm optimization algorithm to make particles reach the optimal value in the cross mutation with individual extreme value and population extreme value, so as to solve the problem that particle similarity cannot jump out of the boundary of local optimal solution when the population converges.(1) Individual Code. Firstly, the scheduling table is coded, and the particle individual coding adopts integer coding. Each particle represents the specific allocation of n messages to a column. The Part B messages to be optimized are M4~M14, a total of 11 messages. These 11 messages need to be reasonably allocated to 4 columns to minimize the total column width. The initial coding vector of individual particles is defined according to the initial system matrix, where the number of vector elements is 11, representing the 11 messages M4~M14, and the vector value is the value of the column in which the message is located is 1,2,3,4. A total of 4 columns need to be optimized, so the column numbers are allocated from 1 to 4. Therefore, in this numbering method, the initial vector is [1–4], representing that the 11 messages M4~M14 are allocated to the first, third, first, and fourth columns, respectively. Use the same numbering method to generate any individual particle.(2) Design Fitness Function and Calculate Individual Fitness. The fitness function is divided into two parts: one is the cost of the whole; the other part is the penalty function of illegal particles. The overall cost is calculated through the objective function, and the bus utilization is used as the evaluation standard. The overall cost of the k-th particle is as follows:
(9)fkvk=∑i=1mmaxCjxijk∣j=1,⋯,n,k=1,2,⋯,M,where vk is the position of the k-th particle, and xijk is the corresponding decision variable, and the particle swarm size is M.Since the total weight of each column of messages cannot exceed the current column capacity, in order to prevent the coding of some particles from exceeding this limit during the optimization process, a penalty function is introduced to deal with the problem that particles violate constraints. The penalty function factorpk is shown in the following formulas:
(10)pk=∑i=1mpik=1,2,⋯,M,pi=0,if∑i=1mxij=1j=1,⋯,n,α0∑j=1nwjxij−Wi,otherwise.If the formula∑i=1mxij=1,j=1,⋯,n is satisfied, then Pi is 0. Otherwise, a large positive number α0 is introduced to reduce the fitness. The fitness formula consists of an evaluation function and a penalty function. The evaluation function is expressed in the following formula:
(11)evalvk=1fkvk+pkk=1,2,⋯,M.(3) Crossover Operation. Individuals are updated by crossing with individual extremum and group extremum, and the cross method is a certificate cross method. First, a crossover position is randomly selected, and then individuals and individual extremum or individual and group extremum are crossed [19].(4) Mutation Operation. The mutation method is to randomly select a mutation position for each individual and then randomly change the value of the position into other values within a range.(5) Judge Whether the Termination Conditions Are Met. If the conditions are met, the optimal individual is selected and the number of iterations is given. If not, the particle swarm location is updated to continue the calculation.


## 3.3.2. Nonperiodic Message Dynamic Scheduling Optimization Based on Uniform Strategy

For nonperiodic messages, it is also necessary to ensure a certain real-time performance. They are transmitted in the arbitration window of the matrix cycle. The message transmission cannot be interrupted, which will affect the transmission of periodic messages [20]. The occurrence time of the message shall be recorded, and the arbitration window shall be dynamically allocated to the message according to the priority, transmission time, and waiting time of the message. Only when the nonperiodic message is reliably transmitted in the arbitration window can the stable transmission of periodic messages be guaranteed. The start sending time of acquiring bus right for aperiodic messages can be expressed as the following equation:
(12)Sm=Tp+Wm,where Tp is the time waiting for the transmission of periodic scheduling message to end and Wm is the waiting time from c competing with other aperiodic messages for the bus to obtaining the bus in the arbitration window.It can be seen from equation (7) that Sm can be realized by reducing Tp and Wm. In order to achieve higher real-time performance of aperiodic messages, the following is to reduce the time for messages to wait for arbitration by reducing Tp through the uniform distribution algorithm. The dynamic identifier priority mechanism of delay priority is introduced to ensure the transmission of some nonperiodic messages with low priority.(1) Uniformly Distributed Scheduling Strategy. Uniform distribution scheduling is to adopt the idea of uniform, distribute the arbitration time evenly according to the number of exclusive windows in the basic cycle of the system matrix, and add an equally distributed arbitration window after each exclusive window [21]. In addition, in order to prevent node identification confusion caused by the transmission of adjacent periodic messages, a time interval window tgap shall be introduced between adjacent periodic messages. The length of uniformly distributed arbitration window is calculated as follows:
(13)tw=BCT−TCPNw−tgap,where tw is the width of each arbitration window equally divided; BCT is the basic cycle; TCP is the time occupied by periodic messages in a basic cycle; Nw is the number of exclusive windows, which is consistent with the number of arbitration windows after equal distribution; and tgap is the reasonable interval set between messages. For the convenience of analysis, tgap=0 is taken.Of course, the average width of each arbitration window can guarantee the transmission of the longest non periodic message transmission timetm. If tw<tm, it indicates that the uniform distribution time is insufficient. You can consider merging some uniformly distributed arbitration windows, so as to reduce the number of arbitration windows in the basic cycle to tw>tm.After the design according to the above principles, the last arbitration window of the system optimization matrix is divided into four subwindowsArb1,Arb2,Arb3,Arb4, with window widths of [360,360,360,656], respectively, to ensure the longest transmission time of nonperiodic messages of 328μs, so as to reduce the response delay of nonperiodic messages.(2) Dynamic Priority Scheduling Policy. Due to the arbitration mechanism of CAN bus, in order to avoid that messages with low priority cannot get the bus control right for a long time, a dynamic priority scheduling mechanism is introduced, and the delay priority is taken as an indicator of priority [22]. Delay priority is the number of message frames that have been transmitted during the waiting period of the arbitration window.


## 4. Result Analysis

For periodic messages, the hybrid particle swarm optimization algorithm is used in MATLAB to design the program and optimize the part of the system matrix. The parameters of the algorithm are set as follows: the population size is 20, the evolution times is 100, the penalty function factor is 1000, the number of message columns is 4, and the number of messages is 11. The simulation results of the algorithm are shown in Figure4. Figure 4(a) shows the optimal individual fitness, and Figure 4(b) shows the total transmission time. The total transmission time of periodic messages is iterated from the initial 2080 to the 43rd generation to obtain a stable optimal value of 1928, and the fitness is optimized from 3.43×10−4to5.19×10−4. The sum of the minimum transmission time of the four column windows is 1928 μs, and the corresponding optimal individual M4~M14 is [1 3 3 3 2 2 4 4 1 2 4].Figure 4
Hybrid algorithm generation results.
(a)
Optimal individual fitness(b)
Total transmission timeTCopt={368,484,484,444,520,444,520,1736 is the message scheduling sequence, in which the width occupied by periodic messages is 3264 μs, and the available width of the arbitration window is 1736 μs; TC0={368,484,484,444,520,520,520,1660} is the periodic message sequence of the initial matrix, where the occupied width of the periodic message is 3340 μs and the available width of the arbitration window is 1660 μs. Compared with the initial state, the optimized message sequence of periodic messages saves 76 μs, and the arbitration window time is 76 μs more, which improves the bus utilization efficiency. When the number of nodes in the bus is more and the amount of message data is larger, the optimization effect is more prominent. The experimental results are as follows: according to the hybrid particle swarm optimization algorithm, the sum of partial minimum transmission time is 1928, and there are multiple optimal individuals. Compared with the traditional genetic algorithm and single particle swarm optimization algorithm, the hybrid algorithm is better than the traditional genetic algorithm and particle swarm optimization algorithm in terms of iteration times and average fitness value.


## 5. Conclusion

Based on the communication model of frequency converter monitoring system, this paper designs the TTCAN scheduling optimization algorithm. Aiming at the periodic messages of the system, the scheduling problem is transformed into a multidimensional knapsack problem, which is optimized by the combination of genetic algorithm and particle swarm optimization algorithm. The optimization matrix is obtained through MATLAB simulation experiments, which improves the bus utilization. For occasional messages, the uniform distribution strategy is adopted to arrange the arbitration window, and the delay priority is introduced as a part of the identifier to ensure the reliable transmission of event messages. In the more complex monitoring system with similar communication structure, the scheduling optimization algorithm can play a more obvious role in improving bus utilization and reducing communication delay.



---

*Source: 1178508-2022-07-23.xml*