Multi-slave self-adaptive numbering method and multi-slave self-adaptive numbering system
Through the adaptive numbering method of level signal transmission, the problem of large host burden and complex hardware structure is solved, efficient numbering and system scalability is achieved, troubleshooting is simplified, and the number of slaves is changed.
Patent Information
- Application Number
- CN202510489220.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-18
- Publication Date
- 2025-08-29
AI Technical Summary
Among the existing multi-slave numbering methods, the host has a large burden, low numbering efficiency, complex hardware structure and poor system expansion, making it difficult to adapt to changes in the number of slaves and troubleshooting.
Adaptive numbering method is adopted to transmit level signals between the host and the slave, and the numbering is allocated through level signals transmission between the host and the slave 1 and between adjacent slaves. The adjacent slave judges its own number by the number of level signals, and the previous slave reports the numbering result to the host. The host periodically initiates the numbering process to ensure the normal operation of the system.
Significantly reduce the burden on the host, improve numbering efficiency, reduce hardware costs, enhance system scalability and flexibility, simplify troubleshooting, and adapt to changes in the number of slaves.
Smart Images

Figure CN120567602A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a method and system for adaptive numbering of multiple slaves. Background Art
[0002] In fields like industrial control automation, the increasing demand for communication has led to a growing number of slaves in the system, placing higher demands on slave numbering management. In traditional systems with a single master and multiple slaves, slave numbers typically require manual configuration or rely on master broadcasts for allocation. Manual numbering becomes a significant workload for a large number of slaves, while master broadcasts place an increased burden on the master. To address these challenges, hardware-based automatic numbering methods have emerged.
[0003] However, existing hardware-based automatic numbering methods still have numerous shortcomings. For one, they still require host broadcasts, placing a heavy burden on the host and inefficient numbering. Another issue is that they shift reliance on the host to hardware, resulting in complex and costly hardware. Furthermore, when the system needs to be expanded or adjusted, such as adding or removing slave devices, existing numbering methods lack scalability, making it difficult to quickly adapt to changes and inefficient for troubleshooting. Summary of the Invention
[0004] The purpose of the present invention is to propose a multi-slave adaptive numbering method and a multi-slave adaptive numbering system based on autonomous numbering and judgment of the slaves, thereby effectively reducing the burden on the host and improving signal efficiency.
[0005] To achieve the above object, the present invention proposes a multi-slave adaptive numbering method, including a master and multiple slaves, wherein the numbering process is as follows: the master sends numbering information to slave 1, and after slave 1 completes the numbering, it sends numbering information to slave 2, and so on, until all slaves complete the numbering task;
[0006] The slave n at the previous level is responsible for determining whether the numbering of the slave n+1 at the next level is correct. If it is wrong, the slave n reports to the master; if all are correct, the slave at the end actively reports the numbering completion information to the master.
[0007] Furthermore, the number allocation process is completed between the master and slave 1 and between adjacent slaves through the transmission of level signals.
[0008] Furthermore, the numbering process based on the level signal is as follows: the host sends a level signal containing a falling edge to slave 1, and after slave 1 receives one falling edge signal, it determines that its own number is 1. Slave 1 sends a level signal containing two falling edges to slave 2, and after slave 2 receives two falling edge signals, it determines that its own number is 2. And so on, slave n sends a level signal containing n+1 falling edges to slave n+1, and after slave n+1 receives n+1 falling edge signals, it determines that its own number is n+1, until all slaves complete the numbering task based on the number of falling edges of the level signal.
[0009] Furthermore, the judgment process of the upper-level slave on the lower-level slave is as follows: while slave 1 sends a signal containing two falling edge levels to slave 2, slave 1 synchronously sends a signal containing two falling edge levels to the host, and the host judges whether slave 1 is numbered correctly based on the number of falling edges; while slave 2 sends a signal containing three falling edge levels to slave 3, slave 2 synchronously sends a signal containing three falling edge levels to slave 1, and slave 1 judges whether slave 2 is numbered correctly based on the number of falling edges; and so on, while slave n+1 sends a signal containing n+2 falling edge levels to slave n+2, slave n+1 synchronously sends a signal containing n+2 falling edge levels to slave n, and slave n judges whether slave n+1 is numbered correctly based on the number of falling edges.
[0010] Furthermore, if the number of falling edges of the level signal of slave n+1 parsed by slave n is not n+2, it is determined that the numbering fails, and slave n reports the error level signal to the master;
[0011] If slave n successfully sends a level signal to slave n+1, but does not receive feedback from slave n+1, it is determined that slave n+1 is faulty and the host does not trust slaves n+1 and subsequent numbers.
[0012] If the output signal port of slave n is a low-level signal, it is determined that slave n+1 is offline or does not exist, and the system numbering is completed.
[0013] Furthermore, in addition to initiating the initial number allocation process when the host is powered on, it will also periodically initiate the number allocation process to ensure the normal operation of the system.
[0014] The present invention also proposes a multi-slave adaptive numbering system, comprising a master and multiple slaves; the master communicates with each slave via a communication bus 5, and adjacent slaves are connected via level signal lines.
[0015] Furthermore, the OUT signal output port of the host is connected to the IN signal input port of slave 1, and the OUT signal output port of slave 1 is connected to the IN signal input port of the host;
[0016] The OUT signal output port of slave n is connected to the left IN signal input port of slave n+1, and the IN signal input port of slave n is connected to the OUT signal output port of slave n+1.
[0017] Compared with the prior art, the advantages of the present invention are:
[0018] 1. The host burden is greatly reduced and numbering efficiency is significantly improved: This invention adopts a unique signal transmission and numbering mechanism, which allows slaves to independently complete the number allocation process. Compared with the traditional method that relies on host broadcasts, it greatly reduces the communication and control burden of the host, allowing the host to use more resources for other core tasks. At the same time, the numbering process quickly and accurately assigns numbers to slaves through clear signal interaction and judgment steps, avoiding complex communication delays and error troubleshooting, significantly improving numbering efficiency, and better adapting to complex scenarios with a large number of slaves.
[0019] 2. Simple hardware structure and enhanced system scalability: This invention significantly reduces its reliance on hardware circuits, eliminating the need for complex hardware connections and configurations to implement the numbering function, thus reducing hardware costs. Furthermore, when the system needs to be expanded or adjusted, the numbering process can be automatically completed according to the established signal interaction process after the new slave is connected, eliminating the need for large-scale reconfiguration of the entire system. This makes troubleshooting more convenient, effectively improving the system's scalability and flexibility, and facilitating subsequent upgrades and maintenance. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 This is a schematic diagram of signal connections between the master and slave devices in Example 1 of the present invention.
[0021] Figure 2 This is a schematic diagram of signal connections between a host and multiple slaves in Example 1 of the present invention.
[0022] Figure 3 1 is a flow chart of adaptive numbering of multiple slaves in embodiment 2 of the present invention.
[0023] Figure 4 This is a timing diagram of the numbering process of the multi-slave adaptive numbering system in embodiment 2 of the present invention.
[0024] Figure 5 This is a schematic diagram of level signal transmission in Example 2 of the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be further described below.
[0026] Example 1:
[0027] This embodiment proposes a multi-slave adaptive numbering system, such as Figure 2 As shown in the figure, it consists of a master and three slaves; Figure 1 As shown, the host is connected to each slave via a communication bus 5. The communication bus 5 realizes bidirectional data transmission between the host and the slave, transmits host instructions and slave feedback information, and can adopt a variety of communication protocols and standards. In this embodiment, Figure 1 RS-485 is used in the illustration, and in other embodiments, Modbus, CAN, etc. may be used.
[0028] The OUT signal output port of the host is connected to the left IN signal input port of slave 1, and the IN signal input port of the host is connected to the left OUT signal output port of slave 1; the OUT signal output port of slave 1 is connected to the left IN signal input port of slave 2, and the IN signal input port of slave 1 is connected to the left OUT signal output port of slave 2; the OUT signal output port of slave 2 is connected to the left IN signal input port of slave 3, and the IN signal input port of slave 2 is connected to the left OUT signal output port of slave 3. All of the above realize bidirectional transmission of level signals through the level signal line 6, as shown in FIG. Figure 1 and Figure 2 As shown, a stable power supply is achieved between the host and the slave through the power line VCC7; when the device is powered on, all signal ports are in a high level state.
[0029] Example 2:
[0030] This embodiment proposes a multi-slave adaptive numbering method, the brief steps are as follows: Figure 3 As shown:
[0031] S1: n=1, the host sends a signal to slave 1, slave 1 completes the numbering and responds to the host;
[0032] S2: The master checks the signal to determine whether the slave 1 number is correct. If it is correct, it jumps to S3, otherwise it jumps to S5.
[0033] S3: Slave n sends a signal to slave n+1, and slave n+1 completes the numbering and responds to slave n;
[0034] S4: Slave n checks the signal to determine whether the number of slave n+1 is correct. If it is correct, then n=n+1 and jump to S3. Otherwise, jump to S5.
[0035] S5: Slave n reports to the master.
[0036] After applying the above steps to the multi-slave adaptive numbering system in Example 1, the system operation steps are as follows: Figure 4 As shown:
[0037] Step 1: The host starts sending number information to the slave. The host sends a falling edge level signal to slave 1, and slave 1 completes the numbering "1";
[0038] Step 2: Slave 1 sends two falling edge level signals to slave 2, and feeds back the two falling edge level signals to the host at the same time;
[0039] Step 3: The host checks the signal to confirm whether the number of falling edges of the feedback level signal is 2. If so, jump to step 4; otherwise, jump to step 12.
[0040] Step 4: Slave 2 completes the number "2" based on the number of falling edges of the level signal;
[0041] Step 5: Slave 2 sends three falling edge level signals to slave 3, and at the same time feeds back the three falling edge level signals to slave 1;
[0042] Step 6: Slave 1 checks the signal to confirm whether the number of falling edges of the feedback level signal is 3. If so, jump to step 7; otherwise, jump to step 12.
[0043] Step 7: Slave 3 completes the number "3" based on the number of falling edges of the level signal;
[0044] Step 8: Slave 3 sends four falling edge level signals to slave 4, and at the same time feeds back the four falling edge level signals to slave 2;
[0045] Step 9: Slave 2 checks the signal to confirm whether the number of falling edges of the feedback level signal is 4. If so, jump to step 10; otherwise, jump to step 12.
[0046] Step 10: Since slave 4 does not exist in Example 1, slave 3 cannot send a level signal. Its right OUT signal output port is low, indicating that no next-level slave is connected to the system. Slave 3 reports the numbering completion information to the master and proceeds to step 11.
[0047] S11: Based on the low-level signal fed back, the host determines that slave 4 is offline or does not exist, and the system numbering is completed;
[0048] S12: The host's logic for determining the slave number is incorrect, and the host does not trust the slave and subsequent numbers.
[0049] In other embodiments, if slave 4 exists, similar to Figure 4 and Figure 5 As shown in the figure, slave 3 successfully sent 4 falling edge level signals to slave 4. Slave 4 had no signal to upload, and slave 3 did not receive any feedback, indicating that slave 4 was faulty and the number could not be parsed. Slave 3 reported the slave fault information to the host, and the host did not trust slave 4 and subsequent numbers.
[0050] In this embodiment, in addition to initiating the initial number allocation process when the host is powered on, the host will also periodically initiate the number allocation process to ensure normal operation of the system.
[0051] Example 3:
[0052] The traditional host broadcast numbering method has the following process:
[0053] S1: The host starts the numbering process: The host starts the numbering process and prepares to send numbering instructions to all slaves.
[0054] S2: The host sends a numbering instruction to slave 1: The host sends a numbering instruction "1" to slave 1.
[0055] S3: Slave 1 responds to the host: After receiving the numbering instruction, slave 1 completes the numbering "1" and sends a confirmation signal to the host.
[0056] S4: The master verifies the response of slave 1: After receiving the confirmation signal from slave 1, the master verifies whether the serial number is correct. If correct, it jumps to S5; if not, it jumps to S12.
[0057] S5: The host sends a numbering instruction to slave 2: The host sends a numbering instruction "2" to slave 2.
[0058] S6: Slave 2 responds to the host: After receiving the numbering instruction, slave 2 completes the numbering "2" and sends a confirmation signal to the host.
[0059] S7: The master verifies the response of slave 2: After receiving the confirmation signal from slave 2, the master verifies whether the serial number is correct. If correct, the process proceeds to step 8; if not, the process proceeds to step 12.
[0060] S8: The host sends a numbering instruction to slave 3: The host sends a numbering instruction "3" to slave 3.
[0061] S9: Slave 3 responds to the host: After receiving the numbering instruction, slave 3 completes the numbering "3" and sends a confirmation signal to the host.
[0062] S10: The master verifies the response of slave 3: After receiving the confirmation signal from slave 3, the master verifies whether the serial number is correct. If correct, the master jumps to S11; if not, the master jumps to S12.
[0063] S11: The host sends a numbering instruction to slave 4: The host sends a numbering instruction "4" to slave 4.
[0064] S12: Slave 4 responds to the host: If slave 4 does not exist and the host does not receive a response within the specified time, it is determined that slave 4 is offline or does not exist, and the system numbering is completed; if slave 4 exists, the numbering "4" is completed and a confirmation signal is sent to the host.
[0065] S13: The host verifies the response of slave 4: If the host receives a confirmation signal from slave 4, it performs a verification; if the verification is correct, it continues the numbering process of subsequent slaves; if the verification is wrong or no response is received, it jumps to S14.
[0066] S14: The host judges the numbering logic error: The host judges the slave numbering logic error and does not trust the slave numbering and subsequent numbers.
[0067] There are significant differences in many aspects between the traditional host broadcast numbering method and the multi-slave adaptive numbering method of the present application. In terms of numbering time, the traditional method requires the host to communicate with each slave in turn to complete numbering and verification, with a time complexity of O(N), that is, the numbering time is proportional to the number of slaves. However, the method of the present application uses level signal transmission between slaves, and the numbering and verification processes can be completed in parallel, with a time complexity of O(1), which is independent of the number of slaves, greatly shortening the numbering time. In the scenario of 3 slaves, the traditional method may take up to 200ms in total due to conflict retry, one-by-one allocation and error handling. In contrast, the adaptive numbering method of embodiments 1 and 2 of this invention uses a chain level signal transmission mechanism to disperse the numbering process to the slaves for autonomous completion. In the same scenario of 3 slaves, the total time consumed for signal transmission and verification is only 75ms, a time reduction of 62.5%. In terms of the host burden, in the traditional method, the host is the core and needs to handle all communications and verifications, which is a heavy burden; while in the method of this application, the host only needs to initiate the numbering process, and the subsequent numbering is completed autonomously by the slave, which greatly reduces the burden.
[0068] Based on the above analysis, the present invention adopts a unique signal transmission and numbering mechanism, and the number allocation process can be completed independently between slaves. Compared with the traditional method that relies on host broadcasting, the communication and control burden of the host is greatly reduced, so that the host can use more resources for other core tasks. At the same time, the numbering process quickly and accurately assigns numbers to slaves through clear signal interaction and judgment steps, avoids complex communication delays and error troubleshooting, significantly improves numbering efficiency, and can better adapt to complex scenarios with a large number of slaves. In addition, the present invention greatly reduces the degree of dependence on hardware circuits, and does not require complex hardware connections and configurations to achieve the numbering function, reducing hardware costs. When the system needs to be expanded or adjusted, after a new slave is connected, the numbering can be automatically completed according to the established signal interaction process, without the need for large-scale reconfiguration of the entire system. Troubleshooting is also more convenient, effectively improving the scalability and flexibility of the system, and facilitating subsequent upgrades and maintenance.
[0069] The above description is merely a preferred embodiment of the present invention and does not limit the present invention in any way. Any person skilled in the art who, without departing from the scope of the present invention, makes any equivalent substitution, modification, or other changes to the technical solution and technical content disclosed in the present invention shall be deemed to be within the scope of the present invention and still fall within the scope of protection of the present invention.
Claims
1. A method for adaptive numbering of multiple slaves, characterized in that: Including the master and multiple slaves, the number assignment process is: the master sends number information to slave 1, and after slave 1 completes the numbering, it sends number information to slave 2, and so on, until all slaves complete the numbering task; The slave n at the previous level is responsible for judging whether the numbering of the slave n+1 at the next level is correct. If it is wrong, the slave n reports to the master; if everything is correct, the slave at the end actively reports the numbering completion information to the master.
2. The multi-slave adaptive numbering method according to claim 1, characterized in that: The number allocation process is completed between the host and the slave 1 and between adjacent slaves through the transmission of level signals.
3. The multi-slave adaptive numbering method according to claim 2, characterized in that: The numbering process based on the level signal is as follows: the host sends a level signal containing one falling edge to slave 1, and after slave 1 receives one falling edge signal, it determines that its own number is 1. Slave 1 sends a level signal containing two falling edges to slave 2, and after slave 2 receives two falling edge signals, it determines that its own number is 2. And so on, slave n sends a level signal containing n+1 falling edges to slave n+1, and after slave n+1 receives n+1 falling edge signals, it determines that its own number is n+1, until all slaves complete the numbering task based on the number of falling edges of the level signal.
4. The multi-slave adaptive numbering method according to claim 3, characterized in that: The judgment process of the upper-level slave on the lower-level slave is as follows: when slave 1 sends a signal containing two falling edge levels to slave 2, slave 1 synchronously sends a signal containing two falling edge levels to the host, and the host judges whether slave 1 is numbered correctly based on the number of falling edges; when slave 2 sends a signal containing three falling edge levels to slave 3, slave 2 synchronously sends a signal containing three falling edge levels to slave 1, and slave 1 judges whether slave 2 is numbered correctly based on the number of falling edges; and so on, when slave n+1 sends a signal containing n+2 falling edge levels to slave n+2, slave n+1 synchronously sends a signal containing n+2 falling edge levels to slave n, and slave n judges whether slave n+1 is numbered correctly based on the number of falling edges.
5. The multi-slave adaptive numbering method according to claim 4, characterized in that: If the number of falling edges of the level signal of slave n+1 parsed by slave n is not n+2, it is determined that the numbering fails, and the slave n reports the error level signal to the host; If slave n successfully sends a level signal to slave n+1 but does not receive feedback from slave n+1, it is determined that slave n+1 is faulty and the host does not trust slaves n+1 and subsequent numbers. If the output signal port of slave n is a low-level signal, it is determined that slave n+1 is offline or does not exist, and the system numbering is completed.
6. The multi-slave adaptive numbering method according to claim 1, characterized in that: In addition to initiating the initial number allocation process when the host is powered on, the host will also periodically initiate the number allocation process to ensure the normal operation of the system.
7. A multi-slave adaptive numbering system, using the multi-slave adaptive numbering method according to any one of claims 1 to 6, characterized in that: It includes a host and multiple slaves; the host communicates with each of the slaves via a communication bus 5, and adjacent slaves are connected via level signal lines.
8. The multi-slave adaptive numbering system according to claim 7, characterized in that: The OUT signal output port of the host is connected to the IN signal input port of slave 1, and the OUT signal output port of slave 1 is connected to the IN signal input port of the host; The OUT signal output port of slave n is connected to the left IN signal input port of slave n+1, and the IN signal input port of slave n is connected to the OUT signal output port of slave n+1.