Statistical based algorithm for reducing bit stuffing in the Controller Area Networks

https://doi.org/10.1016/j.mejo.2020.104794Get rights and content

Abstract

One of the problems with the Controller Area Network is jitter of response time because of the bit-stuffing mechanism. In real-time cases where timing accuracy is important, jitter may deteriorate the quality of the control procedure noticeably. A new method based on XOR masking, named Statistical Mask Calculation (SMC), is presented in this study. The method uses the statistical parameters of data to generate a proper mask for each case. The performance of the proposed method on the reduction of the number of stuff bits is evaluated by considering real data set and a comparison with existing original XOR masking is done. The results indicate that applying the proposed method on the case study increases the probability of zero bit stuffing up to 46% compared to the original XOR mask. It should be noted that the proposed technique is more effective for systems that are usually predictable. Therefore, the adaption of this technique depends on the required application.

Introduction

Over the recent years, due to the fast progression of real-time system applications, the necessity of communication policy that can satisfy real-time message transmission has been significantly increased. Controller Area Network is a serial communication bus developed by “Robert Bosch Gmbh” for the first time in a motor vehicle [[1], [2], [3]]. Although the CAN bus network was firstly introduced for application in automotive industries, it has received wide attention in industrial automation and other real-time control applications because of its low cost, high reliability, robustness and its desirable features in noisy environments [[4], [5], [6], [7], [8], [9], [10], [11], [12]].

