Explain in detail the conversion of the transparent belt mark in the serial port to CAN

The application of UART to CAN has been widely used in all walks of life, so the form requirements for data frame conversion are gradually increasing. At present, the mainstream conversion forms include transparent conversion, transparent band logo conversion and custom conversion. How is it implemented? This article will introduce the transparent belt logo conversion for you.

The application of UART to CAN has been widely used in all walks of life, so the form requirements for data frame conversion are gradually increasing. At present, the mainstream conversion forms include transparent conversion, transparent band logo conversion and custom conversion. How is it implemented? This article will introduce the transparent belt logo conversion for you.

In the last article, I have introduced the “working principle of transparent conversion in UART data to CAN data”. This article will introduce another data conversion pattern – transparent band mark conversion.

1 Applicable scenarios

When does the serial port to CAN module need to be used? First, the old product is facing an upgrade and needs to use CAN bus communication, but the MCU in the hardware platform does not have a controller integrated with the CAN bus. Second, the selected MCU already contains the CAN bus interface, but the quantity cannot meet the project requirements. If the above two situations occur and the MCU has an idle serial port, the serial port to CAN module CSM100T can be used to solve it.

Explain in detail the conversion of the transparent belt mark in the serial port to CAN

Figure 1 Application industry

2 How to use

This type of module can be easily embedded into the device with UART interface, and the device can obtain the CAN-bus communication interface without changing the original hardware structure, and realize the data communication between the device with UART and the CAN-bus network. . The industrial-grade conversion module also includes analog and digital devices, optocouplers, DC/DC converters, CAN-bus interfaces, etc., which are necessary to realize the CAN and UART conversion with isolation.

Figure 2 Product Architecture

3Format Description

CSM100 series modules provide 3 protocol conversion methods: transparent conversion, transparent label conversion, and custom protocol conversion. The previous article has introduced the conversion method of the transparent conversion mode. This article will briefly describe the conversion format of the transparent band mark of the module with the modules of the CSM100 series.

The “frame ID” in the serial frame of this conversion mode is automatically converted into the frame ID in the CAN message. As long as the module is told in the configuration that the address number of the “frame ID” is at the start position and length of the serial frame, the module extracts this “frame ID” and fills it in the frame ID field of the CAN message during conversion, as the string The frame ID of the CAN message when the line frame is forwarded. When the CAN message is converted into a serial frame, the CAN message frame ID is also converted into the corresponding position of the serial frame.

Figure 3 Conversion method

Comparing the “transparent conversion” mode and the “transparent band identification” mode, it is not difficult to find the difference between them: the CAN ID information comes from the serial port stream data or from the configuration information of the module itself. Since the CAN ID in the “transparent conversion” mode comes from the module configuration information, which is provided by the host computer software, the frame ID sent by the node using this mode is fixed. Different from the “transparent band identification” mode, it can send CAN frames with multiple frame IDs from one node.

4 Conversion forms

The maximum buffer length of a serial frame is 255 bytes, and when in this mode, serial reception is set with a timeout, that is, if serial data cannot be received within a certain period of time, it will be packaged as one frame and sent by default. Therefore, in the transparent band mark conversion mode, it is necessary to ensure that the module obtains a complete serial data frame, otherwise it will cause packet errors.

In the transparent band mark conversion mode, the form of the serial frame is converted into a CAN message as shown in Figure 5. It should be noted that the starting address and length of the CAN message “frame ID” in the serial frame can be set by configuration. The range of the start address is 0 to 7, and the range of the length is 1 to 2 (standard frame) or 1 to 4 (extended frame). If the frame type is specified as a standard frame in the configuration, and the frame ID information start address is 3 and the length is 1, the valid bits of the frame ID are only 8 bits. The CAN ID1 in address 3 is used as the upper 8 bits of the standard frame ID, and the remaining bits are all filled with 0.

Figure 5 Serial frame to CAN frame

In the transparent band mark conversion mode, the CAN message is converted into a serial frame in the form as shown in Figure 6. If the CAN frame information is also configured as a standard frame, and the frame ID information is the first 3 and the length 1, the data of ID0 will be lost during conversion. At this time, the data in the CAN frame can be received normally, but the frame ID information must be missing (when ID0 itself is not all 0). In order to convert the frame ID information of the standard frame normally, the frame length in the frame ID information must be set to 2 in the conversion scenario shown below.

Figure 6 CAN frame to serial frame

5 Conversion examples

Assuming that the starting address of the CAN message “frame ID” in the serial frame is 2 and the length is 3 (in the case of extended frame), the data sent by the serial frame are 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, the conversion result is shown in Figure 7.

Figure 7 Example 1

If the configuration start address is 2, the length is 3 (in the case of extended frame), the frame ID of the CAN message is 0x00123456, and the data is 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, and the conversion result is shown in Figure 8.

Figure 8 Example 2

6 Summary

The above is the conversion method of serial port to CAN “transparent with identification” mode. The feature of this mode is that the CAN frame ID information sent by a node can be flexibly set. The author will introduce the content of transparent conversion, transparent band logo conversion, custom protocol conversion and moudbus conversion. Welcome to the previous and later articles.

The Links:   FP35R12KT4 1DI400MP-120