Intelligent capacitor automatic networking system and method
By using serial number ID and random number delay algorithm to automatically assign slave addresses in the reactive power compensation system, the problems of distribution transformer measurement and control terminal failure and the complexity of distributed system address settings are solved, and the reliability and efficiency of the system are improved. Efficient communication between devices is ensured.
Patent Information
- Application Number
- CN202410931447.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-09-10
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing reactive power compensation system cannot continue to be used when the distribution transformer measurement and control terminal fails. It has a complex structure, messy circuit connections, and complicated maintenance. In addition, setting the slave address in the distributed system is time-consuming and laborious, resulting in system configuration delays and impact on response speed.
By reading its own unique serial number ID and generating a delay time based on the serial ID and random number, the slave machine after the delay time sends the command to obtain the master mode, and the master machine sends the report device serial number ID command to the slave machine to automatically allocate the slave machine. Communication address, reduce collision probability and human operation complexity, and improve system reliability and efficiency.
It realizes automated slave address allocation, reduces human operation complexity and error rate, improves system reliability and efficiency, reduces configuration delays, and ensures communication reliability and efficiency between devices.
Smart Images

Figure CN118631785A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of automatic networking technology, and in particular to an intelligent capacitor automatic networking system and method. Background Art
[0002] Most of the existing reactive power compensation uses a reactive power compensation controller to control multiple capacitors to complete the switching. Although this control structure is simple, if the distribution transformer measurement and control terminal fails during use, the capacitor will not be able to continue to be used, affecting the normal power supply of the power supply system. At the same time, the existing reactive power compensation box also has problems such as complex structure, messy circuit connection, large size, and complex maintenance. In the design of traditional RS-485 bus communication system, the slave address is usually set one by one using a dip switch or human-machine input method. However, in some distributed systems, due to the long distance between the host and the slave, there are many slaves in the network, especially when the slave installation environment is harsh, if the slave address must be set at the device installation site, it will be time-consuming and laborious. Therefore, it is particularly important to automatically assign the slave device address in the system.
[0003] In the Chinese invention application with application publication number CN107453844A, a method and apparatus for automatic networking of intelligent devices are disclosed, including sending a first serial number parameter to a sub-device and receiving a first response message sent by the sub-device; when it is determined that a collision conflict occurs, the first serial number parameter is changed and sent to the sub-device again, until no collision occurs, a unique sub-device address is obtained, and it is addressed.
[0004] In the above invention application, the host sends a serial number parameter to the sub-device and receives a response from the sub-device. When it is determined that a collision conflict occurs, the host changes the serial number parameter to narrow the search range, and uses the search algorithm to search repeatedly until no collision conflict occurs. The sub-device address corresponding to the unique response information is obtained and addressed. However, when a collision conflict has occurred in the sub-device, the addressing relief measures taken, each collision conflict and the process of reallocating the address will increase the overall system configuration time. Multiple collisions may cause significant configuration delays and affect the response speed of the system.
[0005] To this end, the present invention provides a smart capacitor automatic networking system and method. Summary of the invention
[0006] 1. Technical issues to be resolved In view of the deficiencies in the prior art, the present invention provides an intelligent capacitor automatic networking system and method. The present invention reads its own unique serial number ID and generates a delay time based on the serial ID and a random number. When the delay time is reached, the slave sends a command to obtain the host mode and becomes the master, and the other slaves automatically switch to the receiving state. The host sends a command to report the device serial number ID to the slave until no new slave devices are generated. Through the automated master-slave system, the probability of slave collision is reduced, the slave transmission is automatically and orderly allocated, and the reliability and efficiency of the system are improved, thereby solving the technical problems recorded in the background technology.
[0007] (II) Technical solution To achieve the above objectives, the present invention is implemented through the following technical solutions: a smart capacitor automatic networking method, comprising the following steps: After the initial power-on, all devices are in slave state, read their own unique serial number ID and generate a delay time based on the serial ID and random number. The slave device that has reached the delay time sends a command to obtain the host mode and becomes the master. Other slave devices automatically switch to the receiving state. The master sends a command to report the device serial number ID to the slave device until no new slave devices are generated. When the host has recorded the number of all slave devices and their corresponding IDs, the host will assign communication addresses to the slaves in sequence according to the device IDs. After receiving the communication addresses, the slaves will upload confirmation commands. The host will determine whether all recorded slave addresses have been set successfully based on the confirmation commands. If all are successful, the automatic networking is completed.
[0008] Furthermore, after the initial power-on, all devices are in slave state, read their own unique serial number ID and generate a delay time based on the serial ID and the random number; the slave device that has reached the delay time sends a command to obtain the host mode and becomes the host, and at the same time pulls the status line low to indicate that the bus is busy. After other slave devices detect that the status line is busy, they automatically switch to the receiving state and receive the command issued by the host. To ensure that all slave devices can receive the command issued by the host, the device will repeat the host command several times after grabbing the host.
[0009] The sample code of the delay algorithm is as follows: import random random_number = random.randint(1, 1000) # Generate a random number between 1 and 1000 import hashlib import time # Assume serial_id is your device serial number (string) serial_id = "your_device_serial_number" random_number = random.randint(1, 1000) # Combine the serial number and random number and process them through the hash function combined = f"{serial_id}{random_number}" hashed = hashlib.sha256(combined.encode()).hexdigest() # Take the first few characters of the hash value (here we take 8, you can adjust as needed) and convert it to an integer # Then use this integer as the delay time in milliseconds delay_time_ms = int(hashed[:8], 16) % 10000 # Assume we want a delay between 0 and 10000 milliseconds # Delay time.sleep(delay_time_ms / 1000.0) Furthermore, after a short delay, the host sends a command to report the device serial number ID to the slave, and pulls up the status line to switch to the receiving state; after the slave receives the command to upload the device ID, it generates a random delay time based on its own ID + random number to upload its own device ID. The slave that completes the delay first pulls the status line low, indicating that the bus is busy, and sends the ID to the host at the same time. If other slaves detect that the status line has been set to busy status by other slaves after the delay, they will regenerate a random delay time and wait again. After the current slave completes the report, it will pull up the status line to indicate that the bus is idle, and other slaves will complete the report in turn.
[0010] Furthermore, after receiving the device ID reported by the slave, the host will verify the correctness of the device ID, remember the correct ID, and record the number of slave devices + 1. Since the ID + random number method cannot ensure that all slave IDs are not lost, it is necessary to repeat the slave ID upload process after a period of time until no new slave devices are generated.
[0011] The host verifies the correctness of the device ID by length verification, character set verification, validity verification, range verification, checksum, hash verification, permission verification, status check, timestamp verification, and validity period verification.
[0012] Length check is to check whether the length of the device ID is correct according to the system agreement. For example, if the system stipulates that the device ID should be 19 digits (such as some IDs generated using the snowflake algorithm), then check whether the received ID length is 19 digits; Character set verification verifies that the device ID contains only allowed characters. For digital IDs, it should be ensured that non-numeric characters are not included in the ID. Validity verification checks whether the device ID is valid based on business logic. For example, the database can be queried to confirm whether the ID corresponds to a registered device. Range verification verifies whether the device ID is within a specific range if it has a specific range limit. Checksum verifies whether the device ID is within the ...
[0013] Furthermore, when the host has recorded the number of all slave devices and their corresponding IDs, the host will assign communication addresses to the slaves in turn according to the device ID. All slaves will receive the address assignment command at the same time. After receiving the address, the slave will compare the device ID in the command with its own ID to determine whether the address assignment is its own. If so, it will save the assigned address. If not, it will continue to wait.
[0014] The host first determines the available communication address range. For example, if the system uses 8-bit addresses, the address range is 0-255. The host can assign addresses according to the registration order of the slave IDs or some sorting rules (such as ascending or descending order of ID values). If the address range is large, or a certain hash relationship is required between the slave ID and the communication address, a hash function can also be used for mapping.
[0015] Furthermore, after waiting for a period of time, the host sends address confirmation commands in sequence according to the addresses. After receiving the communication address, the slave uploads a confirmation command. The host determines whether all the recorded slaves have successfully set the addresses based on the confirmation command. If all are successful, the automatic networking is completed and communication begins; otherwise, the address is reset.
[0016] Furthermore, after the networking is successful, the host will periodically send data query commands to the slaves. After receiving the query command, the slave will upload the corresponding data and record the time interval between the host sending data. Once the host fails, any slave can send a command to query whether the host is normal after the timeout. If there is still no host response after the timeout, all slaves will repeat the automatic networking process to generate a new host.
[0017] An intelligent capacitor automatic networking system, comprising: The host confirmation module, after the initial power-on, all devices are in slave state, read their own unique serial number ID and generate a delay time based on the serial ID and random number; the slave that has reached the delay time sends a command to obtain the host mode and becomes the host, and at the same time pulls the status line low to indicate that the bus is busy. After other slaves detect that the status line is busy, they automatically switch to the receiving state and receive the command issued by the host. To ensure that all slaves can receive the command issued by the host, the device will repeat the host command several times after grabbing the host; Automatic networking module, when the host has recorded the number of all slave devices and the corresponding IDs, the host will assign communication addresses to the slaves in sequence according to the device IDs. After receiving the communication addresses, the slaves upload confirmation commands. The host determines whether all the recorded slaves have successfully set addresses based on the confirmation commands. If all are successful, the automatic networking is completed.
[0018] (III) Beneficial effects The present invention provides a smart capacitor automatic networking system and method, which has the following beneficial effects: 1. After the initial power-on, all devices are in slave state, read their own unique serial number ID and generate a delay time based on the serial ID and random number. The slave that has reached the delay time sends a command to obtain the host mode and becomes the master. Other slaves automatically switch to the receiving state. The host sends a command to report the device serial number ID to the slave until no new slave devices are generated. Through the automated master-slave system, the complexity and error rate of manual operations can be reduced, and the reliability and efficiency of the system can be improved.
[0019] 2. When the host has recorded the number of all slave devices and their corresponding IDs, the host will assign communication addresses to the slaves in turn according to the device IDs. After receiving the communication addresses, the slaves will upload confirmation commands. The host will determine whether all the recorded slaves have successfully set their addresses based on the confirmation commands. If all are successful, the automatic networking is completed, reducing the workload and possible error rate of manual configuration and improving the consistency and accuracy of system configuration. In addition, communication between devices has become more reliable and efficient, and address conflicts or confusion will not occur. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1A schematic diagram of a flow chart of an automatic networking method of intelligent capacitors according to the present invention; Figure 2 The present invention is a schematic diagram of the structure of an intelligent capacitor automatic networking system. DETAILED DESCRIPTION
[0021] 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.
[0022] See also Figure 1 The present invention provides a method for automatically networking smart capacitors, comprising the following steps: Step 1: After the initial power-on, all devices are in slave state, read their own unique serial number ID and generate a delay time based on the serial ID and random number. The slave device that has reached the delay time sends a command to obtain the host mode and becomes the master. Other slave devices automatically switch to the receiving state. The master sends a command to report the device serial number ID to the slave device until no new slave devices are generated.
[0023] The step 1 includes the following contents: Step 101, after the initial power-on, all devices are in slave state, read their own unique serial number ID and generate a delay time based on the serial ID and random number. The slave that has reached the delay time sends a command to obtain the host mode and becomes the host, and at the same time pulls the status line low to indicate that the bus is busy. After other slaves detect that the status line is busy, they automatically switch to the receiving state and receive the command issued by the host. To ensure that all slaves can receive the command issued by the host, the device will repeat the host command several times after grabbing the host.
[0024] The sample code of the delay algorithm is as follows: import random random_number = random.randint(1, 1000) # Generate a random number between 1 and 1000 import hashlib import time # Assume serial_id is your device serial number (string) serial_id = "your_device_serial_number" random_number = random.randint(1, 1000) # Combine the serial number and random number and process them through the hash function combined = f"{serial_id}{random_number}" hashed = hashlib.sha256(combined.encode()).hexdigest() # Take the first few characters of the hash value (here we take 8, you can adjust as needed) and convert it to an integer # Then use this integer as the delay time in milliseconds delay_time_ms = int(hashed[:8], 16) % 10000 # Assume we want a delay between 0 and 10000 milliseconds # Delay time.sleep(delay_time_ms / 1000.0) Step 102, after a short delay, the host sends a command to report the device serial number ID to the slave, and pulls up the status line to switch to the receiving state; after receiving the upload device ID command, the slave generates a random delay time according to its own ID + random number to upload its own device ID. The slave that completes the delay first pulls the status line low, indicating that the bus is busy, and sends the ID to the host at the same time. If other slaves detect that the status line has been set to busy state by other slaves after the delay, they will regenerate a random delay time and wait again. After the current slave completes the report, it will pull up the status line to indicate that the bus is idle, and other slaves will complete the report in turn.
[0025] Step 103, after receiving the device ID reported by the slave, the host will verify and confirm the correctness of the device ID, remember the correct ID, and record the number of slave devices + 1. Since the ID + random number method cannot ensure that all slave IDs are not lost, it is necessary to repeat the slave ID upload process after a period of time until no new slave devices are generated.
[0026] The host verifies the correctness of the device ID by length verification, character set verification, validity verification, range verification, checksum, hash verification, permission verification, status check, timestamp verification, and validity period verification.
[0027] Length check is to check whether the length of the device ID is correct according to the system agreement. For example, if the system stipulates that the device ID should be 19 digits (such as some IDs generated using the snowflake algorithm), then check whether the received ID length is 19 digits; Character set verification verifies that the device ID contains only allowed characters. For digital IDs, it should be ensured that non-numeric characters are not included in the ID. Validity verification checks whether the device ID is valid based on business logic. For example, the database can be queried to confirm whether the ID corresponds to a registered device. Range verification verifies whether the device ID is within a specific range if it has a specific range limit. Checksum verifies whether the device ID is within the ...
[0028] When using, combine the contents in steps 101 to 103: After the initial power-on, all devices are in slave state, read their own unique serial number ID and generate a delay time based on the serial ID and random number. The slave that has reached the delay time sends a command to obtain the host mode and becomes the master. The other slaves automatically switch to the receiving state. The host sends a command to report the device serial number ID to the slave until no new slave devices are generated. Through the automated master-slave system, the complexity and error rate of manual operations can be reduced, and the reliability and efficiency of the system can be improved.
[0029] Step 2: After the host has recorded the number of all slave devices and their corresponding IDs, the host will assign communication addresses to the slaves in sequence according to the device IDs. After receiving the communication addresses, the slaves will upload confirmation commands. The host will determine whether all recorded slave addresses have been set successfully based on the confirmation commands. If all are successful, the automatic networking is completed.
[0030] The step 2 includes the following contents: Step 201, when the host has recorded the number of all slave devices and the corresponding IDs, the host will assign communication addresses to the slaves in turn according to the device ID. All slaves will receive the address assignment command at the same time. After receiving the address, the slave will compare the device ID in the command with its own ID to determine whether the address assignment is its own. If so, it will save the assigned address. If not, it will continue to wait.
[0031] The host first determines the available communication address range. For example, if the system uses 8-bit addresses, the address range is 0-255. The host can assign addresses according to the registration order of the slave IDs or some sorting rules (such as ascending or descending order of ID values). If the address range is large, or a certain hash relationship is required between the slave ID and the communication address, a hash function can also be used for mapping.
[0032] Step 202, after waiting for a period of time, the host sends an address confirmation command in sequence according to the address, and after receiving the communication address, the slave uploads a confirmation command. The host determines whether all the recorded slaves have successfully set the address according to the confirmation command. If all are successful, the automatic networking is completed and communication begins. Otherwise, the address is reset.
[0033] Step 203, after the networking is successful, the host will periodically send data query commands to the slaves. After receiving the query command, the slave will upload the corresponding data and record the time interval for the host to send data. Once the host fails, any slave can send a command to query whether the host is normal after the timeout. If there is still no host response after the timeout, all slaves will repeat the automatic networking process again to generate a new host.
[0034] When using, combine the contents in steps 201 to 203: When the host has recorded the number of all slave devices and their corresponding IDs, the host will assign communication addresses to the slaves in turn according to the device ID. After receiving the communication address, the slave will upload a confirmation command. The host will determine whether all the recorded slaves have successfully set their addresses based on the confirmation command. If all are successful, the automatic networking is completed, reducing the workload and possible error rate of manual configuration and improving the consistency and accuracy of system configuration. In addition, communication between devices has become more reliable and efficient, and there will be no address conflicts or confusion.
[0035] See also Figure 2 The present invention provides an intelligent capacitor automatic networking system, comprising: The host confirmation module, after the initial power-on, all devices are in slave state, read their own unique serial number ID and generate a delay time based on the serial ID and random number. The slave that has reached the delay time sends a command to obtain the host mode and becomes the host, and at the same time pulls the status line low to indicate that the bus is busy. After other slaves detect that the status line is busy, they automatically switch to the receiving state and receive the command issued by the host. To ensure that all slaves can receive the command issued by the host, the device will repeat the host command several times after grabbing the host.
[0036] Automatic networking module, when the host has recorded the number of all slave devices and the corresponding IDs, the host will assign communication addresses to the slaves in sequence according to the device IDs. After receiving the communication addresses, the slaves upload confirmation commands. The host determines whether all the recorded slaves have successfully set addresses based on the confirmation commands. If all are successful, the automatic networking is completed.
[0037] The above embodiments may be implemented in whole or in part by software, hardware, firmware or any other combination thereof. When implemented using software, the above embodiments may be implemented in whole or in part in the form of a computer program product. A person of ordinary skill in the art may appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein may be implemented in electronic hardware, or in a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution.
[0038] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0039] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. A method for automatic networking of smart capacitors, characterized in that: The steps include: After the initial power-on, all devices are in slave state, read their own unique serial number ID and generate a delay time based on the serial ID and random number. The slave device that has reached the delay time sends a command to obtain the host mode and becomes the master. Other slave devices automatically switch to the receiving state. The master sends a command to report the device serial number ID to the slave device until no new slave devices are generated. When the host has recorded the number of all slave devices and their corresponding IDs, the host will assign communication addresses to the slaves in sequence according to the device IDs. After receiving the communication addresses, the slaves will upload confirmation commands. The host will determine whether all recorded slave addresses have been set successfully based on the confirmation commands. If all are successful, the automatic networking is completed.
2. The method for automatically networking smart capacitors according to claim 1, characterized in that: After the initial power-on, all devices are in slave state, read their own unique serial number ID and generate a delay time based on the serial ID and random number; the slave device that has reached the delay time sends a command to obtain the host mode and becomes the host, and at the same time pulls the status line low to indicate that the bus is busy. After other slave devices detect that the status line is busy, they automatically switch to the receiving state and receive the command issued by the host. To ensure that all slave devices can receive the command issued by the host, the device will repeat the host command several times after grabbing the host.
3. The method for automatically networking smart capacitors according to claim 2, characterized in that: After a short delay, the host sends a command to report the device serial number ID to the slave, and pulls up the status line to switch to the receiving state; after receiving the upload device ID command, the slave generates a random delay time based on its own ID + random number to upload its own device ID. The slave that completes the delay first pulls the status line low to indicate that the bus is busy, and sends the ID to the host at the same time. If other slaves detect that the status line has been set to busy by other slaves after the delay, they will regenerate a random delay time and wait again. After the current slave completes the report, it will pull up the status line to indicate that the bus is idle, and other slaves will complete the report in turn.
4. The method for automatically networking smart capacitors according to claim 3, characterized in that: After receiving the device ID reported by the slave, the host will verify the correctness of the device ID, remember the correct ID, and record the number of slave devices + 1. Since the ID + random number method cannot ensure that all slave IDs are not lost, it is necessary to repeat the slave ID upload process after a period of time until no new slave devices are generated.
5. The method for automatically networking smart capacitors according to claim 4, characterized in that: When the host has recorded the number of all slave devices and their corresponding IDs, the host will assign communication addresses to the slaves in turn according to the device ID. All slaves will receive the address assignment command at the same time. After receiving the address, the slave will compare the device ID in the command with its own ID to determine whether the address assignment is its own. If so, it will save the assigned address. If not, it will continue to wait.
6. The method for automatic networking of smart capacitors according to claim 5, characterized in that: After waiting for a while, the host sends address confirmation commands in sequence according to the addresses. After receiving the communication address, the slave uploads the confirmation command. The host determines whether all the recorded slaves have successfully set the addresses based on the confirmation command. If all are successful, the automatic networking is completed and communication begins; otherwise, the address is reset.
7. The method for automatic networking of smart capacitors according to claim 6, characterized in that: After the network is successfully established, the host will periodically send data query commands to the slaves. After receiving the query command, the slave will upload the corresponding data and record the time interval for the host to send data. Once the host fails, any slave can send a command to query whether the host is normal after the timeout. If there is still no response from the host after the timeout, all slaves will repeat the automatic networking process to generate a new host.
8. An intelligent capacitor automatic networking system, used to implement the method according to any one of claims 1 to 7, characterized in that: include: The host confirmation module, after the initial power-on, all devices are in slave state, read their own unique serial number ID and generate a delay time based on the serial ID and random number; The slave whose delay time is up sends a command to obtain the host mode and becomes the master. At the same time, it pulls the status line low to indicate that the bus is busy. After detecting that the status line is busy, other slaves automatically switch to the receiving state and receive the command sent by the master. To ensure that all slaves can receive the command sent by the master, the device will repeat the master command several times after grabbing the master. Automatic networking module, when the host has recorded the number of all slave devices and the corresponding IDs, the host will assign communication addresses to the slaves in sequence according to the device IDs. After receiving the communication addresses, the slaves upload confirmation commands. The host determines whether all the recorded slaves have successfully set addresses based on the confirmation commands. If all are successful, the automatic networking is completed.
Citation Information
Cited By
Parallel operation automatic stacking addressing method and system based on BMSCAN communication
CN119342038A
IP address dynamic allocation method and system and storage medium
CN119383166A
Control method and control equipment of parallel operation system and storage medium
CN119945978A
A control method, control device, and storage medium of a parallel system
CN119945978B
Multi-protocol ammeter bus address self-allocation method based on dynamic conflict avoidance
CN121151371A