Predictable timing behavior is one of the key factors in real-time systems [13,14]. “Bit Stuffing” mechanism, which is used in CAN for clock synchronization, and removing bit-patterns which is used in CAN for error signaling, makes it difficult to predict the precise transmission time of messages. Due to bit stuffing, the message length of CAN 2.0A may vary between 0 and 24 bits. This variation of frame length leads to the variation of transmission time which is known as jitter [[15], [16], [17], [18]]. For example, in the case of transmitting an 8-byte data payload through CAN 2.0A, the minimum message length (corresponding to no bit stuffing is 111 bits, whereas the maximum message length (corresponding to the worst-case level of bit stuffing) is 135 bits [1]. Thus, approximately 22% variation in the total length of messages is observed. When translated to the jitter, a jitter in the order of 24 ​μs ​at the maximum CAN baud rate (1 Mbit/s), and a jitter of 0.2 ​ms for the commonly used baud rate of 125 Kbit/s is expected. The presence of jitter can adversely affect the performance of most of the distributed embedded systems such as embedded systems for periodic data acquisition [16]. It was shown that a jitter rate greater than 10% of the task period, has significant adverse effects on the data acquisition tasks [19].

It should be mentioned that bit stuffing is not the only source of the unpredictability of timing behavior of systems. Some other possible sources of jitter in CAN-based control networks and proposed solutions to bound such jitter types are discussed in Ref. [6]. However, this study is focused on the jitter caused by bit stuffing.

Several studies have been carried out to explore techniques for bounding the jitter related to bit stuffing. Some of these techniques such as Software Bit Stuffing (SBS) [15], inversion bit stuffing mechanism (IBSM) [20], third-bit complement (TBC) [21], 8B9B encoding [22], and Eight-to-Eleven Modulation (EEM) [23] are able to prevent the occurrence of stuff bits in the data field completely by using suitable encoding schemes but these approaches cause message payload reduction. In SBS data encoding, the sequence of bits in every given frame is checked before transmission. If four sequential bits are identical, the algorithm adds an opposite additional bit afterward. In the IBSM algorithm, the data field of message is checked byte by byte, and if five consecutive identical bits are found, the fifth bit will be inverted (11111 ​→ ​11110 or 00000 ​→ ​00001). In this approach one byte is reserved as a flag. As a result, seven bytes remain to be used for data. In TBC algorithm, after every three bits, complement of the third bit is inserted to avoid bit stuffing. 8B9B encodes each byte of the original payload separately, replacing it with a pattern of 9 bits using a specified lookup table. In this technique, the maximum payload is 7 bytes. EEM encodes every byte in the original payload to an 11-bit pattern. EEM inserts invert of first, fourth and seventh bits after each of them. Table 1 shows the maximum payload of each method.

XOR masking is another method that is used to reduce the number of stuff bits without restricting the message payload [24,25]. In this method, the data field of each CAN frame is XOR-ed with the binary bit-pattern 101010…. The receiver extracts the original data by applying the same bit-operation. Because of the ability of the XOR masking method to reduce bit stuffing without imposing a large computational overhead or memory usage, improvement of this method has become an attractive field of study [24,26]. For example in Ref. [26], two new methods named Nolte B and Nolte C are proposed based on XOR masking. In the Nolte B method, the data set is tested frame-by-frame and the XOR operation is applied if bit stuffing occurs. In Nolte C, each frame is tested byte-by-byte and the XOR operation is applied to a particular byte if bit stuffing occurs. In Ref. [24] XOR masking and carefully selecting identifier methods are combined in order to significantly reduce the variation of the frame length of CAN messages. To the best of our knowledge, until now, the only method, based on XOR masking, reported in Refs. [27] named MXOR does not reduce payload, which check byte by byte and XOR with mask.

In this study, a new method, which is named as Statistical Mask Calculation (SMC) is introduced. The proposed method enhances XOR masking approach using statistical data parameters. In fact, in XOR masking, the mask pattern is fixed for all messages which leads to an increment in bit stuffing when adjacent bits of data have a lot of changes relative to each other. In contrast, in the proposed method, a proper mask (using statistical parameters of data) is generated for each ID. Fig. 1 depicts the way of applying SMC mask to data filed of CAN bus messages.

The rest of the paper is structured as follows. Section 2 introduces an overview on CAN protocol. The bit stuffing mechanism is described in section 3. The proposed method is elaborated in section 4. For validation purposes, the proposed method is applied to a real system and the experimental results are presented in section 5. Section 6 concludes the study.

Section snippets

Controller area network

CAN is a multi-master broadcast bus designed for short message transmission. It is governed by ISO-11898 (high-speed up to 1Mbps) and ISO-11519 (low-speed up to 125kbps). Each message has a unique identifier (11 bits for CAN 2.0A and 29 bits for CAN 2.0 ​B) according to which it gains access to the bus. Besides the identifier, a CAN frame contains 4 bits DLC (shows number of data bytes), data field between 0 and 8 bytes, 25 bits for the control of transmission, error checking in the Cyclic

Bit-stuffing mechanism

In CAN, six consecutive bits of the same polarity (111111 or 000000) is used for error and protocol control signaling. To avoid these special bit patterns in transmitted frames, CAN protocol standard allows only 5 consecutive bits of the same polarity between the Start of Frame and the CRC field of a message frame. The station which sends bits adds a bit of opposite polarity (stuff bit) after five consecutive bits of the same polarity before transmission and the receiver eliminates the “stuff

Method

The proposed SMC method is based on the XOR technique. The basic idea of XOR-masking is to remove identical consecutive bits (111 … or 000…) to prevent bit stuffing. For this purpose, transmitted frames are XOR-ed with the bit-pattern 101010 … (XOR a bit with 1 flips the bit and XOR with 0 remains the bit unchanged). In the XOR masking method, a fixed mask is always applied to data. However, applying XOR mask to parts of data, in which adjacent bits have a lot of changes relative to each other,

Experimental results

In order to validate the proposed method in real applications, samples were taken from a set of messages, which are transmitted through CAN network between six different subsystems of a prototype drone are used. The six subsystems are: battery (‘Battery’), Accelerometer (‘Acc’), Gyroscope (‘Gyro’), Magnetometer (‘Mag’), Pressure and Temperature sensors (‘Pressure & Temp’), and tilt Angle sensor (‘Angle’) of the drone. All messages are periodic. Fig. 6 specifics the requirements of the messages

Conclusions

Predictable timing behavior is one of the key factors in real-time systems. variations in the frame length due to bit stuffing makes it difficult to predict the precise transmission time of messages. several approaches have been reported to reduce bit stuffing but all of them reduce message payload. This work has developed a novel method based on XOR masking to reduce bit stuffing without payload reduction. Unlike the conventional XOR masking method, which uses a fixed mask for all messages,

Declaration of competing interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

References (27)

  • F.G. Tinetti et al.

    CAN bus experiments of real-time communications

  • C.A.G. Ferreira

    A hydraulic-pump speed controller in agricultural sprayers based on the automation and use of the control area network (CAN) bus. in Semantic Computing (ICSC)

  • Y. Liu

    Improved robust speed tracking controller design for an integrated motor-transmission powertrain system over controller area network

    IEEE ASME Trans. Mechatron.

    (2018)
  • View full text