Master-slave communication method, system, electronic device and readable storage medium

The dynamic sorting method is used to automatically identify and sort slave machines, which solves the problem of time-consuming, labor-intensive and poor reliability of manual sorting when slave machines are added or replaced in multi-user electric energy meters, and improves the management efficiency and reliability of electric energy meters.

CN118612014BActive Publication Date: 2024-10-25DELIXI GROUP INSTRUMENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411081065.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-08
Publication Date
2024-10-25
Estimated Expiration
2044-08-08

AI Technical Summary

Technical Problem

Existing multi-user energy meters need to be manually reordered when adding or replacing slave machines, which is time-consuming and labor-intensive, and has poor reliability.

Method used

Using the dynamic sorting method, the host sends requests to the slaves through the series cascade sequence, obtains the cascade position information and address information of each slave, automatically determines the target serial number and address, generates the sorting results, and ensures the order in which the slaves transmit data.

Benefits of technology

It realizes automatic identification and sorting of slave machines, flexibly responds to new additions and replacements, reduces manual intervention, reduces the probability of sorting errors, saves time and effort, and improves the reliability of master-slave communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118612014B_ABST
    Figure CN118612014B_ABST
Patent Text Reader

Abstract

The present application provides a master-slave communication method, system, electronic device and readable storage medium. The master-slave communication method includes: sending a first request to the first slave in a serial cascade sequence; receiving the cascade position information and slave address information sent by the first slave through a first communication bus, and determining the target sequence number and address of the first slave based on the cascade position information and slave address information corresponding to the first slave; controlling the first slave that has sent the cascade position information and slave address information to send a first request to the second slave, so that the second slave that receives the first request sends its own cascade position information and slave address information to the host through the first communication bus, which is used for the host to determine the target sequence number and address of the second slave, until the host successfully determines the target sequence number and address of the last slave in the serial cascade; generating sorting results corresponding to multiple slaves based on the target sequence numbers and addresses corresponding to multiple slaves.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a master-slave communication method, system, electronic device and readable storage medium. Background Art

[0002] With the development and popularization of smart grids, multi-user energy meters have been widely used in power systems because they can monitor and record the energy usage of multiple users at the same time and achieve accurate management of power resources. Multi-user energy meters usually include multiple slaves (i.e., energy meters) and a host (i.e., controller). Multiple slaves are connected to the host for data transmission, and the host can manage multiple slaves.

[0003] When adding or replacing slaves in a multi-user electric energy meter, the host needs to quickly identify and sort the slaves to ensure the accuracy and real-time nature of the data transmitted by the slaves. In the related art, a static sorting method is usually used to sort multiple slaves. The static sorting method is to pre-sort all slaves of the multi-user electric energy meter when the multi-user electric energy meter is initialized, and the host collects and transmits data from all slaves according to the pre-defined order.

[0004] When a static sorting method is used to sort multiple slaves, if a slave is added or replaced, the multiple slaves need to be manually re-sorted, which is time-consuming and labor-intensive. In addition, manual sorting is prone to errors and has poor reliability. Summary of the invention

[0005] The present application provides a master-slave communication method, system, electronic device and readable storage medium to solve the problem in the prior art that when adding or replacing a slave, multiple slaves need to be manually reordered, which is time-consuming, labor-intensive and has poor reliability.

[0006] In a first aspect, the present application provides a master-slave communication method, which is applied to a master-slave communication system, wherein the master-slave communication system comprises a host and a plurality of slaves; the plurality of slaves are cascaded in series, the first of the cascaded slaves is connected to the host, and two adjacent slaves among the plurality of slaves are connected via a second communication bus; the plurality of slaves are also respectively connected to the host via a first communication bus;

[0007] The method comprises:

[0008] When the host determines to sort the multiple slaves, a first request is sent to the first slave in a series cascade order; the first request is used to request the multiple slaves to send cascade position information and slave address information of each slave to the host respectively;

[0009] Receiving the cascade position information and the slave address information sent by the first slave through the first communication bus, and determining the target sequence number and address of the first slave based on the cascade position information and the slave address information corresponding to the first slave;

[0010] Controlling the first slave that has sent the cascade position information and the slave address information to send the first request to the second slave, so that the second slave that receives the first request sends its own cascade position information and the slave address information to the host through the first communication bus, so that the host can determine the target sequence number and address of the second slave, until the host successfully determines the target sequence number and address of the last slave in the series cascade; wherein the first slave is any other slave among the multiple slaves except the last slave; and the second slave is adjacent to the first slave along the series cascade direction;

[0011] Based on the target serial numbers and addresses respectively corresponding to the multiple slaves, sorting results corresponding to the multiple slaves are generated; wherein the sorting results are used to indicate the order in which the multiple slaves transmit business data to the host when all the multiple slaves need to transmit business data to the host.

[0012] In one possible design, the first request is sent via a token, and the token carries the first request; wherein the first request includes the address information of the host, the purpose information of the first response, and the data frame structure of the first response; and the first response includes the cascade position information and slave address information of the slave sent by the slave to the host.

[0013] In one possible design, the data frame structure of the first response includes a frame start symbol, an address field, a control word, a data length, a data field, a frame target sequence number, and a frame end symbol;

[0014] Among them, the address field is used to identify the address of the slave that sends cascade position information and slave address information to the host; the control word is used to indicate the type of the first request; the data length indicates the length of the data field; and the frame target sequence number indicates the number of the multiple slaves.

[0015] In a possible design, when the host determines to sort the multiple slaves, before sending the first request to the first slave in a serial cascade order, the method further includes:

[0016] Sending a second request to the multiple slaves in series cascade order; the second request is used to request the multiple slaves to send the current sequence number of each slave to the host respectively;

[0017] Receive multiple second responses respectively sent by the multiple slaves through the first communication bus, and determine whether the multiple slaves need to be sorted based on the contents of the multiple second responses; wherein the second response includes the current sequence number of the slave.

[0018] In a possible design, determining whether the multiple slaves need to be sorted based on the multiple second responses includes:

[0019] In a case where the current sequence number order of the plurality of slaves in the serial cascade sequence does not satisfy the preset sequence, determining that the plurality of slaves need to be sorted;

[0020] In the case that the current sequence of the sequence numbers of the plurality of slaves in the serial cascade sequence satisfies the preset sequence, it is determined that the plurality of slaves do not need to be sorted.

[0021] In one possible design, the method further includes:

[0022] Sending a third request to the multiple slaves in sequence according to a first preset time interval and a series cascade sequence; the third request is used to request the multiple slaves to send the operating status of each of the slaves and / or the power data collected by each of the slaves to the host respectively; wherein the third request includes the address information of the host and the purpose information of the third request;

[0023] Receive multiple third responses respectively sent by the multiple slaves through the first communication bus, and determine the operating status and / or power data of the multiple slaves based on the contents of the multiple third responses; wherein the third responses include the operating status and / or power data of the slaves.

[0024] In one possible design, the method further includes:

[0025] Sending a fourth request to the plurality of slaves in sequence according to a second preset time interval and a serial cascade sequence; the fourth request is used to request each of the plurality of slaves to verify its own current billing parameter based on the target billing parameter, and send the verification result to the host; wherein the fourth request includes the target billing parameter;

[0026] Receive multiple fourth responses respectively sent by the multiple slaves through the first communication bus, and obtain billing parameter verification results of the multiple slaves based on the contents of the multiple fourth responses; wherein the fourth response includes the billing parameter verification results of the slaves.

[0027] In a second aspect, the present application provides a master-slave communication system, the master-slave communication system comprising a master and a plurality of slaves;

[0028] The multiple slaves are cascaded in series, the first slave in the cascaded series is connected to the host, and two adjacent slaves among the multiple slaves are connected via a second communication bus; the multiple slaves are also respectively connected to the host via a first communication bus;

[0029] Wherein, the host is used to implement the master-slave communication method described in any one of the first aspects above.

[0030] In a third aspect, the present application provides an electronic device, including: a memory and a processor;

[0031] The memory is configured to store computer program instructions;

[0032] The processor is configured to run the computer program instructions so that the electronic device implements the master-slave communication method described in any one of the first aspects above.

