Automatic addressing method, device and equipment of CAN communication management system
By detecting and comparing the level frequency of the slave control module input port with the level frequency of the main control module output port, and using the preset address and frequency correspondence table to compile the own address, the technical challenge of automatic addressing of the slave control module under the control of the master control module is solved, and efficient CAN communication management is achieved.
Patent Information
- Application Number
- CN202411754160.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-02-28
AI Technical Summary
In the absence of a master control module, realizing automatic addressing and communication management of slave control modules is a technical challenge, especially in CAN communication, where resource waste and communication efficiency are reduced due to the broadcast mechanism.
By detecting the level frequency of the slave control module input port and determining whether it is consistent with the level frequency output from the main control module output port, if it is consistent, the self-address is compiled according to the preset address and frequency correspondence table, and the output port level is output to the next slave control module with a fixed frequency square wave to make it compile its own address.
It realizes automatic addressing and communication management of slave control modules without the participation of the main control module, improves the efficiency and resource utilization of CAN communication, and avoids the occurrence of communication bottlenecks.
Smart Images

Figure CN119544668A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of controller area network (CAN) communication technology, and in particular to an automatic addressing method, device and equipment for a CAN communication management system. Background Art
[0002] The lack of automatic addressing is a notable feature in Controller Area Network (CAN) communications. The CAN communication protocol was originally designed without automatic addressing, which means that all nodes receive broadcast signals and can be added to the network without configuration. This design makes the CAN bus widely used in automotive, industrial automation and other fields, as they usually require high reliability and real-time performance.
[0003] However, this design also brings some challenges. Since all nodes on the CAN bus will receive the broadcast signal, this may lead to resource waste and reduced communication efficiency. In addition, when the number of nodes in the network increases, this broadcast mechanism may cause communication bottlenecks and affect the overall performance of the system. To overcome these limitations, some advanced CAN controllers and system designs have introduced additional mechanisms to optimize the addressing and communication process. For example, some CAN controllers support fast access and addressing through special registers, while other systems may use specific addressing modes to reduce unnecessary communication load.
[0004] Despite this, automatic addressing without master control module control is still an elusive goal in CAN communication. This is because one of the core features of the CAN protocol is its broadcast mechanism, which requires each node to be able to receive and process all data from other nodes on the network. Therefore, achieving efficient automatic addressing and communication management without a central control module remains a technical challenge. Summary of the invention
[0005] The main purpose of the present invention is to solve the technical problem of how to realize automatic addressing of a slave control module without the control of a master control module.
[0006] A first aspect of the present invention provides an automatic addressing method for a CAN communication management system, the automatic addressing method for the CAN communication management system comprising:
[0007] Detecting the level frequency of the input port of the slave control module, wherein there are multiple slave control modules;
[0008] Determine whether the level frequency of the input port of the slave control module is the level frequency output by the output port of the master control module;
[0009] If yes, compile the address of the slave control module according to the level frequency of the input port of the slave control module and the preset address and frequency correspondence table;
[0010] The level of the output port of the slave control module is output to the next slave control module in the form of a square wave corresponding to a fixed frequency, so that the next slave control module compiles its own address according to the square wave of the fixed frequency.
[0011] Optionally, in a first implementation manner of the first aspect of the present invention, the input port and the output port of the slave control module are IO ports, and the slave control modules are connected sequentially through the IO ports.
[0012] Optionally, in a second implementation of the first aspect of the present invention, outputting the level of the output port of the slave control module to the next slave control module in the form of a square wave corresponding to a fixed frequency, so that the next slave control module compiles its own address according to the square wave of the fixed frequency includes:
[0013] According to the preset incremental frequency and the level frequency outputted by the output port of the master control module, a square wave of a fixed frequency corresponding to the level outputted by the output port of the slave control module is calculated;
[0014] The square wave with the fixed frequency is output to the next slave control module, so that the next slave control module compiles its own address according to the square wave with the fixed frequency.
[0015] Optionally, in a third implementation of the first aspect of the present invention, the calculating, according to the preset incremental frequency and the level frequency output by the output port of the master control module, a square wave of a fixed frequency output corresponding to the level of the output port of the slave control module comprises:
[0016] Determining the sequential position of the slave control module in the CAN communication;
[0017] According to the sequence position, the preset incremental frequency and the level frequency output by the output port of the master control module, a square wave with a fixed frequency output corresponding to the level of the output port of the slave control module is calculated.
[0018] Optionally, in a fourth implementation of the first aspect of the present invention, before compiling the address of the slave control module according to the level frequency of the input port of the slave control module and the preset address and frequency correspondence table, the method further includes:
[0019] Obtaining the level status of the input port of the slave control module;
[0020] If the level state of the input port of the slave control module is a low level, the step of compiling the self-address of the slave control module according to the level frequency of the input port of the slave control module and the preset address and frequency correspondence table is entered, wherein the output port of the slave control module whose self-address is not compiled outputs a high level;
[0021] If the level state of the input port of the slave control module is high level, keep silent.
[0022] A second aspect of the present invention provides an automatic addressing device for a CAN communication management system, on which a computer program is stored, and when the computer program is executed, the automatic addressing method for the CAN communication management system according to any one of claims 1 to 5 is implemented.
[0023] In an embodiment of the present invention, the level frequency of the input port of the slave control module is detected, and there are multiple slave control modules; it is determined whether the level frequency of the input port of the slave control module is the level frequency output by the output port of the master control module; if so, the self-address of the slave control module is compiled according to the level frequency of the input port of the slave control module and the preset address and frequency correspondence table; the level of the output port of the slave control module is output to the next slave control module in the form of a square wave corresponding to a fixed frequency, so that the next slave control module compiles its own address according to the square wave of the fixed frequency. In the present invention, the slave control module compiles its own address by detecting the level frequency of the input port, and after compilation, the level of the output port of the slave control module is output to the next slave control module in the form of a square wave corresponding to a fixed frequency, so that the next slave control module compiles its own address according to the square wave of the fixed frequency, and so on, thereby realizing automatic addressing of all slave control modules without the participation of the master control module. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A schematic diagram of an embodiment of an automatic addressing method of a CAN communication management system in an embodiment of the present invention;
[0025] Figure 2 This is a schematic diagram of the structure of the CAN communication management system module in an embodiment of the present invention;
[0026] Figure 3 A schematic diagram of an embodiment of an automatic addressing device of a CAN communication management system in an embodiment of the present invention;
[0027] Figure 4 It is a schematic diagram of an embodiment of an automatic addressing device of a CAN communication management system in an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The embodiment of the present invention provides an automatic addressing method, device and equipment for a CAN communication management system.
[0029] The embodiments disclosed in the present invention will be described in more detail below with reference to the accompanying drawings. Although certain embodiments disclosed in the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments disclosed in the present invention are only for exemplary purposes and are not intended to limit the scope of protection disclosed in the present invention.
[0030] In the description of the embodiments disclosed in the present invention, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc. may refer to different or the same objects. Other explicit and implicit definitions may also be included below.
[0031] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , an embodiment of the automatic addressing method of the CAN communication management system in the embodiment of the present invention includes:
[0032] S100, detecting the level frequency of the input port of the slave control module.
[0033] In the present embodiment, CAN (Controller Area Network) is an internationally standardized serial communication protocol. The basic principle of CAN communication includes high-speed data transmission between multiple nodes, and is suitable for systems that require high real-time performance and high reliability. The CAN bus consists of two wires: CAN_H (CAN High) and CAN_L (CAN Low), and reliability and real-time performance are guaranteed by differential signal transmission. CAN communication uses NRZ code, and the data itself does not carry clock information. The sending unit starts to send frame data in a bit timing synchronization manner. The implementation method of CAN communication includes using HAL library and standard library to implement CAN communication. In the present invention, the automatic addressing of the slave control module is realized without the participation of the master control module to perform CAN communication. The CAN communication management system includes a master control module and multiple slave control modules. First, the master control module will output a default fixed level frequency. After the CAN communication management system turns on automatic addressing, it detects the level frequency of the slave control module, wherein the level frequency refers to the potential state in which the signal remains stable within a certain time range, which is usually used to represent the logical state of a digital signal, which can be a high level or a low level.
[0034] S200, determining whether the level frequency of the input port of the slave control module is the level frequency output by the output port of the master control module.
[0035] In this embodiment, the level frequency of the input port of the slave control module is detected to determine whether the level frequency of the input port of the slave control module is the level frequency output by the master control module. Optionally, the input capture function can be used to measure the level frequency of the input port of the slave control module. The input capture function can record the value of the counter when the level of the input signal jumps, thereby calculating the frequency of the input signal; or the level change of the input signal is detected by reading the state of the GPIO port to determine whether the input signal is the square wave frequency set by the master control module. Specifically, the GPIO pin needs to be configured as an input mode first. After being configured as an input mode, the current level state can be obtained by reading the input register of the GPIO; in order to detect the change of the level, the level state of the GPIO can be read regularly and compared with the state read last time. If it is found that the level state changes (from high to low or from low to high), it means that there is a signal input. Once the level change is detected, the frequency of the signal can be calculated according to the time interval of the change.
[0036] S300: If yes, compile the address of the slave control module according to the level frequency of the input port of the slave control module and the preset address and frequency correspondence table.
[0037] In this embodiment, if it is detected that the level frequency of the input port of the slave control module is the level frequency output by the output port of the master control module, then according to the preset address and frequency correspondence table, the communication address corresponding to the level frequency is found to compile the self-address of the slave control module, wherein the address and frequency correspondence table is defined according to the actual project requirements, for example, 1K corresponds to communication address 4, 1.1K corresponds to communication address 5, and 1.2K corresponds to communication address 6, so that when the slave control module detects the level frequency, then its own communication response address is set. After the slave control module completes the compilation of its own address, it realizes CAN communication with the master control module or other slave control modules.
[0038] S400: output the level of the output port of the slave control module to the next slave control module in the form of a square wave corresponding to a fixed frequency, so that the next slave control module compiles its own address according to the square wave of the fixed frequency.
[0039] In this embodiment, after the slave control module completes the compilation of its own address, the level of the output port of the slave control module is output to the next slave control module in the form of a square wave corresponding to a fixed frequency. The next slave control module then detects the level frequency of the input port to determine whether the level frequency is the fixed frequency output by the output port of the previous slave control module. If so, the address of the slave control module is compiled according to the fixed frequency, and so on. Among them, the square wave is a non-sinusoidal waveform, which usually appears in electronic and signal processing. The ideal square wave has only two values, "high" and "low". A signal with a rectangular waveform of current or voltage is a rectangular wave signal. The ratio of the time occupied by the high level in a waveform cycle is called the duty cycle, which can also be understood as the ratio of the effective release time of the circuit to the total release time. A rectangular wave with a duty cycle of 50% is called a square wave. By changing the program, for example, outputting "1" (high level) for a period of time, and then outputting "0" (low level) for a period of time, and repeatedly running this program, a square wave output will be obtained.
[0040] In an optional implementation of the first aspect of the present invention, the input port and the output port of the slave control module are IO ports, and the slave control modules are connected in sequence through the IO ports.
[0041] In this embodiment, if Figure 2 As shown, the CAN communication system has n slave control modules, where n is a positive integer greater than or equal to 2, and the n slave control modules are connected in sequence, and each slave control module includes at least two IO ports, which are input port IO1 and output port IO2. The output port IO2 of the previous slave control module is connected to the input port IO1 of the next slave control module, and each slave control module is connected to the main control module through a communication unit for communication. The main control module includes an IO output, which outputs the default fixed frequency main control module. In order to avoid the first power-on, the front slave control module has not completed the address compilation, and the following slave control module has no communication frequency input and automatically defaults to the first module. Therefore, at the beginning of power-on, before the address compilation is completed, the output IO of the slave control module is all high level. Specifically, after the first slave control module is powered on and waits for Td0 time, it detects the level frequency of the input port IO1, determines whether the level frequency of the input port IO1 is the level frequency output by the output port IO of the master control module, and if so, performs automatic addressing according to the level frequency. After completing the addressing, the level of the output port of the slave control module is output to the next slave control module in a square wave corresponding to a fixed frequency. If the input port IO1 of the next slave control module detects the fixed frequency output by the previous slave control module, it performs automatic addressing, and so on, until all slave control modules are addressed. Among them, when the slave control module is automatically addressed, it can compile its own address without the need for the master control module. When the slave control module completes the addressing, it participates in CAN communication.
[0042] In an optional implementation of the first aspect of the present invention, outputting the level of the output port of the slave control module to the next slave control module in the form of a square wave corresponding to a fixed frequency, so that the next slave control module compiles its own address according to the square wave of the fixed frequency includes:
[0043] According to the preset incremental frequency and the level frequency output by the output port of the master control module, the fixed-frequency square wave output corresponding to the level of the output port of the slave control module is calculated; the fixed-frequency square wave is output to the next slave control module, so that the next slave control module compiles its own address according to the fixed-frequency square wave.
[0044] In this embodiment, a fixed incremental frequency is set. After each slave control module completes addressing, the fixed frequency output by the output port IO2 will increase the incremental frequency. For example, if the incremental frequency is set to 0.1K, then the fixed frequency output by the output port IO2 of the first slave control module is increased by 0.1K, and the fixed frequency output by the output port IO2 of the second slave control module is increased by 0.1K+0.1K=0.2K. The dynamic adjustment of the frequency can be achieved by a phase accumulator. The phase accumulator will continuously accumulate a fixed phase increment value. The frequency change rate can be controlled by adjusting this increment value.
[0045] In an optional implementation of the first aspect of the present invention, according to the preset incremental frequency and the level frequency output by the output port of the master control module, calculating the square wave of a fixed frequency output corresponding to the level of the output port of the slave control module includes:
[0046] Determine the sequential position of the slave control module in the CAN communication; calculate the square wave of fixed frequency output corresponding to the level of the output port of the slave control module according to the sequential position, the preset incremental frequency and the level frequency output by the output port of the master control module.
[0047] In this embodiment, the incremental frequency corresponding to the slave control module is determined according to the sequential position of the slave control module in the CAN communication, so as to calculate the fixed frequency of the output corresponding to the level of the output port of the slave control module. Specifically, when the first slave control module input port IO1 outputs the default fixed frequency f0 for the master control module, the local address is compiled as the first set address code, and the output port IO2 high level is output as a square wave with a fixed frequency (f0+f*1), where f is the incremental frequency. When the n+1th slave control module detects that the level frequency of the input IO1 has changed to f0+f*n, the local address is compiled as the n+1th set address code, and the output IO2 high level is changed to a square wave output with a fixed frequency f0+f*(n+1). And so on, the autonomous addressing of all modules is finally completed.
[0048] In an optional implementation of the first aspect of the present invention, before compiling the address of the slave control module itself according to the level frequency of the input port of the slave control module and the preset address and frequency correspondence table, the method further includes:
[0049] Obtain the level state of the input port of the slave control module; if the level state of the input port of the slave control module is a low level, enter the step of compiling the slave control module's own address according to the level frequency of the input port of the slave control module and the preset address and frequency correspondence table, wherein the output port of the slave control module whose own address is not compiled outputs a high level; if the level state of the input port of the slave control module is a high level, remain silent.
[0050] In this embodiment, when the slave control module has not completed automatic addressing, the output port IO2 outputs a high level by default. First, the level state of the input port of the slave control module is obtained. If the level state of the input port of the slave control module is a low level or the level frequency output by the output port of the master control module, the slave control module's own address is compiled according to the level frequency of the input port of the slave control module and the preset address and frequency correspondence table. After compiling its own address, the level output by the output port is changed; if the level state of the input port of the slave control module is a high level, it remains silent.
[0051] See also Figure 3 According to a second aspect of the present invention, there is provided an automatic addressing device for a CAN communication management system, the automatic addressing device for the CAN communication management system comprising:
[0052] A level frequency detection unit 10, used to detect the level frequency of the input port of the slave control module, and there are multiple slave control modules;
[0053] A level frequency determination unit 20, used to determine whether the level frequency of the input port of the slave control module is the level frequency output by the output port of the master control module;
[0054] The address compiling unit 30 is used to compile the address of the slave control module according to the level frequency of the input port of the slave control module and the preset address and frequency correspondence table;
[0055] The square wave output unit 40 is used to output the level of the output port of the slave control module to the next slave control module in the form of a square wave corresponding to a fixed frequency, so that the next slave control module compiles its own address according to the square wave of the fixed frequency.
[0056] In an optional implementation of the second aspect of the present invention, the input port and the output port of the slave control module are IO ports, and the slave control modules are connected in sequence through the IO ports.
[0057] In an optional implementation of the second aspect of the present invention, the square wave output unit 40 is also used to calculate the fixed-frequency square wave output corresponding to the level of the output port of the slave control module according to the preset incremental frequency and the level frequency output by the output port of the master control module; and output the fixed-frequency square wave to the next slave control module, so that the next slave control module compiles its own address according to the fixed-frequency square wave.
[0058] In an optional implementation of the second aspect of the present invention, the square wave output unit 40 is also used to determine the sequential position of the slave control module in the CAN communication; based on the sequential position, the preset incremental frequency and the level frequency output by the output port of the master control module, the square wave of fixed frequency corresponding to the level of the output port of the slave control module is calculated.
[0059] In an optional implementation of the second aspect of the present invention, the automatic addressing device of the CAN communication management system further includes:
[0060] The level status detection unit is used to obtain the level status of the input port of the slave control module; if the level status of the input port of the slave control module is a low level, then enter the step of compiling the self-address of the slave control module according to the level frequency of the input port of the slave control module and the preset address and frequency correspondence table, wherein the output port of the slave control module whose self-address is not compiled outputs a high level; if the level status of the input port of the slave control module is a high level, remain silent.
[0061] Figure 4 1 is a schematic diagram of the structure of an automatic addressing device of a CAN communication management system provided by an embodiment of the present invention. The automatic addressing device 500 of the CAN communication management system includes a central computer 510 (host module) and multiple power modules 520 (slave modules). The central computer 510 includes a CAN communication chip 511, a CPU control chip 512, and an IO output line 513. The power module 520 includes a CAN communication chip 521, a DSP control chip 522, and an IO input and output line 523. The IO output of the central computer 510 provides a fixed output frequency level. The IO of the power module 520 is bridged in series to the central computer. At the same time, the CAN communication of all power modules 520 is directly connected to the CAN bus of the central computer 510. Then the power module 520 executes the automatic addressing method of the CAN communication management system to complete the CAN communication address compilation. After the power module 520 completes the address compilation, each power module 520 has an independent communication address, so the central computer 510 can control each independent power module 520 to perform charging and discharging functions through CAN communication.
[0062] In addition, although each operation is described in a specific order, this should be understood as requiring such operation to be performed in the specific order shown or in a sequential order, or requiring that all illustrated operations should be performed to obtain desired results. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single implementation in combination. On the contrary, the various features described in the context of a single implementation can also be implemented in multiple implementations individually or in any suitable sub-combination mode.
[0063] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. An automatic addressing method for a CAN communication management system, characterized in that: The automatic addressing method of the CAN communication management system includes: Detecting the level frequency of the input port of the slave control module, wherein there are multiple slave control modules; Determine whether the level frequency of the input port of the slave control module is the level frequency output by the output port of the master control module; If yes, compile the address of the slave control module according to the level frequency of the input port of the slave control module and the preset address and frequency correspondence table; The level of the output port of the slave control module is output to the next slave control module in the form of a square wave corresponding to a fixed frequency, so that the next slave control module compiles its own address according to the square wave of the fixed frequency.
2. The automatic addressing method of the CAN communication management system according to claim 1 is characterized in that: The input port and the output port of the slave control module are IO ports, and the slave control modules are connected in sequence through the IO ports.
3. The automatic addressing method of the CAN communication management system according to claim 1 is characterized in that: The step of outputting the level of the output port of the slave control module to the next slave control module in the form of a square wave corresponding to a fixed frequency, so that the next slave control module compiles its own address according to the square wave of the fixed frequency comprises: According to the preset incremental frequency and the level frequency outputted by the output port of the master control module, a square wave of a fixed frequency corresponding to the level outputted by the output port of the slave control module is calculated; The square wave with the fixed frequency is output to the next slave control module, so that the next slave control module compiles its own address according to the square wave with the fixed frequency.
4. The automatic addressing method of the CAN communication management system according to claim 3 is characterized in that: The step of calculating the square wave of a fixed frequency outputted corresponding to the level of the output port of the slave control module according to the preset incremental frequency and the level frequency outputted by the output port of the master control module comprises: Determining the sequential position of the slave control module in the CAN communication; According to the sequence position, the preset incremental frequency and the level frequency output by the output port of the master control module, a square wave with a fixed frequency output corresponding to the level of the output port of the slave control module is calculated.
5. The automatic addressing method of the CAN communication management system according to claim 1, characterized in that: Before compiling the address of the slave control module according to the level frequency of the input port of the slave control module and the preset address and frequency correspondence table, the method further includes: Obtaining the level status of the input port of the slave control module; If the level state of the input port of the slave control module is a low level, the step of compiling the self-address of the slave control module according to the level frequency of the input port of the slave control module and the preset address and frequency correspondence table is entered, wherein the output port of the slave control module whose self-address is not compiled outputs a high level; If the level state of the input port of the slave control module is high level, keep silent.
6. An automatic addressing device for a CAN communication management system, characterized in that: The automatic addressing device of the CAN communication management system comprises: A level frequency detection unit, used to detect the level frequency of the input port of the slave control module, wherein there are multiple slave control modules; A level frequency judgment unit, used to judge whether the level frequency of the input port of the slave control module is the level frequency output by the output port of the master control module; An address compiling unit, configured to compile the address of the slave control module itself according to the level frequency of the input port of the slave control module and a preset address and frequency correspondence table; The square wave output unit is used to output the level of the output port of the slave control module to the next slave control module in the form of a square wave corresponding to a fixed frequency, so that the next slave control module compiles its own address according to the square wave of the fixed frequency.
7. An automatic addressing device for a CAN communication management system, characterized in that: A computer program is stored on the automatic addressing device of the CAN communication management system, and when the computer program is executed, the automatic addressing method of the CAN communication management system according to any one of claims 1 to 5 is implemented.