# Experimental Study on Communication Delay of Powertrain System of Plug-In Hybrid Electric Vehicles

Authors: Dafang Wang; Bowen Yang; Cheng Zhu; Ji Qi; Geliang Ni
Journal: Mathematical Problems in Engineering
 (2013)

---

## Abstract

In order to contrast and analyze the real-time performance of the powertrain system of a plug-in hybrid electric vehicle, a mathematical model of the system delay is established under the circumstances that the transmission adopts the CAN (controller area network) protocol and the TTCAN (time-triggered CAN) protocol, respectively, and the interior of the controller adopts the foreground-background mode and the OSEK mode respectively. In addition, an experimental platform is developed to test communication delays of messages under 4 different implementation models. The 4 models are testing under the CAN protocol while the controller interior adopts the foreground-background mode; testing under the CAN protocol while the controller interior adopts the OSEK mode; testing under the TTCAN protocol while the controller interior adopts the foreground-background mode, and testing under the TTCAN protocol while the controller interior adopts the OSEK mode. The theoretical and testing results indicate that the communication delay of the OSEK mode is a little longer than the one of the foreground-background mode. Moreover, compared with the CAN protocol, the periodic message has a better real-time performance under the TTCAN protocol, while the nonperiodic message has a worse one.


---

## Body

## 1. Introduction

The controlling and managing system of a plug-in hybrid electric vehicle controls the main assemblies through bus and makes full use and coordination of advantages of each part, so that the vehicle can get the best operating condition. The system adopts network-based control mode, which affects the real-time performance. References [1–5] analyze the relationship between network-induced delays and system performance, introducing network-induced delay in the system modeling, considering the network-induced delays and random data-missing occurrence, analyzing the problem of stability control under different network-induced latency, and pointing out that it is necessary to consider network-induced delays in the choice of control algorithms. The controlling and managing system of the plug-in hybrid electric vehicle is a typical distributed real-time control system. Calculation delay of the controller interior and arbitration and transmission delay during the network communication process have a significant effect on the performance of the system. Nowadays, the mainstream bus of the vehicle distributed real-time control system is CAN bus, while the TTCAN bus is adopted in some condition asking for a high-quality real-time performance. The controller interior mainly adopts the foreground-background mode and the OSEK mode.The delay of the bus communication can be divided into 4 parts: generating delay, queue delay, transmission, and receiving delay [6]. According to the influencing factors, the delay can be divided into two parts. The first one is on-line delay, which includes queuing delay and transmission delay. This sort of delay is related to the process of data transmitting on the network. Concretely, it is related to the priority setting of data, the type of communication network, and the protocol. The second one is on-chip delay, which includes generating delay and receiving delay. This sort of delay is related to the behaviors in controller nodes. Specifically, it is related to hardware indexes like the operating frequency and the software indexes such as the realization of the control algorithm and the task priority setting of the controller.On the aspect of the on-line delay of CAN bus, [7–13] put forward the worst transmission delay and the queue delay models aimed at periodic massages. The queue delay models built by the abovementioned references are the same, while the transmission delay models are a little different. Reference [14] presents a buffered estimation method aimed at the system-on-chip (SoC) based on a priority-ranked queuing model and builds a buffered queuing model. The queue is an M/G/1 queue with several different client levels and nonpreemptive arbitration. A mathematical model of average waiting time is deduced, which can provide some reference value for us to build the average waiting-time model of the nonperiodic message on CAN bus. However, there is no actual test of the delay in [14]. References [15, 16] assume that the arrival of message accords with Poisson process and take the transmission process of CAN message as an M/G/1 queuing process to be analyzed. A mathematical model of average delay of message is deduced.On the aspect of the on-line delay of TTCAN bus, [17, 18] develop a TTCAN experimental platform which can realize the sending and receiving of massages on LEVEL1 which is stipulated by the TTCAN protocol. To periodic messages, the delay time of CAN and TTCAN bus is contrasted and analyzed through measurement. It is pointed out that the real-time performance of periodic messages transmitting on the TTCAN bus cannot be influenced by other nodes, which means that the real-time property of the network is improved. Reference [12] sends nonperiodic messages through arbitration windows. Assuming that the generating moments of nonperiodic messages accord with uniform distribution and then considering the effects of monopolized windows and free windows, a mathematical expectation model for on-line delays of nonperiodic messages with TTCAN protocol is established. The average delays of messages with different IDs are tested through experiments. After contrasting and analyzing the measured and theoretical values as well as the delay time of nonperiodic messages under CAN and TTCAN modes, it is pointed out that TTCAN protocol degrades real-time performance of the nonperiodic messages.Most of the studies on the vehicular network delay have paid attention to the on-line delay, while they have ignored the on-chip delay [8–12, 15–18]. They point out that the on-chip delay can be neglected for the delay of the vehicular network. If aiming at the message adopted the CAN protocol, meanwhile the processing speed of the chip is fast and the sending-and-receiving priority level of the CAN message is high, the statement can be tenable. But the on-chip delay cannot be ignored when these conditions are not satisfied. At the same time, if adopting the TTCAN protocol, the task scheduling inside the nodes need to match up with the TTCAN task window; otherwise, it will cause the exacerbation of the delay of the TTCAN message.On the aspect of the on-chip delay based on the foreground-background mode, [8] thinks that the generating delay of messages is permanent without considering the preemption of multiple interrupts in nodes. It is stressed that the receiving delay firstly depends on the receiving mode being roll-polling mode or interrupt trigger mode and secondly depends on the multiple interrupt scheduling methods in nodes. A mathematical model of receiving delay is given out, but there is no measured delay data.And for the analysis on the aspect of the on-chip delay based on the OSEK mode, aiming at general static embedded real-time operating system, [19, 20] point out that the RM scheduling algorithm is the best scheduling algorithm, and the schedulable rules of the RM arithmetic are given as well. References [21, 22] discuss the burden of microcontroller caused by the embedded kernel and give out the cost time of alarming, triggering tasks, scheduling tasks, and terminating tasks in the OSEK mode. Meanwhile, the worst responding time of fixed priority/first-in-first-out (FP/FIFO) scheduling policy in the OSEK mode is given, separately adopting the preemptive and nonpreemptive mechanisms. And the difference of theoretical responding time is contrasted and analyzed in the condition of considering and not considering the burdens of microcontroller caused by embedded kernel of OSEK. The difference between measured and theoretical responding time is also contrasted, taking the burdens of microcontroller caused by embedded kernel of OSEK into consideration. Then, the necessity of considering the burdens of microcontroller caused by embedded kernel of OSEK is pointed out. References [23, 24] consider that the use of OSEK model can improve the efficiency of the transplant and achieve the reuse of software modules. However, the burden added to the MCU caused by the OSEK system is not taken into consideration.In this paper, the delay characteristic of the vehicular distributed real-time control system is analyzed, including the on-line delay and the on-chip delay. To finally achieve a better performance of the system, the overall delay model which adopts the different on-chip mechanisms and the different networking protocols is analyzed, and the cooperation of the on-chip scheduling and the network scheduling is also taken into consideration.


## 2. The Powertrain Network of Plug-In Hybrid Electric Vehicles

### 2.1. Topology Structure of the Powertrain System

The power comes from three parts: vehicle engines and power units in an APU system, power battery pack, and plug-in charging system. However, the actual power for the running vehicle is mainly supplied by the APU system and the vehicle-mounted power battery pack. The composition of the plug-in controlling system is shown in Figure1.Figure 1
Composition of the plug-in controlling system.In Figure1, the light-color segments represent signal transmission, including the figure signals, analog signals, and messages on the CAN bus, while the dark-color segments represent driving connections, including high-voltage signals and mechanical connection signals. Powertrain system network is connected with CAN bus, and the transmission rate is 250 Kbits/s. The powertrain CAN network includes 5 nodes which are vehicle controller, motor controller, variable-speed controller, battery controlling system, and APU controller. In the test, they can be realized by the 5 nodes in the network hardware nodes system correspondingly in the experimental platform testing the CAN communication delay. To the driver instrument node in Figure 1, the node does not belong to the powertrain part, but the node is in the powertrain network in the real vehicle to function on monitoring and display. The node only receives messages from the network, but it does not send messages through the network. It can be realized by the upper computer nodes in the experimental platform testing the CAN communication delay, and the purpose here is to monitor the time parameter of the network message transmission.


### 2.2. Definition of Parameter Groups of Each Node in the Powertrain