[0033] In a fourth aspect, the present application provides a readable storage medium, comprising: computer program instructions, at least one processor of an electronic device executes the computer program instructions so that the electronic device implements the master-slave communication method described in any one of the above-mentioned first aspects.

[0034] In an embodiment of the present application, a master-slave communication method is provided, which is applied to a master-slave communication system, wherein the master-slave communication system includes a host and a plurality of slaves connected in series, wherein the first slave connected in series is connected to the host through a second communication bus, and two adjacent slaves in the plurality of slaves are also connected through a second communication bus, wherein the number of the second communication buses is equal to the number of the plurality of slaves and corresponds one to one, and at the same time, the plurality of slaves are also connected to the host through the same first communication bus. When the host sorts the plurality of slaves, the host firstly sends a request to the first slave according to the serial cascade sequence of the plurality of slaves, so as to obtain the cascade position information and slave address information of the first slave, and then determines the target sequence number and address of the first slave; secondly, the host controls the first slave to send a request to the next slave connected to the first slave through the second communication bus, so as to obtain the cascade position information and slave address information of the next slave, and determines the target sequence number and address of the next slave, and repeats this step for many times until the host determines the target sequence number and address of the last slave; finally, the host obtains the sorting results corresponding to the plurality of slaves according to the target sequence numbers and addresses corresponding to the plurality of slaves. The present application realizes automatic identification and sorting of slaves by the host through a dynamic sorting method, can flexibly respond to the addition and replacement of slaves, automatically adjust the sorting of multiple slaves, reduce the possibility of manual intervention, thereby reducing the probability of sorting errors, saving time and effort, and effectively enhancing the reliability of master-slave communication. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1A schematic diagram of a master-slave communication method provided in an embodiment of the present application;

[0036] Figure 2 A schematic diagram of the structure of a master-slave communication system provided in an embodiment of the present application;

[0037] Figure 3 A schematic diagram of the structure of a host device provided in an embodiment of the present application;

[0038] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0039] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0040] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by technicians in the technical field to which this application belongs; the terms used in the specification of the application are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification, claims and drawings of this application are intended to cover non-exclusive inclusions.

[0041] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase "embodiments" in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0042] The term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists, A and B exist at the same time, and B exists. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0043] In the description of the present application, unless otherwise specified, “plurality” means more than two (including two), and similarly, “plurality groups” means more than two (including two).

[0044] A multi-user electric energy meter is a device that can measure electric energy for multiple users at the same time. The multi-user electric energy meter includes a host and multiple slaves.

[0045] The host is responsible for data transmission with the slaves and external communication equipment (such as data centers, centralized control systems, etc.), and manages multiple slaves. The host usually includes a main controller and a communication module. The main controller is used to process the data sent by the slaves and perform data storage, billing calculations, and control commands, etc. The communication module is used to communicate with external communication equipment. Among them, the communication method used between the communication module and the external communication equipment can be Ethernet communication, RS485 communication, etc.

[0046] The slave is used to independently measure and record the power consumption of its corresponding user and upload the data to the host. The slave usually includes a slave controller, a metering module and a storage module; the metering module includes a current transformer, a voltage transformer and a metering chip. The metering module is used to measure current and voltage and calculate the power consumed by the user corresponding to the slave; the storage module is used to store the user information corresponding to the slave and the power data consumed by the user.

[0047] In order to ensure the orderliness and efficiency of communication between multiple slaves and the host, multiple slaves need to be sorted so that the host can better manage the communication of multiple slaves, optimize resource allocation and data transmission processes, and ensure the efficient operation of multi-user electricity meters.

[0048] In the related art, a static sorting method is usually used to sort multiple slaves. The static sorting method is to pre-sort all slaves of the multi-user electricity meter when the multi-user electricity meter is initialized, and the host subsequently collects and transmits data from all slaves according to the pre-defined sorting order.

[0049] However, with the expansion of residential areas, commercial buildings or industrial parks, new users may join, and new slaves will be needed to measure the power consumption of the new users; or, when the original users move out or vacate the lease and new users move in, the slaves need to be replaced to re-measure the power usage of the new users. In this case, multiple slaves need to be manually re-ordered, which is time-consuming and labor-intensive, and manual ordering is prone to errors and has poor reliability.

[0050] In an embodiment of the present application, a master-slave communication method is provided, which is applied to a master-slave communication system, wherein the master-slave communication system includes a host and a plurality of slaves connected in series, wherein the first slave connected in series is connected to the host through a second communication bus, and two adjacent slaves in the plurality of slaves are also connected through a second communication bus, wherein the number of the second communication buses is equal to the number of the plurality of slaves and corresponds one to one, and at the same time, the plurality of slaves are also connected to the host through the same first communication bus. When the host sorts the plurality of slaves, the host firstly sends a request to the first slave according to the serial cascade sequence of the plurality of slaves, so as to obtain the cascade position information and slave address information of the first slave, and then determines the target sequence number and address of the first slave; secondly, the host controls the first slave to send a request to the next slave connected to the first slave through the second communication bus, so as to obtain the cascade position information and slave address information of the next slave, and determines the target sequence number and address of the next slave, and repeats this step for many times until the host determines the target sequence number and address of the last slave; finally, the host obtains the sorting results corresponding to the plurality of slaves according to the target sequence numbers and addresses corresponding to the plurality of slaves. The present application realizes automatic identification and sorting of slaves by the host through a dynamic sorting method, can flexibly respond to the addition and replacement of slaves, automatically adjust the sorting of multiple slaves, reduce the possibility of manual intervention, thereby reducing the probability of sorting errors, saving time and effort, and effectively enhancing the reliability of master-slave communication.

[0051] Next, some specific embodiments and drawings are used to describe in detail how the present application solves the above-mentioned problem that it is time-consuming, labor-intensive, and has poor reliability when reordering multiple slaves using the static sorting method.

[0052] Figure 1 A flow chart of a master-slave communication method provided in an embodiment of the present application is shown as follows: Figure 1 As shown, the master-slave communication method provided in the embodiment of the present application specifically includes S101 to S104, and S101 to S104 are described in detail below.

[0053] In an embodiment of the present application, the master-slave communication method uses a master-slave communication system, which includes a host and multiple slaves. The multiple slaves are cascaded in series, the first slave in the series cascade is connected to the host through a second communication bus, and two adjacent slaves among the multiple slaves are also connected through a second communication bus; the multiple slaves are also connected to the host through the same first communication bus.

[0054] Figure 2 The structure diagram of a master-slave communication system provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the master-slave communication system includes a master 200 and N slaves, and the master 200 supplies power to the N slaves.

[0055] Wherein, N is a positive integer, and N≥2.

[0056] It should be noted that the value of N depends on the power system maintenance personnel, and this embodiment does not make any specific limitation on this.

[0057] For example, N is 3.

[0058] According to the serial cascade sequence of the N slaves, the N slaves are slave 201, slave 202, ..., slave 20N.

[0059] N slaves correspond to N second communication buses. The second communication bus corresponding to slave 201 is second communication bus 2-201, the second communication bus corresponding to slave 202 is second communication bus 2-202, ..., and the second communication bus corresponding to slave 20N is 2-20N.

[0060] The first transmitting end of the main controller of the host 200 is connected to the first receiving end of the slave controller of the slave 201 through the second communication bus 2-201 corresponding to the slave 201, the first transmitting end of the slave controller of the slave 201 is connected to the first receiving end of the slave controller of the slave 202 through the second communication bus 2-202 corresponding to the slave 202, the first transmitting end of the slave controller of the slave 202 is connected to the first receiving end of the slave controller of the slave adjacent to the slave 202 in the series cascade direction through the second communication bus 2-203,…, the first transmitting end of the slave controller of the slave located before the slave 20N in the series cascade direction is connected to the first receiving end of the slave controller of the slave 20N through the second communication bus 2-20N corresponding to the slave 20N.

