Controller backboard communication method and system based on CAN
By automatically allocating the CAN ID of the controller from the module and communicating backplane data in the controller backplane communication system, the contradiction between the complexity of the backplane structure and the convenience of the controller expansion is solved, reducing costs and improving the system reliability.
Patent Information
- Application Number
- CN202411499612.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-02-18
AI Technical Summary
Existing CAN-based controller backplane communication cannot effectively resolve the contradiction between backplane structure complexity and controller expansion convenience, resulting in increased costs and reduced system reliability.
By responding to the requested CAN ID message after the controller's slave module is powered on, the address bus is used to select and send CAN ID configuration messages through the data bus, the automatic allocation of CAN IDs of the controller's slave module and the backplane data communication is realized.
Without the need for dedicated backplane bottom plate or hardware support, the controller automatically allocates CAN ID and backplane data communication from the module, reducing costs, improving system reliability and expansion convenience.
Smart Images

Figure CN119472386A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of controller backplane communication, and in particular to a controller backplane communication method and system based on CAN. Background Art
[0002] Backplane communication technology is a key technology in the field of industrial automation. It involves data transmission and communication between modules inside the controller. The backplane bus is an important part of the controller. Through the backplane bus, the controller CPU module and each controller slave module can realize data transmission and signal exchange, thereby ensuring the normal operation of the entire system. Therefore, the design and implementation of the backplane bus is crucial to the performance and reliability of the controller. CAN bus has become one of the widely used fieldbus standards in the world because of its low cost, fast speed, real-time and high reliability. It is also used as the controller backplane bus by more and more controller manufacturers.
[0003] However, the current CAN-based controller backplane communication cannot effectively solve the contradiction between the complexity of the backplane structure and the convenience of controller expansion. Although the dedicated backplane baseplate method realizes the flexible expansion and replacement of the controller slave module, the backplane structure is complex, which increases the cost and reduces the reliability of the system; the controller slave module adopts hardware methods such as code pulling, which saves the dedicated baseplate, but the controller slave module CAN ID cannot be automatically allocated, resulting in insufficient convenience in expanding and replacing the controller slave module. Summary of the invention
[0004] The main purpose of the present invention is to provide a controller backplane communication method and system based on CAN, aiming to solve at least one of the above technical problems.
[0005] To achieve the above object, the present invention provides a controller backplane communication method based on CAN, comprising:
[0006] In response to a CAN ID request message automatically sent by the controller slave module after power-on, selecting the controller slave module for matching through the address bus and sending a CAN ID configuration message to the controller slave module through the data bus;
[0007] When the controller slave module is matched successfully, resetting the CAN ID of the controller slave module according to the CAN ID configuration message;
[0008] In response to a confirmation message sent by the controller slave module based on the reset CAN ID, maintaining a CAN ID mapping table based on the confirmation message to manage the CAN ID of the controller slave module;
[0009] The backplane data communication is performed with the controller slave module according to the CAN ID mapping table.
[0010] In some embodiments, in response to the CAN ID request message automatically sent by the controller slave module after power-on, selecting the controller slave module for matching through the address bus and sending the CAN ID configuration message to the controller slave module through the data bus includes:
[0011] After the controller is powered on from the module, it enters the CAN ID configuration state and sets the CAN ID to the initial application ID;
[0012] In response to the application CAN ID message automatically sent via the data bus according to the initial application ID, sending the module number via the address bus to select the controller slave module to match;
[0013] Based on the initial application ID, a CAN ID configuration message is sent to the successfully matched controller slave module through the data bus.
[0014] In some embodiments, sending the module number through the address bus to select the controller slave module for matching includes:
[0015] Sending a module number to a first controller slave module via an address bus, so that the first controller slave module subtracts one from the received module number to obtain a first update module number, and determines whether the first update module number is 0;
[0016] If the first update module number is 0, the first controller slave module is matched successfully;
[0017] If the first update module number is not 0, the first update module number is sent to the second controller slave module through the address bus for matching until the controller slave module matches successfully or N controller slave modules do not match; wherein N is a positive integer.
[0018] In some embodiments, when the controller slave module is matched successfully, resetting the CAN ID of the controller slave module according to the CAN ID configuration message includes:
[0019] When the controller slave module matches successfully, a CAN ID configuration message is sent to the successfully matched controller slave module through the data bus based on the initial application ID, so that the controller slave module parses the CAN ID configuration message to obtain the sent CAN ID, and resets the CAN ID according to the sent CAN ID.
[0020] In some embodiments, in response to a confirmation message sent by the controller slave module based on the reset CAN ID, maintaining a CAN ID mapping table based on the confirmation message to manage the CAN ID of the controller slave module includes:
[0021] Receiving, via the data bus, a confirmation message sent by the controller slave module based on the reset CAN ID;
[0022] Parsing the confirmation message to determine whether the controller slave module has successfully reconfigured the CAN ID;
[0023] When it is confirmed that the controller slave module has successfully reconfigured the CAN ID, the corresponding relationship between the module number of the controller slave module and the reset CAN ID is added to the CAN ID mapping table to manage the CAN ID of the controller slave module.
[0024] In addition, to achieve the above purpose, the present invention also proposes a CAN-based controller backplane communication system, including: a data bus, an address bus, a controller CPU module and N controller slave modules, where N is a positive integer; wherein,
[0025] The controller CPU module is used to respond to the CAN ID application message automatically sent by the controller slave module after power-on, select the controller slave module for matching through the address bus and send the CAN ID configuration message to the controller slave module through the data bus;
[0026] When the controller slave module is matched successfully, resetting the CAN ID of the controller slave module according to the CAN ID configuration message;
[0027] In response to a confirmation message sent by the controller slave module based on the reset CAN ID, maintaining a CAN ID mapping table based on the confirmation message to manage the CAN ID of the controller slave module;
[0028] The backplane data communication is performed with the controller slave module according to the CAN ID mapping table.
[0029] In some embodiments, the controller CPU module includes a CAN ID sending submodule, a CAN ID management submodule, and a backplane data communication submodule.
[0030] In some embodiments, the controller slave module includes a slave module reporting submodule, a CAN ID receiving submodule, and a slave module responding submodule.
[0031] In some embodiments, the data bus is a CAN communication bus, including a CANH data line and a CANL data line, which is used for the controller CPU module to communicate with N controller slave modules.
[0032] In some embodiments, the address bus is a GPIO pin line; the controller CPU module includes 5 GPIO output pins, and each of the controller slave modules includes 5 GPIO input pins and 5 GPIO output pins;
[0033] The output of the controller CPU module is connected to the input of the first controller slave module, the output of the first controller slave module is connected to the input of the second controller slave module, and so on, until it is connected to the input of the Nth controller slave module;
[0034] The address bus is used by the controller CPU module to select the controller slave module for CAN ID allocation.
[0035] The present invention provides a controller backplane communication method based on CAN, including: in response to a CAN ID application message automatically sent by a controller slave module after power-on, selecting the controller slave module for matching through an address bus and sending a CAN ID configuration message to the controller slave module through a data bus; when the controller slave module matches successfully, resetting the CAN ID of the controller slave module according to the CAN ID configuration message; in response to a confirmation message sent by the controller slave module based on the reset CAN ID, maintaining a CAN ID mapping table based on the confirmation message to manage the CAN ID of the controller slave module; and performing backplane data communication with the controller slave module according to the CAN ID mapping table. In the present invention, through the data bus and the address bus and the above-mentioned implementation process, the automatic allocation of the CAN ID of the controller slave module and the backplane data communication can be realized without the need for hardware support such as a dedicated backplane base plate and code pulling, and has the advantages of low cost, simple structure, and thus improved reliability. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a flow chart of an embodiment of a controller backplane communication method based on CAN of the present invention;
[0037] Figure 2 It is a schematic diagram of the implementation process involved in the embodiment of the present invention;
[0038] Figure 3 This is a schematic diagram of the module structure of a CAN-based controller backplane communication system involved in an embodiment of the present invention;
[0039] Figure 4It is a structural block diagram of an embodiment of a CAN-based controller backplane communication system of the present invention;
[0040] Figure 5 The present invention is a schematic diagram of the structure of an electronic device in a hardware operating environment according to an embodiment of the present invention.
[0041] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] It should be noted that all directional indications in the embodiments of the present invention (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0044] In addition, the descriptions of "first", "second", etc. in the present invention are only used for descriptive purposes and cannot be understood as indicating or implying their 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 addition, the technical solutions between the various embodiments can be combined with each other, but it must be based on the ability of ordinary technicians in the field to implement. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by the present invention. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0045] The present invention provides a controller backplane communication method and system based on CAN.
[0046] The embodiment of the present invention provides a controller backplane communication method based on CAN, referring to Figure 1 , Figure 1 The figure is a flow chart of an embodiment of a controller backplane communication method based on CAN of the present invention.
[0047] like Figure 1 As shown, the controller backplane communication method based on CAN includes:
[0048] Step S100: In response to a CAN ID application message automatically sent by the controller slave module after power-on, selecting the controller slave module for matching through the address bus and sending a CAN ID configuration message to the controller slave module through the data bus;
[0049] Step S200: when the controller slave module is matched successfully, resetting the CAN ID of the controller slave module according to the CAN ID configuration message;
[0050] Step S300: In response to a confirmation message sent by the controller slave module based on the reset CAN ID, maintaining a CAN ID mapping table based on the confirmation message to manage the CAN ID of the controller slave module;
[0051] Step S400: performing backplane data communication with the controller slave module according to the CAN ID mapping table.
[0052] It should be noted that this embodiment is described by taking a CAN-based controller backplane communication system including: a data bus, an address bus, a controller CPU module and N controller slave modules as an example. It can be understood that the execution subject in this embodiment can be the controller CPU module.
[0053] In this embodiment, data communication between the controller CPU module and all controller slave modules is performed through the data bus; and a designated controller slave module is selected for the controller CPU module to perform CAN ID allocation through the address bus.
[0054] In one embodiment, in response to a CAN ID application message automatically sent by a controller slave module after power-on, the controller slave module is selected for matching through an address bus and a CAN ID configuration message is sent to the controller slave module through a data bus, including: entering a CAN ID configuration state after the controller slave module is powered on, and setting the CAN ID to an initial application ID; in response to a CAN ID application message automatically sent through a data bus according to the initial application ID, sending a module number through an address bus to select a controller slave module for matching; and sending a CANID configuration message to a successfully matched controller slave module through the data bus based on the initial application ID.
[0055] For example, Figure 2 As shown, step 1, the controller reports from the module: after the controller module is powered on, it automatically sends a CAN ID application message to the controller CPU module.
[0056] Specifically, after the controller slave module is powered on, it enters the CAN ID configuration state, the controller slave module sets its own CANID as the initial application ID, and the controller slave module sends a CAN ID application message to the controller CPU module through the data bus with the initial application ID.
[0057] For example, Figure 2 As shown, step 2, CAN ID sending: the controller CPU module selects the controller slave module through the address bus and sends the CAN ID configuration message to the controller slave module.
[0058] Specifically, the controller CPU module receives the CAN ID application message, determines the next available CAN ID (unused CAN ID) through the CAN ID mapping table, generates a CAN ID configuration message based on the available CAN ID and sends it to the controller slave module to configure the CAN ID. During configuration, the controller CPU module sends the module number through the address bus to select the specified controller slave module, and sends the CAN ID configuration message through the data bus with the initial configuration ID.
[0059] In one embodiment, sending a module number via an address bus to select a controller slave module for matching includes: sending the module number to a first controller slave module via the address bus, so that the first controller slave module subtracts one from the received module number to obtain a first update module number, and determines whether the first update module number is 0; if the first update module number is 0, the first controller slave module is matched successfully; if the first update module number is not 0, the first update module number is sent to the second controller slave module via the address bus for matching, until the controller slave module is matched successfully or N controller slave modules are not matched; wherein N is a positive integer.
[0060] In one embodiment, when the controller slave module matches successfully, the CAN ID of the controller slave module is reset according to the CAN ID configuration message, including: when the controller slave module matches successfully, based on the initial application ID, the CAN ID configuration message is sent to the successfully matched controller slave module through the data bus, so that the controller slave module parses the CAN ID configuration message to obtain the sent CAN ID, and resets the CAN ID according to the sent CAN ID.
[0061] For example, Figure 2 As shown, step 3, CAN ID reception: after matching the slave module through the address bus, the controller receives the CAN ID configuration message transmitted by the data bus, parses the CAN ID configuration message to obtain an available CAN ID, and resets the CAN ID according to the available CAN ID.
[0062] Specifically, the first controller slave module receives the module number through the address bus, decrements the module number by 1 and determines whether its value is 0. If the value of the module number decrements by 1 is 0, the first controller slave module is successfully matched, and the first controller slave module selects the module for configuring the CAN ID for the controller CPU module, so that the first controller slave module receives the CAN ID configuration message through the data bus through the initial configuration ID, and resets the CAN ID of the first controller slave module to the ID issued by the controller CPU module. If the value of the module number decrements by 1 is not 0, the module number decrements by 1 is sent to the next controller slave module (for example, the second controller slave module) through the address bus, and the next controller slave module receives the module number decrements by 1 from the address bus, and decrements by 1 to determine its value. If the value is 0, the CAN ID is configured, and if it is not 0, it continues to be sent to the next controller slave module, and the calculation and judgment are repeated until a controller slave module successfully matches or all controller slave modules do not match.
[0063] In one embodiment, in response to a confirmation message sent by the controller slave module based on the reset CAN ID, a CAN ID mapping table is maintained based on the confirmation message to manage the CAN ID of the controller slave module, including: receiving a confirmation message sent by the controller slave module based on the reset CAN ID via a data bus; parsing the confirmation message to determine whether the controller slave module has successfully reconfigured the CAN ID; and when confirming that the controller slave module has successfully reconfigured the CAN ID, adding a correspondence between the module number of the controller slave module and the reset CAN ID to the CAN ID mapping table to manage the CAN ID of the controller slave module.
[0064] For example, Figure 2 As shown, step 4, the controller slave module responds: the controller slave module sends a confirmation message to the controller CPU module based on the reset CAN ID.
[0065] Specifically, the successfully matched controller slave module sends a confirmation message to the controller CPU module through the data bus with the reset CAN ID, and then the controller slave module switches to a normal communication state.
[0066] For example, Figure 2 As shown, step 5, CAN ID management: the controller CPU module maintains the CAN ID mapping table according to the received CAN ID confirmation message, and manages the CAN ID of the controller slave module.
[0067] Specifically, the controller CPU module receives the CAN ID confirmation message through the data bus, confirms the correspondence between the controller slave module number and the CAN ID, and maintains the slave module number and CAN ID mapping table to manage the CANID of all controller slave modules. Among them, maintenance operations include but are not limited to adding, deleting and modifying. For example, when adding a controller slave module, the corresponding CAN ID in the mapping table is added in real time; when reducing a controller slave module, the corresponding CAN ID in the mapping table is deleted in real time; when replacing a controller slave module, the corresponding CAN ID in the mapping table is modified in real time.
[0068] In one embodiment, backplane data communication is performed with the controller slave module according to the CAN ID mapping table.
[0069] For example, Figure 2 As shown, step 6, backplane data communication: the controller CPU module uses the CAN ID mapping table to communicate backplane data with the controller slave module.
[0070] Specifically, the controller CPU module queries the CAN ID corresponding to any controller slave module according to the CAN ID mapping table, and performs backplane data communication through the data bus.
[0071] It is understandable that the following Figure 3 The module structure diagram of the controller backplane communication system based on CAN is shown in the figure. The example of adding a sixth controller slave module when the controller CPU module is running with five controller slave modules is used as an example to illustrate:
[0072] Step 1: Report from the module: After the module is powered on, the controller automatically sends a CAN ID request message to the controller CPU module.
[0073] In this example, when the controller CPU module is running with 5 controller slave modules, a sixth controller slave module is added. After the sixth controller slave module is inserted and powered on, it enters the CAN ID configuration state after completing the relevant initialization configuration. The CAN ID is set to 256. The controller slave module uses 256 as the CAN ID to send a message to the controller CPU module through the data bus. The message content is F2 D80100.
[0074] Step 2, CAN ID sending: The controller CPU module selects the controller slave module through the address bus and sends the CAN ID configuration message to the controller slave module.
[0075] In this example, the controller CPU module receives message F2 D80100 with CAN ID 256 and enters the CAN ID allocation process. It determines that the next available CAN ID is 11 through the CAN ID mapping table maintained by itself. The controller CPU module sends module number 6 through the address bus and sends CAN ID configuration message F2 D8000B with CAN ID 257 through the data bus.
[0076] Step 3, CAN ID reception: After matching the slave module according to the address bus, the controller receives the CANID configuration message of the data bus, parses the message and resets the CAN ID.
[0077] In this example, the first controller slave module receives module number 6 from the address bus, decrements it by 1 to get a value of 5, and sends it to the next controller slave module (the second controller module) through the address bus. The next controller slave module decrements 1 and continues to send it until it is sent to the sixth controller slave module. The sixth controller slave module receives module number 1 from the address bus, which is decremented by 1 to get a value of 0. At this time, the sixth controller slave module is successfully matched, and the sixth controller slave module is the module selected by the controller CPU module to configure the CAN ID. The sixth controller slave module receives message F2 D8000B from the data bus through CAN ID 257, and parses the message to obtain the CAN ID configured by the controller CPU module as 11, so the sixth controller slave module sets the sending CAN ID to 11 and the receiving CAN ID to 12.
[0078] Step 4, slave module response: The controller slave module sends a confirmation message to the controller CPU module based on the reset CAN ID.
[0079] In this example, the sixth controller slave module sends a confirmation message F2 D8000B to the controller CPU module through the data bus with CAN ID 11, after which the sixth controller slave module enters the normal communication state.
[0080] Step 5, CAN ID management: The controller CPU module maintains the CAN ID mapping table according to the received CAN ID confirmation message and manages the CAN ID of the controller slave module;
[0081] In this example, the controller CPU module receives message F2 D8000B with CAN ID 11, indicating that the CAN ID of the sixth controller slave module is successfully configured, and the mapping relationship (i.e. module number 6, CAN ID 11) is added to the controller slave module number and CAN ID mapping table.
[0082] Step 6: Backplane data communication: The controller CPU module uses the CAN ID mapping table to communicate backplane data with the controller slave module.
[0083] In this example, when the controller CPU module receives a message with a CAN ID of 11, it uses the CAN ID mapping table to query the module number as 6, thereby determining that the message is sent by the 6th controller slave module; when the controller CPU module sends a message to the 6th controller slave module, it uses the CAN ID mapping table to query the CAN ID as 11, thereby sending the message to the 6th controller slave module with CAN ID 12.
[0084] It should be noted that, compared with the existing CAN-based controller backplane communication method, the beneficial effects of the method described in this embodiment include: compared with the system using a dedicated backplane base plate, this embodiment does not require a dedicated base plate, which not only reduces the cost, but also improves reliability due to its simple structure; compared with the use of fixed CAN ID methods such as hard-swap codes, this embodiment realizes the automatic allocation of controller slave module CAN ID and backplane data communication through the data bus and address bus and the corresponding above-mentioned implementation process, thereby making the expansion and replacement of the controller slave module more convenient and efficient, and is particularly suitable for online expansion and rapid replacement of side-expansion type controller slave modules.
[0085] This embodiment provides a controller backplane communication method based on CAN, including: in response to a request CAN ID message automatically sent by a controller slave module after power-on, selecting the controller slave module for matching through an address bus and sending a CAN ID configuration message to the controller slave module through a data bus; when the controller slave module matches successfully, resetting the CAN ID of the controller slave module according to the CAN ID configuration message; in response to a confirmation message sent by the controller slave module based on the reset CAN ID, maintaining a CAN ID mapping table based on the confirmation message to manage the CAN ID of the controller slave module; and performing backplane data communication with the controller slave module according to the CAN ID mapping table. In this embodiment, through the data bus and the address bus and the above-mentioned implementation process, the automatic allocation of the CAN ID of the controller slave module and the backplane data communication can be realized without the need for a dedicated backplane base plate, without the need for hardware support such as code pulling, which has the advantages of low cost, simple structure and improved reliability.
[0086] In addition, an embodiment of the present invention further proposes a storage medium, on which a CAN-based controller backplane communication program is stored. When the CAN-based controller backplane communication program is executed by a processor, the steps of the CAN-based controller backplane communication method described above are implemented.
[0087] Reference Figure 4 , Figure 4 It is a structural block diagram of an embodiment of a CAN-based controller backplane communication system of the present invention.
[0088] like Figure 4 As shown, the CAN-based controller backplane communication system includes: a data bus, an address bus, a controller CPU module and N controller slave modules, where N is a positive integer; wherein,
[0089] The controller CPU module is used to respond to the CAN ID application message automatically sent by the controller slave module after power-on, select the controller slave module for matching through the address bus and send the CAN ID configuration message to the controller slave module through the data bus;
[0090] When the controller slave module is matched successfully, resetting the CAN ID of the controller slave module according to the CAN ID configuration message;
[0091] In response to a confirmation message sent by the controller slave module based on the reset CAN ID, maintaining a CAN ID mapping table based on the confirmation message to manage the CAN ID of the controller slave module;
[0092] The backplane data communication is performed with the controller slave module according to the CAN ID mapping table.
[0093] In one embodiment, if Figure 3 As shown, the controller CPU module includes a CAN ID sending submodule, a CAN ID management submodule and a backplane data communication submodule.
[0094] In one embodiment, if Figure 3 As shown, the controller slave module includes a slave module reporting submodule, a CAN ID receiving submodule and a slave module responding submodule.
[0095] In one embodiment, if Figure 3 As shown, the data bus is a CAN communication bus, including a CANH data line and a CANL data line, which is used for the controller CPU module to communicate with N controller slave modules.
[0096] In one embodiment, the address bus is a GPIO pin line; the controller CPU module includes 5 GPIO output pins, and each of the controller slave modules includes 5 GPIO input pins and 5 GPIO output pins;
[0097] The output of the controller CPU module is connected to the input of the first controller slave module, the output of the first controller slave module is connected to the input of the second controller slave module, and so on, until it is connected to the input of the Nth controller slave module;
[0098] The address bus is used by the controller CPU module to select the controller slave module for CAN ID allocation.
[0099] Specifically, Figure 3 As shown, the CAN-based controller backplane communication system includes a data bus, an address bus, a slave module reporting submodule, a CAN ID sending submodule, a CAN ID receiving submodule, a slave module response submodule, a CAN ID management submodule, and a backplane data communication submodule. Among them, the data bus is a CAN communication bus, including two data lines CANH and CANL, which are used for data communication between the controller CPU module and all controller slave modules. The address bus is a GPIO pin line, including 5 GPIO output pins of the controller CPU module, 5 GPIO input pins and 5 GPIO output pins of the controller slave module. The output of the controller CPU module is connected to the input of the first controller slave module, and the output of the first controller slave module is connected to the input of the next controller slave module. The connections are repeated in sequence, and the controller CPU module selects the specified controller slave module for CAN ID allocation.
[0100] Specifically, the slave module reporting submodule is used for the controller to enter the CAN ID configuration state after the slave module is powered on, and the CANID is set to the initial application ID. The controller slave module sends an application CAN ID message to the controller CPU module through the data bus with the initial application ID.
[0101] Specifically, the CAN ID sending submodule is used for the controller CPU module to receive the CAN ID application message, determine the next available CAN ID through the CAN ID mapping table maintained by itself, and configure the CAN ID for the controller slave module. During configuration, the controller CPU module sends the module number through the address bus to select the specified slave module, and sends the CAN ID configuration message through the data bus with the initial configuration ID.
[0102] Specifically, the CAN ID receiving submodule is used for the first controller slave module to receive the module number from the address bus, decrement it by 1 and determine whether its value is 0. If the value is 0, the match is successful, and the slave module is the module selected by the controller CPU module to configure the CAN ID, so that the slave module receives the CAN ID configuration message from the data bus through the initial configuration ID, and resets the CAN ID of the slave module to the ID issued by the controller CPU module; if the value is not 0, the module number after decrementing by 1 is sent to the next controller slave module through the address bus. The next controller slave module receives the module number from the address bus, decrements it by 1 and determines its value. If the value is 0, the CAN ID is configured, and if it is not 0, it continues to be sent to the next controller slave module, and repeats until a controller slave module matches successfully or all controller slave modules do not match.
[0103] Specifically, the slave module responds to the submodule, and the successfully matched controller slave module sends a confirmation message to the controller CPU module through the data bus with the reset CAN ID, and the controller slave module switches to a normal communication state.
[0104] Specifically, the CAN ID management submodule is used for the controller CPU module to receive the CAN ID confirmation message through the data bus, confirm the corresponding relationship between the controller slave module number and the CAN ID, and maintain the mapping table between the controller slave module number and the CAN ID to manage the CAN IDs of all controller slave modules. When adding a controller slave module, the corresponding CAN ID in the table is added in real time; when reducing a controller slave module, the corresponding CAN ID in the table is deleted in real time; when replacing a controller slave module, the corresponding CAN ID in the table is modified in real time.
[0105] Specifically, the backplane data communication submodule is used for the controller CPU module to query the CAN ID corresponding to any controller slave module using the CAN ID mapping table, and perform backplane data communication through the data bus.
[0106] The present embodiment discloses a controller backplane communication system based on CAN, wherein the controller CPU module communicates data with all controller slave modules through the data bus; the controller CPU module selects the designated controller slave module through the address bus for CAN ID allocation; the slave module reporting submodule sends a CAN ID application message to the controller CPU module after the controller slave module is powered on; the CAN ID sending submodule configures the CAN ID of the controller slave module after the controller CPU module receives the CAN ID application message; the CAN ID receiving submodule resets the CAN ID of the controller slave module after the controller slave module is successfully matched; the slave module response submodule sends a confirmation message to the controller CPU module with the reset CAN ID; the CAN ID management submodule maintains the slave module number and CAN ID mapping table to manage the CAN ID of all controller slave modules; the backplane data communication submodule uses the CAN ID mapping table to query the CAN ID corresponding to any slave module to perform controller backplane data communication. In the present embodiment, there is no need for a base plate or a code puller, and the controller slave module CAN ID automatic allocation and backplane data communication are realized, so that the expansion and replacement of the controller slave module are more convenient and efficient, and the backplane structure is simple, which not only reduces the cost but also improves the reliability.
[0107] It is understandable that the following Figure 3 The module structure diagram of the controller backplane communication system based on CAN shown in the figure takes the case where the controller CPU module is running with 5 controller slave modules and the sixth controller slave module is added as an example to illustrate the system described in this embodiment:
[0108] Specifically, the CAN-based controller backplane communication system includes a data bus, an address bus, a slave module reporting submodule, a CAN ID sending submodule, a CAN ID receiving submodule, a slave module response submodule, a CAN ID management submodule, and a backplane data communication submodule. The data bus is a CAN communication bus, including two data lines, CANH and CANL, which are used for data communication between the controller CPU module and all controller slave modules.
[0109] In this example, the CAN data bus is connected to the controller CPU module and five controller slave modules. After the sixth controller slave module is inserted, the controller slave module is connected to the CAN data bus through the side contacts.
[0110] Specifically, the address bus is a GPIO pin line, including 5 GPIO output pins of the controller CPU module, 5 GPIO input pins and 5 GPIO output pins of the controller slave module.
[0111] In this example, the 5 GPIO output pins of the controller CPU module are connected to the 5 GPIO input pins of the first controller slave module, and the 5 GPIO output pins of the first controller slave module are connected to the 5 GPIO input pins of the second controller slave module, and the connection is repeated until the fifth controller slave module. After the sixth controller slave module is inserted, the 5 GPIO output pins of the fifth controller slave module are connected to the 5 GPIO input pins of the sixth controller slave module, thereby realizing the address bus connection of all six controller slave modules.
[0112] Specifically, the slave module reporting submodule is used for the controller slave module to send a CAN ID application message to the controller CPU module through the data bus.
[0113] In this example, when the controller CPU module is running with 5 controller slave modules, a sixth controller slave module is added. After the sixth controller slave module is inserted and powered on, it enters the CAN ID configuration state after completing the relevant initialization configuration. The CAN ID is set to 256. The controller slave module uses 256 as the CAN ID to send a message to the controller CPU module through the data bus. The message content is F2 D80100.
[0114] Specifically, the CAN ID sending submodule is used for the controller CPU module to receive the CAN ID application message and configure the CAN ID for the controller slave module.
[0115] In this example, the controller CPU module receives message F2 D80100 with CAN ID 256 and enters the CAN ID allocation process. It determines that the next available CAN ID is 11 through the CAN ID mapping table maintained by itself. The controller CPU module sends module number 6 through the address bus and sends CAN ID configuration message F2 D8000B with CAN ID 257 through the data bus.
[0116] Specifically, the CAN ID receiving submodule is used to receive the module number from the address bus of the controller slave module and determine whether its value is 0. If the value is 0, the match is successful; if the value is not 0, the module number minus 1 is sent to the next controller slave module through the address bus. This is repeated until a controller slave module is matched successfully or all controller slave modules are not matched.
[0117] In this example, the first controller slave module receives module number 6 from the address bus, decrements it by 1 to get a value of 5, and sends it to the next controller slave module through the address bus. The next controller slave module decrements 1 and continues to send it until it is sent to the sixth controller slave module. The sixth controller slave module receives module number 1 from the address bus, which is decremented by 1 to get a value of 0, and the match is successful. The sixth controller slave module is the module selected by the controller CPU module to configure the CAN ID. The sixth controller slave module receives message F2 D8000B from the data bus via CAN ID 257, and parses the message to obtain the CAN ID configured by the controller CPU module as 11, so the sixth controller slave module sets the sending CAN ID to 11 and the receiving CAN ID to 12.
[0118] Specifically, the slave module response submodule is used for the successfully matched controller slave module to send a confirmation message to the controller CPU module through the data bus with the reset CAN ID.
[0119] In this example, the sixth controller slave module sends a confirmation message F2 D8000B to the controller CPU module through the data bus with CAN ID 11, after which the sixth controller slave module enters the normal communication state.
[0120] Specifically, the CAN ID management submodule is used for the controller CPU module to receive the CAN ID confirmation message through the data bus, confirm the corresponding relationship between the controller slave module number and the CAN ID, and manage the CAN IDs of all controller slave modules.
[0121] In this example, the controller CPU module receives message F2 D8000B with CAN ID 11, indicating that the CAN ID configuration of the sixth controller slave module is successful, and the mapping (module number 6, CAN ID 11) is added to the controller slave module number and CAN ID mapping table.
[0122] Specifically, the backplane data communication submodule is used for the controller CPU module to query the CAN ID corresponding to any controller slave module using the CAN ID mapping table, and perform backplane data communication through the data bus.
[0123] In this example, when the controller CPU module receives a message with a CAN ID of 11, it uses the CAN ID mapping table to query the module number as 6, thereby determining that the message is sent by the 6th controller slave module; when the controller CPU module sends a message to the 6th controller slave module, it uses the CAN ID mapping table to query the CAN ID as 11, thereby sending the message to the 6th controller slave module with CAN ID 12.
[0124] This embodiment provides a controller backplane communication system based on CAN. Through the data bus and address bus and the above implementation process, it can realize the automatic allocation of CAN ID and backplane data communication of the controller slave module without the need for hardware support such as a dedicated backplane base plate and code pulling, thereby making the expansion and replacement of the controller slave module more convenient and efficient, and is particularly suitable for online expansion and rapid replacement of side expansion type controller slave modules. In addition, it has the advantages of low cost, simple structure, and improved reliability.
[0125] It should be noted that the technical details that are not described in detail in this CAN-based controller backplane communication system embodiment can be found in the CAN-based controller backplane communication method provided in any embodiment of the present invention as described above, and will not be repeated here.
[0126] Reference Figure 5 , Figure 5 The figure is a schematic diagram of the structure of an electronic device of the hardware operating environment involved in the embodiment of the present invention.
[0127] like Figure 5 As shown, the electronic device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM memory) or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0128] Those skilled in the art will understand that Figure 5 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0129] like Figure 5 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a CAN-based controller backplane communication program.
[0130] exist Figure 5 In the electronic device shown, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the electronic device of the present invention can be set in the electronic device, and the electronic device calls the CAN-based controller backplane communication program stored in the memory 1005 through the processor 1001, and executes the CAN-based controller backplane communication method provided in an embodiment of the present invention.
[0131] It should be understood that the above is only an example and does not constitute any limitation on the technical solution of the present invention. In specific applications, technicians in this field can make settings as needed, and the present invention does not limit this.
[0132] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.
[0133] In addition, it should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0134] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0135] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory (ROM) / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0136] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A controller backplane communication method based on CAN, characterized in that: include: In response to a CAN ID request message automatically sent by the controller slave module after power-on, selecting the controller slave module for matching through the address bus and sending a CAN ID configuration message to the controller slave module through the data bus; When the controller slave module is matched successfully, resetting the CAN ID of the controller slave module according to the CAN ID configuration message; In response to a confirmation message sent by the controller slave module based on the reset CAN ID, maintaining a CAN ID mapping table based on the confirmation message to manage the CAN ID of the controller slave module; The backplane data communication is performed with the controller slave module according to the CAN ID mapping table.
2. The method according to claim 1, characterized in that The method of responding to the CAN ID application message automatically sent by the controller slave module after power-on, selecting the controller slave module for matching through the address bus and sending the CANID configuration message to the controller slave module through the data bus includes: After the controller is powered on from the module, it enters the CAN ID configuration state and sets the CAN ID to the initial application ID; In response to the application CAN ID message automatically sent via the data bus according to the initial application ID, sending the module number via the address bus to select the controller slave module to match; Based on the initial application ID, a CAN ID configuration message is sent to the successfully matched controller slave module through the data bus.
3. The method according to claim 2, characterized in that The step of sending the module number through the address bus to select the controller slave module for matching includes: Sending a module number to a first controller slave module via an address bus, so that the first controller slave module subtracts one from the received module number to obtain a first update module number, and determines whether the first update module number is 0; If the first update module number is 0, the first controller slave module is matched successfully; If the first update module number is not 0, the first update module number is sent to the second controller slave module through the address bus for matching until the controller slave module matches successfully or N controller slave modules do not match; wherein N is a positive integer.
4. The method according to claim 2, characterized in that When the controller slave module is matched successfully, resetting the CAN ID of the controller slave module according to the CAN ID configuration message includes: When the controller slave module matches successfully, a CAN ID configuration message is sent to the successfully matched controller slave module through the data bus based on the initial application ID, so that the controller slave module parses the CAN ID configuration message to obtain the sent CAN ID, and resets the CAN ID according to the sent CAN ID.
5. The method according to claim 1, characterized in that The step of responding to a confirmation message sent by the controller slave module based on the reset CAN ID, maintaining a CAN ID mapping table based on the confirmation message to manage the CAN ID of the controller slave module includes: Receiving, via the data bus, a confirmation message sent by the controller slave module based on the reset CAN ID; Parsing the confirmation message to determine whether the controller slave module has successfully reconfigured the CAN ID; When it is confirmed that the controller slave module has successfully reconfigured the CAN ID, the corresponding relationship between the module number of the controller slave module and the reset CAN ID is added to the CAN ID mapping table to manage the CAN ID of the controller slave module.
6. A CAN-based controller backplane communication system, characterized in that: include: Data bus, address bus, controller CPU module and N controller slave modules, N is a positive integer; where, The controller CPU module is used to respond to the CAN ID application message automatically sent by the controller slave module after power-on, select the controller slave module for matching through the address bus and send the CAN ID configuration message to the controller slave module through the data bus; When the controller slave module is matched successfully, resetting the CAN ID of the controller slave module according to the CAN ID configuration message; In response to a confirmation message sent by the controller slave module based on the reset CAN ID, maintaining a CAN ID mapping table based on the confirmation message to manage the CAN ID of the controller slave module; The backplane data communication is performed with the controller slave module according to the CAN ID mapping table.
7. The system according to claim 6, characterized in that The controller CPU module includes a CAN ID sending submodule, a CAN ID management submodule and a backplane data communication submodule.
8. The system according to claim 6, characterized in that The controller slave module includes a slave module reporting submodule, a CAN ID receiving submodule and a slave module responding submodule.
9. The system according to claim 6, characterized in that The data bus is a CAN communication bus, including a CANH data line and a CANL data line, and is used for the controller CPU module to communicate with N controller slave modules.
10. The system according to claim 9, characterized in that The address bus is a GPIO pin line; the controller CPU module includes 5 GPIO output pins, and each of the controller slave modules includes 5 GPIO input pins and 5 GPIO output pins; The output of the controller CPU module is connected to the input of the first controller slave module, and the output of the first controller slave module is connected to the input of the second controller slave module, until it is connected to the input of the Nth controller slave module; The address bus is used by the controller CPU module to select the controller slave module for CAN ID allocation.
Citation Information
Cited By
Motor rapid deployment method based on CAN bus
CN121056264A