The powertrain system of a plug-in hybrid electric vehicle consists of 5 nodes, and the setting conditions of parameter groups of each node are given out in Table1.Table 1
Message sending conditions of each node of powertrain.
Sending node
Message
Sending rate (ms)
Receiving node
Message content
Vehicle controller
ID06
10
Motor controller
Motor controls parameter
ID10
40
APU controller
APU controls parameter
ID15
80
All of the nodes
Condition of the vehicle controller
ID03
Nonperiodic
All of the nodes
Vehicle is giving an alarm
Motor controller
ID07
10
Vehicle controller
Motor working parameter
ID12
40
All of the nodes
Motor working condition
ID01
Nonperiodic
All of the nodes
Motor is giving an alarm
Variable speed controller
ID08
20
All of the nodes
Transmission working parameter
ID11
40
All of the nodes
Transmission working condition
ID02
Nonperiodic
All of the nodes
Transmission is giving an alarm
Battery management system
ID09
20
Vehicle controller
Battery pack working parameter
ID16~44
80
Message display
Battery pack is collection points message
ID04
Nonperiodic
All of the nodes
Battery system is giving an alarm
APU controller
ID13
40
All of the nodes
APU working parameter
ID14
80
All of the nodes
APU working condition
ID05
Nonperiodic
All of the nodes
APU is giving an alarmAccording to Table1, the powertrain CAN network transmits 44 messages with different IDs, and the priorities of messages are the same with the numbers, which means that the priority of the message ID01 is the highest and the priority of the message ID44 is the lowest. The messages include 39 periodic messages, and the longest sending period among them is 80 ms, while the shortest is 10 ms. There are also 5 nonperiodic messages whose generating process is assumed to be a Poisson process.


## 2.1. Topology Structure of the Powertrain System

The power comes from three parts: vehicle engines and power units in an APU system, power battery pack, and plug-in charging system. However, the actual power for the running vehicle is mainly supplied by the APU system and the vehicle-mounted power battery pack. The composition of the plug-in controlling system is shown in Figure1.Figure 1
Composition of the plug-in controlling system.In Figure1, the light-color segments represent signal transmission, including the figure signals, analog signals, and messages on the CAN bus, while the dark-color segments represent driving connections, including high-voltage signals and mechanical connection signals. Powertrain system network is connected with CAN bus, and the transmission rate is 250 Kbits/s. The powertrain CAN network includes 5 nodes which are vehicle controller, motor controller, variable-speed controller, battery controlling system, and APU controller. In the test, they can be realized by the 5 nodes in the network hardware nodes system correspondingly in the experimental platform testing the CAN communication delay. To the driver instrument node in Figure 1, the node does not belong to the powertrain part, but the node is in the powertrain network in the real vehicle to function on monitoring and display. The node only receives messages from the network, but it does not send messages through the network. It can be realized by the upper computer nodes in the experimental platform testing the CAN communication delay, and the purpose here is to monitor the time parameter of the network message transmission.


## 2.2. Definition of Parameter Groups of Each Node in the Powertrain

The powertrain system of a plug-in hybrid electric vehicle consists of 5 nodes, and the setting conditions of parameter groups of each node are given out in Table1.Table 1
Message sending conditions of each node of powertrain.
Sending node
Message
Sending rate (ms)
Receiving node
Message content
Vehicle controller
ID06
10
Motor controller
Motor controls parameter
ID10
40
APU controller
APU controls parameter
ID15
80
All of the nodes
Condition of the vehicle controller
ID03
Nonperiodic
All of the nodes
Vehicle is giving an alarm
Motor controller
ID07
10
Vehicle controller
Motor working parameter
ID12
40
All of the nodes
Motor working condition
ID01
Nonperiodic
All of the nodes
Motor is giving an alarm
Variable speed controller
ID08
20
All of the nodes
Transmission working parameter
ID11
40
All of the nodes
Transmission working condition
ID02
Nonperiodic
All of the nodes
Transmission is giving an alarm
Battery management system
ID09
20
Vehicle controller
Battery pack working parameter
ID16~44
80
Message display
Battery pack is collection points message
ID04
Nonperiodic
All of the nodes
Battery system is giving an alarm
APU controller
ID13
40
All of the nodes
APU working parameter
ID14
80
All of the nodes
APU working condition
ID05
Nonperiodic
All of the nodes
APU is giving an alarmAccording to Table1, the powertrain CAN network transmits 44 messages with different IDs, and the priorities of messages are the same with the numbers, which means that the priority of the message ID01 is the highest and the priority of the message ID44 is the lowest. The messages include 39 periodic messages, and the longest sending period among them is 80 ms, while the shortest is 10 ms. There are also 5 nonperiodic messages whose generating process is assumed to be a Poisson process.


## 3. Theoretical Model of Communication Delay

The bus adopts the CAN transmission and TTCAN protocol, and the interior of controller nodes adopts the foreground-background mode and the OSEK mode, respectively, to realize the total communication delay of the powertrain distributed real-time controlling system of a plug-in hybrid electric vehicle under these 4 working conditions. Considering the specific application to be a passenger car, the vehicle communication should be corresponding to protocol SAEJ1939. Therefore, the massage form is defined as expanding frame form.


### 3.1. Composition of Communication Delay

Aiming at the distributed real-time controlling system based on the CAN bus, [7] gives out the composition of the communication delay of point-to-point messages, which is shown in Figure 2.Figure 2
Communication delay model.The communication delay of the bus can be divided into 4 parts, which are generating delay, queue delay, transmission delay, and receiving delay [6].The generating delay: the period from the moment of microcontroller that sends node receiving the request from the same node to the moment of writing the prepared data into the sending cache queue of the CAN controller.The queue delay: the period from the moment of massage entering the sending cache queue of the CAN controller to the moment of the massage obtaining controlling right of the bus.The transmission delay is the period from the moment of massage occupying the bus to the moment of massage leaving the bus.The receiving delay is the period from the moment of massage leaving the bus to providing the effective data to the microcontroller that receives nodes.To describe it easier, this paper divided the communication delay into two parts: on-line delay which includes queue delay and transmission delay and on-chip delay which includes generating delay and receiving delay.


### 3.2. Mathematical Model of Communication Delay

#### 3.2.1. The Model of the On-Line Delay

For the periodic message, the queue delay could be expressed with an iteration formula as follows:(1)tmn+1=∑∀j∈hp(m)[tmn+Jj+τbitTj]cj+∑j=1Ncj22Tj.In the previous formula,n represents the iteration. When tmn+1=tmn, the iteration is convergence, and the result value is supposed to be the average queue delay. hp(m) is the gather of message frames whose priority is higher than m. Tj is the transmission period of the periodic message frame j. Jj is the maximum error of message frame js period. cj is the transmission delay of the message frame j. cj is the time needed to transmit a bit on the transmission media.The transmission delay of messagem is cm, and the transmission delay of the expending message frame is expressed as follows:
(2)cm=(67+8sm+⌈⌊(54+8sm)/4⌋2⌉)τbit+ρcons.In the previous formula,sm is the number of bytes contained by the message m data field and is an integer between 0 and 8. ρcons is a constant related to the electrical specification of the bus physical medium.The average queue delay and transmission delay are independent of each other, and the average on-line delay is the sum of the two:(3)Tm=tm+cm.In the previous formula,Tm is the average on-line delay.Substituting (1) and (2) into (3), we can acquire that
(4)Tm=∑∀j∈hp(m)[tm+Jj+τbitTj]cj+∑j=1Ncj22Tj+(67+8sm+⌈⌊(54+8sm)/4⌋2⌉)τbit+ρcons.To the nonperiodic messages, according to the priorities ranking from high to low, the highest-priority message is called type 1 message; the second high-priority message is called type 2 message, and so on, while the lowest-priority message is called typen message.Firstly, consider type 1 message, which means the problem of the average queue delay of messages with the highest-priority.When a type 1 message requests to transmit on the bus, its average waiting timeWq1¯  is
(5)Wq1¯=We¯=∑i=1nλiE(χi2)2.In the previous formula,Wq1¯ represents the average waiting time of the type 1 message, which means the period from the moment of requesting to transmit to the moment of occupying the bus. We¯ is the average remaining time of the massage that is transmitted currently when type 1 message arrives.n represents the amount of the message types. λi is the requesting rate of type i message. χi represents the transmission time of type i message and is a random variable.Then, consider the problem of the average queue delay of typei messages.When a typei message requests to transmit on the bus, its average waiting time Wqi¯ is
(6)Wqi¯=Wq(i-1)¯(1-∑j=1i-2ρj+ρi-1)(1-∑j=1i-1ρj).In the previous formula,ρ=λ/μ, λ is a parameter of the Poisson process and μ is the reciprocal of the average servicing time.Then, consider the transmission delay; the on-line delay of the message is(7)Wi¯=cm+Wqi¯.What is different from the analysis of on-line delay of the periodic CAN messages is that every periodic TTCAN message transmits in the appointed exclusive-time window, ensuring that the bus is free when each periodic massage gets triggered by scheduling the overall time. Therefore, the queue delay of the periodic message will not exist any longer. As a result, under the TTCAN protocol, the on-line delay of the periodic message is just transmission delay. Substitutingtm=0 into (3), the mathematical model of the average on-line delay of the periodic TTCAN message can be acquired, and is shown as follow:
(8)Tm=(67+8sm+⌈⌊(54+8sm)/4⌋2⌉)τbit+ρcons.Nonperiodic TTCAN messages are all assumed to be scheduled in the arbitration time window. Based on the analysis of average on-line delay of the CAN nonperiodic message, the effects of exclusive-time window and free-time window are taken into consideration. When the nonperiodic messagem generates in a certain exclusive-time window i, it could only be sent when it is delayed to a following certain arbitration time window.Set the number of the exclusive-time windows (or the free-time windows) within the average arriving period of nonperiodic massages to beK and the length of the time window to be h. In that way, the average delay caused by the nonperiodic messages which are affected by the exclusive-time window (or the free-time window) is supposed to be
(9)Gm=∑i=1K(Li+cm)2(1-e-λh)(2×h).In the previous formula,Li represents the time length of the exclusive-time window (or the free-time window) i.According to (9) and (7), the average on-line delay formula based on the queue theory should be
(10)Wi¯=1μi+Wqi¯+Gm.