[0061] The second receiving end and the second transmitting end of the slave controller of slave 201, the second receiving end and the second transmitting end of the slave controller of slave 202, ..., and the second receiving end and the second transmitting end of the slave controller of slave 20N are all connected to the second transmitting end and the second receiving end of the main controller of host 200 through the first communication bus 2-1.

[0062] It should be noted that the first transmitting end and the second transmitting end of the master controller refer to different transmit data (Transmit Data, TXD) pins on the master controller, the second receiving end of the master controller refers to the receive data (Receive Data, RXD) pin on the master controller, the first transmitting end and the second transmitting end of the slave controller refer to different TXD pins on the slave controller, and the first receiving end and the second receiving end of the slave controller refer to different RXD pins on the slave controller.

[0063] The first communication bus includes two communication buses, one communication bus is used for the host 200 to send data to N slaves, and the other communication bus is used for the host 200 to receive data reported by the N slaves.

[0064] It should be noted that the host 200 communicates only with the slave 201 through the second communication bus 2-201, and does not communicate with the slaves 202, ..., and slave 20N; the slaves 201, slaves 202, ..., and slave 20N can all communicate with the host 200 through the first communication bus 2-1.

[0065] Among them, the first transmitting end, the second transmitting end and the second receiving end of the main controller of the host, and the first receiving end, the first transmitting end, the second receiving end and the second transmitting end of the slave controller of each slave are all provided with a short-circuit protection circuit and an anti-static protection circuit to protect the receiving end and the transmitting end of the master controller or the slave controller, ensure the normal operation of the master controller or the slave controller, and then ensure the normal operation of the master-slave communication system, and improve the reliability and durability of the master-slave communication system.

[0066] It should be noted that the short circuit protection circuit and the anti-static protection circuit are existing circuits, and will not be described in detail in this embodiment.

[0067] It should be noted that, based on the above-mentioned host being connected to multiple slaves through a first communication bus, the host is also connected to the first slave through a second communication bus, and two adjacent slaves are also connected through different second communication buses. The slave can be inserted or unplugged during the operation of the master-slave communication system without affecting the normal operation of the master-slave communication system; that is, the master-slave communication system supports hot plugging.

[0068] When the master-slave communication system supports hot-swap, the power system maintenance personnel can add, replace or remove slaves without affecting the operation of the master-slave communication system, which improves the maintainability of the master-slave communication system; at the same time, since there is no need to shut down or restart the master-slave communication system, the downtime of the master-slave communication system is effectively reduced, and the availability and reliability of the master-slave communication system are improved. In addition, since the master-slave communication system supports hot-swap function, the use of the master-slave communication system is more flexible, and the power system maintenance personnel can dynamically adjust the number and configuration of slaves according to actual needs to adapt to different application requirements.

[0069] Among them, in the master-slave communication system provided in the present application, the first communication bus and the second communication bus are used to share the data transmission task, which can effectively improve the data transmission efficiency and reliability of the master-slave communication system.

[0070] It should be noted that the first communication bus is mainly responsible for high-real-time and high-frequency tasks that have high requirements for data transmission speed and response time. The host can send instructions to any of the multiple slaves through the first communication bus, and can also receive data reported by any of the multiple slaves through the first communication bus.

[0071] For example, the host sends a broadcast command, reads real-time data, performs single-point setting on a certain slave among multiple slaves, or sends an operation command to a certain slave among multiple slaves through the first communication bus.

[0072] For example, the master broadcasts a time synchronization command to all slaves to ensure that the clocks of all slaves are synchronized.

[0073] For another example, the host broadcasts a setting command to all slaves, such as uniformly setting parameters such as rates and time periods.

[0074] For another example, the host sends an instruction to report current power data to all slaves through the first communication bus, so as to quickly obtain the current power data of all slaves.

[0075] For another example, the host sends a parameter adjustment instruction to a specific slave among the multiple slaves through the first communication bus to adjust the parameters of the specific slave.

[0076] For another example, the host sends a switch-on or switch-off operation instruction to a specific slave among the multiple slaves through the first communication bus to control the specific slave to perform the switch-on or switch-off operation.

[0077] It should be noted that the second communication bus is mainly responsible for the management of the slaves and low-frequency tasks with low real-time requirements, which is crucial to the management and maintenance of the master-slave communication system. The second communication bus is only used to transmit instructions issued by the host to the slaves, and is not used to report the slave data to the host.

[0078] The host can send instructions to the first slave among multiple slaves cascaded in series through the second communication bus, but cannot send instructions to other slaves except the first slave among the multiple slaves cascaded in series; among the multiple slaves cascaded in series, any slave can send instructions to the slaves adjacent to it along the series cascade direction through the second communication bus, but cannot send instructions to other slaves.

[0079] For example, based on the second communication bus, the host can perform slave access, slave sequencing, and slave removal judgment tasks.

[0080] For another example, based on the second communication bus, the host can obtain the address information of multiple slaves in sequence according to the series cascade order of the multiple slaves, and complete the host's table search task for the multiple slaves. The table search task does not conflict with the data reading task on the first communication bus, thereby ensuring the stable operation of the master-slave communication system; at the same time, the table search task will be performed after all slaves have completed initialization, avoiding table search failure due to failure of some slaves to complete initialization.

[0081] In this embodiment, through the cooperation of the first communication bus and multiple second communication buses, the first communication bus is responsible for high-real-time and high-frequency tasks with high requirements for data transmission speed and response time, and the second communication bus is mainly responsible for the management of the slave machine and low-frequency tasks with lower real-time requirements, effectively sharing the data reading pressure of the host, improving the efficiency of data transmission between the host and the slave, and ensuring the reliability and maintainability of the host and the slave during the communication process.

[0082] S101: When the host determines to sort multiple slaves, the host sends a first request to the first slave in a series cascade sequence. Correspondingly, the first slave receives the first request sent by the host.

[0083] When at least one new slave joins the master-slave communication system, at least one slave is removed from the master-slave communication system, and / or the master-slave communication system is initialized, the host determines that multiple slaves need to be sorted.

[0084] The serial cascade sequence of the multiple slaves is the physical connection sequence of the multiple slaves and the host.

[0085] It should be noted that the first slave is a slave among the multiple slaves that is connected to the host through the second communication bus.

[0086] like Figure 2 As shown, the slave 201 is the first slave among multiple slaves, and the first transmitting end of the main controller of the host 200 is connected to the first receiving end of the slave controller of the slave 201 through the second communication bus 2-201.

[0087] The first request is used to request multiple slaves to send cascade position information and slave address information of each slave to the host respectively.

[0088] The first request includes the address information of the host, the purpose information of the first response and the data frame structure of the first response.

[0089] It should be noted that the address information of the host is a unique address or identifier used to identify the host in the communication network. By carrying the address information of the host in the first request, each slave receiving the first request can know the address of the host, so that the slave can correctly send the first response back to the host when responding to the first request.

[0090] The first response includes the cascade position information and slave address information of the slave sent by the slave to the host.

[0091] It should be noted that each of the multiple slaves has its own address information stored inside. After receiving the first request sent by the host, the first slave determines that it is the first of the multiple slaves based on the first request, and the first slave sets its own cascade position information to 1, and then packages its own cascade position information and its own address information to form a first response, and finally sends the first response to the host through the first communication bus.

[0092] It should be noted that the purpose information of the first response is used to indicate the purpose of the host obtaining the cascade position information and slave address information of each slave, which enables the slave to understand the intended purpose of the host's request for the cascade position information and slave address information of the slave, and helps the slave to correctly prepare and send the first response.

[0093] It should be noted that the data frame structure of the first response defines the format and content of the data frame of the first response when the slave responds to the first request sent by the host, to ensure that the data frame returned by the slave conforms to the expected format of the host, so that the host can correctly parse and process the first response returned by the slave.

[0094] For any slave, the cascade position information of the slave is used to identify the physical position or order of the slave in the multiple slaves cascaded in series. The cascade position information of the slave can help the host determine the specific position of the slave in the multiple slaves cascaded in series, thereby helping the host to accurately sort and manage the multiple slaves.

[0095] It should be noted that the cascade position information may be a simple integer or other forms, which is not specifically limited in this embodiment.

