Explain the cyclic redundancy check (CRC) method in CAN and CAN FD communication in detail

Data verification is a verification operation to ensure the integrity of the data. CAN communication adopts CRC check as an important error detection method, which is the basis for nodes to judge the integrity of CAN frame information and generate confirmation responses.

Abstract: Data verification is a verification operation to ensure the integrity of the data. CAN communication adopts CRC check as an important error detection method, which is the basis for nodes to judge the integrity of CAN frame information and generate confirmation responses.

In the actual application of fieldbus communication and control, the industrial application environment is often extreme temperature and electromagnetic noise or other harsh environments. It is very important that the system can work normally under this condition. Just imagine if the production line equipment sends Errors occurred during the transmission of location information, which may cause production paralysis, or equipment damage or even personal injury.

In the CAN bus communication process, the CAN controller has complete error detection capabilities, including: bit error detection, format error detection, filling error detection, response error detection and CRC error detection. As an important error detection method, CRC error detection is the basis for the receiving node to judge the integrity of CAN frame information and acknowledge the response to the bus.

1. Common verification methods

1. The simplest verification is to actively read back the data after sending it, and the result is consistent before confirming that the transmission is successful. Obviously this method of transmission and communication is very intuitive and very accurate, but the readback operation doubles the amount of data transmission. That is, transmission requires high bandwidth and low efficiency;

2. Parity check is the use of an extra bit in the transmission to record whether the number of 1s in the binary number of the transmitted data is odd or even. This scheme is suitable for most hardware and has moderate transmission overhead, so it is widely used, such as the common Serial communication;

3. Accumulation and verification. The principle of this algorithm is to accumulate the data one by one to get a value. The receiver also accumulates the data while receiving the data and finally compares it with the accumulated sum sent. The algorithm is simple to calculate, no matter in Hardware or software implementation can ensure high efficiency, and is often used for low-speed serial data communication check and chip code integrity judgment;

4. CRC check, the algorithm is based on the result of a polynomial division and the remainder. It has dozens of versions according to the number of bits and the change of the polynomial. With its simple hardware implementation, strong bit reversal error detection capability and moderate computational overhead The advantages are widely used in the fields of digital network transmission and data storage, such as disk data verification, USB, GSM/CDMA communication, and the compression/decompression data integrity check of RAR and ZIP files that are often encountered in computer applications. algorithm;

5. MD5 and SHA represent information digest verification. The data digest algorithm is also called Hash algorithm or hash algorithm. The digest algorithm is used in situations where the amount of data is relatively large. It extracts fingerprint information from all data to achieve data signatures, data integrity verification and other functions. Due to its irreversibility, it is sometimes used to encrypt sensitive information, such as the content protection of software registration authorization files, and often Large files downloaded from the Internet (for example, ISO images up to GB level) usually carry MD5, SHA1 and other information to facilitate users to check the integrity of the transmitted data.

2. CRC check in CAN frame

1. The position of the CRC domain in the CAN frame

Explain the cyclic redundancy check (CRC) method in CAN and CAN FD communication in detail

figure 1

As shown in the orange block box in Figure 1, in a traditional CAN frame structure, the CRC field is placed before the response detection after the end of the data. It is also the same position for CAN FD. This information is invisible to the user application interface. Obtain the corresponding CRC data Display from the bus analog waveform through the CANscope bus analyzer decoding window or an oscilloscope with CAN protocol decoding capability, as shown in Figure 2.

Explain the cyclic redundancy check (CRC) method in CAN and CAN FD communication in detail

figure 2

2. The generation of CRC in CAN frame

Explain the cyclic redundancy check (CRC) method in CAN and CAN FD communication in detailIn classic CAN, 15-bit CRC is used, and the hardware can use shift and exclusive-or operations to complete the calculation of CRC. In the CAN FD specification, the frame data length is extended. For CAN FD frames with a data length less than or equal to 16 bytes , 17-bit CRC is used, and 21-bit CRC is used for CAN FD frames with a data length greater than 16 bytes. Several versions of CRC generator polynomial g used in CAN bus are arranged as shown in Table 1.

Table 1

Algorithm name

application

Polynomial representation (g)

CRC-1

Parity check

x +1

CRC-15

Traditional CAN

x 15 + x 14 + x 10 + x 8 + x 7 + x 4 + x 3 + x 0

CRC-17

ISO CAN FD

x 17 + x 16 + x 14 + x 13 + x 11 + x 6 + x 4 + x 3 + x 1 + x 0

CRC-21

ISO CAN FD

x twenty one + x 20 + x 13 + x 11 + x 7 + x 4 + x 3 + x 0

3. How does CRC complete the verification work

The safety check of the CAN frame based on the CRC polynomial is that the transmitter calculates the check value according to the sent bits and provides the result in the CRC field of the CAN frame structure. The receiver uses the same polynomial to calculate the check value of the bit seen on the bus, and compares the self-calculated check value with the received calibration value. If they match, the frame is considered to be received correctly, and the receiving node is in the ACK time slot. The dominant state is sent in, thus covering the recessive state of the transmitter. In the case of a mismatch, the receiving node sends an error frame after the ACK delimiter.

The current CAN FD controller CRC check implementation process is relatively complicated. In a CAN bus network, all nodes start to use three sets of polynomials g15, g17, and g21 to calculate the CRC sequence synchronously after the start of the frame is detected. Contains the sending node. Since the calculation of CRC is affected by the CAN frame type and DLC length, the corresponding CRC generation sequence is not selected until the control field of the CAN frame and DLC is confirmed. The determined CRC sequence will be used in the CRC field of the frame structure. For sending or receiving comparison.

4. ISO CAN FD and non-ISO CAN FD compatibility issues related to CRC

Explain the cyclic redundancy check (CRC) method in CAN and CAN FD communication in detailThe current CAN FD protocol has two versions. In order to improve the fault (error) detection capability, the new version introduces a 3-bit stuffing counter and an additional parity bit. In addition, the CRC calculation method has also changed. These improvements make the latest CAN FD protocol incompatible with the original CAN FD protocol developed by BOSCH. The working group responsible for ISO has completed its document and submitted it to DIS (Draft International Standard) for voting procedures.

To avoid misunderstandings, CiA recommends the use of the terms “ISO CAN FD” and “non-ISO CAN FD”. All products complying with ISO 11898-2:2015 should be called “ISO CAN FD”. Products that implement BOSCH’s original CAN FD protocol should be named “non-ISO CAN FD”. The main purpose of products at this transition stage is for preliminary evaluation and development. In the future, all products will comply with ISO standards.

Please note that some of the components or tools provided by suppliers are for the non-ISO CAN FD protocol, including some CAN FD products currently on sale. CiA recommends using only ISO CAN FD products for design and development, but you can continue Use non-ISO CAN FD for evaluation and pre-development, because protocol changes are not visible to the user interface, but note that non-ISO CAN FD and ISO CAN FD interface devices cannot be mixed in the same network, which will cause CAN bus errors It is impossible to complete sending and receiving. If you only send or receive traditional CAN frames, it will not be affected in any way. Fortunately, some equipment vendors provide components or tools that allow users to choose to support ISO or non-ISO mode, which is very good. To help you complete your work during the transition period.

3. Summary:

The check mechanism adopted by traditional CAN and current CAN FD ensures that frame data damaged during transmission will hardly be received and the response is successful, which can effectively prevent physical layer transmission errors, so that the user interface does not need to pay extra attention to the correctness of the frame transmission data. sex.

The Links:   6MBP100RS060 G150XTN035