#### 3.2.2. On-Chip Delay Model

In the node of the controller, the average performing time of the task can be expressed as follows:(11)ri=ei+∑∀j∈hp(i)[riPj]ej.In the previous formula,ri is the average performing time of task i, hp(i) is the set of the tasks whose priorities are higher than those of task i, ei is the performing time of task Ti, and Pi is the period of task Ti. The first part on the right side of (11) means the performing time when there is only task, and the second part means the disturbing time caused by the performing of the task with a higher priority.The generating delay of messages means the time needed from the moment of sending node requesting to generate message to the moment of writing the generated message into the sending cache of bus controller, which means the period from the moment that the message sends the task to the moment that the task is finished in the node. Message receiving delay means the time needed from the moment that the message leaves from the bus to the moment that the carried data is provided to the target task of receiving nodes, which means the period from the moment that the message receives the task to the moment that the task is finished in the node.


## 3.1. Composition of Communication Delay

Aiming at the distributed real-time controlling system based on the CAN bus, [7] gives out the composition of the communication delay of point-to-point messages, which is shown in Figure 2.Figure 2
Communication delay model.The communication delay of the bus can be divided into 4 parts, which are generating delay, queue delay, transmission delay, and receiving delay [6].The generating delay: the period from the moment of microcontroller that sends node receiving the request from the same node to the moment of writing the prepared data into the sending cache queue of the CAN controller.The queue delay: the period from the moment of massage entering the sending cache queue of the CAN controller to the moment of the massage obtaining controlling right of the bus.The transmission delay is the period from the moment of massage occupying the bus to the moment of massage leaving the bus.The receiving delay is the period from the moment of massage leaving the bus to providing the effective data to the microcontroller that receives nodes.To describe it easier, this paper divided the communication delay into two parts: on-line delay which includes queue delay and transmission delay and on-chip delay which includes generating delay and receiving delay.


## 3.2. Mathematical Model of Communication Delay

### 3.2.1. The Model of the On-Line Delay

For the periodic message, the queue delay could be expressed with an iteration formula as follows:(1)tmn+1=∑∀j∈hp(m)[tmn+Jj+τbitTj]cj+∑j=1Ncj22Tj.In the previous formula,n represents the iteration. When tmn+1=tmn, the iteration is convergence, and the result value is supposed to be the average queue delay. hp(m) is the gather of message frames whose priority is higher than m. Tj is the transmission period of the periodic message frame j. Jj is the maximum error of message frame js period. cj is the transmission delay of the message frame j. cj is the time needed to transmit a bit on the transmission media.The transmission delay of messagem is cm, and the transmission delay of the expending message frame is expressed as follows:
(2)cm=(67+8sm+⌈⌊(54+8sm)/4⌋2⌉)τbit+ρcons.In the previous formula,sm is the number of bytes contained by the message m data field and is an integer between 0 and 8. ρcons is a constant related to the electrical specification of the bus physical medium.The average queue delay and transmission delay are independent of each other, and the average on-line delay is the sum of the two:(3)Tm=tm+cm.In the previous formula,Tm is the average on-line delay.Substituting (1) and (2) into (3), we can acquire that
(4)Tm=∑∀j∈hp(m)[tm+Jj+τbitTj]cj+∑j=1Ncj22Tj+(67+8sm+⌈⌊(54+8sm)/4⌋2⌉)τbit+ρcons.To the nonperiodic messages, according to the priorities ranking from high to low, the highest-priority message is called type 1 message; the second high-priority message is called type 2 message, and so on, while the lowest-priority message is called typen message.Firstly, consider type 1 message, which means the problem of the average queue delay of messages with the highest-priority.When a type 1 message requests to transmit on the bus, its average waiting timeWq1¯  is
(5)Wq1¯=We¯=∑i=1nλiE(χi2)2.In the previous formula,Wq1¯ represents the average waiting time of the type 1 message, which means the period from the moment of requesting to transmit to the moment of occupying the bus. We¯ is the average remaining time of the massage that is transmitted currently when type 1 message arrives.n represents the amount of the message types. λi is the requesting rate of type i message. χi represents the transmission time of type i message and is a random variable.Then, consider the problem of the average queue delay of typei messages.When a typei message requests to transmit on the bus, its average waiting time Wqi¯ is
(6)Wqi¯=Wq(i-1)¯(1-∑j=1i-2ρj+ρi-1)(1-∑j=1i-1ρj).In the previous formula,ρ=λ/μ, λ is a parameter of the Poisson process and μ is the reciprocal of the average servicing time.Then, consider the transmission delay; the on-line delay of the message is(7)Wi¯=cm+Wqi¯.What is different from the analysis of on-line delay of the periodic CAN messages is that every periodic TTCAN message transmits in the appointed exclusive-time window, ensuring that the bus is free when each periodic massage gets triggered by scheduling the overall time. Therefore, the queue delay of the periodic message will not exist any longer. As a result, under the TTCAN protocol, the on-line delay of the periodic message is just transmission delay. Substitutingtm=0 into (3), the mathematical model of the average on-line delay of the periodic TTCAN message can be acquired, and is shown as follow:
(8)Tm=(67+8sm+⌈⌊(54+8sm)/4⌋2⌉)τbit+ρcons.Nonperiodic TTCAN messages are all assumed to be scheduled in the arbitration time window. Based on the analysis of average on-line delay of the CAN nonperiodic message, the effects of exclusive-time window and free-time window are taken into consideration. When the nonperiodic messagem generates in a certain exclusive-time window i, it could only be sent when it is delayed to a following certain arbitration time window.Set the number of the exclusive-time windows (or the free-time windows) within the average arriving period of nonperiodic massages to beK and the length of the time window to be h. In that way, the average delay caused by the nonperiodic messages which are affected by the exclusive-time window (or the free-time window) is supposed to be
(9)Gm=∑i=1K(Li+cm)2(1-e-λh)(2×h).In the previous formula,Li represents the time length of the exclusive-time window (or the free-time window) i.According to (9) and (7), the average on-line delay formula based on the queue theory should be
(10)Wi¯=1μi+Wqi¯+Gm.


### 3.2.2. On-Chip Delay Model

In the node of the controller, the average performing time of the task can be expressed as follows:(11)ri=ei+∑∀j∈hp(i)[riPj]ej.In the previous formula,ri is the average performing time of task i, hp(i) is the set of the tasks whose priorities are higher than those of task i, ei is the performing time of task Ti, and Pi is the period of task Ti. The first part on the right side of (11) means the performing time when there is only task, and the second part means the disturbing time caused by the performing of the task with a higher priority.The generating delay of messages means the time needed from the moment of sending node requesting to generate message to the moment of writing the generated message into the sending cache of bus controller, which means the period from the moment that the message sends the task to the moment that the task is finished in the node. Message receiving delay means the time needed from the moment that the message leaves from the bus to the moment that the carried data is provided to the target task of receiving nodes, which means the period from the moment that the message receives the task to the moment that the task is finished in the node.


## 3.2.1. The Model of the On-Line Delay