[0096] For example, the master-slave communication system includes 4 slaves, the cascade position information of slave 1 is 1, the cascade position information of slave 2 is 2, the cascade position information of slave 3 is 3, and the cascade position information of slave 4 is 4.

[0097] The slave address information is an address or identifier used to uniquely identify the slave. Each slave has a unique address in the master-slave communication system, and the master can communicate with any slave through the address of the slave.

[0098] It should be noted that the slave address information may be a binary or hexadecimal value of a fixed length.

[0099] For example, the master-slave communication system includes four slaves, the address information of slave 1 is 0x01, the address information of slave 2 is 0x02, the address information of slave 3 is 0x03, and the address information of slave 4 is 0x04.

[0100] S102, the host receives the cascade position information and slave address information sent by the first slave through the first communication bus, and determines the target sequence number and address of the first slave based on the cascade position information and slave address information corresponding to the first slave;

[0101] It should be noted that after receiving the first response sent by the first slave, the host parses and extracts the first response to obtain the cascade position information and slave address information of the first slave.

[0102] The target sequence number refers to the unique sequence number assigned by the host to each slave according to the cascade position information of the slave. The target sequence number can be used to determine the communication order between the slave and the host in the master-slave communication system to ensure the order of data transmission and data processing of multiple slaves.

[0103] It should be noted that the target sequence number of the first slave is related to the cascade position information of the first slave. The order of the first slave indicated by the cascade position information of the first slave among the multiple slaves cascaded in series is the target sequence number of the first slave.

[0104] It should be noted that the address of the first slave is directly determined by the host based on the slave address information in the first response sent by the first slave to the host.

[0105] S103, the host controls the first slave that has sent the cascade position information and slave address information to send a first request to the second slave, so that the second slave that receives the first request sends its own cascade position information and slave address information to the host through the first communication bus, which is used by the host to determine the target serial number and address of the second slave, until the host successfully determines the target serial number and address of the last slave in the series cascade.

[0106] The first slave is any other slave among the multiple slaves except the last slave; the second slave is adjacent to the first slave along the series cascade direction.

[0107] It should be noted that, after the host determines the target sequence number and address of the first slave based on the first response sent by the first slave through the first communication bus, the host instructs the first slave to pass the first request to the next slave, and the next slave is a slave connected to the first slave through the second communication bus. After the next slave receives the first request sent by the first slave, the next slave sends the first response corresponding to the next slave to the host, and the first response corresponding to the next slave includes the cascade position information and address information of the next slave. The host determines the target sequence number and address of the next slave according to the first response corresponding to the next slave; thereafter, the next slave is regarded as the first slave, and the next slave connected to the next slave through the second communication bus in the serial cascade direction is regarded as the next slave, and the above steps are repeated until the host determines the target sequence number and address of the last slave according to the first response corresponding to the last slave sent by the last slave in the serial cascade to the host. At this time, the host completes the sorting of all slaves.

[0108] Exemplarily, the master-slave communication system includes a host and three slaves, the three slaves are slave A, slave B and slave C in a series cascade order, the host is connected to slave A via the first second communication bus corresponding to slave A, slave A is connected to slave B via the second second communication bus corresponding to slave B, slave B is connected to slave C via the third second communication bus corresponding to slave C, and slaves A, slave B and slave C are also connected to the host via the first communication bus respectively. In this case, the first slave is slave A or slave B, the second slave is slave B or slave C, the host can send instructions to slave A via the first second communication bus, but cannot send instructions to slaves B and slave C; slave A can send instructions to slave B via the second second communication bus, but cannot send instructions to slave C; slave B can send instructions to slave C via the third second communication bus, but cannot send instructions to slave A.

[0109] Based on the master-slave communication method provided in the present application, the host sends a first request to slave A through the first and second communication buses, requesting slave A to return the cascade position information and address information of slave A. After receiving the first request, slave A returns the cascade position information and address information of slave A to the host through the first communication bus. The host determines the target serial number and address of slave A based on the cascade position information and address information of slave A.

[0110] Afterwards, slave A sends the first request to slave B through the second second communication bus. After receiving the first request, slave B sends the cascade position information and address information of slave B to the host through the first communication bus, so that the host can determine the target sequence number and address of slave B based on the cascade position information and address information of slave B.

[0111] Finally, slave B sends the first request to slave C through the third second communication bus. After receiving the first request, slave C sends the cascade position information and address information of slave C to the host through the first communication bus, so that the host can determine the target sequence number and address of slave C according to the cascade position information and address information of slave C, so as to complete the host's sorting of slaves A, slave B and slave C.

[0112] In this embodiment, the host can obtain the cascade position information and address information of all slaves by transmitting the first request step by step and receiving the first response, and determine the target sequence number and address of each slave according to the cascade position information and address information of all slaves, thereby ensuring the automation and accuracy of slave sorting and improving the efficiency of slave sorting.

[0113] S104: The host generates sorting results corresponding to the multiple slaves based on the target sequence numbers and addresses respectively corresponding to the multiple slaves.

[0114] The sorting result is used to indicate the order in which the multiple slaves transmit the service data to the host when the multiple slaves all need to transmit the service data to the host.

[0115] It should be noted that the sorting result includes the target sequence numbers and addresses of all slaves in the master-slave communication system. The sorting result can be represented as a mapping table, which can be stored in the memory of the host, so that the host can efficiently manage and schedule each slave in the subsequent communication process.

[0116] In this embodiment, when multiple slaves in the master-slave communication system need to transmit business data to the host, the multiple slaves transmit the business data to the host in the order indicated by the sorting result, avoiding conflicts and confusion caused by multiple slaves transmitting business data to the host at the same time, thereby improving the communication efficiency and data transmission accuracy of the master-slave communication system.

[0117] In an embodiment of the present application, a master-slave communication method is provided, which is applied to a master-slave communication system, wherein the master-slave communication system includes a host and a plurality of slaves connected in series, wherein the first slave connected in series is connected to the host through a second communication bus, and two adjacent slaves in the plurality of slaves are also connected through a second communication bus, wherein the number of the second communication buses is equal to the number of the plurality of slaves and corresponds one to one, and at the same time, the plurality of slaves are also connected to the host through the same first communication bus. When the host sorts the plurality of slaves, the host firstly sends a request to the first slave according to the serial cascade sequence of the plurality of slaves, so as to obtain the cascade position information and slave address information of the first slave, and then determines the target sequence number and address of the first slave; secondly, the host controls the first slave to send a request to the next slave connected to the first slave through the second communication bus, so as to obtain the cascade position information and slave address information of the next slave, and determines the target sequence number and address of the next slave, and repeats this step for many times until the host determines the target sequence number and address of the last slave; finally, the host obtains the sorting results corresponding to the plurality of slaves according to the target sequence numbers and addresses corresponding to the plurality of slaves. The present application realizes automatic identification and sorting of slaves by the host through a dynamic sorting method, can flexibly respond to the addition and replacement of slaves, automatically adjust the sorting of multiple slaves, reduce the possibility of manual intervention, thereby reducing the probability of sorting errors, saving time and effort, and effectively enhancing the reliability of master-slave communication.

[0118] In the above embodiment, the host needs to send a first request to the first slave, and the first slave also needs to send a first request to the second slave, so that each of the multiple slaves sends its own cascade position information and slave address information to the host. Next, the sending method of the first request is described in detail.

[0119] In a possible embodiment, the first request is sent via a token, and the token carries the first request.

[0120] A token is a small data packet that carries information and is used to pass requests and responses between the master and slave.

[0121] It should be noted that the token can not only carry the content of the first request, but also contain security information, serial number, timestamp, etc. to ensure the integrity and security of data transmission.

