Disclosure of Invention
In order to solve the above technical problems, the present invention provides a serial communication system and a serial communication method, in which a plurality of node devices are connected in a closed loop, any first node device can initiate communication, and at least one second node device can be used as a receiving end to receive data, so that communication flexibility can be improved, and communication control is simple and efficient.
According to a first aspect of the present invention, there is provided a serial communication system comprising: the serial communication system comprises a plurality of node devices which are connected into a closed loop by buses, wherein any first node device is used as a sending end, at least one second node device is used as a receiving end, the serial communication system is started from the first node device, the bus state of the input end of the next-stage node device is sequentially set in the closed loop, and communication data are sequentially sent to the input end of the next-stage node device.
Preferably, the first node device checks according to the return information of the closed loop to determine whether the communication is successful.
Preferably, the plurality of node devices sequentially set the bus state of the input terminal of the node device of the next stage and sequentially transmit communication data to the input terminal of the node device of the next stage during data communication.
Preferably, the first node device sets a bus busy state at the output terminal after the input terminal detects the bus idle state, and delays the transmission of the communication data at the output terminal for the second period of time.
Preferably, the second node device sets the bus busy state at the output terminal with a delay for a first period of time after detecting the bus busy state at the input terminal, and then transmits the communication data at the output terminal with a delay for a second period of time.
Preferably, the return information includes a return time from when the first node device is set to the busy bus state at its output terminal to when the busy bus state is detected at its input terminal.
Preferably, the sending ends of the plurality of node devices perform time check to determine whether data communication is successful or not according to a return time from when the output end of the sending end is set to be in the bus busy state to when the input end of the sending end detects the bus busy state.
Preferably, the sending end of the plurality of node devices determines that the communication is successful when the return time dt satisfies the following formula, where dt is (n-1) × t1, where n is the number of node devices in the serial communication system, and t1 is the first time period, and represents a fixed delay time between the detection of a busy bus state at the input end and the setting of busy bus at the output end of each node device as a receiving end in the serial communication system.
Preferably, the plurality of node apparatuses respectively include: a serial communication module including a clock terminal, an input terminal, and an output terminal connected to the bus, receiving a clock signal via the clock terminal, detecting a bus state and receiving communication data via the input terminal, setting the bus state and transmitting the communication data via the output terminal; and the micro control unit is connected with the serial communication module, provides data content for the serial communication module when the node equipment is a sending end, and acquires the data content from the serial communication module when the node equipment is a receiving end.
Preferably, the serial communication module stores a device address, acquires a target address from the received communication data, and compares the device address with the target address to determine whether the device address is a receiving end.
Preferably, the first node device of the plurality of node devices broadcasts the communication data to the remaining node devices.
Preferably, the first node device of the plurality of node devices transmits the same or different communication data to the remaining node devices by means of shifting.
According to a second aspect of the present invention, there is provided a serial communication method, in a serial communication system including a plurality of node devices connected in a closed loop by using a bus, any first node device serving as a transmitting end and at least one second node device serving as a receiving end, the serial communication method including: and starting from the first node equipment, sequentially setting the bus state of the input end of the next-level node equipment in a closed loop, and sequentially sending communication data to the input end of the next-level node equipment.
Preferably, the first node device checks according to the return information of the closed loop to determine whether the communication is successful.
Preferably, the first node device sets a bus busy state at the output terminal after the input terminal detects the bus idle state, and delays the transmission of the communication data at the output terminal for a second period of time.
Preferably, the second node device sets the bus busy state at the respective output terminal for a first period of time after the detection of the bus busy state at the input terminal, and then transmits the communication data at the respective output terminal for a second period of time.
Preferably, the return information includes a return time from when the first node device is set to the busy bus state at its output terminal to when the busy bus state is detected at its input terminal.
Preferably, the first node device performs time check to determine whether data communication is successful, based on a return time from when its output terminal is set to the busy state to when its input terminal detects the busy state.
Preferably, the first node device determines that the communication is successful when the return time dt satisfies the following formula, where dt is (n-1) × t1, where n is the number of node devices in the serial communication system, and t1 is the first time period, and represents a fixed delay time from when each node device as a receiving end in the serial communication system detects a busy bus state at an input end to when the busy bus is set at an output end.
Preferably, the second node device stores a device address, and acquires a destination address from the received communication data, and compares the device address with the destination address to determine whether it is a receiving end.
Preferably, the first node device of the plurality of node devices broadcasts the communication data to the remaining node devices.
Preferably, the first node device of the plurality of node devices transmits the same or different communication data to the remaining node devices by means of shifting.
Preferably, the bus state includes a bus busy state represented by a high level signal and a bus idle state represented by a low level signal.
According to the serial communication system and the serial communication method of the embodiment of the invention, a plurality of node devices are connected into a closed loop in the serial communication system, and each node device controls the data communication process according to the bus states of the input end and the output end, so that each node device can initiate communication. The serial communication system and the serial communication method can improve the communication flexibility, and the communication control is simple and efficient.
Detailed Description
To facilitate an understanding of the invention, the invention will now be described more fully with reference to the accompanying drawings. Preferred embodiments of the present invention are shown in the drawings. The invention may, however, be embodied in different forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.
Unless defined otherwise, all techniques and terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
It should be understood that the steps in the flowcharts of the present application are shown in order as indicated by the arrows, but the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
The present invention will be described in detail below with reference to the accompanying drawings.
Fig. 2 shows a schematic block diagram of a serial communication system according to an embodiment of the present invention. The serial communication system 200 includes a plurality of node apparatuses 101 to 10 n. The node devices 101 to 10n respectively include input terminals and output terminals, and are connected via a serial bus in a closed loop so that the output terminal of a node device of a previous stage is connected to the input terminal of a node device of a subsequent stage.
In the serial communication system 200, the node apparatuses 101 to 10n are each assigned an address. Each node device may serve as a sending end to initiate communication, and at least one of the remaining node devices serves as a receiving end to receive communication data. For example, during communication, node device 102 serves as a transmitting end to initiate data communication, and node device 101 serves as a receiving end to receive communication data.
In this embodiment, the node apparatuses 101 to 10n are assigned addresses. The communication data transmitted from the node apparatus 102 to the node apparatus 101 via the serial bus includes a destination address and data content, and the node apparatus 101 determines whether or not the data should be received based on the address matching. In an alternative embodiment, node devices 101 to 10n may not be assigned addresses, and the node device initiating the communication broadcasts communication data to the remaining node devices. In other alternative embodiments, node devices 101 to 10n may not be assigned addresses, and the node device initiating the communication transmits the same or different data to the remaining node devices, for example by shifting.
The node devices 103 to 10n receive communication data, and match a target address in the communication data with their own device addresses. The node apparatuses 103 to 10n forward the communication data if the destination address in the communication data does not match the apparatus address. The node apparatuses 103 to 10n sequentially forward the communication data until the node apparatus 101 receives the communication data.
When the node apparatus 101 determines that the destination address in the communication data matches the apparatus address, it receives the data content in the communication data and forwards the communication data to the next node apparatus, thereby completing the communication process in which the node apparatus 102 sends data to the node apparatus 101.
In this embodiment, a plurality of node devices in a serial communication system are connected in a closed loop, and each node device controls a data communication process according to the bus states of an input terminal and an output terminal, so that each node device can initiate communication. The serial communication system and the serial communication method can improve the communication flexibility, and the communication control is simple and efficient.
Fig. 3 shows a schematic block diagram of a node device of the serial communication system shown in fig. 2. Taking the node apparatus 101 as an example, the node apparatus 101 includes a micro control unit 1011 and a serial communication module 1012. The serial communication module 1012 is connected to the micro control unit 1011, and transmits data contents of data communication therebetween.
When node apparatus 101 is the transmitting side, micro control unit 1011 of node apparatus 101 generates data content and further supplies the data content to serial communication module 1012, and when node apparatus 101 is the receiving side, micro control unit 101 of node apparatus 101 receives the data content from serial communication module 1012 and further processes the received data content.
The serial communication module 1012 includes a clock terminal, an input terminal, and an output terminal. Referring to fig. 2, in a serial communication system 200, a plurality of node apparatuses 101 to 10n are connected in a closed loop via a serial bus. The serial communication module 1012 of the node device 101 obtains the clock signal CLK from the serial bus via the clock terminal, connects with the output terminal of the node device of the previous stage via the input terminal to receive the communication data Di, and connects with the input terminal of the node device of the next stage via the output terminal to transmit the communication data Do. The communication data Di and Do include a destination address and data content.
The serial communication module 1012 of the node apparatus 101 detects the bus state of the input terminal to determine whether to initiate communication and receive communication data according to the bus state, and sets the bus state of the output terminal to notify the node apparatus of the next stage of receiving communication data. The serial communication module 1012 internally stores the device address of the node device 101, and compares the destination address of the communication data with the device address to determine whether the node device 101 is the receiving side. Upon determining as the receiving end, the serial communication module 1012 acquires the data content from the communication data and supplies it to the micro control unit 1011, and continues to forward the communication data to the node apparatus at the next stage. When the determination is that the receiver is not the receiving end, the serial communication module 1012 forwards the communication data.
Fig. 4 shows an operation timing diagram of a node device of the serial communication system shown in fig. 2. In the serial communication system, node devices 101 to 103 are connected in sequence on a closed loop of a serial bus, and node device 101 initiates data communication as a transmitting end. The clock terminals of node devices 101 through 103 receive a clock signal of period T from the serial bus, and the communication data provided on the serial bus at the output terminals are denoted as Do [0], Do [1], Do [2], respectively.
When the input terminal detects the bus state, the node device 101 initiates data communication when detecting that the serial bus is in the idle state, and sets the output terminal to be in the bus busy state to notify the input terminal of the node device of the next stage of receiving communication data. Then, after a delay of a fixed time T2 (e.g., 1 clock cycle T), the communication data Do [0] is issued at the output terminal.
The node device 102 starts receiving communication data upon detecting that the serial bus is busy when the input terminal detects the bus state, and sets the output terminal to the bus busy state after delaying a fixed time T1 (for example, 1 clock cycle T) to notify the input terminal of the next-stage device of receiving communication data. Then, after a further delay of a fixed time T2 (e.g., 1 clock cycle T), the communication data Do [0] is forwarded at the output terminal, i.e., the communication data Do [1] is output at the output terminal.
Node device 103 and its subsequent nodes are analogized in turn, and the system busy state and the reception/forwarding of communication data are set at respective output terminals. Thus, after node device 101 detects the bus state at the input, node device 101 sends communication data Do [0] through T2 (i.e., 1 clock cycle T), node device 102 receives/forwards communication data D [0] through T1+ T2 (i.e., 2 clock cycles 2T), output Do [1] through 2T 1+ T2 (i.e., 3 clock cycles 3T), node device 103 receives/forwards communication data D [1], output communication data Do [2], and communication data D [0], D [1], and D [2] may be the same or different.
In this embodiment, the node devices of the serial communication system are connected in a closed loop. After traversing all the node devices, the output end of the last node device sets a system busy state, thereby notifying the node device as the transmitting end that the serial communication is finished.
Fig. 5 is a flowchart showing a process in which a node apparatus of the serial communication system shown in fig. 2 transmits data. Referring to fig. 2, in a serial communication system 200, node devices 101 to 10n are connected in turn in a closed loop through a serial bus. In this embodiment, the node apparatus 102 initiates data communication as a sender. An input of node device 102 is coupled to an output of node device 101, an output of node device 102 is coupled to an input of node device 103, and so on.
In step S01, the node apparatus 102 detects the bus state at the input terminal. For example, node device 102 detects bus signal levels at an input. If the input signal level is maintained at a low level, it is determined that the serial bus in the serial communication system 200 is in an idle state. If the input signal level is maintained at the high level, it is determined that the serial bus in the serial communication system 200 is in the bus busy state.
In step S02, when the node device 102 detects the busy bus state, it abandons this time of initiating data communication, returns to step S01 to continue detecting the bus state until the bus is in the idle state, and re-initiates data communication. In the case where the node apparatus 102 detects the bus idle state, the node apparatus 102 sets its output terminal to a high level, i.e., to a bus busy state
Data communication is initiated and further steps S03 and subsequent steps are performed.
In step S03, the node apparatus 102 transmits the communication data at the output terminal after delaying for a fixed time T2 (e.g., 1 clock cycle T).
The input of the next-level node apparatus 103 receives communication data. The next-level node device 103 sets the output terminal to the bus busy state after delaying for a fixed time T1 (for example, 1 clock cycle T) to notify the input terminal of the next-level device of the reception of the communication data. The communication data is then forwarded at the output after a delay of a fixed time T2 (e.g., 1 clock cycle T). And so on, the node devices receive/forward communication data stage by stage until the rest of the node devices in the serial communication system 200 are traversed.
In the serial communication system 200, all node devices are connected in a closed loop. An output of node device 101 is connected to an input of node device 102. Therefore, after traversing the node devices of the serial communication system 200, the respective node devices sequentially switch the bus state, and finally the output terminal of the node device 101 sets the input terminal of the node device 102 to the bus busy state.
In step S04, the node apparatus 102 detects the bus state at the input terminal. For example, node device 102 detects bus signal levels at an input. If the input terminal signal level is inverted from the low level to the high level, it is determined that the serial bus in the serial communication system 200 is in the busy state. If the input signal level is maintained at a low level, it is determined that the serial bus in the serial communication system 200 is in a bus idle state.
In step S05, in the case where the node apparatus 102 detects the bus idle state, it returns to step S05 to continue detecting the bus state of the input terminal. In the case where the node apparatus 102 detects the bus busy state, time verification is performed, and the steps S06 to S08 are further performed.
In step S06, the node apparatus 102 performs time check, that is, the node apparatus 102 determines whether or not the return time dt from the start of counting the time set to the bus busy state at its output terminal to the detection of the system busy state at its input terminal satisfies:
dt=(n-1)*t1, (1)
where n is the number of node devices in the serial communication system, and t1 is a fixed delay time from the detection of a bus busy state at the input terminal to the setting of the bus busy state at the output terminal of each node device in the serial communication system.
In step S07, if the return time dt satisfies the above equation (1), the node apparatus 102 determines that the communication is successful.
In step S08, if the return time dt satisfies the condition that does not satisfy the above formula (1), for example, the return time is too short, dt < (n-1) × t1, or the return time is overtime, dt > (n-1) × t1, the node apparatus 102 judges that the communication has failed. The node apparatus 102 may return to step S01 to reinitiate the communication.
In this embodiment, when a node device connected in series with a node device serving as a sending end does not detect that a bus is busy after communication starts, the system is determined to be in an idle state according to a bus state at an input end of the node device to initiate communication, and the input end of the node device serving as the sending end determines that the bus is in the busy state in advance, and then determines that the communication is unsuccessful.
Fig. 6 shows a flowchart of receiving data by a node device of the serial communication system shown in fig. 2. Referring to fig. 3, in the serial communication system 200, node devices 101 to 10n are connected in turn in a closed loop by a serial bus. In this embodiment, node apparatus 101 receives data communications as a receiving end. The input of node device 101 is connected to the output of node device 10n, the output of node device 101 is connected to the input of node device 102, and so on.
In step S11, the node apparatus 101 detects the bus state at the input terminal. For example, the node apparatus 101 detects the bus signal level at the input terminal. If the input signal level is maintained at a low level, it is determined that the serial bus in the serial communication system 200 is in an idle state. If the input signal level is maintained at the high level, it is determined that the serial bus in the serial communication system 200 is in the bus busy state.
In step S12, in case that the node apparatus 101 detects the bus idle state, it returns to step S11 to continue detecting the bus state, and waits for the initiator to initiate data communication. When detecting the bus busy state, the node apparatus 101 starts receiving the communication data, and further performs step S13 and subsequent steps.
In step S13, the node device 101 sets the output terminal to a bus busy state (e.g., a high level signal) after delaying a fixed time T1 (e.g., 1 clock cycle T) to notify the input terminal of the next-stage node device 102 of the reception of the bus state and the reception of the communication data.
In step S14, the node apparatus 101 receives the communication data after delaying a fixed time T2 (e.g., 1 clock cycle T), and forwards the communication data at the output terminal. The input end of the next node device 102 receives the communication data, and so on, the node devices forward the data step by step until the other node devices in the traversal serial communication system 200 reach the transmitting end.
It should be noted that in the description of the present invention, it is to be understood that the terms "upper", "lower", "inner", and the like, indicate orientation or positional relationship, are only for convenience of describing the present invention and simplifying the description, but do not indicate or imply that the referenced components or elements must have a particular orientation, be constructed and operated in a particular orientation, and thus should not be construed as limiting the present invention.
Further, in this document, the contained terms "include", "contain" or any other variation thereof are intended to cover a non-exclusive inclusion, so that a process, a method, an article or an apparatus including a series of elements includes not only those elements but also other elements not explicitly listed or inherent to such process, method, article or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
Finally, it should be noted that: it should be understood that the above examples are only for clearly illustrating the present invention and are not intended to limit the embodiments. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are neither required nor exhaustive of all embodiments. And obvious variations or modifications of the invention may be made without departing from the scope of the invention.