For the periodic message, the queue delay could be expressed with an iteration formula as follows:(1)tmn+1=∑∀j∈hp(m)[tmn+Jj+τbitTj]cj+∑j=1Ncj22Tj.In the previous formula,n represents the iteration. When tmn+1=tmn, the iteration is convergence, and the result value is supposed to be the average queue delay. hp(m) is the gather of message frames whose priority is higher than m. Tj is the transmission period of the periodic message frame j. Jj is the maximum error of message frame js period. cj is the transmission delay of the message frame j. cj is the time needed to transmit a bit on the transmission media.The transmission delay of messagem is cm, and the transmission delay of the expending message frame is expressed as follows:
(2)cm=(67+8sm+⌈⌊(54+8sm)/4⌋2⌉)τbit+ρcons.In the previous formula,sm is the number of bytes contained by the message m data field and is an integer between 0 and 8. ρcons is a constant related to the electrical specification of the bus physical medium.The average queue delay and transmission delay are independent of each other, and the average on-line delay is the sum of the two:(3)Tm=tm+cm.In the previous formula,Tm is the average on-line delay.Substituting (1) and (2) into (3), we can acquire that
(4)Tm=∑∀j∈hp(m)[tm+Jj+τbitTj]cj+∑j=1Ncj22Tj+(67+8sm+⌈⌊(54+8sm)/4⌋2⌉)τbit+ρcons.To the nonperiodic messages, according to the priorities ranking from high to low, the highest-priority message is called type 1 message; the second high-priority message is called type 2 message, and so on, while the lowest-priority message is called typen message.Firstly, consider type 1 message, which means the problem of the average queue delay of messages with the highest-priority.When a type 1 message requests to transmit on the bus, its average waiting timeWq1¯  is
(5)Wq1¯=We¯=∑i=1nλiE(χi2)2.In the previous formula,Wq1¯ represents the average waiting time of the type 1 message, which means the period from the moment of requesting to transmit to the moment of occupying the bus. We¯ is the average remaining time of the massage that is transmitted currently when type 1 message arrives.n represents the amount of the message types. λi is the requesting rate of type i message. χi represents the transmission time of type i message and is a random variable.Then, consider the problem of the average queue delay of typei messages.When a typei message requests to transmit on the bus, its average waiting time Wqi¯ is
(6)Wqi¯=Wq(i-1)¯(1-∑j=1i-2ρj+ρi-1)(1-∑j=1i-1ρj).In the previous formula,ρ=λ/μ, λ is a parameter of the Poisson process and μ is the reciprocal of the average servicing time.Then, consider the transmission delay; the on-line delay of the message is(7)Wi¯=cm+Wqi¯.What is different from the analysis of on-line delay of the periodic CAN messages is that every periodic TTCAN message transmits in the appointed exclusive-time window, ensuring that the bus is free when each periodic massage gets triggered by scheduling the overall time. Therefore, the queue delay of the periodic message will not exist any longer. As a result, under the TTCAN protocol, the on-line delay of the periodic message is just transmission delay. Substitutingtm=0 into (3), the mathematical model of the average on-line delay of the periodic TTCAN message can be acquired, and is shown as follow:
(8)Tm=(67+8sm+⌈⌊(54+8sm)/4⌋2⌉)τbit+ρcons.Nonperiodic TTCAN messages are all assumed to be scheduled in the arbitration time window. Based on the analysis of average on-line delay of the CAN nonperiodic message, the effects of exclusive-time window and free-time window are taken into consideration. When the nonperiodic messagem generates in a certain exclusive-time window i, it could only be sent when it is delayed to a following certain arbitration time window.Set the number of the exclusive-time windows (or the free-time windows) within the average arriving period of nonperiodic massages to beK and the length of the time window to be h. In that way, the average delay caused by the nonperiodic messages which are affected by the exclusive-time window (or the free-time window) is supposed to be
(9)Gm=∑i=1K(Li+cm)2(1-e-λh)(2×h).In the previous formula,Li represents the time length of the exclusive-time window (or the free-time window) i.According to (9) and (7), the average on-line delay formula based on the queue theory should be
(10)Wi¯=1μi+Wqi¯+Gm.


## 3.2.2. On-Chip Delay Model

In the node of the controller, the average performing time of the task can be expressed as follows:(11)ri=ei+∑∀j∈hp(i)[riPj]ej.In the previous formula,ri is the average performing time of task i, hp(i) is the set of the tasks whose priorities are higher than those of task i, ei is the performing time of task Ti, and Pi is the period of task Ti. The first part on the right side of (11) means the performing time when there is only task, and the second part means the disturbing time caused by the performing of the task with a higher priority.The generating delay of messages means the time needed from the moment of sending node requesting to generate message to the moment of writing the generated message into the sending cache of bus controller, which means the period from the moment that the message sends the task to the moment that the task is finished in the node. Message receiving delay means the time needed from the moment that the message leaves from the bus to the moment that the carried data is provided to the target task of receiving nodes, which means the period from the moment that the message receives the task to the moment that the task is finished in the node.


## 4. Experimental Study of Communication Delay

### 4.1. Experiment Environment

#### 4.1.1. Basic Experiment Environment

The bus adopts the CAN and TTCAN transmission protocols, respectively, and interior of the controller nodes adopts the foreground-background mode and the OSEK mode, respectively. The overall communication delay of the powertrain distributed real-time controlling system of a plug-in hybrid electric vehicle under these four working conditions is analyzed. The specific experiment environment is expressed as follows.The bus baud rate of the communication delay testing platform is set to be 250 Kbit/s, and the expanding data frame form is adopted to write communication programs of the 5 nodes shown in Figure1. In order to simplify the analysis process, assumptions of the node program of the vehicle controller are put forward as follows.(1)
The program is divided into 5 tasks, which is used for realizing the transmission of 3 periodic messages and 1 nonperiodic message as well as the receiving of messages.(2)
The controlling strategy related to each task is finished inside the task.(3)
The priority of the receiving tasks of messages in the node is the highest, and the priority of tasks sending from the message equals the priority of the message.Table2 gives out the measured performing time of the 5 tasks of the vehicle controller nodes under the foreground-background mode.Table 2
The individual performing time of tasks under the foreground-background mode.
Description of tasks
Performing time (ms)
Sending message ID03
0.0132
Sending message ID06
0.0352
Sending message ID10
0.0272
Sending message ID15
0.0162
Message receiving
0.0142Table3 gives out the measured performing time of the 5 tasks of the vehicle controller nodes under the OSEK mode.Table 3
The individual performing time of tasks under the OSEK mode.
Description of tasks
Performing time (ms)
Sending message ID03
0.0292
Sending message ID06
0.0512
Sending message ID10
0.0432
Sending message ID15
0.0322
Message receiving
0.0302According to Tables2 and 3, for the same task, the performing time under the OSEK mode is longer than that under the foreground-background mode, which is related to the task scheduling structure inside the OSEK system. And this indicates that load to microcontroller in the OSEK mode is larger than that in the foreground-background mode.


#### 4.1.2. The Establishment and the Schedulable Analysis of the TTCAN Matrix Period

When the transmission protocol adopts the TTCAN mode, the matrix period, the basic period, and the width of the time window which means the transmission column width in the matrix period should be determined.Firstly, assume that the matrix includesP lines and Q columns. The transmission column width of a column must guarantee the transmission of a package of whole messages, and, for the expanding frame message, the width is supposed to be
(12)TCWj=maxM0,jMP,j[(67+8sm+⌊54+8sm4⌋)τbit+ρcons].In the previous formula,TCWj is the transmission column width of the column j, and Mi,j is the line i column j of the matrix period.Length of the basic period is usually set as the greatest common divisor of all message periods, while the length of the matrix period is usually set as the least common multiple of all message periods. The calculated matrix period needs a schedulable analysis in order to explain whether the matrix period is enough for scheduling all of the messages or not. Reference [25] puts forward a sort of scheduling algorithm based on the AL (average loading) without considering the effects of nonperiodic messages. Modify the algorithm, and then give out an AL scheduling algorithm which considers periodic messages and nonperiodic messages at the same time.In advance,N is defined to be the number of periodic messages, periodic is set to be T={T1,T2,…,TM}, and M is defined to be the number of the periods. The number of the message whose periodic is Ti among them is ni, 1≤i≤M. V is the number of nonperiodic messages. It is defined that the reaching process of nonperiodic messages is accorded with a Poisson process whose average rate is λ. Then,
(13)N=∑i=1Mni.Let the width of each column in the matrix period be the same, and the widthTCW is
(14)TCW>maxj=1Q(TCWj).Let the basic period be the greatest common divisor (GCD) of the period:(15)TBC=GCD(T1,T2,…,TM).Let the matrix period be the lowest common multiple (LCM) of the period:(16)TMC=LCM(T1,T2,…,TM).The ratioki of the message period and the basic period is
(17)ki=TiTBC.The number of the basic periodsNBC is
(18)NBC=TMCTBC.The number of the time window needed in a basic period is(19)Si=Si-1+⌈niki⌉+⌈VλTBC⌉.LetS0 be equal to 0; the largest message number which could be transmitted in a basic period is
(20)γmax=(TBC-TRM)TCW.In the previous formula,TRM is the length of the time window of referential message.If the schedulable condition is satisfied:(21)SM≤γmax,
then we can reach a conclusion that the message can be scheduled. According to this, the qualified matrix period can be established.For the messages sent by each node of the powertrain of a plug-in hybrid electric vehicle which is defined in Table1, according to (12), TCWj=0.64 can be get and then substitute it to (14), and TCW=1. According to (15), TBC=10, and, according to (16), TMC=80. According to (18), NBC=8, and, according to (19), S4=9. Let TRM=1, according to (20), γmax=9. Therefore, the conditions of (21) are met, and then a conclusion can be reached that the message can be scheduled, and the matrix period established is shown in Figure 3.Figure 3
The matrix period of the plug-in powertrain of the TTCAN protocol.In Figure3, AW stands for the arbitration window, and FW stands for the free window. The matrix period includes 8 basic periods, and the length of each basic period is 10 ms, so the length of the matrix period is 80 ms. Moreover, the width of each column is the same, which is 1 ms. Nonperiodic messages ID1~ID5 are transmitted in the arbitration window.