[0122] When the host sends a first request to multiple slaves cascaded in series through a token, first, the host generates a token, which carries the content of the first request (the host's address information, the purpose information of the first response, and the data frame structure of the first response), and sends the token to the first slave through the second communication bus corresponding to the first slave in the multiple slaves cascaded in series; secondly, after receiving the token, the first slave parses the request content in the token, performs the requested operation based on the request content in the token, generates a response corresponding to the request, and reports the response to the host through the first communication bus; finally, after reporting the response to the host through the first communication bus, the first slave sends the token to the next slave through the second communication bus corresponding to the next slave adjacent to the first slave in the multiple slaves cascaded in series, and the next slave repeats the steps executed by the above-mentioned first slave until the last slave in the multiple slaves cascaded in series reports a response to the host through the first communication bus, thereby completing the transmission of the token.

[0123] It should be noted that only one slave holds the token and transmits data at the same time, which effectively avoids network conflicts; and the token carries all necessary information by transmitting the first request, which can reduce the number of data packets, improve communication efficiency, and avoid multiple round trips of requests and responses. In addition, the token can contain a serial number and a timestamp to prevent the request carried by the token from being tampered with.

[0124] In this embodiment, the host efficiently transmits the first request to multiple slaves through tokens, and sequentially receives first responses returned by multiple slaves based on the first request, thereby improving communication efficiency and communication security, simplifying the processing logic of the slaves, and enhancing the maintainability and reliability of master-slave communication.

[0125] In the above embodiment, the first request includes the data frame structure of the first response to ensure that the data frame returned by the slave conforms to the expected format of the host, so that the host can correctly parse and process the response returned by the slave. Next, the data frame structure of the first response is described in detail.

[0126] In a possible embodiment, the data frame structure of the first response includes a frame start character, an address field, a control word, a data length, a data field, a frame target sequence number and a frame end character.

[0127] The frame start character is used to mark the beginning of the data frame, helping the host to identify the starting position of the data frame and ensure the complete reception of the data frame.

[0128] The address field is used to identify the address of the slave that sends the cascade position information and slave address information to the host, ensuring that the host can correctly identify the slave that sends the first response and improve the accuracy of data transmission.

[0129] The control word is used to indicate the type of the first request, and helps the host understand the purpose and processing method of the data frame. For example, the control word may indicate that the first request is a sorting request.

[0130] Data length indicates the length of the data field and is used to inform the host of the specific length of the data field, so that the host can correctly parse and process the data content in the data frame.

[0131] The data field is used to transmit actual business data, contains specific data content, and is the core part of the data frame. For example, the data field includes cascade position information and slave address information.

[0132] The frame target sequence number indicates the number of multiple slaves and is used to help the host understand the total number of multiple slaves in the master-slave communication system, so as to facilitate the host to sort and manage multiple slaves.

[0133] The frame end character is used to mark the end of the data frame, helping the host to identify the end position of the data frame and ensure the complete reception of the data frame.

[0134] In the embodiment of the present application, the data frame structure of the first response defines in detail the function of each field in the data frame, so that the host can accurately parse and process the data frame, and achieve the accuracy, reliability and flexibility of data transmission. The frame start character, address field, control word, data length, data field, frame target sequence number and frame end character each have their own functions, and together ensure the complete transmission and accurate parsing of the data frame, significantly improving the communication efficiency and maintainability of the master and slave machines.

[0135] Exemplarily, in the case where the host sorts the multiple slaves, the host sequentially obtains the addresses of the multiple slaves according to the serial cascade order of the multiple slaves.

[0136] Assuming the host address is 11, according to the serial cascade sequence, the addresses of the multiple slaves are 22, 33, ... The specific method for the host to sequentially obtain the addresses of the multiple slaves according to the serial cascade sequence of the multiple slaves is described.

[0137] In the first step, the host sends the first request to the first slave (address 22). The request carries the data frame format of the first response. The data frame format of the first response is "68 AA AA AA AA AA AA 68 05 01 01 cs 16"; among them, "68" is the frame start character; "AA AA AA AA AA AA" is the address of the slave that sends the first response to the host; "05" is the control word, indicating that the data frame is an address communication data frame; "01" indicates the data length; "01" is the frame sequence number; "cs" indicates the checksum; and "16" is the frame end character.

[0138] In the second step, after the first slave (address 22) receives the first request sent by the host, it sends the first response to the host through the first communication bus. The response includes the frame number and the slave type. The data frame corresponding to the first response sent by the first slave to the host is "68 22 00 00 00 00 00 68 85 02 01 01 cs 16"; among them, "22 00 00 00 0000" represents the address of the first slave; "85" is the control word, indicating that the data frame is a response frame; "02" represents the data length; "01" is the frame number (indicating that this is the first slave); "01" represents the slave type (01 indicates that the first slave is a single-phase slave).

[0139] In the third step, the first slave continues to send the first request to the next slave (address 33) adjacent to the first slave in the serial cascade sequence. In the first request sent by the first slave to the next slave, the data frame format of the first response is "68 AA AA AA AA AA AA 68 05 01 02 cs 16", where "02" is the frame number, indicating that the request is sent to the second slave in the multiple slaves in the serial cascade.

[0140] In the fourth step, after receiving the first request sent by the first slave (address 22), the next slave (address 33) sends the first response to the host through the first communication bus. The data frame corresponding to the first response sent by the next slave to the host is "68 33 00 00 00 00 00 68 85 02 02 03 cs 16"; "33 00 00 00 00 00" represents the address of the next slave; "02" represents the data length; "02" is the frame number (indicating that this is the second slave); "03" represents the slave type (03 indicates that the second slave is a three-phase four-wire slave).

[0141] The above steps are repeated until the last slave in the multiple slaves cascaded in series sends a first response to the host through the first communication bus, and the host can complete the acquisition of the addresses of the multiple slaves.

[0142] In the above embodiment, before the host sends the first request to the first slave in the serial cascade order, the host needs to determine whether it is necessary to sort the multiple slaves. When the host determines that the multiple slaves need to be sorted, the host sends the first request to the first slave in the serial cascade order. Next, a method for the host to determine whether it is necessary to sort the multiple slaves is described in detail.

[0143] In a possible embodiment, when S101, the host determines to sort multiple slaves, before the host sends a first request to the first slave in a series cascade order, the master-slave communication method also includes steps a1 and a2, and steps a1 and a12 are described in detail below.

[0144] Step a1: The host sends a second request to multiple slaves in series cascade order. Correspondingly, the multiple slaves receive the second request in sequence.

[0145] The second request is used to request multiple slaves to send the current sequence number of each slave to the master. The second request includes the address information of the master, the purpose information of the second response and the data frame structure of the second response.

[0146] It should be noted that by carrying the address information of the host in the second request, each slave receiving the second request can know the address of the host, so that the slave can correctly send the second response back to the host when responding to the second request.

[0147] The purpose information of the second response is used to indicate the purpose of the host obtaining the current sequence number of each slave, which enables the slave to understand the intended purpose of the host requesting the slave's current sequence number, and helps the slave to correctly prepare and send the second response.

[0148] In this embodiment, the purpose information of the second response is to determine whether multiple slaves need to be sorted.

[0149] The data frame structure of the second response is similar to the data frame structure of the first response in the above-mentioned S101 embodiment, and will not be described in detail in this embodiment.

[0150] It should be noted that the method in which the host sends the second request to multiple slaves in series cascade order is similar to the method in which the host sends the first request to multiple slaves in S101 to S103, which will not be described in detail in this embodiment. The second request can also be sent via a token.

[0151] Step a2: The host receives a plurality of second responses respectively sent by the plurality of slaves through the first communication bus, and determines whether the plurality of slaves need to be sorted based on the contents of the plurality of second responses.

[0152] The multiple second responses correspond to the multiple slaves one by one, and the second response of each slave includes the current sequence number of the slave.

[0153] The current serial number of the slave refers to the serial number assigned by the host to the slave when the host last completed sequencing of multiple slaves.

[0154] It should be noted that, for each of the multiple slaves, after the slave receives the second request, the slave reads its own current sequence number, packages its own current sequence number to form a second response, and sends the second response to the host through the first communication bus, so that the host can check the current sequence numbers of the multiple slaves and determine whether sorting is required based on the current sequence numbers of the multiple slaves.

[0155] In the embodiment of the present application, the host obtains the current sequence numbers of all slaves through the second request, and sorts the multiple slaves only when necessary, which reduces the frequency of use of the first communication bus and the second communication bus, and reduces the communication overhead. In addition, by checking the current sequence numbers of multiple slaves, the host can dynamically determine the sorting status of multiple slaves, and when it is necessary to sort multiple slaves, sort the multiple slaves in time, which helps to optimize the performance of the master-slave communication system.

[0156] In the above embodiment, the host needs to determine whether to sort the multiple slaves based on the current sequence numbers of the multiple slaves. Next, a method for the host to determine whether to sort the multiple slaves based on the current sequence numbers of the multiple slaves is described in detail.

[0157] In a possible embodiment, step a2, the host determines whether to sort multiple slaves based on multiple second responses, which can be achieved through steps a21 and a22. Steps a21 and a22 are described in detail below.

[0158] Step a21: When the current sequence of the serially connected slaves does not satisfy the preset sequence, the host determines that the slaves need to be sorted.

[0159] The current serial number assigned by the master to the slave is represented by Arabic numerals, and the preset sequence is the natural sequence of Arabic numerals.

[0160] It should be noted that after the host completed the last sorting of multiple slaves, the minimum current serial number assigned by the host to the slaves was 1; thereafter, if a new slave is connected, the host sends a second request to the multiple slaves in sequence in the series cascade order. Since the host has not yet assigned a number to the newly connected slave, the current serial number of the newly connected slave in the second response sent by the newly connected slave to the host based on the second request is 0.

[0161] For example, in the first time period, the master-slave communication system includes a host and three serially cascaded slaves, the three slaves are slave A, slave B and slave C in the order of serial cascade, the host sorts slave A, slave B and slave C, the sequence number of slave A is 1, the sequence number of slave B is 2, and the sequence number of slave C is 3. In a second time period after the first time period, slave D is newly connected to the master-slave communication system, and slave D is located before slave A and slave B. The host sends a second request to slave A, slave D, slave B and slave C in series cascade order. In the second response sent by slave A to the host, the current sequence number of slave A is 1, and in the second response sent by slave D to the host, the current sequence number of slave D is 0. In the second response sent by slave B to the host, the current sequence number of slave B is 2, and in the second response sent by slave C to the host, the current sequence number of slave C is 3. At this time, the current sequence number order of slave A, slave D, slave B and slave C is 1, 0, 2, 3, and the current sequence number order of slave A, slave D, slave B and slave C does not satisfy the natural order of Arabic numerals. Therefore, the host needs to reorder slave A, slave D, slave B and slave C according to steps S101 to S104 in the above embodiment.

[0162] Step a22: When the current sequence of the serially connected slaves satisfies the preset sequence, the host determines that it is not necessary to sort the slaves.

[0163] For example, in the first time period, the master-slave communication system includes a host and three serially cascaded slaves, the three slaves are slave A, slave B and slave C in the order of serial cascade, the host sorts slave A, slave B and slave C, the sequence number of slave A is 1, the sequence number of slave B is 2, and the sequence number of slave C is 3. In a second time period after the first time period, slaves A, slave B and slave C in the master-slave communication system remain unchanged, and no new slaves are connected. At this time, the host sends a second request to slaves A, slave B and slave C in series cascade order. In the second response sent by slave A to the host, the current sequence number of slave A is 1, and in the second response sent by slave B to the host, the current sequence number of slave B is 2. In the second response sent by slave C to the host, the current sequence number of slave C is 3. At this time, the current sequence numbers of slaves A, slave B and slave C are 1, 2, and 3 in order. The current sequence number order of slaves A, slave B and slave C meets the natural order of Arabic numerals. Therefore, the host does not need to reorder slaves A, slave B and slave C.

[0164] For another example, in a first time period, the master-slave communication system includes a host and three slaves connected in series cascade. The three slaves are slave A, slave B and slave C in the order of series cascade. The host sorts slave A, slave B and slave C, and the sequence number of slave A is 1, the sequence number of slave B is 2, and the sequence number of slave C is 3. In a second time period after the first time period, slave C is removed. At this time, the host sends a second request to slave A and slave B in sequence in the order of series cascade. In the second response sent by slave A to the host, the current sequence number of slave A is 1, and in the second response sent by slave B to the host, the current sequence number of slave B is 2. At this time, the current sequence numbers of slave A and slave B are 1 and 2, and the current sequence number sequence of slave A and slave B meets the natural order of Arabic numerals. Therefore, the host does not need to re-sort slave A and slave B.

[0165] In an embodiment of the present application, the host obtains the current serial numbers of multiple serially cascaded slaves, determines whether the current serial number order of the multiple slaves satisfies the natural order of Arabic numerals, and then determines whether the multiple slaves need to be sorted, thereby ensuring the stability and reliability of the master-slave communication system, reducing manual intervention, and improving the automation level of the master-slave communication system.

[0166] In the above embodiment, after the host generates the sorting results corresponding to the multiple slaves based on the target sequence numbers and addresses respectively corresponding to the multiple slaves, when the multiple slaves all need to transmit business data to the host, the multiple slaves can transmit the business data to the host in the order indicated by the sorting results. The business data may include the power data collected by the slaves and the operating status data of the slaves. Next, a method for transmitting the power data collected by each slave and the operating status data of each slave to the host in the order indicated by the sorting results is described in detail.

[0167] In a possible embodiment, the master-slave communication method further includes step b1 and step b2. Step b1 and step b2 are described in detail below.

[0168] Step b1: The host sends a third request to multiple slaves in sequence according to a first preset time interval and a series cascade sequence.

[0169] The third request is used to request multiple slaves to send the running status of each slave and / or the power data collected by each slave to the host. The third request includes the address information of the host and the purpose information of the third request.

[0170] It should be noted that the first preset time interval can be set by the power system maintenance personnel themselves, and this embodiment does not specifically limit this.

[0171] For example, the first preset time interval may be 24 hours.

[0172] By carrying the address information of the host in the third request, each slave receiving the third request can know the address of the host, so that the slave can correctly send the third response back to the host when responding to the third request.

[0173] The purpose information of the third response is used to indicate the purpose of the host obtaining the operating status of each slave and / or the power data collected by each slave, which enables the slave to understand the intended purpose of the host's request for the slave's operating status and / or the power data collected by the slave, and helps the slave to correctly prepare and send the third response.

[0174] The host can request multiple slaves to send the operating status of each slave through the third request, and can also request multiple slaves to send the power data collected by each slave. It can also request multiple slaves to send the operating status of each slave and the power data collected by each slave at the same time. This embodiment does not make specific limitations on this.

[0175] The method in which the host sends the third request to multiple slaves in series cascade order is similar to the method in which the host sends the first request to multiple slaves in S101 to S103, which will not be described in detail in this embodiment. The third request can also be sent via a token.

[0176] The third request also includes a data frame structure of a third response.

[0177] It should be noted that the data frame structure of the third response includes a frame start character, an address field, a control word, a data length, a data item code, a data field, a checksum, and a frame end character.

[0178] The frame start character is used to mark the beginning of the data frame, helping the host to identify the starting position of the data frame and ensure the complete reception of the data frame.

[0179] The address field is used to identify the address of the slave that sends the third response to the host, ensuring that the host can correctly identify the slave that sends the third response, thereby improving the accuracy of data transmission.

[0180] The control word is used to indicate the type of the third request, and helps the host understand the purpose and processing method of the data frame. For example, the control word may indicate that the third request is a request to obtain the electrical quantity data of the slave.

[0181] Data length indicates the length of the data field and is used to inform the host of the specific length of the data field, so that the host can correctly parse and process the data content in the data frame.

[0182] Data item code, indicating the specific data item code, for example, positive active power.

[0183] Checksum, used to verify the integrity of the data frame.

[0184] The frame end character is used to mark the end of the data frame, helping the host to identify the end position of the data frame and ensure the complete reception of the data frame.

[0185] Exemplarily, when the host sends a third request to multiple slaves in sequence, and the third request is used to request to obtain the power data of each slave, the host can obtain the power data of each slave in the multiple slaves cascaded in series in sequence.

[0186] Assuming that the host address is 11, and in the serial cascade sequence, the addresses of the multiple slaves are 22, 33, ..., respectively, a specific method for the host to sequentially obtain the power data of each of the multiple slaves in the serial cascade sequence of the multiple slaves is described.

[0187] In the first step, the host sends the third request to the first slave (address 22). The third request is used to request the slave that receives the third request to send the forward active power data of the previous settlement day to the host. The third request carries the data frame format of the third response. The data frame format of the third response is "68 AA AA AA AA AA AA 68 11 04 34 33 34 33cs 16"; "68" is the frame start character; "AA AA AA AA AA AA" is the address of the slave that sends the third response to the host; "11" is the control word, indicating a data read request; "04" indicates the length of the data item encoding; "34 33 34 33" is the data item encoding, indicating the binary-coded decimal (BCD) of the data item 00 01 00 01; "cs" indicates the checksum; and "16" is the frame end character.

[0188] In the second step, after the first slave (address 22) receives the third request sent by the host, it sends a third response to the host through the first communication bus. The third response includes the forward active power data of the first slave on the previous settlement day. The data frame corresponding to the third response sent by the first slave to the host is "68 22 00 00 00 00 00 68 91 DATA cs 16", where "22 00 00 00 00 00" represents the address of the first slave; "91" is the control word, indicating that the data frame is a response frame; "DATA" is the forward active power data of the first slave.

[0189] In the third step, the first slave continues to send a third request to the next slave (address 33) adjacent to the first slave in the serial cascade sequence. In the third request sent by the first slave to the next slave, the data frame format of the third response is "68 AA AA AA AA AA AA 68 11 04 34 33 34 33 cs 16".

[0190] In the fourth step, after receiving the third request sent by the first slave (address 22), the next slave (address 33) sends a third response to the host through the first communication bus. The data frame corresponding to the third response sent by the next slave to the host is "68 33 00 00 00 00 00 68 91 DATA CS 16", where "33 00 00 00 00 00" represents the address of the next slave.

[0191] Repeat the above steps until the last slave in the multiple slaves cascaded in series sends a third response to the host through the first communication bus, so that the host can complete the acquisition of the forward active power data of each slave in the multiple slaves on the previous settlement day.

[0192] Step b2: the host receives a plurality of third responses respectively sent by the plurality of slaves through the first communication bus, and determines the operating status and / or power data of the plurality of slaves based on the contents of the plurality of third responses.

[0193] The third response includes the operating status and / or power data of the slave.

[0194] It should be noted that, for each slave among the multiple slaves, after the slave receives the third request, the slave reads its own operating status and / or power data, packages its own operating status and / or power data to form a third response, and sends the third response to the host through the first communication bus, so that the host can understand the operating status and / or power status of the slave based on the third response of the slave, thereby realizing the host's monitoring and management of the slave.

[0195] In an embodiment of the present application, the host can regularly obtain the operating status and power data of the slave, monitor the operating status of the slave in real time, and facilitate timely discovery of problems in the operation of the slave.

[0196] In the above embodiment, after the host generates the sorting results corresponding to the multiple slaves based on the target sequence numbers and addresses respectively corresponding to the multiple slaves, the host can also verify the current charging parameters of the multiple slaves. Next, the method for the host to verify the current charging parameters of the multiple slaves is described in detail.

[0197] In a possible embodiment, the master-slave communication method further includes step c1 and step c2. Step c1 and step c2 are described in detail below.

[0198] Step c1: The host sends a fourth request to the plurality of slaves in sequence according to a second preset time interval and a series cascade sequence. Correspondingly, the plurality of slaves receive the fourth request sent by the host in sequence.

[0199] It should be noted that the second preset time interval can be set by the power system maintenance personnel themselves, and this embodiment does not specifically limit this.

[0200] For example, the second preset time interval may be 48 hours.

[0201] The fourth request is used to request each of the multiple slaves to verify its own current billing parameters based on the target billing parameters, and send the verification result to the host; the fourth request includes the target billing parameters.

[0202] It should be noted that the billing parameters include rate, time period, time and time zone. The target billing parameters of multiple slaves are the same, and the target billing parameters are stored in the master.

[0203] By correcting the rate settings of the slaves, the slaves can be made to comply with the latest electricity price policies and rate standards. Rate correction includes electricity prices in different time periods (such as peak electricity prices, valley electricity prices, and normal electricity prices) and rates for specific user categories.

[0204] By correcting the time period setting inside the slave, it is ensured that the slave can accurately record and distinguish the power consumption in different time periods. Time period correction usually involves determining the peak and valley electricity price periods, working days and non-working days, etc.

[0205] Ensure accurate timekeeping of the slave by correcting the slave's internal clock. Clock correction of the slave involves synchronizing the slave's time with a standard time source, so that the slave remains accurate during long-term operation.

[0206] By correcting the time zone setting of the slave, ensure that the time displayed by the slave is consistent with the actual local time to prevent slave measurement errors.

[0207] Step c2: the host receives a plurality of fourth responses respectively sent by the plurality of slaves through the first communication bus, and obtains billing parameter verification results of the plurality of slaves based on the contents of the plurality of fourth responses.

[0208] The fourth response includes the billing parameter verification result of the slave.

[0209] Among them, for any slave among the multiple slaves, after the slave receives the fourth request, the slave reads its own current billing parameters, compares its own current billing parameters with the target billing parameters carried in the fourth request, obtains the billing parameter verification result, and packages the billing parameter verification result to form a fourth response, and sends the fourth response to the host through the first communication bus, so that the host can understand the billing parameter verification result of the slave and ensure the accuracy of the billing parameters of the slave.

[0210] It should be noted that, for any slave among the multiple slaves, when the current billing parameters of the slave are consistent with the target billing parameters, the billing parameter verification result of the slave is consistent verification; when the current billing parameters of the slave are inconsistent with the target billing parameters, the billing parameter verification result of the slave is inconsistent verification.

[0211] When the host receives a billing parameter verification result of a slave among multiple slaves that is inconsistent, the host sends a verification update instruction to the slave through the first communication bus to control the slave to update the current billing parameters of the slave based on the target billing parameters, so that the updated current billing parameters of the slave are consistent with the target billing parameters.

[0212] In the embodiment of the present application, the host can ensure that the billing parameters of all slaves are accurate and avoid slave billing errors by regularly checking the billing parameters of the slaves.

[0213] Figure 3 This is a schematic diagram of the structure of a host device provided in an embodiment of the present application. Figure 3 As shown, the host 300 provided in this embodiment can exist independently or be integrated in other devices, and can communicate with the slaves mentioned above to implement the operations corresponding to the host in any of the above method embodiments.

[0214] The host device 300 may include: a transceiver module 301 and a processing module 302. The processing module 302 is used for data processing, and the transceiver module 301 may implement corresponding communication functions. The transceiver module 301 may also be called a communication interface or a communication unit.

[0215] Optionally, the host device 300 may further include a storage unit, which may be used to store instructions and / or data, and the processing module 302 may read the instructions and / or data in the storage unit so that the host device 300 implements the steps implemented by the host in the aforementioned method embodiment.

[0216] The transceiver module 301 is used to execute the reception-related operations of the host in the above method embodiment, and the processing module 302 is used to execute the processing-related operations of the host in the above method embodiment.

[0217] Optionally, the transceiver module 301 may include a sending module and a receiving module. The sending module is used to perform the sending operation in the above method embodiment. The receiving module is used to perform the receiving operation in the above method embodiment.

[0218] It should be noted that the host device 300 may include a sending module but not a receiving module. Alternatively, the host device 300 may include a receiving module but not a sending module. Specifically, it depends on whether the above solution executed by the host device 300 includes a sending action and a receiving action.

[0219] As an example, the host device 300 is used to execute the above Figure 1 Actions performed by the host in the illustrated embodiment.

[0220] The host device 300 may include a transceiver module 301 and a processing module 302 .

[0221] The transceiver module 301 is used to send a first request to the first slave in a series cascade order when the host determines to sort multiple slaves; the first request is used to request multiple slaves to send the cascade position information and slave address information of each slave to the host respectively.

[0222] The processing module 302 is used to receive the cascade position information and slave address information sent by the first slave through the first communication bus, and determine the target sequence number and address of the first slave based on the cascade position information and slave address information corresponding to the first slave.

[0223] The processing module 302 is also used to control the first slave that has sent the cascade position information and slave address information to send a first request to the second slave, so that the second slave that receives the first request sends its own cascade position information and slave address information to the host through the first communication bus, which is used by the host to determine the target serial number and address of the second slave until the host successfully determines the target serial number and address of the last slave in the series cascade; wherein the first slave is any other slave among the multiple slaves except the last slave; and the second slave is adjacent to the first slave along the series cascade direction.

[0224] The processing module 302 is also used to generate sorting results corresponding to multiple slaves based on the target serial numbers and addresses corresponding to the multiple slaves respectively; wherein the sorting results are used to indicate the order in which multiple slaves transmit business data to the host when multiple slaves need to transmit business data to the host.

[0225] It should be understood that the execution of the above-mentioned corresponding processes by each module has been described in detail in the above-mentioned method embodiment, and for the sake of brevity, it will not be repeated here.

[0226] The processing module 302 in the above embodiment can be implemented by at least one processor or processor-related circuit. The transceiver module 301 can be implemented by a transceiver or a transceiver-related circuit. The transceiver module 301 can also be called a communication unit or a communication interface. The storage unit can be implemented by at least one memory.

[0227] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 4 As shown, the electronic device 400 provided in this embodiment includes: a memory 401 and a processor 402 .

[0228] The memory 401 may be an independent physical unit, and may be connected to the processor 402 via a bus 403. The memory 401 and the processor 402 may also be integrated together and implemented by hardware, etc. The memory 401 is used to store program instructions, and the processor 402 calls the program instructions to execute the operations performed by the host or the slave in any of the above method embodiments.

[0229] Optionally, when part or all of the methods of the above embodiments are implemented by software, the electronic device 400 may also include only a processor 402. The memory 401 for storing programs is located outside the electronic device 400, and the processor 402 is connected to the memory through circuits / wires to read and execute the programs stored in the memory. The processor 402 may be a central processing unit (CPU), a network processor (NP) or a combination of a CPU and NP. The processor 402 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.

[0230] The memory 401 may include a volatile memory, such as a random-access memory (RAM); the memory may also include a non-volatile memory, such as a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); the memory may also include a combination of the above types of memory.

