Communication method between generator set controller and host computer
By adopting CAN bus communication between the generator set controller and the host computer, and using the CAN protocol frame format to transmit control instructions and data information, it solves the problems of low long-distance transmission efficiency and data consistency in the existing technology, and achieves high efficiency and reliability. Multi-node data transmission meets the needs of industrial automation and high-security industries.
Patent Information
- Application Number
- CN202210085771.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-25
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2042-01-25
AI Technical Summary
The existing communication method between the generator set controller and the host computer is inefficient in long-distance transmission, cannot meet the needs of high-frequency and large-volume data transmission, cannot guarantee the consistency of data at the same time among multiple nodes, and cannot meet the requirements of industrial automation and high-speed transmission. security industry needs.
CAN bus is used for communication. The host computer control terminal group and the generator set controller composed of multiple host computers are connected to the CAN bus. The CAN protocol frame format is used to encapsulate and transmit control instructions, data information and alarm information to achieve efficient and reliable Long-distance data transmission, and data consistency is ensured through check codes and packetization mechanisms.
It achieves efficient and reliable long-distance data transmission and ensures the data consistency of all nodes on the network at the same time. It has the advantages of simple structure, high speed, anti-interference and low price.
Smart Images

Figure CN114531317B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of generator set control, and more specifically, to a communication method between a generator set controller and a host computer. Background Art
[0002] At present, the communication between the generator controller and the host computer is generally carried out through USB, RS485, RS232, MODBUS RTU, MODBUS TCP / IP and other methods. However, these three communication methods cannot meet the needs of long-distance transmission. Once the application scenarios of the generator controller include places such as trains and factory areas that require long-distance communication, they will lose their functions; although the communication method of MODBUS RTU can meet the needs of long-distance transmission, it does not have the ability to transmit large amounts of data at high frequencies, and cannot meet the IoT communication needs of efficient transmission of large amounts of data. The communication method of MODBUSTCP / IP requires the use of Ethernet for communication. It is under the coordination of the bus controller to realize the transmission of large amounts of data between two nodes, and is subject to the question-and-answer mode of the MODBUS protocol. It cannot guarantee the consistency of data detected by all nodes on the network at the same time, and cannot meet the stringent requirements of high-security industries such as industrial automation, building security, and fire monitoring. Therefore, the existing technology cannot meet the needs of various users. Summary of the invention
[0003] In order to solve the problems of existing communication methods between generator set controllers and host computers, such as high efficiency over short distances, low efficiency over long distances, and high efficiency over long distances but unable to ensure data consistency among multiple nodes at the same time, the present invention innovatively provides a communication method between a generator set controller and a host computer, which can achieve long-distance transmission with high transmission efficiency, can ensure that the data detected by all nodes on the network at the same time are consistent, and has the advantages of simple structure, high speed, anti-interference, reliability, and low price.
[0004] In order to achieve the above technical objectives, the present invention discloses a communication method between a generator set controller and a host computer, comprising:
[0005] A host computer control terminal group consisting of multiple host computers and a generator set controller are connected to the CAN bus;
[0006] The host computer control terminal group generates a control instruction set, and any host computer encapsulates the commands in the control instruction set into a CAN protocol frame format and sends it to the generator set controller via the CAN bus;
[0007] The generator set controller receives the command frame in the CAN protocol frame format, responds to the command frame, and sets an error code;
[0008] The generator set controller autonomously uploads data information and alarm information, and encapsulates the data information and alarm information into a CAN protocol frame format;
[0009] The host computer control terminal group receives the command frame, error code, data information and alarm information replied by the generator set controller transmitted via the CAN bus, and performs synchronization.
[0010] Furthermore, the data segment format of the control command in the control instruction set is: byte 1 is the command frame number, byte 2 is the instruction code, bytes 3 to n are the instruction content, bytes n+1 and n+2 are check codes, where n is a positive integer greater than 3.
[0011] Furthermore, the data frame in the CAN protocol frame format includes a protocol data unit, each of which includes a packetization flag, a destination address, a source address, a subject number and a data field; if the byte length of the data segment is less than or equal to 8, the data segment is directly loaded with a packetization flag and sent as a separate packet; if the byte length of the data segment exceeds 8, the packet is sent and the packetization flag is set, and the data segment format of each packet is: byte 1 is the frame number, bytes 2 to n' are data content, byte n'+1 is the data length, bytes n'+2 and n'+3 are check values, where n' is 3, 4 or 5.
[0012] Furthermore, the byte order used by the CAN protocol is little-endian byte order.
[0013] Furthermore, the control instruction set includes a process control instruction, an instruction for reading controller configuration information, an instruction for reading controller basic information, an instruction for reading controller identity information, an instruction for writing controller configuration information, and an instruction for writing controller identity information.
[0014] Furthermore, the format of the command frame replied by the generator set controller is the same as the format of the received command frame.
[0015] Furthermore, the error code includes a frame sequence number duplication error and a frame sequence number discontinuity error.
[0016] Furthermore, the data information autonomously uploaded by the generator set controller is sent periodically, and the alarm information autonomously uploaded by the generator set controller is sent immediately.
[0017] The beneficial effects of the present invention are:
[0018] The communication method between the generator set controller and the host computer of the present invention can realize long-distance transmission with high transmission efficiency, can ensure that the data detected by all nodes on the network at the same time are consistent, and has the advantages of simple structure, high speed, anti-interference, reliability, low price, etc. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 is a flow chart of a communication method between a generator set controller and a host computer according to an embodiment of the present invention;
[0020] Figure 2 It is a schematic diagram of the CAN protocol frame format of an embodiment of the present invention. DETAILED DESCRIPTION
[0021] The communication method between the generator set controller and the host computer provided by the present invention is explained and illustrated in detail below in conjunction with the drawings in the specification.
[0022] This embodiment specifically discloses a communication method between a generator set controller and a host computer, such as Figure 1 As shown, including:
[0023] Step 1: A host control terminal group composed of multiple host computers and a generator controller are connected to the CAN bus; in this embodiment, all devices (i.e., all host computers and generator controllers) initialize the CAN2.0B standard interface and connect to the CAN bus, connect multiple host computers and generator controllers to the CAN bus, and realize data transmission between multiple host computers and generator controllers through the CAN bus. In this embodiment, an extended frame mode, i.e., a 29-bit ID, is adopted, and the transmission rate can be adjusted according to the communication distance. The lower the rate, the longer the transmission distance.
[0024] Step 2, the host computer controls the terminal group to generate a control instruction set, and any host computer encapsulates the commands in the control instruction set into the CAN protocol frame format and sends it to the generator set controller via the CAN bus; the data segment format of the control command in the control instruction set is: byte 1 is the command frame number (the first frame of the command frame number is 0, and the subsequent cycles are from 1 to 255), byte 2 is the instruction code, bytes 3 to n are the instruction content, bytes n+1 and n+2 are check codes, where n is a positive integer greater than 3. The verification method of this embodiment is XOR (only the data segment content is verified), and the check code byte order is low first and high later (high byte is filled with zero). In this embodiment, the control instruction set includes process control instructions, instructions for reading controller configuration information, instructions for reading controller basic information, instructions for reading controller identity information, instructions for writing controller configuration information, and instructions for writing controller identity information. The data segment instructions for flow control instructions, instructions for reading controller configuration information, instructions for reading controller basic information, and instructions for reading controller identity information are all: byte 1 is the command frame number (the first frame is 0, and the subsequent frames are 1 to 255), byte 2 is the instruction code, byte 3 is the instruction content, and bytes 4 to 5 are checksums. The data segment bytes of instructions for writing controller configuration information and writing controller identity information may exceed 8 bytes.
[0025] The data frame in the CAN protocol frame format includes a protocol data unit (PDU), and each protocol data unit includes a subpacket flag, a destination address, a source address, a subject number, and a data field. If the byte length of the data segment is less than or equal to 8, the data segment is directly loaded with a subpacket flag and sent as a separate packet, and is sent as a protocol data unit with the corresponding destination address, source address, subject number, and data field; if the byte length of the data segment exceeds 8, it is sent in packets and the subpacket flag is set. The data segment format of each packet is: byte 1 is the frame sequence number, bytes 2 to n' are the data content, byte n'+1 is the data length, bytes n'+2 and n'+3 are check values, where n' is 3, 4, or 5. Figure 2 As shown, DF is the sub-packet flag. When there is only one packet, DF=00; when there are multiple packets, the first packet is DF=01; the last packet is DF=11; the middle packet is DF=10. If the length of the data segment is more than 8 BYTES, it needs to be sent in packets, and the receiving end needs to combine and then parse; DA is the target address (target device number, which can be broadcast); SA is the source address (source device number); PF is the subject number; the data content is filled in each packet data segment, and the byte number is 1, 2, 3...8 according to the byte position. Any host computer encapsulates the control command in the control command data segment format into the CAN protocol frame format to facilitate direct transmission of the CAN bus.
[0026] The generator controller receives the command frame in the CAN protocol frame format and responds to it, then replies to the command frame and sets the error code; the format of the command frame replied by the generator controller is the same as the received command frame format, both of which are in the CAN protocol frame format and can be directly transmitted back to the host control terminal group through the CAN bus. The error code includes the frame sequence number duplication error and the frame sequence number discontinuity error. If an error frame sequence number is received, the corresponding command will not be executed, that is, no response will be made, but it will not affect the frame command reply.
[0027] At the same time, the generator set controller automatically uploads data information and alarm information, and encapsulates the data information and alarm information into the CAN protocol frame format; the data information and alarm information uploaded by the generator set controller are also uploaded according to the defined data segment format. The method of encapsulating data by the generator set controller is the same as that of the host computer. If the data segment bytes do not exceed 8, it is directly loaded as a separate package with a subpacket flag, and sent as a protocol data unit with the corresponding target address, source address, subject number and data field; if the data segment bytes exceed 8, it is subpacketized and the subpacket flag is set. The data segment format is: byte 1 is the frame number, bytes 2 to n' are the data content, byte n'+1 is the data length, bytes n'+2 and n'+3 are the check values, the check method is XOR (only the data segment content is checked), the check code byte order is low first and high later (high byte is padded with zero), the low byte is sent first and the high byte is sent later in the multi-byte field; multi-byte number types, such as float type, are sent or received in the way of memory copy, and pay attention to the conversion of big and small ends; the frame data content is limited to 8 bytes, and the byte number is 1, 2, 3...8 according to the byte position. The upload of the error code can be included in the alarm information. The generator set controller encapsulates the autonomously uploaded data information and alarm information into the CAN protocol frame format, and the reply command frame and error code are also in the CAN protocol frame format, which can be directly transmitted through the CAN bus.
[0028] Step 3: The host computer control terminal group receives the command frame, error code, data information and alarm information replied by the generator set controller in the CAN protocol frame format transmitted via the CAN bus, and synchronizes them to the host computer.
[0029] The data information uploaded by the generator set controller is sent at a scheduled time, and the sending interval can be set (default 1s); the alarm information uploaded by the generator set controller is sent immediately, and the number of sending cycles can be set (default 3 times) to improve transmission efficiency.
[0030] The communication method of this embodiment uses multiple host computers to access the CAN bus, and realizes data interaction between the generator set controller and multiple host computers through the CAN bus, with high transmission efficiency and large amount of data transmitted. The host computer encapsulates the control command into the CAN protocol frame format, and the generator set controller also encapsulates the uploaded data information and alarm information into the CAN protocol frame format, which can ensure that the data detected by all nodes on the network at the same time is consistent, and can achieve long-distance transmission. Moreover, in the same bus, it can ensure that each host computer can instantly obtain the latest control results, data information and alarm information.
[0031] In the description of the present invention, it is to be understood that the terms “center”, “longitudinal”, “lateral”, “length”, “width”, “thickness”, “up”, “down”, “front”, “back”, “left”, “right”, “vertical”, “horizontal”, “top”, “bottom”, “inside”, “outside”, “clockwise”, “counterclockwise”, “axial”, “radial”, “circumferential”, etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.
[0032] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0033] In the description of this specification, the description with reference to the terms "this embodiment", "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in a suitable manner in any at least one embodiment or example. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples, unless they are contradictory.
[0034] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0035] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and simple improvements made to the essential contents of the present invention should be included in the protection scope of the present invention.
Claims
1. A communication method between a generator set controller and a host computer, characterized in that: include: A host computer control terminal group consisting of multiple host computers and a generator set controller are connected to the CAN bus; The host computer control terminal group generates a control instruction set, and any host computer encapsulates the commands in the control instruction set into a CAN protocol frame format and sends it to the generator set controller via the CAN bus; the control instruction set includes process control instructions, instructions for reading controller configuration information, instructions for reading controller basic information, instructions for reading controller identity information, instructions for writing controller configuration information and instructions for writing controller identity information; the data segment format of the control commands in the control instruction set is: byte 1 is the command frame number, byte 2 is the instruction code, bytes 3 to n are the instruction content, bytes n+1 and n+2 are check codes, where n is a positive integer greater than 3; wherein, the data segment instructions of the process control instructions, instructions for reading controller configuration information, instructions for reading controller basic information and instructions for reading controller identity information are all: byte 1 is the command frame number, the first frame is 0, and the subsequent cycles are from 1 to 255, and the bytes are Section 2 is the instruction code, byte 3 is the instruction content, and bytes 4 to 5 are checksums; the data frame in the CAN protocol frame format includes a protocol data unit, each of which includes a subpacket flag, a target address, a source address, a subject number, and a data field; if the byte length of the data segment is less than or equal to 8, the data segment is directly loaded with a subpacket flag and sent as a separate packet; if the byte length of the data segment exceeds 8, it is sent in packets and the subpacket flag is set. The data segment format of each packet is: byte 1 is the frame sequence number, bytes 2 to n' are the data content, bytes n'+1 are the data length, bytes n'+2 and n'+3 are the checksum values, where n' is 3, 4, or 5; DF is the subpacket flag, when there is only one packet, DF=00; when there are multiple packets, the first packet is DF=01; the last packet is DF=11; the middle packet is DF=10; the check mode is XOR, only the data segment content is checked, the check code byte order is low first and high later, and the high byte is filled with zero; The generator set controller receives a command frame in the CAN protocol frame format and responds to it, then replies to the command frame and sets an error code; the error code includes a frame sequence number duplication error and a frame sequence number discontinuity error. If an error frame sequence number is received, the corresponding command is not executed, and no response is made, but the frame command reply is not affected; the format of the command frame replied by the generator set controller is the same as the format of the received command frame; The generator set controller autonomously uploads data information and alarm information, and encapsulates the data information and alarm information into a CAN protocol frame format; the data information autonomously uploaded by the generator set controller is sent at a scheduled time, and the alarm information autonomously uploaded by the generator set controller is sent immediately; The host computer control terminal group receives the command frame, error code, data information and alarm information replied by the generator set controller transmitted via the CAN bus, and performs synchronization.
2. The communication method between the generator set controller and the host computer according to claim 1, characterized in that: The byte order used by the CAN protocol is little-endian.