#### 4.1.3. The On-Chip and On-Line Combined Scheduling of the Periodic Message under the TTCAN Mode

For the periodic message, the transmission under the TTCAN mode needs the cooperation of the interior scheduling of the node and the window scheduling on the bus.The periodic messageF is sent from window Mi,j of the matrix period, that is, when the message is sent from line i column j of the matrix period. The beginning moment of window Mi,j is defined as IMi,j; then, inside the node, the best beginning moment ITF of task TF that is, sending periodic message F is defined, which means the phase of task TF. It is shown as follows:
(22)ITF=IMi,j-rTFp.In the previous formula,rTFp is the worst performing time of task TF.The cooperation of the trigger phase of the sending task and the transmission window of the corresponding message on the bus can be realized by the overall time stamp provided by the reference message. According to the trigger phaseTF defined by (22), on one hand, it could guarantee that the data could be written into the cache before the sending window of the periodic message F reaching; on the other hand, it could guarantee that the data written in the sending cache are the newest data.


### 4.2. Testing Results

Then, the tests of the communication delay of the powertrain of a plug-in hybrid electric vehicle are conducted in 4 working conditions separately, which are the following: testing under the CAN communication protocol while the controller interior adopts the foreground-background mode; testing under the CAN communication protocol while the controller interior adopts the OSEK mode; testing under the TTCAN communication protocol while the controller interior adopts the foreground-background mode; testing under the TTCAN communication protocol while the controller interior adopts the OSEK mode.


#### 4.2.1. The Testing Results of Communication Delay under the Foreground-Background Mode with the CAN Protocol

Under the foreground-background mode, 3 timer interruptions control the sending of 3 periodic CAN messages, an exterior triggered interruption controls the sending of a nonperiodic CAN message, and a CAN receiving interruption controls the real-time receiving of the CAN message. Figure4 gives out the communication delay of the nonperiodic message, and Figure 5 gives out the communication delays of the 3 periodic messages under this mode. The communication delay is the delay summation of the four parts including generating, queue, transmission, and receiving.Figure 4
The communication delay of the nonperiodic message under the foreground-background mode with CAN protocol.The communication delay of the periodic message under the foreground-background mode with CAN protocol.
(a)
(b)
(c)According to Figures4 and 5, the average communication delay of each ID message can be acquired after the statistic analysis, which is shown in Table 4.Table 4
The comparison of the measured and theoretical communication delays of the message of the vehicle controller node under foreground-background mode with the CAN protocol.
Message ID
Measured average communication delay (ms)
Theoretical average communication delay (ms)
Average communication delay error
Maximum measured communication delay (ms)
ID03
0.75585
0.73658
−2.62%
1.4599
ID06
0.73184
0.75523
3.10%
1.4097
ID10
0.80478
0.77407
−3.97%
2.3594
ID15
0.79332
0.78634
−0.89%
3.9359


#### 4.2.2. The Testing Results of Communication Delay under the OSEK Mode with the CAN Protocol

Under the OSEK mode, the sending and receiving of the message are directly controlled by OSEK tasks. The communication delay of nonperiodic messages is shown in Figure6, and the communication delays of the 3 periodic messages are shown in Figure 7.Figure 6
The communication delay of the nonperiodic message of the vehicle controller node under the OSEK mode with the CAN protocol.The communication delay of the periodic message of the vehicle controller node under the OSEK mode with the CAN protocol.
(a)
(b)
(c)According to Figures6 and 7, the average communication delay of each ID message can be acquired after the statistic analysis, which is shown in Table 5.Table 5
The comparison of the measured and theoretical communication delays of the message of the vehicle controller node under OSEK mode with the CAN protocol.
Message ID
Measured average communication delay (ms)
Theoretical average communication delay (ms)
Average communication delay error
Maximum measured communication delay (ms)
ID03
0.76043
0.7692
1.14%
1.6344
ID06
0.76505
0.78827
2.95%
1.6427
ID10
0.86326
0.80728
−6.93%
2.1817
ID15
0.88312
0.81935
−7.78%
3.878


#### 4.2.3. The Testing Results of Communication Delay under the Foreground-Background Mode with the TTCAN Protocol

Figure8 gives out the communication delay of the nonperiodic message, and Figure 9 gives out the communication delays of 3 periodic messages.Figure 8
The communication delay of the nonperiodic message of the vehicle controller node under the foreground-background mode with the TTCAN protocol.The communication delay of the periodic message of the vehicle controller node under foreground-background mode with the TTCAN protocol.
(a)
(b)
(c)For the communication delay of the periodic message shown in Figure9, the sending and receiving delay parts are only disturbed by the sending task of the nonperiodic message inside the node, while the other periodic tasks and the receiving tasks are all finished inside their own region, which have no effect on the sending of periodic messages.According to Figures8 and 9, the average communication delay of each ID message can be acquired after the statistic analysis, which is shown in Table 6.Table 6
The comparison of the measured and theoretical communication delays of the message of the vehicle controller node under foreground-background mode with the TTCAN protocol.
Message ID
Measured average communication delay (ms)
Theoretical average communication delay (ms)
Average communication delay error
Maximum measured communication delay (ms)
ID03
5.2397
5.1803
−1.15%
15.317
ID06
0.6094
0.6174
1.30%
0.6173
ID10
0.6014
0.6094
1.31%
0.6093
ID15
0.5904
0.5984
1.34%
0.5983


#### 4.2.4. The Testing Results of Communication Delay under the OSEK Mode with the TTCAN Protocol

Under the OSEK mode, the sending and receiving of the message are directly controlled by OSEK tasks. Figure10 gives out the communication delay of the nonperiodic message, and Figure 11 gives out the communication delay of the 3 periodic messages.Figure 10
The communication delay of the nonperiodic message of the vehicle controller node under OSEK mode with the TTCAN protocol.The communication delay of the periodic message of the vehicle controller node under OSEK mode with the TTCAN protocol.
(a)
(b)
(c)According to Figures10 and 11, the average communication delay of each ID message can be acquired after the statistic analysis, which is shown in Table 7.Table 7
The comparison of the measured and theoretical communication delays of the message of the vehicle controller node under OSEK mode with the TTCAN protocol.
Message ID
Measured average communication delay (ms)
Theoretical average communication delay (ms)
Average communication delay error
Maximum measured communication delay (ms)
ID03
5.3449
5.213
−2.53%
16.198
ID06
0.6414
0.6494
1.23%
0.6830
ID10
0.6334
0.6414
1.25%
0.6334
ID15
0.6224
0.6304
1.27%
0.6640


### 4.3. The Data Analysis of the Communication Delay

The following analysis results can be acquired according to Tables4 to 7.(1)
According to the measured transmission process of messages, the matrix period and the schedulable analysis proposed in Section4.1.2 are verified to be true. The schedule of messages can be finished.(2)
Under all kinds of the working conditions and modes, the theoretical and the measured results are approaches. The maximal error is just −7.78%, which indicates that the theoretical model is reasonable.(3)
Under the CAN protocol, for the same message no matter it is periodic or nonperiodic, the average communication delay under the OSEK mode is longer than the one under the foreground-background mode. The reason is that the generating delay and the receiving delay (on-chip delay) under the OSEK mode are longer than the ones under the foreground-background mode.(4)
Under the CAN protocol, the longest communication delay of each message under the OSEK mode is not consistently longer than the longest communication delay under the foreground-background mode, which means that the longest communication delay has more randomness than the average communication delay.(5)
Under the TTCAN protocol, for the same message no matter it is periodic or nonperiodic, the communication delay under the OSEK mode is longer than the one under the foreground-background mode. The reason is that the generating delay and the receiving delay (on-chip delay) under the OSEK mode are longer than the ones under the foreground-background mode.(6)
For the periodic message, no matter it is the foreground-background mode or the OSEK mode, the communication delay under the TTCAN protocol is shorter than the one under the CAN protocol. It is mainly because the queue delay of the communication delay under the TTCAN protocol is 0, which makes the integral communication delay decline.(7)
For the nonperiodic message, no matter it is the foreground-background mode or the OSEK mode, the communication delay under the TTCAN protocol is much longer than the one under the CAN protocol. It is mainly because only arbitration window in the network bandwidth allows the sending of the nonperiodic message under the TTCAN protocol. As a result, the exclusive window and the free window enlarge the queue delay of the nonperiodic message and delay the transmission of the nonperiodic message, which causes the increase of the communication delay of nonperiodic messages.The analysis results above are acquired under the conditions that the periodic message and the nonperiodic message are transmitted in the network at the same time and that the working conditions of the sending delay and the receiving delay inside the node under the foreground-background mode and the OSEK mode are considered at the same time.