[0231] Exemplarily, the present application provides a chip, comprising: an interface circuit and a logic circuit, wherein the interface circuit is used to receive signals from other chips outside the chip and transmit them to the logic circuit, or to send signals from the logic circuit to other chips outside the chip, and the logic circuit is used to execute the operations performed by the host or slave in any of the above method embodiments.

[0232] Illustratively, the present application provides a readable storage medium on which computer program instructions are stored. The computer program instructions are executed by a processor of an electronic device so that the electronic device performs the operations performed by the host or slave in any of the above method embodiments.

[0233] Illustratively, the present application provides a computer program product. When the computer program product is executed on an electronic device, the electronic device executes the operations executed by the host or the slave in any of the above method embodiments.

[0234] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A master-slave communication method, characterized in that: Applicable to a master-slave communication system, the master-slave communication system comprises a master and a plurality of slaves, and a short-circuit protection circuit and an anti-static protection circuit arranged at a receiving end and a transmitting end of each slave; the plurality of slaves are cascaded in series, the first of the cascaded slaves is connected to the master, and two adjacent slaves among the plurality of slaves are connected via a second communication bus; the plurality of slaves are also respectively connected to the master via a first communication bus; The first communication bus and the second communication bus are both serial communication buses; The method comprises: Sending a second request to the multiple slaves in series cascade order; the second request is used to request the multiple slaves to send the current sequence number of each slave to the host respectively; wherein the current sequence number of the slave is the sequence number assigned by the host to the slave when the host last sorted the multiple slaves; receiving a plurality of second responses respectively sent by the plurality of slaves through the first communication bus, and determining whether the plurality of slaves need to be sorted based on the contents of the plurality of second responses; wherein the second response includes the current sequence number of the slave; When the host determines to sort the multiple slaves, a first request is sent to the first slave in a series cascade order; the first request is used to request the multiple slaves to send cascade position information and slave address information of each slave to the host respectively; Receiving the cascade position information and the slave address information sent by the first slave through the first communication bus, and determining the target sequence number and address of the first slave based on the cascade position information and the slave address information corresponding to the first slave; Controlling the first slave that has sent the cascade position information and the slave address information to send the first request to the second slave, so that the second slave that receives the first request sends its own cascade position information and the slave address information to the host through the first communication bus, so that the host can determine the target sequence number and address of the second slave, until the host successfully determines the target sequence number and address of the last slave in the series cascade; wherein the first slave is any other slave among the multiple slaves except the last slave; and the second slave is adjacent to the first slave along the series cascade direction; Based on the target serial numbers and addresses respectively corresponding to the multiple slaves, sorting results corresponding to the multiple slaves are generated; wherein the sorting results are used to indicate the order in which the multiple slaves transmit business data to the host when all the multiple slaves need to transmit business data to the host.

