How to build your own CAN-bus application layer protocol

How to build your own CAN-bus application layer protocol

With the decline in the price of CAN-bus related chips and the increase in MCUs with built-in CAN controllers, CAN-bus has now entered many fields that could not be used in the early days due to cost issues, and has become a field bus with great vitality. Today we will discuss how to build your own CAN-bus application layer protocol.

On the CAN-bus network, CAN messages are sent in the form of broadcasts. CAN messages do not contain address information. Whether to process the received CAN message is determined by the software at the receiving point. CAN-bus only provides reliable message transmission services. The use of CAN messages is defined by the user. Therefore, a unified rule must be established for nodes in the CAN network to communicate with each other. The CAN application layer protocol is such a rule.

[[190861]]

This rule defines the use of frame ID and frame data in CAN messages, such as defining frame ID as the address of the CAN node that needs to process the frame data. Depending on the application scenario, a variety of CAN application layer protocols have emerged internationally. The common CAN-bus application layer protocols are as follows:

Next, let's take a look at how to build the CAN-bus application layer protocol

To build a fieldbus network, the key technical issues that need to be solved are:

The speed, capacity, priority, node capacity, etc. of bus transmission information;

Reliable data transmission in high electromagnetic interference environments;

***Determination of the delay size during transmission distance;

Network fault tolerance technology;

Network monitoring and fault diagnosis functions.

To solve the above problems, it is necessary to fully consider the bus type used by the fieldbus network, because the above problems are closely related to the performance characteristics of the bus, so let's take a look at the above characteristics of the CAN-bus bus:

The CAN-bus network transmission speed can reach up to 1Mbps, and it adopts lossless arbitration, indicating the message priority through the message identifier;

CAN-bus uses differential signal transmission and reliable data verification and error detection mechanisms;

CAN-bus uses frame transmission, and each message is allowed to transmit up to 8 bytes. The frame structure has strict regulations and can determine the maximum transmission delay;

CAN-bus has reliable error and detection mechanisms. The information sent can be resent after being damaged. In the case of serious errors, the node has the function of automatically exiting the bus.

Network monitoring and diagnosis can be solved by formulating a strict CAN-bus application layer protocol.

CAN message allocation

It includes the allocation of message identifiers and message data, and the definition of message formats, which essentially describes the allocation rules of CAN messages in detail.

Definition of message ID:

CAN2.0A frame: 11-bit ID

CAN2.0B frame, 29-bit ID

Definition of message data: Each frame message contains up to 8 bytes of data

Implementation of CAN Network Data Communication

In the CAN network, information is distinguished by the identifier of the message, so the purpose of establishing information links is achieved by allocating various identifiers to the message.

CAN application layer protocol: node-oriented and message-oriented protocol

Data communication protocols can basically be divided into two types: "node-oriented protocols" and "message-oriented protocols", as shown in the following figure:

Develop a CAN application layer protocol

In order to demonstrate to readers how to develop and use the CAN application layer protocol, a simple CAN application protocol stack is defined below. This protocol stack only uses the data frame in the CAN standard frame. The allocation and use of the 11 bits in the frame ID are listed in the following table. The protocol also defines the function parameter array FunData with a function parameter length variable FunDataLen. This array can provide sufficient control parameters for certain specific function functions when needed.

<<:  Live broadcast and fan interaction is popular! Yunfan Accelerator will show you the live broadcast and microphone technology behind it

>>:  Comparative analysis of three types of CDN vendors: Technologically innovative ones lead the way

Recommend

How can we enable ordinary people to use 5G effectively?

In the vigorous wave of 5G construction, my count...

ITU releases draft specification, a big step forward in 5G standardization

According to foreign media reports, despite the o...

Ruijie Cloud Desktop supports Beijing's COVID-19 fight

Imported from abroad, confirmed locally, the sudd...

Share: Construction skills of integrated wiring system

In the process of implementing the integrated wir...

Why Wired Ethernet Connections Still Make Sense Today

Ethernet is faster, more reliable, and more secur...

Master port isolation technology to make the network more secure

Currently, Ethernet technology is widely used in ...

How to Cut an Oxen - Illustrated MySQL 8.0 Optimizer Query Parsing

[[423739]] 1. Background and Architecture We all ...

What are LACP and PAGP? What are the differences?

In order to create maximum availability and stabi...

Practical tips: Teach you step by step to solve the problem of WiFi interference

Suppose there is a large classroom that can accom...

The next corner of the Internet of Things is not love, but 5G

This year, CCTV Spring Festival Gala *** achieved...

Analysis of SpringCloud Gateway routing configuration and positioning principles

[[409660]] Environment: springcloud Hoxton.SR11 T...

After unplugging the network cable, does the original TCP connection still exist?

Hello everyone, I am Xiaolin. Today, let’s talk a...