## 4.1. Experiment Environment

### 4.1.1. Basic Experiment Environment

The bus adopts the CAN and TTCAN transmission protocols, respectively, and interior of the controller nodes adopts the foreground-background mode and the OSEK mode, respectively. The overall communication delay of the powertrain distributed real-time controlling system of a plug-in hybrid electric vehicle under these four working conditions is analyzed. The specific experiment environment is expressed as follows.The bus baud rate of the communication delay testing platform is set to be 250 Kbit/s, and the expanding data frame form is adopted to write communication programs of the 5 nodes shown in Figure1. In order to simplify the analysis process, assumptions of the node program of the vehicle controller are put forward as follows.(1)
The program is divided into 5 tasks, which is used for realizing the transmission of 3 periodic messages and 1 nonperiodic message as well as the receiving of messages.(2)
The controlling strategy related to each task is finished inside the task.(3)
The priority of the receiving tasks of messages in the node is the highest, and the priority of tasks sending from the message equals the priority of the message.Table2 gives out the measured performing time of the 5 tasks of the vehicle controller nodes under the foreground-background mode.Table 2
The individual performing time of tasks under the foreground-background mode.
Description of tasks
Performing time (ms)
Sending message ID03
0.0132
Sending message ID06
0.0352
Sending message ID10
0.0272
Sending message ID15
0.0162
Message receiving
0.0142Table3 gives out the measured performing time of the 5 tasks of the vehicle controller nodes under the OSEK mode.Table 3
The individual performing time of tasks under the OSEK mode.
Description of tasks
Performing time (ms)
Sending message ID03
0.0292
Sending message ID06
0.0512
Sending message ID10
0.0432
Sending message ID15
0.0322
Message receiving
0.0302According to Tables2 and 3, for the same task, the performing time under the OSEK mode is longer than that under the foreground-background mode, which is related to the task scheduling structure inside the OSEK system. And this indicates that load to microcontroller in the OSEK mode is larger than that in the foreground-background mode.


### 4.1.2. The Establishment and the Schedulable Analysis of the TTCAN Matrix Period

When the transmission protocol adopts the TTCAN mode, the matrix period, the basic period, and the width of the time window which means the transmission column width in the matrix period should be determined.Firstly, assume that the matrix includesP lines and Q columns. The transmission column width of a column must guarantee the transmission of a package of whole messages, and, for the expanding frame message, the width is supposed to be
(12)TCWj=maxM0,jMP,j[(67+8sm+⌊54+8sm4⌋)τbit+ρcons].In the previous formula,TCWj is the transmission column width of the column j, and Mi,j is the line i column j of the matrix period.Length of the basic period is usually set as the greatest common divisor of all message periods, while the length of the matrix period is usually set as the least common multiple of all message periods. The calculated matrix period needs a schedulable analysis in order to explain whether the matrix period is enough for scheduling all of the messages or not. Reference [25] puts forward a sort of scheduling algorithm based on the AL (average loading) without considering the effects of nonperiodic messages. Modify the algorithm, and then give out an AL scheduling algorithm which considers periodic messages and nonperiodic messages at the same time.In advance,N is defined to be the number of periodic messages, periodic is set to be T={T1,T2,…,TM}, and M is defined to be the number of the periods. The number of the message whose periodic is Ti among them is ni, 1≤i≤M. V is the number of nonperiodic messages. It is defined that the reaching process of nonperiodic messages is accorded with a Poisson process whose average rate is λ. Then,
(13)N=∑i=1Mni.Let the width of each column in the matrix period be the same, and the widthTCW is
(14)TCW>maxj=1Q(TCWj).Let the basic period be the greatest common divisor (GCD) of the period:(15)TBC=GCD(T1,T2,…,TM).Let the matrix period be the lowest common multiple (LCM) of the period:(16)TMC=LCM(T1,T2,…,TM).The ratioki of the message period and the basic period is
(17)ki=TiTBC.The number of the basic periodsNBC is
(18)NBC=TMCTBC.The number of the time window needed in a basic period is(19)Si=Si-1+⌈niki⌉+⌈VλTBC⌉.LetS0 be equal to 0; the largest message number which could be transmitted in a basic period is
(20)γmax=(TBC-TRM)TCW.In the previous formula,TRM is the length of the time window of referential message.If the schedulable condition is satisfied:(21)SM≤γmax,
then we can reach a conclusion that the message can be scheduled. According to this, the qualified matrix period can be established.For the messages sent by each node of the powertrain of a plug-in hybrid electric vehicle which is defined in Table1, according to (12), TCWj=0.64 can be get and then substitute it to (14), and TCW=1. According to (15), TBC=10, and, according to (16), TMC=80. According to (18), NBC=8, and, according to (19), S4=9. Let TRM=1, according to (20), γmax=9. Therefore, the conditions of (21) are met, and then a conclusion can be reached that the message can be scheduled, and the matrix period established is shown in Figure 3.Figure 3
The matrix period of the plug-in powertrain of the TTCAN protocol.In Figure3, AW stands for the arbitration window, and FW stands for the free window. The matrix period includes 8 basic periods, and the length of each basic period is 10 ms, so the length of the matrix period is 80 ms. Moreover, the width of each column is the same, which is 1 ms. Nonperiodic messages ID1~ID5 are transmitted in the arbitration window.


### 4.1.3. The On-Chip and On-Line Combined Scheduling of the Periodic Message under the TTCAN Mode

For the periodic message, the transmission under the TTCAN mode needs the cooperation of the interior scheduling of the node and the window scheduling on the bus.The periodic messageF is sent from window Mi,j of the matrix period, that is, when the message is sent from line i column j of the matrix period. The beginning moment of window Mi,j is defined as IMi,j; then, inside the node, the best beginning moment ITF of task TF that is, sending periodic message F is defined, which means the phase of task TF. It is shown as follows:
(22)ITF=IMi,j-rTFp.In the previous formula,rTFp is the worst performing time of task TF.The cooperation of the trigger phase of the sending task and the transmission window of the corresponding message on the bus can be realized by the overall time stamp provided by the reference message. According to the trigger phaseTF defined by (22), on one hand, it could guarantee that the data could be written into the cache before the sending window of the periodic message F reaching; on the other hand, it could guarantee that the data written in the sending cache are the newest data.


## 4.1.1. Basic Experiment Environment

The bus adopts the CAN and TTCAN transmission protocols, respectively, and interior of the controller nodes adopts the foreground-background mode and the OSEK mode, respectively. The overall communication delay of the powertrain distributed real-time controlling system of a plug-in hybrid electric vehicle under these four working conditions is analyzed. The specific experiment environment is expressed as follows.The bus baud rate of the communication delay testing platform is set to be 250 Kbit/s, and the expanding data frame form is adopted to write communication programs of the 5 nodes shown in Figure1. In order to simplify the analysis process, assumptions of the node program of the vehicle controller are put forward as follows.(1)
The program is divided into 5 tasks, which is used for realizing the transmission of 3 periodic messages and 1 nonperiodic message as well as the receiving of messages.(2)
The controlling strategy related to each task is finished inside the task.(3)
The priority of the receiving tasks of messages in the node is the highest, and the priority of tasks sending from the message equals the priority of the message.Table2 gives out the measured performing time of the 5 tasks of the vehicle controller nodes under the foreground-background mode.Table 2
The individual performing time of tasks under the foreground-background mode.
Description of tasks
Performing time (ms)
Sending message ID03
0.0132
Sending message ID06
0.0352
Sending message ID10
0.0272
Sending message ID15
0.0162
Message receiving
0.0142Table3 gives out the measured performing time of the 5 tasks of the vehicle controller nodes under the OSEK mode.Table 3
The individual performing time of tasks under the OSEK mode.
Description of tasks
Performing time (ms)
Sending message ID03
0.0292
Sending message ID06
0.0512
Sending message ID10
0.0432
Sending message ID15
0.0322
Message receiving
0.0302According to Tables2 and 3, for the same task, the performing time under the OSEK mode is longer than that under the foreground-background mode, which is related to the task scheduling structure inside the OSEK system. And this indicates that load to microcontroller in the OSEK mode is larger than that in the foreground-background mode.


## 4.1.2. The Establishment and the Schedulable Analysis of the TTCAN Matrix Period