2. The method according to claim 1, characterized in that The first request is sent via a token, which carries the first request; wherein the first request includes the address information of the host, the purpose information of the first response and the data frame structure of the first response; the first response includes the cascade position information and slave address information of the slave sent by the slave to the host.

3. The method according to claim 2, characterized in that The data frame structure of the first response includes a frame start character, an address field, a control word, a data length, a data field, a frame target sequence number and a frame end character; Among them, the address field is used to identify the address of the slave that sends cascade position information and slave address information to the host; the control word is used to indicate the type of the first request; the data length indicates the length of the data field; and the frame target sequence number indicates the number of the multiple slaves.

4. The method according to claim 1, characterized in that: The determining whether the plurality of slaves need to be sorted based on the plurality of second responses includes: In a case where the current sequence number order of the plurality of slaves in the serial cascade sequence does not satisfy the preset sequence, determining that the plurality of slaves need to be sorted; In the case that the current sequence of the sequence numbers of the plurality of slaves in the serial cascade sequence satisfies the preset sequence, it is determined that the plurality of slaves do not need to be sorted.

5. The method according to claim 1, characterized in that The method further comprises: Sending a third request to the multiple slaves in sequence according to a first preset time interval and a series cascade sequence; the third request is used to request the multiple slaves to send the operating status of each of the slaves and / or the power data collected by each of the slaves to the host respectively; wherein the third request includes the address information of the host and the purpose information of the third request; Receive multiple third responses respectively sent by the multiple slaves through the first communication bus, and determine the operating status and / or power data of the multiple slaves based on the contents of the multiple third responses; wherein the third responses include the operating status and / or power data of the slaves.

