Communication method, electronic device, storage medium, power supply, luminaire, lighting system
Patent Information
- Application Number
- CN202610614702.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2026-08-18
AI Technical Summary
如果从机需要有信息上报给主机,也需要等待主机发起和自己的通信时才能告知,此种方式当从机设备较多时系统的实时响应性能低下,影响控制系统的体验
本发明的技术方案提供的通讯方法,由于主机获取从机的上报标识形成确认标识后反馈给从机,从机继而判断其消息在所有从机中的优先级,因此在从机设备较多时,能够快速筛选出优先级最高的消息,从而提高主机的实时响应能力,优化主从系统体验。
Smart Images

Figure CN122601587A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of bus communication technology, and in particular to a communication method, electronic device, storage medium, power supply, lamp, and lighting system. Background Technology
[0002] Most current fieldbus control systems adopt master-slave control systems for the sake of stability, simplicity and reliability.
[0003] A master unit connects to hundreds of slave units, and all communication is initiated by the master unit, with the slave units responding passively. If a slave unit needs to report information to the master unit, it must wait for the master unit to initiate communication with it before it can notify the master unit. This approach results in poor real-time response performance when there are many slave devices, negatively impacting the user experience of the control system.
[0004] The information disclosed in this background section is intended only to enhance the understanding of the general background of the invention and should not be construed as an admission or in any way implying that the information constitutes prior art known to those skilled in the art. Summary of the Invention
[0005] In view of the problems existing in the prior art, the present invention provides a communication method, electronic device, storage medium, power supply, lamp, and lighting system to improve the response speed of the host in the system to multiple slave devices.
[0006] The present invention provides a communication method applied to a host, wherein the host and multiple slave devices are connected, comprising: Send a broadcast packet to all slave devices. The broadcast packet is used to indicate that the master is ready to retrieve information. After sending the broadcast packet, execute several rounds of the first loop; The first cycle ends after several rounds and several information packets are received from slave devices that have the intention to send messages. The first cycle includes: Receive several reporting identifiers, which come from a subset of all slave devices that have the intention to send messages; A confirmation flag is generated based on several reported flags, and the confirmation flag is sent to the slave machines in the subset.
[0007] Optionally, a method for forming an acknowledgment flag based on several reported flags includes: processing several reported flags using wired-AND logic to form an acknowledgment flag.
[0008] Optionally, broadcast packets, acknowledgment packets, and information packets are all sent to the slave device using voltage modulation.
[0009] Optionally, the method of performing several rounds of the first cycle further includes: The number of times the first loop is executed is equal to the number of bits in the preset reporting code, and each bit in the reporting code is assigned a value as the reporting identifier.
[0010] Optionally, broadcast packets can be sent to all slave devices periodically at preset time intervals.
[0011] The technical solution of the present invention also provides a communication method applied to a slave device, wherein multiple slave devices are connected to a master device, including: Receive broadcast packets from the host, which indicate that the host is ready to retrieve information; In response to a broadcast packet, execute several rounds of the second loop; After completing several rounds of the second cycle, determine whether you have the intention to send a message; if the determination is positive, send a packet to the host; if the determination is negative, terminate communication with the host. The second cycle includes: Determine if it intends to send a message; if the determination is positive, send a reporting flag to the host; if the determination is negative, terminate communication with the host. It receives an acknowledgment flag from the host and, based on the acknowledgment flag and the reporting flag it sent, determines whether it should continue to send messages.
[0012] Optionally, the reporting identifier includes at least one of a first identifier and a second identifier, wherein the first identifier is used to indicate the priority of the information packet and the second identifier is used to indicate the priority of the slave device.
[0013] Optional, also includes: The information packet is set with a binary reporting code, and each bit in the reporting code is assigned a value as a reporting identifier; The method of performing several rounds of the second cycle further includes: For each bit in the reported code, a second loop is executed once, and the number of times the second loop is executed is equal to the number of bits in the reported code.
[0014] Optionally, the reporting identifier and information packet are sent to the host using current modulation.
[0015] Optionally, methods for ending the second loop and determining whether the user intends to send a message further include: Determine whether the most recently received acknowledgment identifier and the most recently sent reporting identifier are equal; If the judgment receives a positive result, it is determined that it has the intention to send a message; if the judgment receives a negative result, it is determined that it does not have the intention to send a message.
[0016] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement any of the communication methods described above.
[0017] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, it implements any of the communication methods described above.
[0018] The present invention also provides a power supply that employs any of the communication methods described above for use with a host computer.
[0019] The present invention also provides a lamp that employs any of the communication methods described above for use with a slave device.
[0020] The present invention also provides a lighting system, the lighting system comprising: At least one of the above-mentioned power supplies is used as the host; Multiple of the aforementioned lamps are used as slave units, and the power supply provides power to the multiple lamps.
[0021] Compared with the prior art, the technical solution of the present invention has the following beneficial effects: The communication method provided by the technical solution of the present invention, since the host obtains the reporting identifier of the slave device, forms an acknowledgment identifier, and feeds it back to the slave device, the slave device then determines the priority of its message among all slave devices. Therefore, when there are many slave devices, the message with the highest priority can be quickly filtered out, thereby improving the real-time response capability of the host and optimizing the master-slave system experience. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0023] Figure 1 This is a flowchart illustrating the communication method according to an embodiment of the present invention; Figure 2 This is a timing diagram of the interaction between the host and slave messages in an embodiment of the present invention; Figure 3 This is a schematic diagram of the communication device between the host and slave devices according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the physical structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0025] The communication method provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.
[0026] Example 1 Figure 1 This is a flowchart illustrating the communication method according to an embodiment of the present invention, as shown below. Figure 1 As shown in the figure, this embodiment provides a communication method applied to a host, which connects to multiple slave devices. The method includes the following steps: S100: Send a broadcast packet to all slave devices. The broadcast packet is used to indicate that the master is ready to retrieve information. S200: After sending the broadcast packet, execute several rounds of the first loop; S300: End several rounds of the first cycle and receive several information packets from slave devices that have the intention to send messages; wherein, the first cycle includes: receiving several reporting identifiers from a subset of all slave devices that have the intention to send messages; forming an acknowledgment identifier based on the several reporting identifiers and sending the acknowledgment identifier to the slave devices in the subset.
[0027] Methods for generating confirmation identifiers based on several reported identifiers include: Several reporting flags are processed using wired-AND logic to form an acknowledgment flag.
[0028] In some embodiments, during each round of the loop, an acknowledgment identifier is formed based on all reported identifiers collected in that round.
[0029] Furthermore, if the reporting identifier sent by the first slave device is 0, the reporting identifier sent by the second slave device is 0, and the reporting identifier sent by the third slave device is 0, then the confirmation identifier formed after the wired-AND logic processing is 0.
[0030] If the reporting identifier sent by the first slave device is 1, the reporting identifier sent by the second slave device is 1, and the reporting identifier sent by the third slave device is 1, then the acknowledgment identifier formed after the wired-AND logic processing is 1.
[0031] If the reporting identifier sent by the first slave device is 0, the reporting identifier sent by the second slave device is 1, and the reporting identifier sent by the third slave device is 0, then the acknowledgment identifier formed after the wired-AND logic processing is 1.
[0032] In this embodiment, the broadcast packet, acknowledgment flag, and information packet are all sent to the slave device using voltage modulation.
[0033] In this embodiment, the method of executing several rounds of the first loop further includes: The number of times the first loop is executed is equal to the number of bits in the preset reporting code, and each bit in the reporting code is assigned a value as the reporting identifier. It should be noted that the reporting code serves the information packet; the slave device sets different reporting codes for each generated information packet based on the content of the information packet and the importance of the slave device itself.
[0034] In this embodiment, broadcast packets are sent to all slave devices periodically at preset time intervals.
[0035] This embodiment can improve the real-time response capability of the host and optimize the master-slave system experience when there are many slave devices.
[0036] Example 2 This embodiment provides a communication method applied to slave devices, where multiple slave devices are connected to a master device, including: Receive broadcast packets from the host, which indicate that the host is ready to retrieve information; In response to a broadcast packet, execute several rounds of the second loop; After completing several rounds of the second cycle, determine whether you have the intention to send a message; if the determination is positive, send a packet to the host; if the determination is negative, terminate communication with the host. The second cycle includes: Determine if it intends to send a message; if the determination is positive, send a reporting flag to the host; if the determination is negative, terminate communication with the host. It receives an acknowledgment flag from the host and, based on the acknowledgment flag and the reporting flag it sent, determines whether it should continue to send messages.
[0037] The reporting identifier includes at least one of a first identifier and a second identifier, wherein the first identifier is used to indicate the priority of the information packet and the second identifier is used to indicate the priority of the slave device.
[0038] This embodiment also includes: The information packet is set with a binary reporting code, and each bit in the reporting code is assigned a value as a reporting identifier; The method of performing several rounds of the second cycle further includes: For each bit in the reported code, a second loop is executed once, and the number of times the second loop is executed is equal to the number of bits in the reported code.
[0039] In this embodiment, both the reporting identifier and the information packet are sent to the host using current modulation.
[0040] In this embodiment, the method for ending the second loop and determining whether the user intends to send a message further includes: Determine whether the most recently received acknowledgment identifier and the most recently sent reporting identifier are equal; If the judgment receives a positive result, it is determined that it has the intention to send a message; if the judgment receives a negative result, it is determined that it does not have the intention to send a message.
[0041] In some embodiments, determining whether to continue sending messages based on the acknowledgment identifier and the reporting identifier sent by itself includes: If the confirmation identifier is the same as the reporting identifier sent by itself, the intention to send the message will be maintained; otherwise, the intention to send the message will be canceled.
[0042] Furthermore, if, during a certain loop, the first slave device sends a reporting identifier of 0, the second slave device sends a reporting identifier of 1, and the third slave device sends a reporting identifier of 0, then after the wired-AND logic processing, the resulting acknowledgment identifier is 1. Upon receiving acknowledgment identifier 1, the first slave device finds it different from the reported identifier 0 and cancels its message sending intention. Upon receiving acknowledgment identifier 1, the second slave device finds it is the same as the reported identifier 1 and maintains its message sending intention. Upon receiving acknowledgment identifier 1, the third slave device finds it different from the reported identifier 0 and cancels its message sending intention. In this way, based on the reported identifiers, the importance of messages from the slave devices is quickly filtered, thereby quickly locating the most important messages.
[0043] In this embodiment, the host periodically sends broadcast packets to extract information. After all slaves receive the packet, the information with the highest priority will be reported to the host first through the aforementioned competition mechanism. This solves the problem that information could only be reported when the host communicated with each slave individually, and the overall real-time response performance of the system is greatly improved.
[0044] Example 3 This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the communication method as described in Embodiment 1 or Embodiment 2 above.
[0045] Example 4 This embodiment provides a non-transitory computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the communication method as described in Embodiment 1 or Embodiment 2 above.
[0046] Example 5 The technical solution of the present invention also provides a power supply, which adopts the communication method as described in Embodiment 1 above.
[0047] Example 6 The technical solution of the present invention also provides a lamp that uses the communication method described in Embodiment 2 above.
[0048] Example 7 The present invention also provides a lighting system, the lighting system comprising: At least one power supply in embodiment 5, the power supply being used as a host; In multiple embodiments of 6, the lamps are used as slave devices, and the power supply provides power to multiple lamps.
[0049] It should be noted that both the power supply and the lighting fixtures include controllers used to modulate and demodulate the signals.
[0050] In some embodiments, the lighting system is a fire emergency lighting system that requires periodic monitoring of the status of all luminaires.
[0051] In some embodiments, the luminaire uses a DC carrier wave to send data to the power supply.
[0052] The power supply in this embodiment can quickly respond to messages from the lamps while supplying power to them.
[0053] Example 8 This embodiment provides a communication method.
[0054] The slave device sets binary reporting codes for information packets, including information priority (Level) encoding and slave address (Addr) encoding, with each bit in the encoding serving as a reporting identifier.
[0055] In some embodiments, the information priority (Level) encoding is defined according to 4 bits and can be freely extended and scalable, as shown in Table 1 below.
[0056] Table 1
[0057] In some embodiments, the slave address (Addr) encoding is defined according to 8 bits and can be freely extended or scald, as shown in Table 2 below.
[0058] Table 2 Addr <![CDATA[Addr7]]> <![CDATA[Addr6]]> <![CDATA[Addr5]]> <![CDATA[Addr4]]> <![CDATA[Addr3]]> <![CDATA[Addr2]]> <![CDATA[Addr1]]> <![CDATA[Addr0]]> Equipment No. 0 0 0 0 0 0 0 0 0 Equipment 1 0 0 0 0 0 0 0 1 Equipment 2 0 0 0 0 0 0 1 0 Equipment No. 3 0 0 0 0 0 0 1 1 Equipment No. 4 0 0 0 0 0 1 0 0 …… …… …… …… …… …… …… …… …… Equipment No. 255 1 1 1 1 1 1 1 1 Figure 2 This is a timing diagram of the interaction between the master and slave messages in an embodiment of the present invention, as shown below. Figure 2 As shown, the method includes: a. The host periodically sends out retrieval information broadcast packets; b. After all slave devices receive the information retrieval broadcast packet, if there is information to be uploaded, they will inform the host whether there is information to be uploaded at the time of response; if there is no information to be uploaded, they will jump to f3. c. The host starts receiving the reporting identifier, and the slave uploads the information priority (Level) code and slave address (Addr) code bit by bit according to the encoding format in Table 1 and Table 2. After the reporting is completed, it proceeds to g. d. After receiving the reporting flag (upload bit) of each bit from the slave, the master sends the acknowledgment flag (acknowledgment bit) of that bit based on wired-AND logic. e. The slave device determines whether the received confirmation identifier and the reported identifier uploaded in c are consistent. If they are consistent, it continues to jump to c and the slave device uploads the next reported identifier. If they are inconsistent, it jumps to f to end the reporting. f. End this report and wait for the next reporting opportunity; g. The host extracts the specific information packet, and the slave with address Addr transmits the specific information packet it carries.
[0059] This embodiment provides a communication system that simultaneously considers message priority and slave priority, enabling the master to quickly obtain the most important message packets from the 255 slaves in each cycle.
[0060] Example 9 The communication device for the master and slave provided in this embodiment will be described below. The communication device for the master and slave described below can be referred to in correspondence with the communication method described above.
[0061] Figure 3 This is a schematic diagram of the communication device between the host and slave in an embodiment of the present invention, as shown below. Figure 3 As shown in the figure, this embodiment provides a communication device for a host and slave devices, which is applied to a host and connects the host to multiple slave devices. The device includes the following modules: The broadcast module is used to send broadcast packets to all slave devices. The broadcast packets indicate that the master is ready to retrieve information. The loop module is used to execute several rounds of the first loop after sending a broadcast packet; The receiving module is used to end several rounds of the first cycle and receive several information packets, which come from slave devices that have the intention to send messages; The first cycle includes: Receive several reporting identifiers, which come from a subset of all slave devices that have the intention to send messages; A confirmation flag is generated based on several reported flags, and the confirmation flag is sent to the slave machines in the subset.
[0062] This embodiment improves the real-time response capability of the host and optimizes the master-slave system experience when there are many slave devices.
[0063] Figure 4 This is a schematic diagram of the physical structure of an electronic device according to an embodiment of the present invention, such as... Figure 4 As shown, the electronic device may include: a processor 810, a communications interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communications interface 820, and the memory 830 communicate with each other via the communication bus 840. The processor 810 can call logical instructions in the memory 830 to execute communication methods, applicable to a host, and connecting the host and multiple slave devices, including: Send a broadcast packet to all slave devices. The broadcast packet is used to indicate that the master is ready to retrieve information. After sending the broadcast packet, execute several rounds of the first loop; The first cycle ends after several rounds and several information packets are received from slave devices that have the intention to send messages. The first cycle includes: Receive several reporting identifiers, which come from a subset of all slave devices that have the intention to send messages; A confirmation flag is generated based on several reported flags, and the confirmation flag is sent to the slave machines in the subset.
[0064] Furthermore, the logical instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0065] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, which, when executed by a computer, enable the computer to execute the communication methods provided by the above methods, applied to a host, and connecting the host and multiple slave devices, including: Send a broadcast packet to all slave devices. The broadcast packet is used to indicate that the master is ready to retrieve information. After sending the broadcast packet, execute several rounds of the first loop; The first cycle ends after several rounds and several information packets are received from slave devices that have the intention to send messages. The first cycle includes: Receive several reporting identifiers, which come from a subset of all slave devices that have the intention to send messages; A confirmation flag is generated based on several reported flags, and the confirmation flag is sent to the slave machines in the subset.
[0066] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, is implemented to perform the communication methods provided above, applied to a host, and the host and multiple slave devices are connected, including: Send a broadcast packet to all slave devices. The broadcast packet is used to indicate that the master is ready to retrieve information. After sending the broadcast packet, execute several rounds of the first loop; The first cycle ends after several rounds and several information packets are received from slave devices that have the intention to send messages. The first cycle includes: Receive several reporting identifiers, which come from a subset of all slave devices that have the intention to send messages; A confirmation flag is generated based on several reported flags, and the confirmation flag is sent to the slave machines in the subset.
[0067] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0068] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0069] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An information reporting method, applied to a host, characterized in that, include: The host periodically sends broadcast packets to its associated slave devices, the broadcast packets indicating that the host is ready to retrieve information; The receiving and feedback process is executed multiple times based on a preset number of times, wherein the preset number of times is determined based on the number of bits of the information priority encoding and the number of bits of the address encoding of the slave device; In each round of the process, when the current bit data sent by each slave is received, the corresponding acknowledgment bit data is obtained based on the current bit data and broadcast, so that the slave whose current bit data is inconsistent with the acknowledgment bit data exits the subsequent process. When the process is completed after the preset number of times, the address of the winning slave device is determined, and the specific information packet sent by the winning slave device is extracted and received based on the address.
2. The information reporting method according to claim 1, characterized in that, The method for obtaining the corresponding confirmation bit data based on the current bit data includes: processing the received current bit data using wired-AND logic to form the corresponding confirmation bit data.
3. The information reporting method according to claim 1 or 2, characterized in that, The broadcast packet and the acknowledgment bit data are both sent to the slave device using voltage modulation.
4. The information reporting method according to claim 1, characterized in that, The data of the current bit is the corresponding bit in the binary reporting code. The reporting code includes a first identifier and a second identifier. The first identifier is a priority code used to indicate the priority of the information packet, and the second identifier is an address code used to indicate the priority of the slave device.
5. The information reporting method according to claim 1, characterized in that, The broadcast packets are sent periodically to the multiple slave devices associated with it at preset time intervals.
6. An information reporting method, applied to multiple slave devices associated with the same host, characterized in that, include: It receives broadcast packets from the host and enters a reporting contention state when it has the intention to send a message; In the reporting contention state, in response to the broadcast packet, the data of the current bit is sent bit by bit according to the bit order of information priority encoding and address encoding based on a preset number of times, wherein the preset number of times is determined based on the number of bits of its own information priority encoding and address encoding; During the bit-by-bit transmission process, the system continuously monitors the data of the acknowledgment bit broadcast by the host and compares the data of the current bit it is transmitting with the data of the acknowledgment bit. If the comparison results are inconsistent, the current reporting competition will be terminated, and the transmission of subsequent bits of data will cease. If the preset number of transmissions is completed and the current reporting competition is not withdrawn, the winning slave device will send an information packet to the host.
7. The information reporting method according to claim 6, characterized in that, The method further includes: setting a binary reporting code for the information packet, the reporting code including the information priority code and the address code; The preset number of times is equal to the total number of bits in the reporting code.
8. The information reporting method according to claim 6 or 7, characterized in that, The current data and the information packet are both sent to the host using current modulation.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the information reporting method as described in any one of claims 1-5 or 6-8.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the information reporting method as described in any one of claims 1-5 or 6-8.
11. A power supply, characterized in that, The power supply uses the information reporting method described in any one of claims 1-5.
12. A lamp, characterized in that, The lighting fixture employs the information reporting method described in any one of claims 6-8.
13. A lighting system, characterized in that, The lighting system includes: at least one power source as claimed in claim 11, the power source being used as a master unit; and a plurality of luminaires as claimed in claim 12, the luminaires being used as slave units, the power source supplying power to the plurality of luminaires.