When the transmission protocol adopts the TTCAN mode, the matrix period, the basic period, and the width of the time window which means the transmission column width in the matrix period should be determined.Firstly, assume that the matrix includesP lines and Q columns. The transmission column width of a column must guarantee the transmission of a package of whole messages, and, for the expanding frame message, the width is supposed to be
(12)TCWj=maxM0,jMP,j[(67+8sm+⌊54+8sm4⌋)τbit+ρcons].In the previous formula,TCWj is the transmission column width of the column j, and Mi,j is the line i column j of the matrix period.Length of the basic period is usually set as the greatest common divisor of all message periods, while the length of the matrix period is usually set as the least common multiple of all message periods. The calculated matrix period needs a schedulable analysis in order to explain whether the matrix period is enough for scheduling all of the messages or not. Reference [25] puts forward a sort of scheduling algorithm based on the AL (average loading) without considering the effects of nonperiodic messages. Modify the algorithm, and then give out an AL scheduling algorithm which considers periodic messages and nonperiodic messages at the same time.In advance,N is defined to be the number of periodic messages, periodic is set to be T={T1,T2,…,TM}, and M is defined to be the number of the periods. The number of the message whose periodic is Ti among them is ni, 1≤i≤M. V is the number of nonperiodic messages. It is defined that the reaching process of nonperiodic messages is accorded with a Poisson process whose average rate is λ. Then,
(13)N=∑i=1Mni.Let the width of each column in the matrix period be the same, and the widthTCW is
(14)TCW>maxj=1Q(TCWj).Let the basic period be the greatest common divisor (GCD) of the period:(15)TBC=GCD(T1,T2,…,TM).Let the matrix period be the lowest common multiple (LCM) of the period:(16)TMC=LCM(T1,T2,…,TM).The ratioki of the message period and the basic period is
(17)ki=TiTBC.The number of the basic periodsNBC is
(18)NBC=TMCTBC.The number of the time window needed in a basic period is(19)Si=Si-1+⌈niki⌉+⌈VλTBC⌉.LetS0 be equal to 0; the largest message number which could be transmitted in a basic period is
(20)γmax=(TBC-TRM)TCW.In the previous formula,TRM is the length of the time window of referential message.If the schedulable condition is satisfied:(21)SM≤γmax,
then we can reach a conclusion that the message can be scheduled. According to this, the qualified matrix period can be established.For the messages sent by each node of the powertrain of a plug-in hybrid electric vehicle which is defined in Table1, according to (12), TCWj=0.64 can be get and then substitute it to (14), and TCW=1. According to (15), TBC=10, and, according to (16), TMC=80. According to (18), NBC=8, and, according to (19), S4=9. Let TRM=1, according to (20), γmax=9. Therefore, the conditions of (21) are met, and then a conclusion can be reached that the message can be scheduled, and the matrix period established is shown in Figure 3.Figure 3
The matrix period of the plug-in powertrain of the TTCAN protocol.In Figure3, AW stands for the arbitration window, and FW stands for the free window. The matrix period includes 8 basic periods, and the length of each basic period is 10 ms, so the length of the matrix period is 80 ms. Moreover, the width of each column is the same, which is 1 ms. Nonperiodic messages ID1~ID5 are transmitted in the arbitration window.


## 4.1.3. The On-Chip and On-Line Combined Scheduling of the Periodic Message under the TTCAN Mode

For the periodic message, the transmission under the TTCAN mode needs the cooperation of the interior scheduling of the node and the window scheduling on the bus.The periodic messageF is sent from window Mi,j of the matrix period, that is, when the message is sent from line i column j of the matrix period. The beginning moment of window Mi,j is defined as IMi,j; then, inside the node, the best beginning moment ITF of task TF that is, sending periodic message F is defined, which means the phase of task TF. It is shown as follows:
(22)ITF=IMi,j-rTFp.In the previous formula,rTFp is the worst performing time of task TF.The cooperation of the trigger phase of the sending task and the transmission window of the corresponding message on the bus can be realized by the overall time stamp provided by the reference message. According to the trigger phaseTF defined by (22), on one hand, it could guarantee that the data could be written into the cache before the sending window of the periodic message F reaching; on the other hand, it could guarantee that the data written in the sending cache are the newest data.


## 4.2. Testing Results

Then, the tests of the communication delay of the powertrain of a plug-in hybrid electric vehicle are conducted in 4 working conditions separately, which are the following: testing under the CAN communication protocol while the controller interior adopts the foreground-background mode; testing under the CAN communication protocol while the controller interior adopts the OSEK mode; testing under the TTCAN communication protocol while the controller interior adopts the foreground-background mode; testing under the TTCAN communication protocol while the controller interior adopts the OSEK mode.


### 4.2.1. The Testing Results of Communication Delay under the Foreground-Background Mode with the CAN Protocol

Under the foreground-background mode, 3 timer interruptions control the sending of 3 periodic CAN messages, an exterior triggered interruption controls the sending of a nonperiodic CAN message, and a CAN receiving interruption controls the real-time receiving of the CAN message. Figure4 gives out the communication delay of the nonperiodic message, and Figure 5 gives out the communication delays of the 3 periodic messages under this mode. The communication delay is the delay summation of the four parts including generating, queue, transmission, and receiving.Figure 4
The communication delay of the nonperiodic message under the foreground-background mode with CAN protocol.The communication delay of the periodic message under the foreground-background mode with CAN protocol.
(a)
(b)
(c)According to Figures4 and 5, the average communication delay of each ID message can be acquired after the statistic analysis, which is shown in Table 4.Table 4
The comparison of the measured and theoretical communication delays of the message of the vehicle controller node under foreground-background mode with the CAN protocol.
Message ID
Measured average communication delay (ms)
Theoretical average communication delay (ms)
Average communication delay error
Maximum measured communication delay (ms)
ID03
0.75585
0.73658
−2.62%
1.4599
ID06
0.73184
0.75523
3.10%
1.4097
ID10
0.80478
0.77407
−3.97%
2.3594
ID15
0.79332
0.78634
−0.89%
3.9359


### 4.2.2. The Testing Results of Communication Delay under the OSEK Mode with the CAN Protocol

Under the OSEK mode, the sending and receiving of the message are directly controlled by OSEK tasks. The communication delay of nonperiodic messages is shown in Figure6, and the communication delays of the 3 periodic messages are shown in Figure 7.Figure 6
The communication delay of the nonperiodic message of the vehicle controller node under the OSEK mode with the CAN protocol.The communication delay of the periodic message of the vehicle controller node under the OSEK mode with the CAN protocol.
(a)
(b)
(c)According to Figures6 and 7, the average communication delay of each ID message can be acquired after the statistic analysis, which is shown in Table 5.Table 5
The comparison of the measured and theoretical communication delays of the message of the vehicle controller node under OSEK mode with the CAN protocol.
Message ID
Measured average communication delay (ms)
Theoretical average communication delay (ms)
Average communication delay error
Maximum measured communication delay (ms)
ID03
0.76043
0.7692
1.14%
1.6344
ID06
0.76505
0.78827
2.95%
1.6427
ID10
0.86326
0.80728
−6.93%
2.1817
ID15
0.88312
0.81935
−7.78%
3.878


### 4.2.3. The Testing Results of Communication Delay under the Foreground-Background Mode with the TTCAN Protocol

Figure8 gives out the communication delay of the nonperiodic message, and Figure 9 gives out the communication delays of 3 periodic messages.Figure 8
The communication delay of the nonperiodic message of the vehicle controller node under the foreground-background mode with the TTCAN protocol.The communication delay of the periodic message of the vehicle controller node under foreground-background mode with the TTCAN protocol.
(a)
(b)
(c)For the communication delay of the periodic message shown in Figure9, the sending and receiving delay parts are only disturbed by the sending task of the nonperiodic message inside the node, while the other periodic tasks and the receiving tasks are all finished inside their own region, which have no effect on the sending of periodic messages.According to Figures8 and 9, the average communication delay of each ID message can be acquired after the statistic analysis, which is shown in Table 6.Table 6
The comparison of the measured and theoretical communication delays of the message of the vehicle controller node under foreground-background mode with the TTCAN protocol.
Message ID
Measured average communication delay (ms)
Theoretical average communication delay (ms)
Average communication delay error
Maximum measured communication delay (ms)
ID03
5.2397
5.1803
−1.15%
15.317
ID06
0.6094
0.6174
1.30%
0.6173
ID10
0.6014
0.6094
1.31%
0.6093
ID15
0.5904
0.5984
1.34%
0.5983


### 4.2.4. The Testing Results of Communication Delay under the OSEK Mode with the TTCAN Protocol

Under the OSEK mode, the sending and receiving of the message are directly controlled by OSEK tasks. Figure10 gives out the communication delay of the nonperiodic message, and Figure 11 gives out the communication delay of the 3 periodic messages.Figure 10
The communication delay of the nonperiodic message of the vehicle controller node under OSEK mode with the TTCAN protocol.The communication delay of the periodic message of the vehicle controller node under OSEK mode with the TTCAN protocol.
(a)
(b)
(c)According to Figures10 and 11, the average communication delay of each ID message can be acquired after the statistic analysis, which is shown in Table 7.Table 7
The comparison of the measured and theoretical communication delays of the message of the vehicle controller node under OSEK mode with the TTCAN protocol.
Message ID
Measured average communication delay (ms)
Theoretical average communication delay (ms)
Average communication delay error
Maximum measured communication delay (ms)
ID03
5.3449
5.213
−2.53%
16.198
ID06
0.6414
0.6494
1.23%
0.6830
ID10
0.6334
0.6414
1.25%
0.6334
ID15
0.6224
0.6304
1.27%
0.6640