6. The method according to claim 1, characterized in that The method further comprises: Sending a fourth request to the plurality of slaves in sequence according to a second preset time interval and a serial cascade sequence; the fourth request is used to request each of the plurality of slaves to verify its own current billing parameter based on the target billing parameter, and send the verification result to the host; wherein the fourth request includes the target billing parameter; Receive multiple fourth responses respectively sent by the multiple slaves through the first communication bus, and obtain billing parameter verification results of the multiple slaves based on the contents of the multiple fourth responses; wherein the fourth response includes the billing parameter verification results of the slaves.

7. A master-slave communication system, characterized in that: The master-slave communication system includes a master and a plurality of slaves, and a short circuit protection circuit and an anti-static protection circuit arranged at a receiving end and a transmitting end of each slave; The multiple slaves are cascaded in series, the first slave in the cascaded series is connected to the host, and two adjacent slaves among the multiple slaves are connected via a second communication bus; the multiple slaves are also connected to the host via a first communication bus respectively; the first communication bus and the second communication bus are both serial communication buses; Wherein, the host is used to execute the method described in any one of claims 1 to 6.

8. An electronic device, characterized in that: include: Memory and processor; The memory is configured to store computer program instructions; The processor is configured to execute the computer program instructions so that the electronic device implements the method according to any one of claims 1 to 6.

9. A readable storage medium, characterized in that: include: Computer program instructions, at least one processor of an electronic device executes the computer program instructions so that the electronic device implements the method according to any one of claims 1 to 6.