Communication circuit, communication address allocation method, slave, host and system
By designing the communication circuit in the slave machine and utilizing the sending and receiving mechanism of the identity identifier, the intelligent allocation of the slave address is realized, which solves the interference problem caused by the increase of hardware in the existing technology and improves the stability and adaptability of communication.
Patent Information
- Application Number
- CN202111364739.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-17
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2041-11-17
AI Technical Summary
The existing slave communication address allocation method requires additional hardware components, which causes greater interference, affects communication quality, and is difficult to adapt to different application scenarios.
Design a communication circuit, including a transceiver chip module, a first switching device, a second switching device and a third switching device, to realize intelligence by transmitting and receiving identity identification when the slave is in a high-impedance state and a non-high-impedance state. address allocation, reduce interference and multiplex the bus.
It realizes intelligent allocation of multi-slave addresses, reduces the probability of interference and address allocation problems, adapts to different application scenarios, and improves communication stability.
Smart Images

Figure CN116137618B
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of communication technology, and more specifically, to a communication circuit, a communication address allocation method, a slave, a host, and a system. Background Art
[0002] The energy storage battery system generally contains hundreds of battery cells connected in series. The battery management system responsible for managing these battery cells generally includes a master battery control unit and a slave battery management unit. Each slave battery management unit is responsible for managing dozens of battery cells. Multiple master battery control units will establish communication with multiple slave battery management units. In order to better distinguish the slave battery management units, the addresses of the slave battery management units need to be encoded for easy maintenance.
[0003] The existing slave communication address allocation method usually requires hardware improvement and the addition of many components, such as current detection circuits, rectifier circuits, constant current sources, etc., which will cause greater interference between slaves, affect the communication between slaves and the host, and cause problems in the allocation of communication addresses. Therefore, it is necessary to propose a new slave communication address allocation method. Summary of the invention
[0004] One purpose of the embodiments of the present disclosure is to provide a communication circuit, a communication address allocation method, a slave, a host and a system to realize intelligent allocation of slave addresses, which can be adapted to different application scenarios and has high anti-interference ability.
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided a communication circuit, which is applied to slave communication, the slave having a unique identity, and the communication circuit comprises:
[0006] A transceiver chip module, a first switch device, a second switch device and a third switch device;
[0007] The first end of the first switch device is connected to the second end of the third switch device, and the first end and the second end of the first switch device and the second end of the third switch device are all electrically connected to the first pin of the transceiver chip module;
[0008] The first end of the second switch device is electrically connected to the second pin of the transceiver chip module, the second end of the second switch device, and the first end and the third end of the third switch device respectively; the third end of the second switch device is electrically connected to the third pin of the transceiver chip module; the third end of the first switch device is electrically connected to the fourth pin of the transceiver chip module;
[0009] The transceiver chip module includes a transmitting end and a receiving end; the transmitting end of the transceiver chip module is the transmitting end of the communication circuit, and the receiving end of the transceiver chip module is the receiving end of the communication circuit;
[0010] The communication circuit is configured such that when the slave is in a high impedance state, the first switch device, the second switch device and the third switch device are all in an off state, receiving the first broadcast information sent by the host and sending the identity identification;
[0011] Determine whether the identity identifier sent by the transmitting end of the transceiver chip module and the identity identifier received by the receiving end are the same;
[0012] When it is determined that the identity identifier sent by the transmitting end of the transceiver chip module is different from the identity identifier received by the receiving end, the sending of the identity identifier is stopped, the first broadcast message sent by the host is received again, and the identity identifier is resent;
[0013] When it is determined that the identity identifier sent by the transmitting end of the transceiver chip module is the same as the identity identifier received by the receiving end, receiving the communication address sent by the host in response to the identity identifier, and establishing a communication connection with the host based on the communication address;
[0014] The communication circuit is configured such that when the slave is in a non-high-impedance state, the first switch device, the second switch device and the third switch device are all in a conducting state.
[0015] Optionally, it further includes a first pull-down resistor, a second pull-down resistor and a pull-up resistor;
[0016] The first terminal of the third switch device is grounded through the first pull-down resistor; the third terminal of the second switch device is grounded through the second pull-down resistor; and the third terminal of the first switch device is connected to a power source through the pull-up resistor.
[0017] Optionally, the transceiver chip module includes a transmitting chip and a receiving chip;
[0018] The first pin of the transmitting chip is the first pin of the transceiver chip module, and the second pin of the transmitting chip is the second pin of the transceiver chip module; the first pin of the receiving chip is the third pin of the transceiver chip module, and the second pin of the receiving chip is the fourth pin of the transceiver chip module.
[0019] According to a second aspect of an embodiment of the present disclosure, there is provided a communication circuit applied to any one of the first aspects of the present disclosure, the method comprising:
[0020] In the case of being in a high impedance state, receiving a first broadcast message from a host; the first broadcast message includes a communication address allocation command;
[0021] In response to the first broadcast message, sending an identity to the host, and determining whether the identity on the bus is consistent with the sent identity;
[0022] In the case where it is determined that the identity on the bus is consistent with the sent identity, receiving a communication address from the host; wherein the communication address is allocated based on the identity;
[0023] The communication address is set as the communication address of the slave.
[0024] Optionally, sending the identity identifier to the host and determining whether the identity identifier on the bus is consistent with the sent identity identifier includes:
[0025] Splitting the identity identifier into N sub-identities based on the minimum sending unit; N is an integer greater than zero;
[0026] According to the order of the N sub-identity identifiers in the identity identifier, the sub-identity identifiers are sent through the sending end of the transceiver chip module of the communication circuit, and it is determined whether the sub-identity identifier currently sent is consistent with the sub-identity identifier on the bus received through the receiving end of the transceiver chip module of the communication circuit;
[0027] In case of inconsistency, the sending end of the transceiver chip module of the communication circuit is controlled to stop sending the remaining sub-identity identifiers.
[0028] Optionally, before receiving the first broadcast message from the host, the method further includes:
[0029] receiving a second broadcast message, wherein the second broadcast message includes a communication address allocation preparation command;
[0030] According to the communication address allocation preparation command, the working state is adjusted to the high-impedance state.
[0031] Optionally, after setting the communication address as the communication address of the slave, the method further includes:
[0032] The working state of the slave is adjusted to a non-high-impedance state.
[0033] According to a third aspect of an embodiment of the present disclosure, a communication address allocation method is also provided, including:
[0034] Sending a first broadcast message; wherein the first broadcast message includes a communication address allocation command;
[0035] Receiving an identity from a slave; wherein the identity is used to uniquely identify the slave, and the identity is sequentially sent by the slave when it is determined that the sub-identity currently sent is consistent with the sub-identity on the bus;
[0036] Setting the communication address of the slave according to the received identity identifier;
[0037] The communication address is sent to the slave, so that the slave sets the communication address as the communication address of the slave.
[0038] Optionally, before sending the first broadcast message, the method further includes:
[0039] A second broadcast message is sent, wherein the second broadcast message includes a communication address allocation preparation command, and the communication address allocation preparation command is used to enable the slave to adjust the working state to a high-impedance state.
[0040] According to a fourth aspect of an embodiment of the present disclosure, a slave machine is also provided, comprising a communication circuit as described in any one of the first aspect of the embodiment of the present disclosure, wherein the communication circuit is used to execute the communication address allocation method as described in any one of the second aspect of the embodiment of the present disclosure.
[0041] According to the fifth aspect of an embodiment of the present disclosure, a host is also provided, including a memory and a processor, wherein the memory is used to store executable instructions; the processor is used to execute the communication address allocation method described in any one of the third aspects of the embodiments of the present disclosure under the control of the instructions.
[0042] According to a sixth aspect of an embodiment of the present disclosure, a communication address allocation system is also provided, including:
[0043] The host as described in the fifth aspect of the embodiment of the present disclosure, and a plurality of slaves as described in the fourth aspect of the embodiment of the present disclosure;
[0044] A plurality of slaves are communicatively connected to the host.
[0045] One beneficial effect of the present disclosure is that, by setting a communication circuit in a slave, the communication circuit includes a transceiver chip module, a first switch device, a second switch device and a third switch device; wherein the first end of the first switch device is connected to the second end of the third switch device, and the first end, the second end of the first switch device and the second end of the third switch device are all electrically connected to the first pin of the transceiver chip module; the first end of the second switch device is electrically connected to the second pin of the transceiver chip module, the second end of the second switch device, the first end and the third end of the third switch device respectively; the third end of the second switch device is electrically connected to the third pin of the transceiver chip module; the third end of the first switch device is electrically connected to the fourth pin of the transceiver chip module; the transceiver chip module includes a transmitting end and a receiving end; the transmitting end of the transceiver chip module is the transmitting end of the communication circuit, and the receiving end of the transceiver chip module is the receiving end of the communication circuit; the communication circuit It is configured that when the slave is in a high-impedance state, the first switch device, the second switch device and the third switch device are all in the off state, receive the first broadcast information sent by the host and send the identity identifier; determine whether the identity identifier sent by the sending end of the transceiver chip module is the same as the identity identifier received by the receiving end; when it is determined that the identity identifier sent by the sending end of the transceiver chip module is different from the identity identifier received by the receiving end, stop sending the identity identifier, receive the first broadcast message sent by the host again, and resend the identity identifier; when it is determined that the identity identifier sent by the sending end of the transceiver chip module is the same as the identity identifier received by the receiving end, receive the communication address sent by the host in response to the identity identifier, and establish a communication connection with the host based on the communication address; the communication circuit is configured that when the slave is not in a high-impedance state, the first switch device, the second switch device and the third switch device are all in the on state. In this way, by adding several low-power devices to the communication circuit, the working state of the slave can be controlled, and the existing bus can be reused to realize the intelligent allocation of multiple slave addresses, reduce the interference between slaves, and reduce the probability of problems in the allocation of communication addresses, thereby achieving more stable address allocation. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention.
[0047] Figure 1 is a structural schematic diagram of a communication circuit embodiment 1 according to an embodiment of the present disclosure;
[0048] Figure 2 is a structural schematic diagram of a second embodiment of a communication circuit according to an embodiment of the present disclosure;
[0049] Figure 3 is a schematic diagram of a flow chart of sending an identity identifier by a communication circuit according to an embodiment of the present disclosure;
[0050] Figure 4 is a flow chart of a communication address allocation method according to Embodiment 1 of the present disclosure;
[0051] Figure 5 is a flow chart of a communication address allocation method according to Embodiment 2 of the present disclosure;
[0052] Figure 6 is a flowchart of an example of an embodiment of the present disclosure;
[0053] Figure 7 is a schematic diagram of an exemplary hardware structure of an electronic device;
[0054] Figure 8 The diagram is a schematic diagram of the structure of an exemplary communication address allocation system. DETAILED DESCRIPTION
[0055] Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless otherwise specifically stated.
[0056] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
[0057] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.
[0058] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0059] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0060] <Communication Circuit>
[0061] The communication circuit of the embodiment of the present disclosure is applied to slave communication, and the communication circuit may include a transceiver chip module, a first switch device, a second switch device and a third switch device; wherein the first end of the first switch device is connected to the second end of the third switch device, and the first end, the second end of the first switch device and the second end of the third switch device are all electrically connected to the first pin of the transceiver chip module; the first end of the second switch device is electrically connected to the second pin of the transceiver chip module, the second end of the second switch device, the first end and the third end of the third switch device respectively; the third end of the second switch device is electrically connected to the third pin of the transceiver chip module; the third end of the first switch device is electrically connected to the fourth pin of the transceiver chip module. The transceiver chip module includes a transmitting end and a receiving end; the transmitting end of the transceiver chip module is the transmitting end of the communication circuit, and the receiving end of the transceiver chip module is the receiving end of the communication circuit.
[0062] Furthermore, in the communication circuit of this embodiment, a first pull-down resistor, a second pull-down resistor and a pull-up resistor are further included. The first end of the third switch device is grounded through the first pull-down resistor; the third end of the second switch device is grounded through the second pull-down resistor; and the third end of the first switch device is connected to a power source through the pull-up resistor.
[0063] In this embodiment, the number of transceiver chips used varies according to the type of transceiver chip module used. For example, when an RS485 transceiver chip is used, the number of the transceiver chip modules is two, and when an RS422 transceiver chip is used, the number of the transceiver chip module may be one. This is not specifically limited.
[0064] For example, Figure 1 1 is a schematic diagram of the structure of the communication circuit embodiment 1 according to the embodiment of the present disclosure. Figure 1 As shown, taking an RS422 transceiver chip as an example, the first pin of the transceiver chip module is pin A of the RS422 transceiver chip, the second pin of the transceiver chip module is pin B of the RS422 transceiver chip, the third pin of the transceiver chip module is pin Y of the RS422 transceiver chip, and the fourth pin of the transceiver chip module is pin Z of the RS422 transceiver chip. The receiving pin of the transceiver chip module is pin R of the RS422 transceiver chip, and the sending pin of the transceiver chip module is pin D of the RS422 transceiver chip. The first switch device is Q1, the second switch device is Q2, and the third switch device is Q3. The first pull-down resistor is R1, the second pull-down resistor is R2, and the pull-up resistor is R3.
[0065] In the case where the transceiver chip module includes, the transceiver chip module includes a transmitting chip and a receiving chip, wherein the first pin of the transmitting chip is the first pin of the transceiver chip module, and the second pin of the transmitting chip is the second pin of the transceiver chip module; the first pin of the receiving chip is the third pin of the transceiver chip module, and the second pin of the receiving chip is the fourth pin of the transceiver chip module.
[0066] For example, Figure 2 1 is a schematic diagram of the structure of the communication circuit embodiment 2 according to the embodiment of the present disclosure. Figure 2 As shown, taking the use of two RS485 transceiver chips as an example, the transceiver chip U1 uses the sending function, that is, the sending chip, and the transceiver chip U2 uses the receiving function, that is, the receiving chip.
[0067] Specifically, the first pin of the transceiver chip module is pin A of the RS485 transmitting chip U1, and the second pin of the transceiver chip module is pin B of the RS485 transmitting chip U1; the third pin of the transceiver chip module is pin A of the RS485 receiving chip U2, the fourth pin of the transceiver chip module is pin B of the RS485 receiving chip U2, the receiving pin of the transceiver chip module is pin R of the RS4855 receiving chip U2, and the transmitting pin of the transceiver chip module is pin D of the RS4855 transmitting chip U1. The first switch device is Q1, the second switch device is Q2, and the third switch device is Q3. The first pull-down resistor is R1, the second pull-down resistor is R2, and the pull-up resistor is R3.
[0068] In this embodiment, the communication circuit is configured such that when the slave is in a high-impedance state, the first switch device, the second switch device and the third switch device are all in an off state, the first broadcast information sent by the host is received and the identity identifier is sent; it is determined whether the identity identifier sent by the sending end of the transceiver chip module and the identity identifier received by the receiving end are the same; when it is determined that the identity identifier sent by the sending end of the transceiver chip module and the identity identifier received by the receiving end are different, the sending of the identity identifier is terminated, the first broadcast message sent by the host is received again, and the identity identifier is resent; when it is determined that the identity identifier sent by the sending end of the transceiver chip module and the identity identifier received by the receiving end are the same, the communication address sent by the host in response to the identity identifier is received, and a communication connection with the host is established based on the communication address.
[0069] For example, Figure 3 As shown, when the slave is in a high impedance state, the communication process between the slave and the host may include steps 3100 to 3500:
[0070] Step 3100: The slave receives a first broadcast message sent by the master.
[0071] Step 3200: In response to the first broadcast message, the slave sends an identity identifier to the host through the sending end of the transceiver chip module.
[0072] Step 3300, the slave determines whether the identity identifier on the bus received by the receiving end of the transceiver chip module is consistent with the identity identifier sent by the transmitting end. If they are consistent, execute step 3400; if they are inconsistent, stop sending the identity identifier, return to step 3100, and wait for receiving the next first broadcast message.
[0073] Step 3400, the slave receives the communication address sent by the master in response to the identity identification.
[0074] Step 3500: The slave establishes a communication connection with the host based on the communication address.
[0075] The potential between the first pin A and the second pin B is determined by the result of ANDing the potential sent by the slave and the potential on the bus.
[0076] Among them, when the slave is in a high-impedance state, the identity identifier sent by the transmitting end of the transceiver chip module is the unique identity identifier of the slave itself. Generally, the identity identifier can be a binary string. When multiple slaves work at the same time, it is possible to screen the slaves that can be assigned a communication address by the host based on the comparison result of the identity identifier sent by the transmitting end of the transceiver chip module and the identity identifier received by the receiving end, that is, when it is determined that the identity identifier sent by the transmitting end of the transceiver chip module is the same as the identity identifier received by the receiving end, the communication address sent by the receiving host in response to the identity identifier is received to communicate with the host based on the communication address. When it is determined that the identity identifier sent by the transmitting end of the transceiver chip module is different from the identity identifier received by the receiving end, the sending of the identity identifier is terminated, the first broadcast message sent by the host is received again, and the identity identifier is resent; until all slaves establish a communication connection with the host.
[0077] Taking the RS485 transceiver chip module as an example, the implementation principle of the communication circuit of this embodiment is described. Specifically, according to the RS485 specification, the communication uses two lines A and B to realize differential half-duplex communication. Usually, when the potential of pin A on the bus is greater than the potential of pin B, it is logic 1, and when the potential of pin A is less than or equal to the potential of pin B, it is logic 0.
[0078] When the slave is in high impedance state, that is, the bus is in high impedance state, the following working logic can be realized: when the TXD of all slaves on the bus has a logic level of 0, the RXD logic level is 0, and the logic level on the RS485 bus is 0; when the TXD of all slaves on the bus is a logic level of 1, the RXD logic level is 1, and the logic level on the RS485 bus is 1. A line AND function is realized on the bus, that is, the logic level on the bus is equal to the result of the logic level AND of each slave TXD.
[0079] It can be understood that when the slave is in high impedance state, TXD sends data while RXD can detect the current data on the bus, that is, the slave receives data from the bus while sending data. If the received data is not equal to the sent data, it means that there is higher priority data on the bus. At this time, the slave whose received data is not equal to the sent data will stop sending data, allowing the slave with higher priority to send data first, so that priority arbitration can be achieved. When multiple slaves send data at the same time, the data of the slave with higher priority can be sent completely.
[0080] Exemplarily, it is assumed that the identity of slave 1 is 000, the identity of slave 2 is 010, and the identity of slave 3 is 100. When slave 1, slave 2, and slave 3 send the first bit of the identity to the bus, that is, slave 1 sends 0, slave 2 sends 0, and slave 3 sends 1, at the same time, slave 1, slave 2, and slave 3 will receive data 0 from the bus. At this time, slave 3 determines that the received data 0 is different from the sent data 1, indicating that there is data with a higher priority on the bus, and slave 3 stops sending the identity, while slave 1 and slave 2 determine that the received data 0 is equal to the sent data 0, and will continue to send the second bit of the identity, that is, slave 1 sends 0, and slave 2 sends 1. At this time, slave 2 determines that the received data 0 is different from the sent data 1, indicating that there is data with a higher priority on the bus, and slave 2 stops sending the identity, while slave 1 determines that the received data 0 is equal to the sent data 0, and continues to send the third bit of the identity 0.
[0081] It can be seen that in actual applications, the priority is defined according to the size of the slave code, and the smaller the value of the slave code is, the higher its priority is. This embodiment is not limited to this, and the definition of priority can be set according to actual use requirements.
[0082] The communication circuit is configured such that when the slave is in a non-high-impedance state, the first switch device, the second switch device and the third switch device are all in an on state, and the potential between the first pin and the second pin of the transceiver chip module is equal to the potential on the bus.
[0083] The communication circuit of this embodiment controls the working state of the slave by adding a number of low-power devices in the communication circuit, reuses the existing bus to realize the intelligent allocation of multiple slave addresses, reduces interference between slaves, and reduces the probability of problems in the allocation of communication addresses, thereby achieving more stable address allocation.
[0084] <Method Example>
[0085] Figure 4 It is a flow chart of the communication address allocation method of the first embodiment of the present disclosure. The method can be executed by a slave machine, and the slave machine is provided with the communication circuit as described in the above embodiment.
[0086] like Figure 4 As shown, the communication address allocation method of this embodiment may include the following steps 4100 to 4400:
[0087] Step 4100: receiving a first broadcast message from a host while in a high-impedance state; the first broadcast message includes a communication address allocation command.
[0088] The working state of the slave includes a high-impedance state and a non-high-impedance state, wherein the high-impedance state is a bus high-impedance state, and the non-high-impedance state is a regular communication state. The adjustment of the working state is performed according to the command of the host.
[0089] Specifically, before this step, the method further includes: receiving a second broadcast message, wherein the second broadcast message includes a communication address allocation preparation command; and adjusting the working state to the high-impedance state according to the communication address allocation preparation command.
[0090] In this embodiment, all slaves that receive the second broadcast message will adjust their own working state to a high-impedance state, shut down other non-communication tasks, and prepare for the allocation of communication addresses.
[0091] After adjusting the working state, after a preset time period, the slave will receive a first broadcast message from the master. After receiving the first broadcast message, the slave will determine whether it has been assigned a communication address. If not, it will execute step 4200:
[0092] Step 4200: In response to the first broadcast message, send an identity to the host, and determine whether the identity on the bus is consistent with the sent identity.
[0093] Wherein, the identity identifier is used to uniquely identify the slave. In this embodiment, when the slave sends the identity identifier to the host, the identity identifier can be split into N sub-identifiers based on the minimum sending unit; N is an integer greater than zero; according to the order of the N sub-identifiers in the identity identifier, the sub-identifiers are sent through the sending end of the transceiver chip module of the communication circuit, and it is determined whether the sub-identifier currently sent is consistent with the sub-identifier on the bus received by the receiving end of the transceiver chip module of the communication circuit; in the case of inconsistency, it means that a slave with a higher priority is sending the identity identifier to the host at this time, and at this time, the slave controls the sending end of the transceiver chip module of the communication circuit to stop sending the remaining sub-identifiers and wait for the next address allocation command (i.e., the first broadcast information); in the case where the sub-identifier is consistent with the sub-identifier on the bus, the remaining sub-identifiers continue to be sent until the sending is completed.
[0094] Exemplarily, if the minimum transmission unit is a byte, the slave will split the identity identifier into bytes, send 0 when the bit is 0, and send 0xff when the bit is 1. That is, when sending the identity identifier, the identity identifier is sent in bytes.
[0095] Assuming that the slave's identity is 000111, and assuming that when sending to the fourth bit of the identity, the fourth bit of the received identity is 0, which is inconsistent with the sent sub-identity, the slave stops sending the remaining sub-identities; otherwise, it continues to send the remaining sub-identities until it sends to the last bit of the identity.
[0096] After the slave sends the identity to the master, step 4300 is performed:
[0097] Step 4300: When it is determined that the identity on the bus is consistent with the sent identity, receive a communication address from the host; wherein the communication address is allocated based on the identity.
[0098] Specifically, when the slave determines that the identity on the bus is consistent with its own identity, it indicates that the communication address is currently being assigned to the slave. If they are inconsistent, it indicates that the communication address is currently being assigned to other slaves. In this case, the slave can simply ignore the communication address when it receives it.
[0099] Step 4400, setting the communication address as the communication address of the slave.
[0100] Optionally, after setting the communication address as the communication address of the slave, the slave may also send a communication address allocation response message to the host, so that the host is informed that the communication address allocation is successful.
[0101] Furthermore, after the slave sets the communication address as the communication address of the slave, the slave can also adjust the working state to a non-high-impedance state, which is a conventional communication state.
[0102] The communication address allocation method of this embodiment has been described above in conjunction with the accompanying drawings. In this embodiment, the slave receives a first broadcast message from the host when it is in a high-impedance state; the first broadcast message includes a communication address allocation command; in response to the first broadcast message, an identity is sent to the host, and it is determined whether the identity on the bus is consistent with the identity sent; when it is determined that the identity on the bus is consistent with the identity sent, a communication address is received from the host; wherein the communication address is allocated based on the identity; and the communication address is set as the communication address of the slave. In this way, the existing bus can be reused to realize intelligent address allocation of multiple slaves, which can be adapted to different application scenarios, has high anti-interference ability, reduces the probability of problems in the allocation of communication addresses, and thus realizes more stable address allocation.
[0103] Figure 5 It is a flow chart of the communication address allocation method of the second embodiment of the present disclosure, which can be executed by a host.
[0104] like Figure 5 As shown, the communication address allocation method of this embodiment may include the following steps 5100 to 5400:
[0105] Step 5100: Send a first broadcast message; wherein the first broadcast message includes a communication address allocation command.
[0106] Prior to this step, the method further includes: sending a second broadcast message, wherein the second broadcast message includes a communication address allocation preparation command, and the communication address allocation preparation command is used to enable the slave to adjust the working state to a high-impedance state.
[0107] The host can broadcast a communication address allocation preparation command through a second broadcast message, so that all slaves receiving the second broadcast message adjust their own working state to a high-impedance state, close other non-communication tasks, and prepare for address allocation.
[0108] After a preset time period for sending the second broadcast message, the host sends the first broadcast message.
[0109] Step 5200, receiving an identity from a slave; the identity is used to uniquely identify the slave, and the identity is sent sequentially by the slave when it is determined that the sub-identity currently sent is consistent with the sub-identity on the bus.
[0110] It should be noted that if no identification is received from the slave within the preset time period, it indicates that all slaves have been assigned communication addresses, and the process of assigning communication addresses ends.
[0111] Step 5300: Set the communication address of the slave machine according to the received identity identifier.
[0112] Step 5400: Send the communication address to the slave machine, so that the slave machine sets the communication address as the communication address of the slave machine.
[0113] After setting the communication address of the slave, the host sends the communication address to the slave. Specifically, the slave can compare the identity identifier on the bus with the identity identifier of the slave to determine whether they are consistent. If they are consistent, the communication address is set to the communication address of the slave. If they are inconsistent, it indicates that the current communication address is assigned to other slaves, then the communication address can be ignored.
[0114] It is understandable that, after sending the first broadcast message, the host may also receive a communication address allocation response message from the slave to determine that the communication address of the slave has been set according to the communication address allocation response message.
[0115] The communication address allocation method of this embodiment has been described above in conjunction with the accompanying drawings. In this embodiment, the host sends a first broadcast message; wherein the first broadcast message includes a communication address allocation command; receives an identity from a slave; the identity is used to uniquely identify the slave, and the identity is split into N sub-identities based on the minimum sending unit by the slave, and is sent in sequence according to the order of the N sub-identities in the identity, when it is determined that the sub-identity currently sent is consistent with the sub-identity on the bus; wherein N is an integer greater than zero; the communication address of the slave is set according to the received identity; the communication address is sent to the slave so that the slave sets the communication address as the communication address of the slave. In this way, the existing bus can be reused to realize the intelligent address allocation of multiple slaves, which can adapt to different application scenarios, has high anti-interference ability, reduces the probability of problems in the allocation of communication addresses, and thus realizes more stable address allocation.
[0116] <Example>
[0117] Figure 6 FIG. 1 is a flow chart of an example of a communication address allocation method according to an embodiment of the present disclosure. Figure 6 As shown, in this embodiment, the following steps 6100 to 6700 may be included:
[0118] Step 6100: The host sends a second broadcast message, wherein the second broadcast message includes a communication address allocation preparation command.
[0119] Step 6200: The slave receives a second broadcast message, wherein the second broadcast message includes a communication address allocation preparation command; and adjusts the working state to the high-impedance state according to the communication address allocation preparation command.
[0120] Step 6300: Send a first broadcast message after a preset time period; wherein the first broadcast message includes a communication address allocation command.
[0121] Step 6400: The slave sends an identity to the master.
[0122] Step 6500: The host sets the communication address of the slave according to the received identity.
[0123] Step 6600, the host sends the communication address.
[0124] Step 6700, setting the communication address as the communication address of the slave, and sending a communication address allocation response message to the host.
[0125] The communication address allocation method of this embodiment realizes intelligent address allocation of multiple slaves by reusing the existing bus, can adapt to different application scenarios, has high anti-interference ability, reduces the probability of problems in communication address allocation, and thus realizes more stable address allocation.
[0126] <Slave Implementation>
[0127] This embodiment also provides a slave device, including the communication circuit as described in the above embodiment, wherein the communication circuit is used to execute the above Figure 4 The communication address allocation method of the embodiment.
[0128] <Host Implementation>
[0129] In this embodiment, a host 7000 is also provided.
[0130] like Figure 7 As shown, the host 7000 may include a processor 7100 and a memory 7200, wherein the memory 7200 is used to store executable instructions; the processor 7100 is used to control the electronic device 7000 to execute the above-mentioned Figure 5 The communication address allocation method of the embodiment.
[0131] <System Embodiment>
[0132] In this embodiment, the communication address allocation system may include a host and multiple slaves, and the host and the multiple slaves are communicatively connected via two parallel bus communication cables.
[0133] Figure 8 is a schematic diagram of an exemplary communication address allocation system. Figure 7 As shown, the communication address allocation system includes a host, and slaves 1, 2, 3, 4 and 5. Slave 1, slave 2, slave 3, slave 4 and slave 5 are connected to each other through two bus communication cables, thereby realizing half-duplex communication of one differential signal.
[0134] It can be understood that, in each slave of this embodiment, a communication circuit as described in the above communication circuit embodiment is provided, and the following operations can be performed based on the communication circuit. Figure 3 The communication address allocation method in the embodiment shown in the figure. The host can be used to execute the above Figure 4 The communication address allocation method in the illustrated embodiment.
[0135] The communication address allocation system of this embodiment can realize intelligent address allocation of multiple slaves by reusing the existing bus, can adapt to different application scenarios, has high anti-interference ability, reduces the probability of problems in communication address allocation, and thus realizes more stable address allocation.
[0136] <Medium Example>
[0137] An embodiment of the present disclosure provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the communication address allocation method provided in any of the aforementioned embodiments is implemented.
[0138] The present invention may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present invention.
[0139] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.
[0140] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0141] The computer program instructions for performing the operation of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present invention.
[0142] Various aspects of the present invention are described herein with reference to the flow charts and / or block diagrams of the methods, devices (systems) and computer program products according to embodiments of the present invention. It should be understood that each box of the flow chart and / or block diagram and the combination of each box in the flow chart and / or block diagram can be implemented by computer-readable program instructions.
[0143] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0144] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0145] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a part of a module, a program segment or an instruction, and a part of the module, a program segment or an instruction contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that it is equivalent to implement it by hardware, implement it by software, and implement it by combining software and hardware.
[0146] Embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the marketplace, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein. The scope of the present invention is defined by the appended claims.
Claims
1. A communication circuit, applied to slave communication, wherein the slave has a unique identity, characterized in that: The communication circuit comprises: A transceiver chip module, a first switch device, a second switch device and a third switch device; The first end of the first switch device is connected to the second end of the third switch device, and the first end and the second end of the first switch device and the second end of the third switch device are all electrically connected to the first pin of the transceiver chip module; The first end of the second switch device is electrically connected to the second pin of the transceiver chip module, the second end of the second switch device, and the first end and the third end of the third switch device respectively; the third end of the second switch device is electrically connected to the third pin of the transceiver chip module; the third end of the first switch device is electrically connected to the fourth pin of the transceiver chip module; The transceiver chip module includes a transmitting end and a receiving end; the transmitting end of the transceiver chip module is the transmitting end of the communication circuit, and the receiving end of the transceiver chip module is the receiving end of the communication circuit; The communication circuit is configured such that when the slave is in a high impedance state, the first switch device, the second switch device and the third switch device are all in an off state, receiving the first broadcast information sent by the host and sending the identity identification; Determine whether the identity identifier sent by the transmitting end of the transceiver chip module and the identity identifier received by the receiving end are the same; When it is determined that the identity identifier sent by the transmitting end of the transceiver chip module is different from the identity identifier received by the receiving end, the sending of the identity identifier is stopped, the first broadcast message sent by the host is received again, and the identity identifier is resent; When it is determined that the identity identifier sent by the transmitting end of the transceiver chip module is the same as the identity identifier received by the receiving end, receiving the communication address sent by the host in response to the identity identifier, and establishing a communication connection with the host based on the communication address; The communication circuit is configured such that when the slave is in a non-high-impedance state, the first switch device, the second switch device and the third switch device are all in a conducting state.
2. The communication circuit according to claim 1, characterized in that: Also includes a first pull-down resistor, a second pull-down resistor and a pull-up resistor; The first terminal of the third switch device is grounded through the first pull-down resistor; the third terminal of the second switch device is grounded through the second pull-down resistor; and the third terminal of the first switch device is connected to a power source through the pull-up resistor.
3. The communication circuit according to claim 1, characterized in that: The transceiver chip module includes a transmitting chip and a receiving chip; The first pin of the transmitting chip is the first pin of the transceiver chip module, and the second pin of the transmitting chip is the second pin of the transceiver chip module; the first pin of the receiving chip is the third pin of the transceiver chip module, and the second pin of the receiving chip is the fourth pin of the transceiver chip module.
4. A communication address allocation method, characterized in that: Applied to the communication circuit according to any one of claims 1 to 3, the method comprises: In the case of being in a high impedance state, receiving a first broadcast message from a host; the first broadcast message includes a communication address allocation command; In response to the first broadcast message, sending an identity to the host, and determining whether the identity on the bus is consistent with the sent identity; In the case where it is determined that the identity on the bus is consistent with the sent identity, receiving a communication address from the host; wherein the communication address is allocated based on the identity; The communication address is set as the communication address of the slave.
5. The method according to claim 4, characterized in that The sending of the identity identifier to the host and determining whether the identity identifier on the bus is consistent with the sent identity identifier includes: Splitting the identity identifier into N sub-identities based on the minimum sending unit; N is an integer greater than zero; According to the order of the N sub-identity identifiers in the identity identifier, the sub-identity identifiers are sent through the sending end of the transceiver chip module of the communication circuit, and it is determined whether the sub-identity identifier currently sent is consistent with the sub-identity identifier on the bus received through the receiving end of the transceiver chip module of the communication circuit; In case of inconsistency, the transmitting end of the transceiver chip module of the communication circuit is controlled to stop sending the remaining sub-identity identifiers, and receives the first broadcast information again and sends the identity identifier.
6. The method according to claim 4, characterized in that Before receiving the first broadcast message from the host, the method further includes: receiving a second broadcast message, wherein the second broadcast message includes a communication address allocation preparation command; According to the communication address allocation preparation command, the working state is adjusted to the high-impedance state.
7. The method according to claim 4, characterized in that After setting the communication address as the communication address of the slave, the method further includes: The working state of the slave is adjusted to a non-high-impedance state.
8. A communication address allocation method, characterized in that: include: Sending a first broadcast message; wherein the first broadcast message includes a communication address allocation command; Receiving an identity from a slave; wherein the identity is used to uniquely identify the slave, and the identity is sequentially sent by the slave when it is determined that the sub-identity currently sent is consistent with the sub-identity on the bus; Setting the communication address of the slave according to the received identity identifier; The communication address is sent to the slave, so that the slave sets the communication address as the communication address of the slave, and the slave uses the communication circuit according to any one of claims 1 to 3 to communicate.
9. The method according to claim 8, characterized in that Before sending the first broadcast message, the method further includes: A second broadcast message is sent, wherein the second broadcast message includes a communication address allocation preparation command, and the communication address allocation preparation command is used to enable the slave to adjust the working state to a high-impedance state.
10. A slave device, comprising the communication circuit according to any one of claims 1 to 3, wherein the communication circuit is used to execute the communication address allocation method according to any one of claims 4 to 7.
11. A host, comprising a memory and a processor, wherein the memory is used to store executable instructions; and the processor is used to execute the communication address allocation method according to claim 8 or 9 under the control of the instructions.
12. A communication address allocation system, characterized in that: include: The host as claimed in claim 11, and a plurality of slaves as claimed in claim 10; A plurality of slaves are communicatively connected to the host.