## 4.2.1. The Testing Results of Communication Delay under the Foreground-Background Mode with the CAN Protocol

Under the foreground-background mode, 3 timer interruptions control the sending of 3 periodic CAN messages, an exterior triggered interruption controls the sending of a nonperiodic CAN message, and a CAN receiving interruption controls the real-time receiving of the CAN message. Figure4 gives out the communication delay of the nonperiodic message, and Figure 5 gives out the communication delays of the 3 periodic messages under this mode. The communication delay is the delay summation of the four parts including generating, queue, transmission, and receiving.Figure 4
The communication delay of the nonperiodic message under the foreground-background mode with CAN protocol.The communication delay of the periodic message under the foreground-background mode with CAN protocol.
(a)
(b)
(c)According to Figures4 and 5, the average communication delay of each ID message can be acquired after the statistic analysis, which is shown in Table 4.Table 4
The comparison of the measured and theoretical communication delays of the message of the vehicle controller node under foreground-background mode with the CAN protocol.
Message ID
Measured average communication delay (ms)
Theoretical average communication delay (ms)
Average communication delay error
Maximum measured communication delay (ms)
ID03
0.75585
0.73658
−2.62%
1.4599
ID06
0.73184
0.75523
3.10%
1.4097
ID10
0.80478
0.77407
−3.97%
2.3594
ID15
0.79332
0.78634
−0.89%
3.9359


## 4.2.2. The Testing Results of Communication Delay under the OSEK Mode with the CAN Protocol

Under the OSEK mode, the sending and receiving of the message are directly controlled by OSEK tasks. The communication delay of nonperiodic messages is shown in Figure6, and the communication delays of the 3 periodic messages are shown in Figure 7.Figure 6
The communication delay of the nonperiodic message of the vehicle controller node under the OSEK mode with the CAN protocol.The communication delay of the periodic message of the vehicle controller node under the OSEK mode with the CAN protocol.
(a)
(b)
(c)According to Figures6 and 7, the average communication delay of each ID message can be acquired after the statistic analysis, which is shown in Table 5.Table 5
The comparison of the measured and theoretical communication delays of the message of the vehicle controller node under OSEK mode with the CAN protocol.
Message ID
Measured average communication delay (ms)
Theoretical average communication delay (ms)
Average communication delay error
Maximum measured communication delay (ms)
ID03
0.76043
0.7692
1.14%
1.6344
ID06
0.76505
0.78827
2.95%
1.6427
ID10
0.86326
0.80728
−6.93%
2.1817
ID15
0.88312
0.81935
−7.78%
3.878


## 4.2.3. The Testing Results of Communication Delay under the Foreground-Background Mode with the TTCAN Protocol

Figure8 gives out the communication delay of the nonperiodic message, and Figure 9 gives out the communication delays of 3 periodic messages.Figure 8
The communication delay of the nonperiodic message of the vehicle controller node under the foreground-background mode with the TTCAN protocol.The communication delay of the periodic message of the vehicle controller node under foreground-background mode with the TTCAN protocol.
(a)
(b)
(c)For the communication delay of the periodic message shown in Figure9, the sending and receiving delay parts are only disturbed by the sending task of the nonperiodic message inside the node, while the other periodic tasks and the receiving tasks are all finished inside their own region, which have no effect on the sending of periodic messages.According to Figures8 and 9, the average communication delay of each ID message can be acquired after the statistic analysis, which is shown in Table 6.Table 6
The comparison of the measured and theoretical communication delays of the message of the vehicle controller node under foreground-background mode with the TTCAN protocol.
Message ID
Measured average communication delay (ms)
Theoretical average communication delay (ms)
Average communication delay error
Maximum measured communication delay (ms)
ID03
5.2397
5.1803
−1.15%
15.317
ID06
0.6094
0.6174
1.30%
0.6173
ID10
0.6014
0.6094
1.31%
0.6093
ID15
0.5904
0.5984
1.34%
0.5983


## 4.2.4. The Testing Results of Communication Delay under the OSEK Mode with the TTCAN Protocol

Under the OSEK mode, the sending and receiving of the message are directly controlled by OSEK tasks. Figure10 gives out the communication delay of the nonperiodic message, and Figure 11 gives out the communication delay of the 3 periodic messages.Figure 10
The communication delay of the nonperiodic message of the vehicle controller node under OSEK mode with the TTCAN protocol.The communication delay of the periodic message of the vehicle controller node under OSEK mode with the TTCAN protocol.
(a)
(b)
(c)According to Figures10 and 11, the average communication delay of each ID message can be acquired after the statistic analysis, which is shown in Table 7.Table 7
The comparison of the measured and theoretical communication delays of the message of the vehicle controller node under OSEK mode with the TTCAN protocol.
Message ID
Measured average communication delay (ms)
Theoretical average communication delay (ms)
Average communication delay error
Maximum measured communication delay (ms)
ID03
5.3449
5.213
−2.53%
16.198
ID06
0.6414
0.6494
1.23%
0.6830
ID10
0.6334
0.6414
1.25%
0.6334
ID15
0.6224
0.6304
1.27%
0.6640


## 4.3. The Data Analysis of the Communication Delay

The following analysis results can be acquired according to Tables4 to 7.(1)
According to the measured transmission process of messages, the matrix period and the schedulable analysis proposed in Section4.1.2 are verified to be true. The schedule of messages can be finished.(2)
Under all kinds of the working conditions and modes, the theoretical and the measured results are approaches. The maximal error is just −7.78%, which indicates that the theoretical model is reasonable.(3)
Under the CAN protocol, for the same message no matter it is periodic or nonperiodic, the average communication delay under the OSEK mode is longer than the one under the foreground-background mode. The reason is that the generating delay and the receiving delay (on-chip delay) under the OSEK mode are longer than the ones under the foreground-background mode.(4)
Under the CAN protocol, the longest communication delay of each message under the OSEK mode is not consistently longer than the longest communication delay under the foreground-background mode, which means that the longest communication delay has more randomness than the average communication delay.(5)
Under the TTCAN protocol, for the same message no matter it is periodic or nonperiodic, the communication delay under the OSEK mode is longer than the one under the foreground-background mode. The reason is that the generating delay and the receiving delay (on-chip delay) under the OSEK mode are longer than the ones under the foreground-background mode.(6)
For the periodic message, no matter it is the foreground-background mode or the OSEK mode, the communication delay under the TTCAN protocol is shorter than the one under the CAN protocol. It is mainly because the queue delay of the communication delay under the TTCAN protocol is 0, which makes the integral communication delay decline.(7)
For the nonperiodic message, no matter it is the foreground-background mode or the OSEK mode, the communication delay under the TTCAN protocol is much longer than the one under the CAN protocol. It is mainly because only arbitration window in the network bandwidth allows the sending of the nonperiodic message under the TTCAN protocol. As a result, the exclusive window and the free window enlarge the queue delay of the nonperiodic message and delay the transmission of the nonperiodic message, which causes the increase of the communication delay of nonperiodic messages.The analysis results above are acquired under the conditions that the periodic message and the nonperiodic message are transmitted in the network at the same time and that the working conditions of the sending delay and the receiving delay inside the node under the foreground-background mode and the OSEK mode are considered at the same time.


## 5. Conclusion

Regarding the powertrain network system of a plug-in hybrid electric vehicle as the studying target, the communication delay of the message is tested. Firstly, the topological structure and the definition of the parameter set of each node of the powertrain system of this plug-in hybrid electric vehicle are given out. The bus is established adopting the CAN protocol and the TTCAN protocol, respectively, and the delay model of the foreground-background mode and the OSEK mode systems are adopted inside the node. The schedulable rules under the TTCAN protocol based on the average loading arithmetic which takes the periodic message and the nonperiodic one into consideration at the same time are established. According to the rules, the matrix period of message transmission in the powertrain system of a plug-in hybrid electric vehicle is established as well. Through the measured message transmission process, it could be acquired that the matrix period is enough to finish the schedule of messages, verifying the accuracy of the scheduling algorithm. The on-chip and on-line united scheduling problem of the periodic message under the TTCAN mode is analyzed, and the best on-chip phase of the sending task of the periodic message is defined. Then, the communication delay of the message is tested under the foreground-background mode and the OSEK mode, using the CAN and TTCAN as the transmission protocol, respectively. In the 4 working conditions above, after analyzing the test data, it could be concluded that the communication delay time of the OSEK mode is a little longer than the one of the foreground-background mode in the same condition. The real-time performance of the periodic message under the TTCAN protocol is better than the one under the CAN protocol, while the real-time performance of the nonperiodic message is worse than the one under the CAN protocol. The data of the measured average communication delay is very similar to the theoretical one, and the maximal error is just −7.78%, which means that the theoretical model is reliable.



---

*Source: 758961-2013-11-27.xml*