CN117978349A - Data communication method and communication system - Google Patents
Data communication method and communication system Download PDFInfo
- Publication number
- CN117978349A CN117978349A CN202211304821.5A CN202211304821A CN117978349A CN 117978349 A CN117978349 A CN 117978349A CN 202211304821 A CN202211304821 A CN 202211304821A CN 117978349 A CN117978349 A CN 117978349A
- Authority
- CN
- China
- Prior art keywords
- slave
- value
- message
- data
- segment
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 230000006854 communication Effects 0.000 title claims abstract description 124
- 238000004891 communication Methods 0.000 title claims abstract description 113
- 238000000034 method Methods 0.000 title claims abstract description 99
- 230000001360 synchronised effect Effects 0.000 claims description 40
- 230000008859 change Effects 0.000 claims description 12
- 238000012795 verification Methods 0.000 claims description 11
- 230000005540 biological transmission Effects 0.000 abstract description 36
- 238000011084 recovery Methods 0.000 abstract description 4
- 230000001276 controlling effect Effects 0.000 description 59
- 230000008569 process Effects 0.000 description 24
- 230000000630 rising effect Effects 0.000 description 17
- 230000006872 improvement Effects 0.000 description 16
- 238000010586 diagram Methods 0.000 description 13
- 230000009191 jumping Effects 0.000 description 5
- 102220070930 rs794728599 Human genes 0.000 description 5
- 230000000694 effects Effects 0.000 description 4
- 102220621241 Proline-rich membrane anchor 1_S32A_mutation Human genes 0.000 description 3
- 230000003044 adaptive effect Effects 0.000 description 3
- 230000003111 delayed effect Effects 0.000 description 3
- 125000004122 cyclic group Chemical group 0.000 description 2
- 230000014509 gene expression Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 102220213553 rs1026192345 Human genes 0.000 description 2
- 241001522296 Erithacus rubecula Species 0.000 description 1
- 230000009471 action Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000003090 exacerbative effect Effects 0.000 description 1
- 230000001151 other effect Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 230000001105 regulatory effect Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L12/40006—Architecture of a communication node
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L7/00—Arrangements for synchronising receiver with transmitter
- H04L7/0079—Receiver details
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L7/00—Arrangements for synchronising receiver with transmitter
- H04L7/0091—Transmitter details
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
The invention discloses a data communication method and a communication system, wherein the method comprises the following steps: the control host sends a data message to the slave; when the slave starts to receive a message stop section in the data message, controlling the slave to start counting, and when the counting length value is equal to an early jump value, controlling the slave to enter a next receiving and transmitting state; and the early jump value is smaller than the total value of stop segments counted by the slave in the message stop segment. The data communication method provided by the invention can improve the message receiving capability, the self-recovery capability and the anti-interference capability of the slave, reduce the occurrence probability of communication failure, delay generated by self and interference and errors caused by the delay, and is suitable for the transmission of high-speed continuous data messages.
Description
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a data communication method and a communication system.
Background
Bus communication is a common means for currently completing communication between different devices, and in some application scenarios such as an automobile distributed electronic system, a local interconnect network (LIN, local Interconnect Network) bus can be used to realize communication, so as to achieve the beneficial effects of low cost, small number of signal lines, high transmission rate and the like. For the process of bus communication, the prior art is generally configured to: one or more slaves, upon receiving a falling edge in a communication packet from the master transmission, control the counter to begin counting and zero out the timer after the reception of the current byte is completed. After the reception of all bytes is completed, the timer is closed to wait for the reception of the next communication packet.
The interrupt response is in a data receiving mode, the anti-interference capability and the interference recovery capability are weak, when temperature and power supply changes or external electromagnetic interference (EMI, electromagnetic Interference), electrostatic interference and pulse interference exist, the serial port clocks of the master machine and the slave machine are deviated, and as the slave machine receives the communication packets one by one and sequentially, the communication packets received by the slave machine continuously generate errors, the slave machine cannot distinguish different communication packets, and thus the problems of byte dislocation, communication packet receiving failure, communication 'false death' and the like are caused. On the basis, the problems of unstable communication, packet loss and the like of the communication mode under the scene of continuous transmission of multiple communication packets are solved by considering that the entering and exiting interruption of the slave machine is delayed.
Disclosure of Invention
The invention aims to provide a data communication method, which solves the problems that the data communication in the prior art has poor anti-interference capability, frequent communication failure and incapability of adapting to a continuous data transmission scene.
It is an object of the present invention to provide a data communication system.
To achieve one of the above objects, an embodiment of the present invention provides a data communication method, including: the control host sends a data message to the slave; when the slave starts to receive a message stop section in the data message, controlling the slave to start counting, and when the counting length value is equal to an early jump value, controlling the slave to enter a next receiving and transmitting state; and the early jump value is smaller than the total value of stop segments counted by the slave in the message stop segment.
As a further improvement of an embodiment of the present invention, the method further includes: determining the early jump value according to the stop segment total value and the receiving-transmitting delay value; the receiving and transmitting delay value is a count length value of delay between the master machine and the slave machine.
As a further improvement of an embodiment of the present invention, the data packet includes a synchronization section located before the packet stop section; the method further comprises the steps of: and when the slave starts to receive the synchronous stop segment in the synchronous segments, controlling the slave to start counting, stopping when the slave receives the falling edge of the synchronous stop segment, and obtaining the total value of the stop segments.
As a further improvement of an embodiment of the present invention, the method specifically includes: judging whether the command configuration of the slave comprises a data return instruction or not; if yes, determining the advance jump value according to the difference between the total value of the stop section and the receiving and transmitting delay value; if not, determining the early jump value according to the product of the total value of the stop segment and a preset scaling index and the difference between the total value of the stop segment and the receiving and transmitting delay value.
As a further improvement of an embodiment of the present invention, the scale factor has a value ranging between 0 and 1.
As a further improvement of an embodiment of the present invention, the next transceiving state includes a data return state and a message transceiving state; after the "if yes", determining the early jump value "according to the difference between the total stop segment value and the transmit-receive delay value, the method specifically includes: when the count length value is equal to the early jump value, controlling the slave to enter a data return state, and sending a return message to the host; when the slave starts to send the return stop segment in the return message, controlling the slave to start counting, and when the counting length value is equal to the return jump-out value, controlling the slave to enter a message receiving and transmitting state; and the return jump-out value is smaller than a return stop segment value counted by the slave machine in the return stop segment.
As a further improvement of an embodiment of the present invention, the method specifically includes: and when the counting length value is equal to the return trip-out value, compensating the rest part in the return stop section to the host computer through a pull-up circuit, and simultaneously controlling the slave computer to enter a message receiving and transmitting state.
As a further improvement of an embodiment of the present invention, the next transceiving state includes a message transceiving state; after the step of determining the early jump value according to the product of the total stop segment value and a preset scaling index and the difference between the total stop segment value and the receiving/transmitting delay value, if not, the method specifically comprises the following steps: and when the counting length value is equal to the early jump value, controlling the slave to enter a message receiving and transmitting state.
As a further improvement of an embodiment of the present invention, the transceiving delay value includes at least one of a master transmit delay value, a slave receive delay value, a master receive delay value, a slave transmit delay value, and a connection line delay value.
As a further improvement of an embodiment of the present invention, the method specifically includes: and when the counting length value is equal to the early jump value, compensating the rest part in the message stopping section to the slave machine through a pull-up circuit, and simultaneously controlling the slave machine to enter a next receiving and transmitting state.
As a further improvement of an embodiment of the present invention, the data packet includes a synchronization segment; the method further comprises the steps of: when the slave starts to receive the synchronous segment, controlling the slave to count at least part of level changes in the synchronous segment, and calculating a temporary baud rate value of the data message according to a change count value; and controlling the slave to complete at least part of the communication process with the host according to the temporary baud rate value.
As a further improvement of an embodiment of the present invention, the data packet includes a communication body section and a check section disposed after the synchronization section; the method specifically comprises the following steps: when the count length value is equal to the early jump value, controlling the slave to enter a matching check state; judging whether at least part of the communication main body section is matched with the verification section or not; if yes, the temporary baud rate is stored as a fixed baud rate, and the slave is controlled to complete at least part of the communication process between the slave and the host at the fixed baud rate.
As a further improvement of an embodiment of the present invention, the communication body section includes a command section and a data section; the command section is used for executing command configuration on the slave; the command section comprises at least one of a target chip code, a message type, a data return instruction and message length information; the method specifically comprises the following steps: and controlling the slave to enter a matching verification state, and judging whether at least the target chip code and the data segment are matched with the verification segment or not.
As a further improvement of an embodiment of the present invention, the data packet includes a synchronization interval section disposed at a head of the data packet; the method specifically comprises the following steps of; and when the slave receives that the counting length value of the synchronous interval section is equal to the effective interval value, controlling the slave to enter the receiving state of other data sections in the data message.
As a further improvement of an embodiment of the present invention, the data packet includes a synchronization segment disposed after the synchronization interval segment; the method further comprises the steps of: when the receiving line of the slave machine detects a falling edge from idle, controlling the slave machine to start receiving the synchronous interval section, controlling the slave machine to start counting, and controlling the slave machine to enter a synchronous section receiving state when the counting length value of the synchronous interval section is equal to the effective interval value; or when the slave receives a first level with the duration of the valid interval value, controlling the slave to enter the synchronous segment receiving state.
As a further improvement of an embodiment of the present invention, the method specifically includes: when the count length value is equal to the advance jump value, controlling the slave to sequentially enter a matching check state, a data return state and a message receiving and transmitting state; wherein the early jump value is equal to the difference between the total value of the stop segment and the receiving-transmitting delay value; or when the counting length value is equal to the advanced jump-out value, controlling the slave to sequentially enter a matching check state and a message receiving and transmitting state; and the early jump value is equal to the product of the total value of the stop section and a preset scaling index, and is the difference between the early jump value and the receiving and transmitting delay value.
To achieve one of the above objects, an embodiment of the present invention provides a data communication system, including: the host computer is configured to send a data message to the slave computer; the slave is configured to start counting when the message stop section in the data message starts to be received, and enter the next receiving and transmitting state when the counting length value is equal to the early jump value; and the early jump value is smaller than the total value of stop segments counted by the slave in the message stop segment.
As a further improvement of an embodiment of the present invention, the slave is configured with one or more, and a pull-up circuit is included between the master and the slave.
Compared with the prior art, the data communication method provided by the invention can jump out to the next stage of the data message receiving and transmitting process in advance through the final stage of the last data message receiving, shorten the total time for receiving the single data message and improve the message receiving capability of the slave; when receiving delay is caused by interference, the influence on the next data message receiving process is reduced by virtue of jumping out in advance, the self-recovery capacity and anti-interference capacity of data communication are improved, and the probability of communication failure is reduced; in the scene of continuous transmission of the data messages, the influence of delay caused by self delay and interference on other data messages can be reduced, and in the continuous receiving process, the error caused by delay is gradually reduced, so that most of continuous data messages are ensured to be available.
Drawings
Fig. 1 is a schematic diagram of a data communication system according to an embodiment of the present invention.
Fig. 2 is a schematic structural diagram of a data communication system according to another embodiment of the present invention.
Fig. 3 is a schematic diagram showing steps of a data communication method according to an embodiment of the present invention.
Fig. 4 is a schematic diagram of a structure of transmitting and receiving data from different terminals of a master and a slave when performing a data communication method according to an embodiment of the present invention.
Fig. 5 is a schematic diagram of a structure of transmitting and receiving data from different terminals of a host and a slave when performing a data communication method according to another embodiment of the present invention.
Fig. 6 is a schematic diagram of steps of a first example of a data communication method according to an embodiment of the present invention.
Fig. 7 is a schematic diagram of steps of a first specific example of a first embodiment of a data communication method in an embodiment of the present invention.
Fig. 8 is a schematic diagram of steps of a second specific example of the first embodiment of the data communication method in an embodiment of the present invention.
Fig. 9 is a schematic diagram showing steps of a second example of the data communication method according to an embodiment of the present invention.
Fig. 10 is a schematic diagram showing steps of a specific example of a second embodiment of the data communication method in an embodiment of the present invention.
Fig. 11 is a schematic diagram showing steps of a third example of the data communication method according to an embodiment of the present invention.
Fig. 12 is a schematic diagram showing steps of a specific example of a third embodiment of the data communication method in an embodiment of the present invention.
Fig. 13 is a schematic diagram showing steps of a fourth example of the data communication method according to an embodiment of the present invention.
Detailed Description
The present invention will be described in detail below with reference to specific embodiments shown in the drawings. These embodiments are not intended to limit the invention and structural, methodological, or functional modifications of these embodiments that may be made by one of ordinary skill in the art are included within the scope of the invention.
It should be noted that the term "comprises," "comprising," or any other variation thereof is intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Furthermore, the terms "first," "second," "third," "fourth," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
On the premise of large communication of byte by byte and data messages, the following defects are caused in the prior art by responding to data information sent by a host side in a mode of triggering interrupt by a slave:
(1) The anti-interference capability is poor, and under the application scene of high-speed communication, the data message can be continuously in an error state, and normal communication can not be recovered. Particularly, when there is a fault such as interference or short circuit of a communication line, a part of bytes or segments in the data message may be wrong or lost, and the slave cannot distinguish where to start or end the reception of the data message, which causes a so-called "dead-beat" state.
(2) When a plurality of communication packets, command packets, data messages or message frames are continuously transmitted at a high speed, no interval time exists between the communication packets, and the slave machine enters and exits to interrupt, so that delay exists, the problem in (1) is frequently generated in the actual application process, and the conditions of unstable communication and packet loss are caused.
(3) The baud rate of the slave is usually configured as a fixed value, and when the external environment changes in temperature and power supply, the delay or deviation of serial clocks of the master and the slave increases, thereby exacerbating the situation in (1). The bytes or segments received by the slave are bytes or segments with multi-bit errors, which results in communication failure.
An embodiment of the present invention further provides a data communication system as shown in fig. 1. The data communication system includes a master 100 and a slave 200, both of which complete communication through data information exchange. Wherein the master 100 is configured to send data messages to the slaves. The data message may be understood as a message frame, a communication packet, a data packet, a command packet, and the like, and the detailed description and the structural configuration of the data message provided below may be applied to the scheme under Ren Yiding sense.
The slave 200 is configured to start counting when receiving the message stop segment in the data message, and enter the next transceiving state when the count length value is equal to the early skip value. And the early jump value is smaller than the total value of stop segments counted by the slave in the message stop segment.
For example, when the master 100 transmits the first data packet to the slave 200, the slave 200 can end the reception of the first data packet in advance before the transmission of the first data packet is completed, and then enter the next transmission/reception state. On the one hand, the early jump interrupt does not affect the reception of the first data message, and the part of the first data message located before the message stop section is completely transmitted to the slave 200; on the other hand, when the serial ports of the master machine 100 and the slave machine 200 always have errors or delay rising due to interference or short circuit, the second data message located after the first data message may arrive in advance relative to the slave machine 200, so that the slave machine 200 stops receiving the message stop segment in advance, and can conveniently and quickly respond to the next data message or other receiving and transmitting states, so that the influence of errors on the clock on communication is reduced as much as possible, and the errors are not caused to continuously exist, even continuously increase with the progress of the communication.
The master 100 and the slave 200 may be particularly applied to the industrial communication field. Preferably, the host 100 may be configured as at least one of an MCU (Microcontroller Unit, micro control unit), an FPGA (Field Programmable GATE ARRAY ), or an industrial computer, and the slave 200 may be configured as at least one of various types of ASIC (Application SPECIFIC INTEGRATED Circuit) chips, MCUs, FPGAs, or industrial computers.
In one embodiment, a low level signal may be used as an active data signal between the master 100 and the slave 200, and in particular, a low level signal may be used as an active bit. Based on this, a pull-up circuit may be included between the master 100 and the slave 200, thereby keeping the serial port weakly pulled up and kept at a high potential all the time when the slave 200 does not receive a signal from the master 100. Preferably, the pull-up circuit may include a resistor having one end connected between the master 100 and the slave 200 and the other end connected to the power supply level VCC.
In one embodiment, the communication bus used to connect the master 100 and the slave 200 may be a LIN bus. Thus, the master 100 may include a master transmitting end TX0 and a master receiving end RX0, and the slave 200 may include a slave transmitting end TX1 and a slave receiving end RX1. The master transmitting terminal TX0 is connected to the slave receiving terminal RX1, and the master receiving terminal RX0 is connected to the slave transmitting terminal TX 1. The pull-up circuit preferably comprises two paths, wherein the first path comprises a first pull-up resistor, one end of the first path is connected with a power supply level VCC, and the other end of the first path is connected between a host sending end TX0 and a slave receiving end RX 1; the second path includes a second pull-up resistor, one end of which is connected to the power supply level VCC, and the other end of which is connected between the master receiving end RX0 and the slave transmitting end TX 1.
The slaves 200 may be arranged with only one behind the master 100 as shown in fig. 1. Of course, as shown in fig. 2, a plurality of slaves 200 may be arranged on the side of the master 100. Based on this, the slave 200 may be interpreted as including the first slave 21, the second slave 22, and the nth slave 2n. Wherein the slaves may be arranged in a parallel architecture. The first slave receiving end RX11 of the first slave 21, the second slave receiving end RX12 of the second slave 22 and the nth slave receiving end RX1n of the nth slave 2n are connected to each other to form a first node, and the first node is further connected to the host transmitting end TX0; the first slave transmitter TX11 of the first slave 21, the second slave transmitter TX12 of the second slave 22 and the nth slave transmitter TX1n of the nth slave 2n are connected to each other to form a second node, which is further connected to the master receiver RX0.
The pull-up circuit may be disposed at the first node, the second node, etc., and relatively close to one side of the host 100, so that a plurality of slaves share a set of pull-up circuit, which saves cost and ensures consistency between the slaves.
An embodiment of the present invention further provides a data communication method as shown in fig. 3, where a program or an instruction corresponding to the method may be loaded in the data communication system to achieve a technical effect of data communication. The method specifically comprises the following steps.
S1, the control host transmits a data message to the slave.
The process of sending the data message by the control host can be understood as that the host responds to the output signals of external control equipment such as the central control computer and the like and correspondingly sends the data message; it is also understood that the host forms control of itself according to the stored program, thereby transmitting the data message. It will be appreciated that the "control slaves" provided below may have two similar definitions.
In order to realize communication between the master and the slave, the slave can receive the data message according to a preset clock in the process of sending the data message. Based on this, S1 may be expressed as "control slave receives data message from host", and of course, these two expressions may be executed as two steps approximately simultaneously, or may be set in different technical schemes independently of each other.
The data packets may be interpreted as communication packets, command packets, data packets or message frames, etc. The data message at least comprises a message stopping section in S3, and can also comprise a synchronous interval section, a synchronous section, a communication main body section and the like. Preferably, the communication body section includes a command section, a data section, and a check section, each containing a plurality of command bytes, data bytes, and check bytes. The sync interval segment may also be referred to as a sync interval field and the sync segment may also be referred to as a sync field.
The different segments in the data message may be in the form of high and low levels, so that the definition of the segments is only used as a reference, and in other embodiments, the segments may also be in the form of waveforms formed by high levels, low levels, or high and low levels. For example, the message stop segment may be a continuous high level signal, the synchronization interval segment may be a continuous low level signal, and the synchronization segment may be an alternating high and low level signal.
And S3, when the slave starts to receive a message stop section in the data message, controlling the slave to start counting, and when the counting length value is equal to the early jump value, controlling the slave to enter a next receiving and transmitting state.
A message stop segment may be defined as a segment of a message indicating that the data message is about to end, and is typically disposed at the rear of the data message. The mode of judging whether the slave starts to receive the message stop segment or not or judging whether the slave starts to receive the message stop segment or not by detecting the level change of the data signal can be realized. In embodiments where the low level is an active signal, this may be achieved by detecting whether the received data message triggers a rising edge after a certain period, or whether a continuous high level input is maintained.
As shown in fig. 4 and fig. 5, the host transmits a data message through the host transmitting terminal TX0, and the slave receives a data message through the slave transmitting terminal RX 1. When the host sends to the back of the data message and a rising edge occurs after a certain message segment (e.g., check segment 35), it is determined that the slave starts to receive the message stop segment 301 in the data message, at which point the slave starts counting.
The count length value generated by the slave count may be used to represent the length of the current segment or the duration presented as a transmit-receive level signal. In one embodiment, the unit of the count length value is preferably a bit. For example, the stop segment total value T0 may represent the length of the stop segment 301. The slave message stop segment 501 is correspondingly generated on the slave receiving end RX1, and the slave message stop segment 501 may have a length equal to the total value T0 of the stop segment when other effects are not considered. The total value T0 of the stop segment may be any one of 0.5bit, 1bit, 1.5bit and 2bit, and preferably varies with the data message.
The counting length value and the change counting value defined in the invention should be interpreted differently, the change counting value described in the following description refers to the high-low level condition of the message segment in the range of the counting length value, and the message segment can be considered to represent the information carried by the data message itself, but not the message segment occupies the length of the data message.
The advance skip value T4 may be any value less than the total value T0 of the stop segment, so that the slave machine skips the receiving process of the current data message in advance and enters the next transceiving state and the preparation state thereof. The advance jump-out value T4 may be a preset fixed value, or may be a value that is calculated according to other message segments and/or delay conditions in the data message and changes with the data message.
The master transmitting terminal TX0 transmits the message stopping segment 301 to the slave, and correspondingly forms the slave message stopping segment 501 on the slave receiving terminal RX 1. Preferably, the slave determines to start receiving the message stop segment 301 and starts counting when receiving the first rising edge of the slave message stop segment 501, and enters the next transmission/reception state when the length of the slave message stop segment 501 reaches the advance skip value T4.
In the first example based on the above embodiment, as shown in fig. 6, the data communication method may further include the following steps.
S1, the control host transmits a data message to the slave.
S2, determining an early jump value according to the total value of the stop segment and the receiving and transmitting delay value.
And S3, when the slave starts to receive a message stop section in the data message, controlling the slave to start counting, and when the counting length value is equal to the early jump value, controlling the slave to enter a next receiving and transmitting state.
The receiving and transmitting delay value is a count length value of delay between the master machine and the slave machine. As shown in fig. 4 and fig. 5, the advanced trip value can be dynamically regulated according to the condition of the transceiving delay value, so that the action of the advanced trip interruption of the slave is always enough to offset the delay of the transceiving signal between the host and the slave, and the slave can receive continuous and high-speed data messages transmitted from the host.
Taking the case shown in fig. 4 as an example, when the master transmitting end TX0 transmits the rising edge of the message stopping segment 301 to the slave receiving end RX1, the slave receiving end RX1 correspondingly generates the rising edge of the slave message stopping segment 501 after the duration of the transceiving delay value due to the transceiving delay. If the early skip value T4 is configured to be equal to the total stop segment value T0, when the master completes sending the message stop segment 301, the slave is still in a state of generating the slave message stop segment 501 on the slave receiving end RX1, and does not skip the receiving interruption state of the current data message. When the data packets are continuously sent, the master TX0 sends the header of the next data packet (e.g. the next synchronization interval 31') to the slave immediately at the falling edge of the packet stop segment 301, and the slave continues to delay the reception of the header of the next data packet, resulting in worsening of the transmission delay.
Taking the case shown in fig. 5 as an example, the host triggers the host receiving end RX0 immediately after the transmission of the message stopping segment 301 is completed, and the slave is still in the receiving state of the message stopping segment 301 and cannot trigger the slave transmitting end TX1 to transmit the return message, so that the synchronization and instantaneity of the communication between the host and the slave are further deteriorated.
After implementing the first embodiment, the slave unit enters the next transmitting and receiving state (the message transmitting and receiving state may be the message transmitting state may be the message receiving state may be the message returning state may be the message receiving state is the message returning state may be the message returning state is the message receiving state) when the count length value is equal to the advance skip value, and the advance skip value T4 is adaptively generated according to the total stop segment value T0 and the transmitting and receiving delay value, so that the advance can at least partially offset the influence of the delay amount, so that the slave unit can almost synchronously respond when the state of the host unit changes, and the problems of packet loss, dislocation and high delay during high-speed continuous transmission are improved.
The stop segment total value and the transmit-receive delay value may be configured as fixed values, one of them may be configured as a fixed value, and the other one may be configured as adaptive adjustment according to the actual situation of the data packet, and of course, both may also be configured as adaptive adjustment. The invention preferably configures the receiving and transmitting delay value to adopt the second scheme, configures the total value of the stop segment to change along with the data message, and configures the receiving and transmitting delay value to be preset in the system. On the basis of the first embodiment described above, the present invention provides a first specific example of a data communication method, as shown in fig. 7, including the following steps.
S1, the control host transmits a data message to the slave.
And S20, when the slave starts to receive the synchronous stop segment in the synchronous segments, controlling the slave to start counting, and stopping when the slave receives the falling edge of the synchronous stop segment, so as to obtain the total value of the stop segments.
S2, determining an early jump value according to the total value of the stop segment and the receiving and transmitting delay value.
And S3, when the slave starts to receive a message stop section in the data message, controlling the slave to start counting, and when the counting length value is equal to the early jump value, controlling the slave to enter a next receiving and transmitting state.
Wherein, the data message comprises a synchronization section positioned before the message stop section. As shown in fig. 4 and 5, in this first specific example, the total stop segment value T0 can be determined based on the synchronous stop segment 302 in the synchronous segment 32, so that the advanced skip value T4 is calculated by using the determined total stop segment value T0, which improves the adaptability of the slave to multiple types of data messages on the host side.
The sync segment 32, which may also be referred to as a sync field, may be interpreted as carrying clock information required to transmit and receive the current data message. The clock information may be a baud rate of a current data packet. The clock information can have a high-low level form, and the slave can count the high-low level and determine the baud rate corresponding to the current data message according to the change count value.
The sync stop segment 302 is preferably located at the end of the sync segment 32, indicating that the sync segment 32 is about to end. In the present invention, the sync stop segment 302 may be considered or configured to have the same length as the message stop segment 301 for the slave to predict the message stop segment 301 and adaptively adjust the early skip value T4 accordingly.
The falling edge is formed on the basis of the low level as an effective level signal, and similarly, the description of other parts in the invention is based on the great premise. However, in the scenario of using a high level as an active level signal, the invention can adapt to the situation that only the rising edge is replaced by the falling edge, the falling edge is replaced by the rising edge, and the descriptions of the high level and the low level are interchanged. In other words, the technical scheme generated by the high-low level exchange and the rising and falling edge exchange still falls within the protection scope of the invention.
The sync-stop segment 302 assumes a high level in the present invention, based on which the "slave starts receiving the sync-stop segment" can be interpreted as "slave receives a rising edge of the sync-stop segment". The synchronization stop segment 302 transmitted from the master transmission terminal TX0 correspondingly generates a slave synchronization stop segment 502 (included in the slave synchronization segment 52 corresponding to the synchronization segment 32) on the slave reception terminal RX1 side. Preferably, the sync stop segment 302, the slave sync stop segment 502, the message stop segment 301, and the slave message stop segment 501 have the same count length value, and further, the count length value may be equal to the stop segment total value T0.
Fig. 4 shows an embodiment in which no slave is required to send a return message to the master, and fig. 5 shows an embodiment in which a slave is required to send a return message. For fig. 4, considering that clock information of data transmission and reception by the host, especially, the baud rate may deviate, so that the next data packet arrives in advance, for the technical solution shown in fig. 4, the advance is preferably increased, so as to ensure that the data packet can still be continuously transmitted and received under the condition of hastening.
As further shown in fig. 7, in the above-described first specific example of the present invention, step S2 preferably includes the following steps.
S21, judging whether the command configuration of the slave comprises a data return instruction.
If so, the process goes to S22A, and the advance jump-out value is determined according to the difference between the total value of the stop segment and the transmission/reception delay value.
If not, the process goes to S22B, and the advanced jump-out value is determined according to the product of the total value of the stop segment and the preset scaling index and the difference between the total value of the stop segment and the transmission and reception delay value.
Therefore, for the scene that the next data message receiving program is directly entered without carrying out return message output, a shorter advance jump value is reserved, the advance of jump interruption is increased, and the next data message is ensured not to be affected by delay.
On one hand, for the scene requiring the output of the return message, the baud rate calculation and verification steps can be set in the process, so that the slave is adapted to the baud rate of the host to act, and excessive jump-out interruption is not needed in advance, so that the situation of error jump-out interruption is avoided; on the other hand, corresponding to fig. 5, the next receiving and sending state entered by the slave after the early jump-out can be a data return state, and the slave enjoys initiative, so that excessive early jump-out interruption is not needed, and the problems of incomplete content, incomplete verification and the like of the return message are avoided.
The command configuration can be fixed on the slave side or carried in a data message. In other words, whether the slave is required to send the return message may be preset at the slave side, or may be adjusted at any time according to a command at the master side.
The term "difference according to … …" means that it is not necessary to configure the early jump value directly equal to the calculated difference value, but it is also possible to determine the early jump value based on this difference value in combination with other influencing factors. Of course, the present invention will take the former as an example, and other technical solutions are adaptive adjustments that can be made by those skilled in the art with reference to the actual operation scenario.
Based on this, for the scenario shown in fig. 4 where there is no data return request, at least the following expression may be satisfied between the stop segment total value T0, the transmission/reception delay value Tdelay (may be T1 in fig. 4), and the advance skip value T4:
T4=n*T0-Tdelay。
For the scenario shown in fig. 5 with data return requirements, at least the following equation may be satisfied between the stop segment total value T0, the scaling index n, the transmit-receive delay value Tdelay (may be T1 and/or T2 in fig. 5), and the advance skip value T4:
T4=T0-Tdelay。
Preferably, the scale factor n has a value ranging between 0 and 1. Specifically, the scaling index n ε (0, 1). In one embodiment, the scaling index
It should be noted that the step S20 and the step S21, the step S22A and the step S22B provided above are not necessarily provided in the same technical solution. Step S1, step S20, step S2 and step S3, the technical scheme of adaptively adjusting the total value of the stop segment and determining the early jump value by combining the total value of the stop segment and the receiving and transmitting delay value is provided; step S1, step S21, step S22A, step S22B and step S3 provide a technical solution of giving different weights (i.e. scaling index n) to the total value of the stop segment in its relation to the transceiving delay value and the early jump value, according to whether there is a data return requirement. The two can be combined with each other or independent of each other.
Based on the technical route provided in step S21 to step S22B, the present invention also provides a second specific example based on the above-described first embodiment, as shown in fig. 8. This second specific example includes the following steps.
S1, the control host transmits a data message to the slave.
S21, judging whether the command configuration of the slave comprises a data return instruction.
If so, the process goes to S22A, and the advance jump-out value is determined according to the difference between the total value of the stop segment and the transmission/reception delay value.
If not, the process goes to S22B, and the advanced jump-out value is determined according to the product of the total value of the stop segment and the preset scaling index and the difference between the total value of the stop segment and the transmission and reception delay value.
And S3, when the slave starts to receive a message stop section in the data message, controlling the slave to start counting, and when the counting length value is equal to the early jump value, controlling the slave to enter a next receiving and transmitting state. Step S3, after step S22A, specifically includes the steps of:
And S31A, when the count length value is equal to the early jump value, controlling the slave to enter a data return state, and sending a return message to the host.
And S32A, when the slave starts to send a return stop segment in the return message, controlling the slave to start counting, and when the count length value is equal to the return jump-out value, controlling the slave to enter a message receiving and transmitting state.
The next receiving and transmitting state comprises a data return state and a message receiving and transmitting state, and the return jump-out value is smaller than a return stop segment value counted by the slave in the return stop segment. Therefore, the slave is controlled to finish receiving in advance in the stage of sending the data message to the slave by the host, and the slave is controlled to finish sending in advance in the stage of sending the return message to the host by the slave, so that the return message sending stage after the data message receiving stage can be ensured to respond accurately relative to the slave, the next data message receiving stage after the return message sending stage can be ensured to respond accurately, and the fault tolerance rate of the system and the error adaptability to high-speed continuous data transmission are greatly improved.
As shown in fig. 5, after the slave starts to send the message stop segment 301, the slave starts to form the slave message stop segment 501 after a delay with a length of one type of transmit-receive delay value T1, and when the slave starts to form the slave message stop segment 501, the slave considers to start to receive the message stop segment 301, starts to enter the data return state after jumping out of the length of T4 in advance, generates a falling edge at the slave transmitting end TX1, and transmits a return message (for example, including a return data segment 61 and a return check segment 62). After the slave transmitter TX1 generates the falling edge, the master receiver RX0 starts to form a master return message (e.g., including a master return data segment 41 and a master return check segment 42) corresponding to the return message after a delay of another transmit-receive delay value T2.
When the slave forms a rising edge from the return message, it can be considered to start sending the return stop segment 60 in the return message, at which point the slave starts counting. The host receiving end RX0 also forms a rising edge of the host return stop segment 40 corresponding to the return stop segment 60 after a delay of the length of the further delayed transceiving value T2. When the slave count length value is equal to the return trip value T3, the slave is controlled to end the current data return state and enter the messaging state to receive the next data message (for example, the next synchronization interval 31 'is included on the master side and the next slave synchronization interval 51') is included on the slave side, and at this time, the master side is still in the receiving stage of the return stop segment 60 and the forming stage of the master return stop segment 40.
Preferably, in step S32A, the method may further specifically include: and when the counting length value is equal to the return trip-out value, compensating the rest part in the return stop section to the host computer through a pull-up circuit, and simultaneously controlling the slave computer to enter a message receiving and transmitting state. In this way, even if the slave stops sending the return stop segment 60 to the host in advance, the host can complete the process of forming the host return stop segment 40 based on the pull-up circuit, maintain the integrity of the whole data message, and leave a time margin for the slave to jump out in advance and enter the ready state. It will be appreciated that in the scenario where a high level is used as the active level signal, the remainder of the return stop segment may also be compensated for by the pull-down circuit to the host.
As further shown in fig. 8, in parallel with step S31A and step S32A, step S3 may specifically include the steps of, after step S22B:
And S30B, controlling the slave to enter a message receiving and transmitting state when the count length value is equal to the advance jump-out value.
Wherein the next receiving and transmitting state comprises a message receiving and transmitting state. Therefore, the slave can quickly enter the message receiving and transmitting state of the next data message based on the early jump out, and the continuous data transmission can be ensured.
As shown in fig. 4, after the slave starts the transmission of the message stop segment 301, the slave starts forming the slave message stop segment 501 with a delay of a length of the transmission/reception delay value T1, and the slave considers that the slave starts receiving the message stop segment 301 when starting forming the slave message stop segment 501, and starts entering the message transmission/reception state after the slave starts jumping out of the length of T4 in advance, so as to receive the next data message (for example, the slave includes the next synchronization interval segment 31 'on the master side and the next slave synchronization interval segment 51') on the slave side).
Preferably, the transceiving delay value defined above may include at least one of a master transmission delay value, a slave reception delay value, a master reception delay value, a slave transmission delay value, and a connection line delay value. Specifically, the above-mentioned transmit-receive delay value T1 may refer to a host transmit delay value (which may be a delay caused by an internal circuit, the same applies hereinafter) or a sum thereof with a connection line delay value, and/or refer to a slave receive delay value or a sum thereof with a connection line delay value; the other transmit/receive delay value T2 may refer to a master receive delay value or a sum thereof and a link delay value, and/or refer to a slave transmit delay value or a sum thereof and a link delay value. The specific definition is performed by referring to the transceiving states of the master machine and the slave machine where the transceiving delay value is located.
Preferably, defining the master transmission delay value and the slave reception delay value as T1, and defining the master reception delay value and the slave transmission delay value as T2, the advance skip value T4 at least satisfies the following conditions in the scenario of no data return requirement set forth in fig. 4:
T4=n*T0-T1-T2。
In the scenario with data return requirement set forth in fig. 5, at least:
T4=T0-T1-T2。
In both the application scenarios provided in fig. 4 and fig. 5, it is necessary to compensate for the slave message stop segment 501, which is difficult to be completely received due to the early jump-out, according to the message stop segment 301. Based on this, any of the above steps S3 and its derivative steps may include the steps of: and when the counting length value is equal to the early jump value, compensating the rest part in the message stopping section to the slave machine through a pull-up circuit, and simultaneously controlling the slave machine to enter a next receiving and transmitting state. The "compensating the slave for the remainder of the message stop segment" may be interpreted as complementing the missing portion of the slave message stop segment 501 relative to the message stop segment 301.
In one embodiment, the data message may also include a synchronization segment, and the synchronization segment is used to calculate the baud rate corresponding to the current host and the current data message, thereby utilizing such baud rate to assist in the subsequent communication process. Based on this idea, the present invention provides a second embodiment as shown in fig. 9. This second embodiment includes the following steps.
S1, the control host transmits a data message to the slave.
And S41, when the slave starts to receive the synchronous segment, controlling the slave to count at least part of level changes in the synchronous segment, and calculating a temporary baud rate value of the data message according to the change count value.
And S3, when the slave starts to receive a message stop section in the data message, controlling the slave to start counting, and when the counting length value is equal to the early jump value, controlling the slave to enter a next receiving and transmitting state.
S42, controlling the slave to complete at least part of the communication process with the master according to the temporary baud rate value.
As shown in connection with fig. 4 and 5, the "at least part of the synchronization section" may be further interpreted as other parts of the synchronization section 32 than the synchronization stop section 302, or may be the entire synchronization section 32. The slave can calculate the temporary baud rate of the data message according to the level change condition of the slave synchronization section 52 or other parts except the slave synchronization stop section 502 in the slave synchronization section 52.
In one aspect, the slave may complete its communication with the master at a predetermined baud rate prior to calculating the temporary baud rate. On the other hand, the temporary baud rate can be used for comparing with the counting length value of the synchronous stop segment, so that a stop segment total value T0 is generated, the effect of participating in at least part of the communication process between the slave and the host is achieved, and the communication efficiency and accuracy are improved.
The temporary baud rate may be temporarily stored in a first register of the slave.
Preferably, the data message may further comprise a communication body section and a check section 35 arranged after the synchronization section 32, in particular after the synchronization stop section 302. Based on the above-described second embodiment, the present invention provides a specific example as shown in fig. 10, including the following steps. Step S421 includes step S42.
S1, the control host transmits a data message to the slave.
And S41, when the slave starts to receive the synchronous segment, controlling the slave to count at least part of level changes in the synchronous segment, and calculating a temporary baud rate value of the data message according to the change count value.
And S3, when the slave starts to receive a message stop section in the data message, controlling the slave to start counting, and when the counting length value is equal to the early jump value, controlling the slave to enter a next receiving and transmitting state. The step S3 specifically comprises the steps of:
And S33, controlling the slave to enter a matching check state when the count length value is equal to the early jump value.
S51, judging whether at least part of the communication main body section is matched with the check section.
If yes, step S421 is skipped to store the temporary baud rate as a fixed baud rate, and the slave is controlled to complete at least part of the communication process with the master at the fixed baud rate.
In one aspect, step S421 is shown only as part of step S42, and when step S33 and step S51 are not present, step S42 may further specifically include: and controlling the slave to receive the communication main body section, the check section and/or the message stopping section and/or send the return data section and/or the return check section according to the temporary baud rate. In this way, at least part of the slave-to-master communication process is also completed.
The above specific examples provide a technical solution that the temporary baud rate is selectively converted into a fixed baud rate after being checked, and is applied to the transceiving process of other data messages except the current data message. In combination with the technical scheme that the temporary baud rate is used for receiving the communication main section and the check section, the communication main section and the check section received under the temporary baud rate can be subjected to matching check, so that whether the temporary baud rate is accurate or not is judged, and whether the temporary baud rate is applied to the receiving and transmitting process of at least the next data message or not is determined.
When the currently received data message is the first data message in the communication, if the verification is passed, the temporary baud rate can be replaced by the baud rate preset in the slave machine, so that the fixed baud rate suitable for the communication process can be generated and applied. Therefore, when the communication process changes and the baud rate of the data message changes, the self-adaptive adjustment can be realized, and the problems that the prior art cannot adapt to high-speed continuous data transmission and has large error are solved from the aspects of baud rate and delay.
If the temporary baud rate corresponding to the first data message fails to be checked and matched, the second data message can be continuously received by utilizing the preset baud rate in the slave machine, and the steps are repeatedly executed until the temporary baud rate which is successfully checked and matched is calculated to be used as a new fixed baud rate. In this way, optimal communication quality can be obtained with minimal cost loss by the round robin algorithm.
In one aspect, the communication body section and the check section may likewise be stored in registers of the slave, but it is understood that in order to prevent communication disturbances, the communication body section and the check section are preferably stored in a second register distinct from the first register. On the other hand, the matching check procedure between the communication body segment and the check segment may be configured to implement a cyclic redundancy check (CRC, cyclic Redundancy Check) or parity check algorithm or the like.
Preferably, as shown in connection with fig. 4 and 5, the communication body section may specifically include a command section 33 and a data section 32. On the slave side, a slave command section 53, a slave data section 54, and a slave check section 55 may be generated corresponding to the command section 33, the data section 34, and the check section 35, respectively. Wherein the command field 33 is used to perform command configuration on the slave and may preferably be used to configure whether the slave needs to output a return message.
The command section 33 may specifically include at least one of a destination chip code (or ID, identity document, identification number), a message type, a data return instruction, and message length information. Preferably, command section 33 includes at least the target chip code. Based on this, step S51 may specifically include: and controlling the slave to enter a matching verification state, and judging whether at least the target chip code and the data segment are matched with the verification segment or not. Specifically, it may be determined whether the target chip code and the check segment match, and whether the data segment and the check segment match.
In addition, in the embodiment where the command section 33 includes message length information, the steps between the step S1 and the step S3 may further include: and receiving the data segment and the check segment in the data message according to the message length information.
The present invention provides a third example based on the above embodiment, as shown in fig. 11, and the third example specifically includes the following steps.
S1, the control host transmits a data message to the slave.
And S6, when the slave receives that the counting length value of the synchronous interval section is equal to the effective interval value, controlling the slave to enter the receiving state of other data sections in the data message.
And S3, when the slave starts to receive a message stop section in the data message, controlling the slave to start counting, and when the counting length value is equal to the early jump value, controlling the slave to enter a next receiving and transmitting state.
The data message comprises a synchronous interval section arranged at the head part of the data message. Therefore, the synchronous interval section is arranged at the head of the data message, different data messages which are continuously transmitted are distinguished according to the counting length value received by the slave machine, and the continuous errors caused by delay can be resisted by matching with the step S1 and the step S3, so that the slave machine can conveniently and quickly adjust to enter a new data message receiving state when realizing that the receiving errors occur.
As shown in connection with fig. 4 and 5, the synchronization interval 31 may have a form of a continuous low level, and a slave synchronization interval 51 may be formed at the slave side. The triggering method for counting the synchronization interval 31 may apply various schemes, such as triggering according to a level change, or triggering according to a duration or a distribution length of a certain level (e.g., high level or low level).
In a specific example provided by the present invention and based on the above third embodiment, as shown in fig. 4, 5 and 12, the data packet may include a synchronization segment 32 disposed after the synchronization interval segment 31. Based on this, the specific example may include the following steps.
S1, the control host transmits a data message to the slave.
And S6, when the slave receives that the counting length value of the synchronous interval section is equal to the effective interval value, controlling the slave to enter the receiving state of other data sections in the data message. The step S6 may specifically include:
And S61, when the receiving line of the slave machine detects a falling edge from idle, controlling the slave machine to start receiving the synchronous interval segment, controlling the slave machine to start counting, and when the counting length value of the synchronous interval segment is equal to the effective interval value, controlling the slave machine to enter a synchronous segment receiving state.
And S62, when the slave receives the first level with the duration being the effective interval value, controlling the slave to enter a synchronous segment receiving state.
And S3, when the slave starts to receive a message stop section in the data message, controlling the slave to start counting, and when the counting length value is equal to the early jump value, controlling the slave to enter a next receiving and transmitting state.
In step S61 and step S62, one of them may be selected as the step of triggering the counting of the synchronization interval 31 in step S6, or step S61 and step S62 may be set simultaneously and in parallel, and if one of them is described, the counting of the synchronization interval length is triggered and it is determined whether it is larger than the effective interval value.
For step S62, when the method is applied to the one-to-many parallel communication scenario shown in fig. 2, if one slave fails, the master can force to send the synchronization interval segment, so that all slaves stop receiving and transmitting, and directly enter the receiving state of the synchronization segment, thereby ensuring the absolute control authority of the master on communication.
The present invention provides, based on the above embodiment, a fourth embodiment as shown in fig. 13, where the matching check state, the data return state, the message transceiving state, etc. defined in this embodiment may be implemented alternatively to the explanation thereof. This fourth embodiment specifically includes the following steps.
S1, the control host transmits a data message to the slave.
And S3, when the slave starts to receive a message stop section in the data message, controlling the slave to start counting, and when the counting length value is equal to the early jump value, controlling the slave to enter a next receiving and transmitting state. The step S3 specifically includes the steps of:
and S3A, when the count length value is equal to the early jump value, controlling the slave to sequentially enter a matching check state, a data return state and a message receiving and transmitting state. Wherein the early jump value is equal to a difference between the stop segment total value and a transmit-receive delay value.
And S3B, when the counting length value is equal to the early jump value, controlling the slave to sequentially enter a matching check state and a message receiving and transmitting state. And the early jump value is equal to the product of the total value of the stop section and a preset scaling index, and is the difference between the early jump value and the receiving and transmitting delay value.
Step S3A and step S3B are two parallel steps, and the slave performs the next transmission/reception state process, or performs one of them.
The following will specifically describe the specific procedure of the preferred technical solution of step S3A, step S3B and its backrest with reference to fig. 4 and 5.
The master transmitting terminal TX0 outputs the falling edge of the synchronization interval 31, and outputs the data message with the synchronization interval 31 as the header to the slave receiving terminal RX 1. The slave receiving terminal RX1 receives the above-mentioned falling edge after the delay with the length of the transmit-receive delay value T1 and correspondingly forms the slave synchronization interval section 51, and selectively enters the synchronization section receiving state after judging the count length value of the synchronization interval section 31.
The master transmitting terminal TX0 outputs the rising edge of the sync segment 32 and outputs the high and low level sync segment 32 to the slave receiving terminal RX 1. The slave receiving terminal RX1 receives and forms the slave synchronization segment 52 after the delay, calculates a temporary baud rate according to the change count value of the high and low levels, stores the temporary baud rate in the first register, and receives the synchronization stop segment 302 and forms the slave synchronization stop segment 502 according to the temporary baud rate. The count starts when the rising edge of the synchronization-stop segment 302 is received to form the rising edge of the slave synchronization-stop segment 502, and ends when the falling edge of the synchronization-stop segment 302 is received to form the falling edge of the slave synchronization-stop segment 502, and the count length value is taken as the stop segment total value T0.
The slave reception terminal RX1 continues to receive the command section 33, the data section 34 and the check section 35 from the master transmission terminal TX0 at the temporary baud rate, forming a slave command section 53, a slave data section 54 and a slave check section 55. Firstly, receiving a data section 34 and a check section 35 according to message length information in a command section 33, and storing the three in a second register; secondly, when the slave machine finishes transmitting the check segment 35 and generates the rising edge of the slave machine check segment 55, the slave machine considers that the message receiving stop segment 301 starts to be counted, and enters a matching check state when the count length value is equal to the advance jump-out value T4; thirdly, the slave matches the target chip code in the slave command section 53 with the bytes in the slave check section 55, matches the bytes in the slave data section 54 and the slave check section 55, and if the matching is successful, determines the temporary baud rate as a fixed baud rate; fourth, the slave determines whether the data return instruction is included in the slave command section 53, and if so, enters "case one" corresponding to fig. 4 and step S3B, and if not, enters "case two" corresponding to fig. 5 and step S3A.
It will be appreciated that the first, second, third and fourth described above are not necessarily limited to the order of processing. In this process, the master receiver RX0 and the slave transmitter TX1 are continuously high. And may specifically be pulled high by a pull-up circuit.
[ Condition one ]
The slave jumps (jumps out of interrupt) in the message stop segment receiving state with the duration of advance jump-out value T4 (t4=n×t0-T1-T2, parameter definition refers to the preamble), and when the master has not completed the transmission of the message stop segment 301, the slave message stop segment 501 is completed by means of the pull-up circuit and at the same time enters the message transmitting/receiving state, prepares to receive the next synchronization interval segment 31 'in the next data message, and generates the corresponding next slave synchronization interval segment 51'. In this process, the master receiver RX0 and the slave transmitter TX1 are always high. And may specifically be pulled high by a pull-up circuit.
[ Condition two ]
The slave jumps (jumps out of interrupt) in the message stop segment receiving state with the duration of advance jump-out value T4 (t4=t0-T1-T2, parameter definition refers to the foregoing), and when the host has not completed the transmission of the message stop segment 301, the slave message stop segment 501 is completed by means of the pull-up resistor, and at the same time, a falling edge is formed at the slave transmitting end TX1, triggering the slave to enter the data return state. The slave transmitting terminal TX1 transmits the return data segment 61 and the return check segment 62 to the host, and the host forms a falling edge and the corresponding host return data segment 41 and host return check segment 42 at the host receiving terminal RX0 after being delayed by the length of another transmit-receive delay value T2.
When the slave machine finishes transmitting the return check segment 62 and generates the rising edge of the master machine return check segment 42, it is considered that the transmission of the return stop segment 60 is started and the counting is started, and the master machine receiving terminal RX0 forms the master machine return stop segment 40 after a delay having a length of another transmission/reception delay T2. When the count length value is equal to the return trip value T3, the message transmitting/receiving state is entered, the next synchronization interval 31 'in the next data message is ready to be received, and the corresponding next slave synchronization interval 51' is generated. The host receive RX0 complements the host return stop segment 40 by means of a pull-up circuit.
It is to be understood that, between the foregoing embodiments, examples, specific examples, and specific steps in different technical solutions provided by the present invention, on the premise that no functional effect limitation and no special effect description are provided, the combination or the sequential adjustment may be performed, and the new technical solutions thus produced are all within the protection scope of the present invention.
In summary, according to the data communication method provided by the invention, the total time for receiving a single data message can be shortened by jumping out to the next stage of the data message receiving and transmitting process in advance in the final stage of the last data message receiving, and the message receiving capability of a slave is improved; when receiving delay is caused by interference, the influence on the next data message receiving process is reduced by virtue of jumping out in advance, the self-recovery capacity and anti-interference capacity of data communication are improved, and the probability of communication failure is reduced; in the scene of continuous transmission of the data messages, the influence of delay caused by self delay and interference on other data messages can be reduced, and in the continuous receiving process, the error caused by delay is gradually reduced, so that most of continuous data messages are ensured to be available.
It should be understood that although the present disclosure describes embodiments, not every embodiment is provided with a separate embodiment, and that this description is for clarity only, and that the skilled artisan should recognize that the embodiments may be combined as appropriate to form other embodiments that will be understood by those skilled in the art.
The above list of detailed descriptions is only specific to practical embodiments of the present invention, and they are not intended to limit the scope of the present invention, and all equivalent embodiments or modifications that do not depart from the spirit of the present invention should be included in the scope of the present invention.
Claims (18)
1. A method of data communication, comprising:
The control host sends a data message to the slave;
when the slave starts to receive a message stop section in the data message, controlling the slave to start counting, and when the counting length value is equal to an early jump value, controlling the slave to enter a next receiving and transmitting state;
And the early jump value is smaller than the total value of stop segments counted by the slave in the message stop segment.
2. The data communication method according to claim 1, characterized in that the method further comprises:
determining the early jump value according to the stop segment total value and the receiving-transmitting delay value;
The receiving and transmitting delay value is a count length value of delay between the master machine and the slave machine.
3. The data communication method according to claim 2, wherein the data message includes a sync segment located before the message stop segment; the method further comprises the steps of:
and when the slave starts to receive the synchronous stop segment in the synchronous segments, controlling the slave to start counting, stopping when the slave receives the falling edge of the synchronous stop segment, and obtaining the total value of the stop segments.
4. The data communication method according to claim 2, characterized in that the method comprises in particular:
judging whether the command configuration of the slave comprises a data return instruction or not;
if yes, determining the advance jump value according to the difference between the total value of the stop section and the receiving and transmitting delay value;
if not, determining the early jump value according to the product of the total value of the stop segment and a preset scaling index and the difference between the total value of the stop segment and the receiving and transmitting delay value.
5. The data communication method of claim 4, wherein the scale factor has a value in a range between 0 and 1.
6. The method of claim 4, wherein the next transceiving state comprises a data return state and a message transceiving state; after the "if yes", determining the early jump value "according to the difference between the total stop segment value and the transmit-receive delay value, the method specifically includes:
When the count length value is equal to the early jump value, controlling the slave to enter a data return state, and sending a return message to the host;
When the slave starts to send the return stop segment in the return message, controlling the slave to start counting, and when the counting length value is equal to the return jump-out value, controlling the slave to enter a message receiving and transmitting state;
And the return jump-out value is smaller than a return stop segment value counted by the slave machine in the return stop segment.
7. The data communication method according to claim 6, characterized in that the method comprises in particular:
and when the counting length value is equal to the return trip-out value, compensating the rest part in the return stop section to the host computer through a pull-up circuit, and simultaneously controlling the slave computer to enter a message receiving and transmitting state.
8. The method of claim 4, wherein the next transceiving state comprises a messaging state; after the step of determining the early jump value according to the product of the total stop segment value and a preset scaling index and the difference between the total stop segment value and the receiving/transmitting delay value, if not, the method specifically comprises the following steps:
and when the counting length value is equal to the early jump value, controlling the slave to enter a message receiving and transmitting state.
9. The data communication method of claim 2, wherein the transmit-receive delay value comprises at least one of a master transmit delay value, a slave receive delay value, a master receive delay value, a slave transmit delay value, and a connection line delay value.
10. The data communication method according to claim 1, characterized in that the method comprises in particular:
and when the counting length value is equal to the early jump value, compensating the rest part in the message stopping section to the slave machine through a pull-up circuit, and simultaneously controlling the slave machine to enter a next receiving and transmitting state.
11. The data communication method according to claim 1, wherein the data message includes a sync segment; the method further comprises the steps of:
when the slave starts to receive the synchronous segment, controlling the slave to count at least part of level changes in the synchronous segment, and calculating a temporary baud rate value of the data message according to a change count value;
and controlling the slave to complete at least part of the communication process with the host according to the temporary baud rate value.
12. The data communication method according to claim 11, wherein the data message includes a communication body section and a check section disposed after the synchronization section; the method specifically comprises the following steps:
When the count length value is equal to the early jump value, controlling the slave to enter a matching check state;
judging whether at least part of the communication main body section is matched with the verification section or not;
if yes, the temporary baud rate is stored as a fixed baud rate, and the slave is controlled to complete at least part of the communication process between the slave and the host at the fixed baud rate.
13. The data communication method according to claim 12, wherein the communication body section includes a command section and a data section; the command section is used for executing command configuration on the slave;
The command section comprises at least one of a target chip code, a message type, a data return instruction and message length information; the method specifically comprises the following steps:
and controlling the slave to enter a matching verification state, and judging whether at least the target chip code and the data segment are matched with the verification segment or not.
14. The method of claim 1, wherein the data message includes a synchronization interval provided at a head of the data message; the method specifically comprises the following steps of;
And when the slave receives that the counting length value of the synchronous interval section is equal to the effective interval value, controlling the slave to enter the receiving state of other data sections in the data message.
15. The data communication method according to claim 14, wherein the data message includes a synchronization segment disposed after the synchronization interval segment; the method further comprises the steps of:
When the receiving line of the slave machine detects a falling edge from idle, controlling the slave machine to start receiving the synchronous interval section, controlling the slave machine to start counting, and controlling the slave machine to enter a synchronous section receiving state when the counting length value of the synchronous interval section is equal to the effective interval value; or alternatively
And when the slave receives a first level with the duration being the effective interval value, controlling the slave to enter the synchronous segment receiving state.
16. The data communication method according to claim 1, characterized in that the method comprises in particular:
when the count length value is equal to the advance jump value, controlling the slave to sequentially enter a matching check state, a data return state and a message receiving and transmitting state; wherein the early jump value is equal to the difference between the total value of the stop segment and the receiving-transmitting delay value; or alternatively
When the counting length value is equal to the early jump value, controlling the slave to sequentially enter a matching check state and a message receiving and transmitting state; and the early jump value is equal to the product of the total value of the stop section and a preset scaling index, and is the difference between the early jump value and the receiving and transmitting delay value.
17. A data communication system, comprising:
The host computer is configured to send a data message to the slave computer;
The slave is configured to start counting when the message stop section in the data message starts to be received, and enter the next receiving and transmitting state when the counting length value is equal to the early jump value;
And the early jump value is smaller than the total value of stop segments counted by the slave in the message stop segment.
18. The data communication system of claim 17, wherein the slave is configured with one or more, and wherein a pull-up circuit is included between the master and the slave.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211304821.5A CN117978349A (en) | 2022-10-24 | 2022-10-24 | Data communication method and communication system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211304821.5A CN117978349A (en) | 2022-10-24 | 2022-10-24 | Data communication method and communication system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117978349A true CN117978349A (en) | 2024-05-03 |
Family
ID=90851929
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211304821.5A Pending CN117978349A (en) | 2022-10-24 | 2022-10-24 | Data communication method and communication system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117978349A (en) |
-
2022
- 2022-10-24 CN CN202211304821.5A patent/CN117978349A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7343437B2 (en) | Synchronization method and control system for the time synchronization of slave units and a synchronizable slave unit | |
US10146725B2 (en) | Method and device for checking the correct functioning of a serial data transmission | |
JP6404975B2 (en) | Slave, serial communication system, and communication method of serial communication system | |
US8223804B2 (en) | Synchronized communication system | |
US9331838B2 (en) | Method for synchronizing clocks in nodes of a vehicle network and node designed to perform the method | |
US9262365B2 (en) | Method and device for serial data transmission at a switchable data rate | |
US20130170498A1 (en) | Ethernet for avionics | |
EP4016942A1 (en) | Method and apparatus for determining sending period in deterministic ip | |
US10735219B2 (en) | System and method for packet transmission in a communications network | |
US20170317812A1 (en) | Controller area network synchronization | |
WO2014006446A1 (en) | Ethercat packet forwarding with distributed clocking | |
KR101519719B1 (en) | Message process method of gateway | |
US20160127067A1 (en) | Method for operating a node of a communications network, a node and a communications network | |
EP1665694B1 (en) | Channel bonding of a plurality of multi-gigabit transceivers | |
US20110271130A1 (en) | Circuit configuration having a transceiver circuit for a bus system and nodes for a bus system | |
Maruyama et al. | Spatial-temporal communication redundancy for high performance EtherCAT master | |
CN106302066A (en) | Master-slave-free communication method and device | |
CN117978349A (en) | Data communication method and communication system | |
JP5930767B2 (en) | Electronic device, communication control method | |
US8897289B2 (en) | Node system and supervisory node | |
US10382188B2 (en) | Communication system, communication device, and communication method | |
CN115037571B (en) | Hub applied to star-shaped TTP network and implementation method thereof | |
JP6379925B2 (en) | Communication waveform generator | |
JP7337021B2 (en) | A master device that controls a slave device connected to an industrial network and a communication module provided in the master device | |
JP5604799B2 (en) | Fault tolerant computer |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |