One-master-multiple-slave high-speed serial communication and synchronous control method, system and medium
Through a one-master-multiple-slave high-speed serial communication and synchronous control method, the transmission delay and frame header redundancy problems of the RS485 bus system when multiple devices collaborate in industrial scenarios are solved, and the high scalability, real-time performance and reliability of the multi-node system are achieved. Dynamic slave station access is supported without power off, reducing hardware costs.
Patent Information
- Application Number
- CN202510949818.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-10
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2045-07-10
AI Technical Summary
The existing RS485 bus system suffers from transmission delay differences when multiple devices collaborate in industrial scenarios, leading to desynchronization of actions, time-consuming expansion, and frame header redundancy leading to a sudden drop in real-time performance. The EtherCAT protocol stack has high hardware costs, and the CAN bus extension protocol has transmission delays in multiple nodes, which cannot meet the needs of precise control.
A one-master-multiple-slave high-speed serial communication and synchronous control method is adopted. Through slave topology identification, aggregated data frame encapsulation and token-driven uplink mechanism, communication pressure is reduced, bus conflicts are avoided, and the scalability, real-time performance and reliability of multi-node synchronous control are improved.
It improves the scalability, real-time performance and reliability of multi-node synchronous control in industrial scenarios, supports dynamic addition and deletion of slave stations without power off and restart, and reduces hardware costs.
Smart Images

Figure CN120475090B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of high-speed serial communication, and more particularly to a one-master-multiple-slave high-speed serial communication and synchronous control method, system and medium. Background Art
[0002] In fields such as industrial automation, collaborative robotics control, and smart homes, high-speed serial communication systems with a single master and multiple slaves are the core infrastructure for achieving multi-node collaboration. While existing RS485 bus systems offer interference immunity and multi-node support, industrial scenarios require multiple devices to coordinate in microseconds. However, traditional polling mechanisms can cause synchronization errors due to transmission delay variations. Furthermore, when production line upgrades require the addition of new sensors, the system must be shut down and restarted, leading to time-consuming capacity expansion. Furthermore, the master sends data frames one by one to the slaves, resulting in redundant frame headers and a significant drop in the real-time performance of multi-node systems.
[0003] Currently, there is a way to improve synchronization by using the EtherCAT protocol stack, but it requires the use of dedicated chips, which leads to a surge in hardware costs; there is also a way to use the CAN bus expansion protocol to support hot-plugging of new slave devices, but there is transmission delay under multiple nodes, which cannot meet the needs of precise control.
[0004] Therefore, there is an urgent need for a highly reliable and scalable one-master-multiple-slave communication synchronization control technology. Summary of the Invention
[0005] In view of the above problems, the purpose of the present invention is to provide a one-master-multiple-slave high-speed serial communication and synchronous control method, system and medium, which accurately identifies the slave devices on the serial communication bus through slave topology identification, uses aggregated data frames to encapsulate all slave control instructions to reduce communication pressure, introduces a token-driven uplink mechanism based on the reverse order of physical connections, avoids bus conflicts, and comprehensively improves the scalability, real-time performance and reliability of multi-node synchronous control in industrial scenarios.
[0006] A first aspect of the present invention provides a one-master-multiple-slave high-speed serial communication and synchronous control method, the method comprising:
[0007] Broadcasting a preset initialization instruction via the master station;
[0008] In response to the device type query instruction sent by the master station, feeding back, through the slave station, a feedback instruction including end mark information;
[0009] If the terminal mark information is a preset mark threshold, the slave station topology identification is completed;
[0010] Broadcasting an aggregate data frame through the master station, the aggregate data frame including all slave station data packets, the slave station data packets including a station number, a data length and slave station data;
[0011] Extract and parse the corresponding slave station data packet according to the station number, execute the task according to the slave station data, and obtain uplink feedback data;
[0012] Feedback uplink feedback data sequentially through the slave station based on a preset physical connection sequence;
[0013] Based on preset check code detection and timeout detection, verify the uplink feedback data and report error information;
[0014] In response to the newly added slave station instruction, the master station broadcasts a preset initialization instruction to re-perform slave station topology identification.
[0015] This solution includes the slave topology identification logic, specifically:
[0016] Generate an increasing station number sequence based on the preset physical connection sequence;
[0017] Generate the device type query instruction in sequence according to the station number sequence;
[0018] In response to the device type query instruction, the slave with the corresponding station number generates a feedback instruction based on the device type and end mark information;
[0019] In response to the feedback instruction, the master station parses and obtains the device type and terminal mark information;
[0020] Generating an initialization parameter set matching the device according to the device type;
[0021] If the end flag information is false, select the next station number according to the station number sequence, and generate and send the device type query instruction again;
[0022] If the end flag information is true, it means that the slave station topology identification is completed.
[0023] This solution includes the construction of an aggregate data frame, specifically:
[0024] By reading the master station status word register, the master station operation status is written into the header of the aggregated data frame;
[0025] Based on the station number sequence recorded in the topology identification record, each slave station data packet is encapsulated in turn;
[0026] Obtaining a first check code according to the slave station data packet based on a preset packet check algorithm;
[0027] forming a slave station data block according to the slave station data packet and the first check code;
[0028] All slave station data blocks are sequentially spliced after the header of the aggregate data frame according to the station number sequence;
[0029] Based on a preset frame check algorithm, a second check code is obtained according to the spliced aggregate data frame;
[0030] The second check code is written into the tail of the aggregated data frame.
[0031] In this solution, the corresponding slave station data packet is extracted and parsed according to the station number, specifically:
[0032] After receiving the aggregated data frame through the slave station, calculating a third check code based on a preset frame check algorithm;
[0033] If the third check code is the same as the second check code, scanning and comparing the station number field in the aggregated data frame according to the slave station number;
[0034] If the station number field matches successfully, the subsequent byte stream is extracted according to the data length to obtain the data packet received from the station;
[0035] Based on a preset packet verification algorithm, a fourth verification code is obtained according to the data packet received from the slave station;
[0036] If the fourth check code is the same as the first check code, a task is executed according to the slave station parameter of the data packet received by the slave station.
[0037] In this solution, the uplink feedback data is fed back sequentially by the slave station based on the preset physical connection order, specifically:
[0038] Determine the end slave station according to the station number sequence;
[0039] After detecting that the bus is idle, the terminal slave first sends a first priority token and then uploads the uplink feedback data corresponding to the slave;
[0040] Upon detecting the first priority token and after the backoff timer times out, if the bus is detected to be idle, the second priority token is sent via the penultimate slave station, and then the uplink feedback data corresponding to the slave station is uploaded;
[0041] All intermediate slave stations repeat backoff timing, bus detection, token upload, and data upload in sequence until the first-end slave station completes uplink feedback data upload;
[0042] When the head-end slave station completes uploading the uplink feedback data, it appends a frame end character.
[0043] This plan also includes:
[0044] Based on the preset configuration library template, the master station generates and sends corresponding slave station configuration instructions;
[0045] For sensor slaves, generate and send configuration instructions including sampling rate and range;
[0046] For execution-type slaves, generate and send configuration instructions containing execution parameters and safety thresholds;
[0047] In response to the slave configuration instruction, it parses the configuration parameters and then feeds back the configuration verification code, and marks it as ready.
[0048] A second aspect of the present invention provides a one-master-multiple-slave high-speed serial communication and synchronization control system, including a one-master-multiple-slave high-speed serial communication and synchronization control method program. When the one-master-multiple-slave high-speed serial communication and synchronization control method program is executed by the processor, the following steps are implemented:
[0049] Broadcasting a preset initialization instruction via the master station;
[0050] In response to the device type query instruction sent by the master station, feeding back, through the slave station, a feedback instruction including end mark information;
[0051] If the terminal mark information is a preset mark threshold, the slave station topology identification is completed;
[0052] Broadcasting an aggregate data frame through the master station, the aggregate data frame including all slave station data packets, the slave station data packets including a station number, a data length and slave station data;
[0053] Extract and parse the corresponding slave station data packet according to the station number, execute the task according to the slave station data, and obtain uplink feedback data;
[0054] Feedback uplink feedback data sequentially through the slave station based on a preset physical connection sequence;
[0055] Based on preset check code detection and timeout detection, verify the uplink feedback data and report error information;
[0056] In response to the newly added slave station instruction, the master station broadcasts a preset initialization instruction to re-perform slave station topology identification.
[0057] This solution includes the slave topology identification logic, specifically:
[0058] Generate an increasing station number sequence based on the preset physical connection sequence;
[0059] Generate the device type query instruction in sequence according to the station number sequence;
[0060] In response to the device type query instruction, the slave with the corresponding station number generates a feedback instruction based on the device type and end mark information;
[0061] In response to the feedback instruction, the master station parses and obtains the device type and terminal mark information;
[0062] Generating an initialization parameter set matching the device according to the device type;
[0063] If the end flag information is false, select the next station number according to the station number sequence, and generate and send the device type query instruction again;
[0064] If the end flag information is true, it means that the slave station topology identification is completed.
[0065] This solution includes the construction of an aggregate data frame, specifically:
[0066] By reading the master station status word register, the master station operation status is written into the header of the aggregated data frame;
[0067] Based on the station number sequence recorded in the topology identification record, each slave station data packet is encapsulated in turn;
[0068] Obtaining a first check code according to the slave station data packet based on a preset packet check algorithm;
[0069] forming a slave station data block according to the slave station data packet and the first check code;
[0070] All slave station data blocks are sequentially spliced after the header of the aggregate data frame according to the station number sequence;
[0071] Based on a preset frame check algorithm, a second check code is obtained according to the spliced aggregate data frame;
[0072] The second check code is written into the tail of the aggregated data frame.
[0073] A third aspect of the present invention provides a computer-readable storage medium, which includes a one-master-multiple-slave high-speed serial communication and synchronous control method program. When the one-master-multiple-slave high-speed serial communication and synchronous control method program is executed by a processor, the steps of the one-master-multiple-slave high-speed serial communication and synchronous control method as described in any one of the above items are implemented.
[0074] The present invention provides a one-master-multiple-slave high-speed serial communication and synchronous control method, system and medium. First, the slave station is reset based on the initialization instruction and the device type query instruction is sent in sequence based on the physical connection order to complete the slave station topology identification; then, the aggregated data frame is periodically constructed, wherein the frame header writes the master station status word, the frame body is the data packets of each slave station spliced in the order of station number, and the frame tail is a check code; finally, the slave station parses the aggregated data frame based on the station number and executes the task, and then relays the task execution result in the physical reverse order; in addition, when a new slave station is connected, the master station switches the status word and triggers the re-initialization of the whole system, and the new slave station is dynamically incorporated into the topology; the present invention comprehensively improves the scalability, real-time performance and reliability of multi-node synchronous control in industrial scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope.
[0076] Figure 1 A flow chart of a one-master-multiple-slave high-speed serial communication and synchronous control method according to the present invention is shown;
[0077] Figure 2 The following is a flowchart of the operation of a slave station topology identification logic provided by an embodiment of the present invention;
[0078] Figure 3 A flowchart of constructing an aggregated data frame provided by an embodiment of the present invention is shown;
[0079] Figure 4 The block diagram of a one-master-multiple-slave high-speed serial communication and synchronization control system of the present invention is shown. DETAILED DESCRIPTION
[0080] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0081] Unless otherwise defined, all terms (including technical and scientific terms) used in the embodiments of the present invention have the same meaning as commonly understood by those skilled in the art to which the present invention belongs. It should also be understood that terms such as those defined in common dictionaries should be interpreted as having meanings consistent with their meanings in the context of the relevant technology, and should not be interpreted in an idealized or extremely formal sense, unless explicitly defined in this manner in the embodiments of the present invention.
[0082] The words "first", "second" and similar terms used in the embodiments of the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Words such as "one", "an" or "the" do not indicate a quantity limitation, but rather indicate the existence of at least one. Similarly, words such as "include" or "comprise" mean that the elements or objects preceding the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. Words such as "connect" or "connected" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The steps before or after the method of the embodiment of the present invention do not necessarily have to be performed in exact order. On the contrary, the various steps may be processed in reverse order or simultaneously. At the same time, other operations may be added to these processes, or one or more steps may be removed from these processes.
[0083] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0084] Figure 1 The flowchart of the one-master-multiple-slave high-speed serial communication and synchronous control method of the present invention is shown.
[0085] like Figure 1 As shown, the first aspect of the present invention discloses a one-master-multiple-slave high-speed serial communication and synchronization control method, the method comprising:
[0086] S102, broadcasting a preset initialization instruction via the master station;
[0087] S104, in response to the device type query instruction sent by the master station, feeding back, via the slave station, a feedback instruction including end flag information;
[0088] S106, if the end mark information is a preset mark threshold, the slave station topology identification is completed;
[0089] S108, broadcasting an aggregated data frame through the master station, wherein the aggregated data frame includes all slave station data packets, and the slave station data packets include a station number, a data length, and slave station data;
[0090] S110, extracting and parsing the corresponding slave station data packet according to the station number, executing a task according to the slave station data, and obtaining uplink feedback data;
[0091] S112, feeding back uplink feedback data sequentially through the slave station based on a preset physical connection order;
[0092] S114, based on preset check code detection and timeout detection, verify the uplink feedback data and report error information;
[0093] S116 , in response to the newly added slave station instruction, the master station broadcasts a preset initialization instruction to re-identify the slave station topology.
[0094] It should be noted that after system startup, the master first broadcasts the initialization command (INIT_DEVICE), forcing all slaves into the pending configuration state. The master then sends device type query commands (GET_DEVICE_TYPE) in sequence, following the physical connection order. Each addressed slave returns a response packet containing the device type code and the last-slave flag (Is_Last_Slave). If the last-slave flag is false, the master increments the slave ID and continues querying the next slave. If the last-slave flag is true, topology identification is complete and a station ID-device type mapping table is generated. After entering the operational phase, the master periodically constructs aggregate data frames, which consist of a header, body, and trailer. The header contains the master status word. For example, the "Running" status indicates normal communication, while the "Initialization" status indicates initialization. The body concatenates the data packets of each slave in station ID order. Each slave data packet contains at least a 4-byte station ID, a 2-byte data length field, and slave data representing control commands. The trailer contains the checksum of the aggregate data frame. After receiving an aggregated frame, a slave station extracts its dedicated data packet through binary matching to perform its task. Slave tasks include sensor acquisition or actuator action. Based on the task execution results, the slave station generates uplink feedback data. Each slave station transmits this uplink feedback data to the master station based on pre-set feedback rules. The end slave station prioritizes bus idleness and uploads data. Other slave stations relay data in reverse physical order, and the leading slave station appends an end-of-frame delimiter. The master station performs double-check data and timeout checks. In one implementation, data verification uses a CRC16 packet checksum combined with a CRC32 frame checksum, and timeout verification uses a timer. If a check fails, data is discarded and an error log is reported. Double error detection prevents the propagation of erroneous data, ensuring system stability. Furthermore, when a new slave station is added, the master station switches the status word to Initialization, triggering a system-wide reinitialization and dynamically integrating the new slave into the topology. A status-word-driven hot reconfiguration mechanism supports dynamic slave addition and removal during runtime without powering down or restarting.
[0095] Figure 2 The flowchart of the operation of the slave station topology identification logic provided by an embodiment of the present invention is shown.
[0096] According to an embodiment of the present invention, Figure 2 As shown, it includes the slave topology identification logic, specifically:
[0097] S202, generating an increasing station number sequence based on a preset physical connection sequence;
[0098] S204, sequentially generating the device type query instruction according to the station number sequence;
[0099] S206, in response to the device type query instruction, the slave corresponding to the station number generates a feedback instruction based on the device type and end mark information;
[0100] S208, in response to the feedback instruction, the master station parses and obtains device type and terminal flag information;
[0101] S210, generating an initialization parameter set matching the device according to the device type;
[0102] S212, if the end flag information is false, select the next station number according to the station number sequence, and generate and send the device type query instruction again;
[0103] S214: If the end flag information is true, it indicates that the slave station topology identification is completed.
[0104] It should be noted that this embodiment provides slave topology identification logic. During the topology identification phase, the master initializes the station number counter and sends a device type query command to the target station number. The addressed slave performs a hardware self-test to check the RS485 interface terminal resistor enable status. As an implementation, the end node must activate the 100Ω resistor and set the terminal flag to true. If the end node does not activate the resistor, the terminal flag is set to false. Simultaneously, the slave reads the device type register (for example, 0x01 represents a temperature sensor and 0x02 represents a stepper motor) and encapsulates the device type and terminal flag information into a response packet and returns it to the master. The master parses the response and performs differentiated configuration, generating sampling rate and range parameters for sensor devices and action delay and torque threshold for actuator devices. The configuration command is sent via unicast to the corresponding slave station. The slave verifies the parameter validity, writes it to non-volatile memory, and returns the configuration hash value for confirmation. If the terminal flag is false, the master increments the station number counter and repeats the query process. If the terminal flag is true, a topology mapping table is generated to record the device type and terminal location corresponding to each station number. Finally, a topology confirmation command is broadcast, causing all slaves to activate their communication protocol stacks. During the topology identification process, if no response is received after three consecutive queries, the node with that station ID is considered disconnected and marked as a faulty node. This embodiment decouples the physical connection order from the logical station ID, making it suitable for non-contiguous wiring scenarios.
[0105] Figure 3 A flow chart of constructing an aggregated data frame provided by an embodiment of the present invention is shown.
[0106] According to an embodiment of the present invention, Figure 3As shown, including the construction of the aggregation data frame, specifically:
[0107] S302, writing the master station operation status into the header of the aggregated data frame by reading the master station status word register;
[0108] S304, based on the station number sequence recorded in the topology identification record, encapsulate each slave station data packet in sequence;
[0109] S306, obtaining a first check code according to the slave station data packet based on a preset packet check algorithm;
[0110] S308, forming a slave data block according to the slave data packet and the first check code;
[0111] S310, splicing all slave station data blocks in sequence after the header of the aggregate data frame according to the station number sequence;
[0112] S312, obtaining a second check code based on the spliced aggregate data frame based on a preset frame check algorithm;
[0113] S314: Write the second check code into the end of the aggregated data frame.
[0114] It should be noted that this embodiment provides a mechanism for constructing an aggregated data frame. First, the status register is read, and the status word Running is written when it is in normal operation. As an implementation method, 0x55 represents Running. Then, the data packets are encapsulated in the order of the station numbers in the topology mapping table, where each slave station data packet starts with a 4-byte station number, followed by a 2-byte data length field, and then the slave station data representing the content of the control instruction. The CRC16 check code, i.e., the first check code, is calculated separately for each slave station data packet and appended to the end of the packet. Finally, after all the slave station packets are spliced in ascending order of the station number, an 8-byte high-precision timestamp is inserted into the frame header, and the full-frame CRC32 check code, i.e., the second check code, is calculated and written to the end of the frame to form a complete aggregated data frame. By aggregating data frames, single-frame data can be aggregated into multiple slave station data, reducing communication overhead and communication pressure; at the same time, based on the packet check algorithm and the frame check algorithm, double check is implemented to ensure end-to-end data integrity.
[0115] According to an embodiment of the present invention, extracting and parsing the corresponding slave station data packet according to the station number is specifically as follows:
[0116] After receiving the aggregated data frame through the slave station, calculating a third check code based on a preset frame check algorithm;
[0117] If the third check code is the same as the second check code, scanning and comparing the station number field in the aggregated data frame according to the slave station number;
[0118] If the station number field matches successfully, the subsequent byte stream is extracted according to the data length to obtain the data packet received from the station;
[0119] Based on a preset packet verification algorithm, a fourth verification code is obtained according to the data packet received from the slave station;
[0120] If the fourth check code is the same as the first check code, a task is executed according to the slave station parameter of the data packet received by the slave station.
[0121] It should be noted that after the slave station receives the aggregated data frame, it first extracts the 4-byte CRC32 checksum at the end of the frame and compares it with the locally calculated full-frame checksum value. If there is any inconsistency, the frame is immediately discarded and a NACK retransmission request is sent to the master station. If there is a consistency, the frame header status word is parsed. If the status word is Initialization, the re-initialization process is triggered. If the status word is Running, data extraction begins. The slave station scans the station number field in the frame byte by byte and performs a binary bit-by-bit comparison with its own stored station number. After a successful match, the subsequent 2-byte data length field is read and the exclusive data block is extracted according to the length. The CRC16 checksum is calculated for the data block and compared with the checksum value at the end of the packet. If the packet check fails, the local error counter is increased, and three consecutive errors trigger a self-reset; if the packet check passes, the instruction type is parsed and the instruction task is executed. This embodiment uses two-level check to isolate local errors to avoid single-point failures that cause the entire frame to be discarded.
[0122] According to an embodiment of the present invention, the uplink feedback data is fed back sequentially by the slave station based on a preset physical connection order, specifically:
[0123] Determine the end slave station according to the station number sequence;
[0124] After detecting that the bus is idle, the terminal slave first sends a first priority token and then uploads the uplink feedback data corresponding to the slave;
[0125] Upon detecting the first priority token and after the backoff timer times out, if the bus is detected to be idle, the second priority token is sent via the penultimate slave station, and then the uplink feedback data corresponding to the slave station is uploaded;
[0126] All intermediate slave stations repeat backoff timing, bus detection, token upload, and data upload in sequence until the first-end slave station completes uplink feedback data upload;
[0127] When the head-end slave station completes uploading the uplink feedback data, it appends a frame end character.
[0128] It should be noted that during the uplink feedback data upload phase, slaves upload feedback data in reverse order, following the physical connection order. The end slave continuously monitors the bus level. When it detects a low level for 200μs, it determines the bus is idle and immediately sends a 1-byte high-priority token to assert transmission rights, then uploads its own feedback data frame. The penultimate slave, upon detecting the high-priority token, starts a backoff timer. After the timer expires and the bus is idle again, it sends a sub-optimal token and uploads feedback data. Intermediate slaves repeat this process: listening for the previous token, starting the backoff timer, detecting idleness, sending the current token, and uploading data. Finally, when the head slave transmits its last feedback data, it appends a 2-byte end-of-frame delimiter to the end of the data, signaling the end of this feedback round. The master station identifies the end-of-frame delimiter to determine the end of the uplink cycle, parses the data link in the order received, and verifies its integrity. Furthermore, if a bus conflict is detected during transmission, it immediately stops transmission and performs a random backoff. The backoff timer is adjusted to reduce the risk of conflict.
[0129] According to an embodiment of the present invention, the further embodiment includes:
[0130] Based on the preset configuration library template, the master station generates and sends corresponding slave station configuration instructions;
[0131] For sensor slaves, generate and send configuration instructions including sampling rate and range;
[0132] For execution-type slaves, generate and send configuration instructions containing execution parameters and safety thresholds;
[0133] In response to the slave configuration instruction, it parses the configuration parameters and then feeds back the configuration verification code, and marks it as ready.
[0134] It should be noted that a library of slave configuration templates is pre-stored in memory. Sensor templates include fields such as sampling rate, range, and filter coefficient; actuator templates include parameters such as response delay, safe torque threshold, and position tolerance. After topology identification is complete, the master station calls the corresponding template based on the slave device type. As an implementation, the master station sends the configuration command [0x01 0x64 0x01 0x0F] to the temperature sensor, indicating a temperature sensor, a 100Hz sampling rate, and a ±50°C range; and sends the command [0x02 0x14 0x32] to the stepper motor, indicating a stepper motor, a 20mx response delay, and 50% maximum torque. Configuration commands are transmitted via unicast. Upon receipt, the slave station performs a three-level validation process, including parameter range checking, logical conflict detection, and hardware compatibility testing. Upon successful validation, the parameters are written to non-volatile memory, the configuration hash value is calculated and returned to the master station, and the ready status register is set. If validation fails, an error code is returned and the slave station remains in standby mode. This embodiment adopts templated configuration to shorten the slave deployment time, and the actuator parameter pre-check mechanism prevents over-limit operation.
[0135] It is worth mentioning that it also includes a timing synchronization mechanism, specifically:
[0136] Generate synchronous pulse signals based on the preset timing trigger mechanism;
[0137] In response to the synchronization pulse signal, broadcasting a synchronization aggregation data frame through the master station according to a preset synchronization field;
[0138] In response to the step-aggregated data frame, after parsing to obtain the synchronization field, the local task timer is started, and the slave task is executed after a preset delay time.
[0139] It should be noted that this embodiment provides a timing synchronization mechanism. The master station has a built-in high-precision timer, which generates a hardware interrupt when the preset synchronization period is reached. In the interrupt service program, the master station performs three steps: first, writes a 2-byte synchronization flag in the header of the aggregate frame; then embeds an 8-byte precise timestamp; and finally broadcasts the synchronized aggregate frame. After receiving the slave station, it detects the synchronization flag. If the synchronization flag matches, it extracts the timestamp and writes it into the local timer to start the task delay countdown, where the delay value is set in the configuration stage, such as 50ms for sensor preheating. After the slave station delay countdown ends, the core tasks are executed synchronously, including data collection by the sensor and the execution of action instructions by the actuator. The master station aligns the start time of all slave station tasks through the timestamp to eliminate the difference in signal transmission delay. In addition, if the slave station does not receive the synchronization frame in the expected window, it uses the timestamp of the previous cycle to predict the execution and reports the synchronization anomaly through the uplink data packet status word.
[0140] It is worth mentioning that it also includes:
[0141] When an abnormality is detected in the feedback from the same slave station, it is marked as an abnormal slave station, and the slave station data packet corresponding to the abnormal slave station is shielded in the aggregated data frame;
[0142] In response to a slave station data packet being missing, resetting the abnormal slave station and initiating a re-registration request;
[0143] In response to the re-registration request, the abnormal slave is re-included in the topology identification table.
[0144] It should be noted that the master station monitors the communication quality in real time. If a single station fails to communicate for three consecutive times, including timeout or CRC error, it will be marked as an abnormal slave station. The data packet with this station number will be skipped when constructing the subsequent aggregated data frame. At the same time, a three-level recovery instruction is sent to the abnormal slave station: first, a software reset command is sent to try to recover; then, if there is no response within the preset time, the hardware reset line is triggered; finally, a re-registration instruction is sent after the reset is successful. The slave station response re-registration process includes returning the device type, end mark and hardware version number to the master station; receiving the latest configuration parameters sent by the master station and reloading; returning the ready status code, and the master station will re-add it to the topology table. If the re-registration fails, the node is isolated and marked as a permanent fault, grayed out in the topology mapping table, and a system expansion warning is triggered.
[0145] Figure 4 The block diagram of a one-master-multiple-slave high-speed serial communication and synchronization control system of the present invention is shown.
[0146] like Figure 4 As shown, the second aspect of the present invention discloses a one-master-multiple-slave high-speed serial communication and synchronization control system 4, comprising a memory 41 and a processor 42. The memory includes a one-master-multiple-slave high-speed serial communication and synchronization control method program. When the one-master-multiple-slave high-speed serial communication and synchronization control method program is executed by the processor, the following steps are implemented:
[0147] Broadcasting a preset initialization instruction via the master station;
[0148] In response to the device type query instruction sent by the master station, feeding back, through the slave station, a feedback instruction including end mark information;
[0149] If the terminal mark information is a preset mark threshold, the slave station topology identification is completed;
[0150] Broadcasting an aggregate data frame through the master station, the aggregate data frame including all slave station data packets, the slave station data packets including a station number, a data length and slave station data;
[0151] Extract and parse the corresponding slave station data packet according to the station number, execute the task according to the slave station data, and obtain uplink feedback data;
[0152] Feedback uplink feedback data sequentially through the slave station based on a preset physical connection sequence;
[0153] Based on preset check code detection and timeout detection, verify the uplink feedback data and report error information;
[0154] In response to the newly added slave station instruction, the master station broadcasts a preset initialization instruction to re-perform slave station topology identification.
[0155] It should be noted that after system startup, the master first broadcasts the initialization command (INIT_DEVICE), forcing all slaves into the pending configuration state. The master then sends device type query commands (GET_DEVICE_TYPE) in sequence, following the physical connection order. Each addressed slave returns a response packet containing the device type code and the last-slave flag (Is_Last_Slave). If the last-slave flag is false, the master increments the slave ID and continues querying the next slave. If the last-slave flag is true, topology identification is complete and a station ID-device type mapping table is generated. After entering the operational phase, the master periodically constructs aggregate data frames, which consist of a header, body, and trailer. The header contains the master status word. For example, the "Running" status indicates normal communication, while the "Initialization" status indicates initialization. The body concatenates the data packets of each slave in station ID order. Each slave data packet contains at least a 4-byte station ID, a 2-byte data length field, and slave data representing control commands. The trailer contains the checksum of the aggregate data frame. After receiving an aggregated frame, a slave station extracts its dedicated data packet through binary matching to perform its task. Slave tasks include sensor acquisition or actuator action. Based on the task execution results, the slave station generates uplink feedback data. Each slave station transmits this uplink feedback data to the master station based on pre-set feedback rules. The end slave station prioritizes bus idleness and uploads data. Other slave stations relay data in reverse physical order, and the leading slave station appends an end-of-frame delimiter. The master station performs double-check data and timeout checks. In one implementation, data verification uses a CRC16 packet checksum combined with a CRC32 frame checksum, and timeout verification uses a timer. If a check fails, data is discarded and an error log is reported. Double error detection prevents the propagation of erroneous data, ensuring system stability. Furthermore, when a new slave station is added, the master station switches the status word to Initialization, triggering a system-wide reinitialization and dynamically integrating the new slave into the topology. A status-word-driven hot reconfiguration mechanism supports dynamic slave addition and removal during runtime without powering down or restarting.
[0156] Figure 2 The flowchart of the operation of the slave station topology identification logic provided by an embodiment of the present invention is shown.
[0157] According to an embodiment of the present invention, Figure 2 As shown, it includes the slave topology identification logic, specifically:
[0158] Generate an increasing station number sequence based on the preset physical connection sequence;
[0159] Generate the device type query instruction in sequence according to the station number sequence;
[0160] In response to the device type query instruction, the slave with the corresponding station number generates a feedback instruction based on the device type and end mark information;
[0161] In response to the feedback instruction, the master station parses and obtains the device type and terminal mark information;
[0162] Generating an initialization parameter set matching the device according to the device type;
[0163] If the end flag information is false, select the next station number according to the station number sequence, and generate and send the device type query instruction again;
[0164] If the end flag information is true, it means that the slave station topology identification is completed.
[0165] It should be noted that this embodiment provides slave topology identification logic. During the topology identification phase, the master initializes the station number counter and sends a device type query command to the target station number. The addressed slave performs a hardware self-test to check the RS485 interface terminal resistor enable status. As an implementation, the end node must activate the 100Ω resistor and set the terminal flag to true. If the end node does not activate the resistor, the terminal flag is set to false. Simultaneously, the slave reads the device type register (for example, 0x01 represents a temperature sensor and 0x02 represents a stepper motor) and encapsulates the device type and terminal flag information into a response packet and returns it to the master. The master parses the response and performs differentiated configuration, generating sampling rate and range parameters for sensor devices and action delay and torque threshold for actuator devices. The configuration command is sent via unicast to the corresponding slave station. The slave verifies the parameter validity, writes it to non-volatile memory, and returns the configuration hash value for confirmation. If the terminal flag is false, the master increments the station number counter and repeats the query process. If the terminal flag is true, a topology mapping table is generated to record the device type and terminal location corresponding to each station number. Finally, a topology confirmation command is broadcast, causing all slaves to activate their communication protocol stacks. During the topology identification process, if no response is received after three consecutive queries, the node with that station ID is considered disconnected and marked as a faulty node. This embodiment decouples the physical connection order from the logical station ID, making it suitable for non-contiguous wiring scenarios.
[0166] Figure 3 A flow chart of constructing an aggregated data frame provided by an embodiment of the present invention is shown.
[0167] According to an embodiment of the present invention, Figure 3 As shown, including the construction of the aggregation data frame, specifically:
[0168] By reading the master station status word register, the master station operation status is written into the header of the aggregated data frame;
[0169] Based on the station number sequence recorded in the topology identification record, each slave station data packet is encapsulated in turn;
[0170] Obtaining a first check code according to the slave station data packet based on a preset packet check algorithm;
[0171] forming a slave station data block according to the slave station data packet and the first check code;
[0172] All slave station data blocks are sequentially spliced after the header of the aggregate data frame according to the station number sequence;
[0173] Based on a preset frame check algorithm, a second check code is obtained according to the spliced aggregate data frame;
[0174] The second check code is written into the tail of the aggregated data frame.
[0175] It should be noted that this embodiment provides a mechanism for constructing an aggregated data frame. First, the status register is read, and the status word Running is written when it is in normal operation. As an implementation method, 0x55 represents Running. Then, the data packets are encapsulated in the order of the station numbers in the topology mapping table, where each slave station data packet starts with a 4-byte station number, followed by a 2-byte data length field, and then the slave station data representing the content of the control instruction. The CRC16 check code, i.e., the first check code, is calculated separately for each slave station data packet and appended to the end of the packet. Finally, after all the slave station packets are spliced in ascending order of the station number, an 8-byte high-precision timestamp is inserted into the frame header, and the full-frame CRC32 check code, i.e., the second check code, is calculated and written to the end of the frame to form a complete aggregated data frame. By aggregating data frames, single-frame data can be aggregated into multiple slave station data, reducing communication overhead and communication pressure; at the same time, based on the packet check algorithm and the frame check algorithm, double check is implemented to ensure end-to-end data integrity.
[0176] According to an embodiment of the present invention, extracting and parsing the corresponding slave station data packet according to the station number is specifically as follows:
[0177] After receiving the aggregated data frame through the slave station, calculating a third check code based on a preset frame check algorithm;
[0178] If the third check code is the same as the second check code, scanning and comparing the station number field in the aggregated data frame according to the slave station number;
[0179] If the station number field matches successfully, the subsequent byte stream is extracted according to the data length to obtain the data packet received from the station;
[0180] Based on a preset packet verification algorithm, a fourth verification code is obtained according to the data packet received from the slave station;
[0181] If the fourth check code is the same as the first check code, a task is executed according to the slave station parameter of the data packet received by the slave station.
[0182] It should be noted that after the slave station receives the aggregated data frame, it first extracts the 4-byte CRC32 checksum at the end of the frame and compares it with the locally calculated full-frame checksum value. If there is any inconsistency, the frame is immediately discarded and a NAK retransmission request is sent to the master station. If there is a consistency, the frame header status word is parsed. If the status word is Initialization, the re-initialization process is triggered. If the status word is Running, data extraction begins. The slave station scans the station number field in the frame byte by byte and performs a binary bit-by-bit comparison with its own stored station number. After a successful match, the subsequent 2-byte data length field is read and the exclusive data block is extracted according to the length. The CRC16 checksum is calculated for the data block and compared with the checksum value at the end of the packet. If the packet check fails, the local error counter is increased, and three consecutive errors trigger a self-reset; if the packet check passes, the instruction type is parsed and the instruction task is executed. This embodiment uses two-level check to isolate local errors to avoid single-point failures that cause the entire frame to be discarded.
[0183] According to an embodiment of the present invention, the uplink feedback data is fed back sequentially by the slave station based on a preset physical connection order, specifically:
[0184] Determine the end slave station according to the station number sequence;
[0185] After detecting that the bus is idle, the terminal slave first sends a first priority token and then uploads the uplink feedback data corresponding to the slave;
[0186] Upon detecting the first priority token and after the backoff timer times out, if the bus is detected to be idle, the second priority token is sent via the penultimate slave station, and then the uplink feedback data corresponding to the slave station is uploaded;
[0187] All intermediate slave stations repeat backoff timing, bus detection, token upload, and data upload in sequence until the first-end slave station completes uplink feedback data upload;
[0188] When the head-end slave station completes uploading the uplink feedback data, it appends a frame end character.
[0189] It should be noted that during the uplink feedback data upload phase, slaves upload feedback data in reverse order, following the physical connection order. The end slave continuously monitors the bus level. When it detects a low level for 200μs, it determines the bus is idle and immediately sends a 1-byte high-priority token to assert transmission rights, then uploads its own feedback data frame. The penultimate slave, upon detecting the high-priority token, starts a backoff timer. After the timer expires and the bus is idle again, it sends a sub-optimal token and uploads feedback data. Intermediate slaves repeat this process: listening for the previous token, starting the backoff timer, detecting idleness, sending the current token, and uploading data. Finally, when the head slave transmits its last feedback data, it appends a 2-byte end-of-frame delimiter to the end of the data, signaling the end of this feedback round. The master station identifies the end-of-frame delimiter to determine the end of the uplink cycle, parses the data link in the order received, and verifies its integrity. Furthermore, if a bus conflict is detected during transmission, it immediately stops transmission and performs a random backoff. The backoff timer is adjusted to reduce the risk of conflict.
[0190] According to an embodiment of the present invention, the further embodiment includes:
[0191] Based on the preset configuration library template, the master station generates and sends corresponding slave station configuration instructions;
[0192] For sensor slaves, generate and send configuration instructions including sampling rate and range;
[0193] For execution-type slaves, generate and send configuration instructions containing execution parameters and safety thresholds;
[0194] In response to the slave configuration instruction, it parses the configuration parameters and then feeds back the configuration verification code, and marks it as ready.
[0195] It should be noted that a library of slave configuration templates is pre-stored in memory. Sensor templates include fields such as sampling rate, range, and filter coefficient; actuator templates include parameters such as response delay, safe torque threshold, and position tolerance. After topology identification is complete, the master station calls the corresponding template based on the slave device type. As an implementation, the master station sends the configuration command [0x01 0x64 0x01 0x0F] to the temperature sensor, indicating a temperature sensor, a 100Hz sampling rate, and a ±50°C range; and sends the command [0x02 0x14 0x32] to the stepper motor, indicating a stepper motor, a 20mx response delay, and 50% maximum torque. Configuration commands are transmitted via unicast. Upon receipt, the slave station performs a three-level validation process, including parameter range checking, logical conflict detection, and hardware compatibility testing. Upon successful validation, the parameters are written to non-volatile memory, the configuration hash value is calculated and returned to the master station, and the ready status register is set. If validation fails, an error code is returned and the slave station remains in standby mode. This embodiment adopts templated configuration to shorten the slave deployment time, and the actuator parameter pre-check mechanism prevents over-limit operation.
[0196] It is worth mentioning that it also includes a timing synchronization mechanism, specifically:
[0197] Generate synchronous pulse signals based on the preset timing trigger mechanism;
[0198] In response to the synchronization pulse signal, broadcasting a synchronization aggregation data frame through the master station according to a preset synchronization field;
[0199] In response to the step-aggregated data frame, after parsing to obtain the synchronization field, the local task timer is started, and the slave task is executed after a preset delay time.
[0200] It should be noted that this embodiment provides a timing synchronization mechanism. The master station has a built-in high-precision timer, which generates a hardware interrupt when the preset synchronization period is reached. In the interrupt service program, the master station performs three steps: first, writes a 2-byte synchronization flag in the header of the aggregate frame; then embeds an 8-byte precise timestamp; and finally broadcasts the synchronized aggregate frame. After receiving the slave station, it detects the synchronization flag. If the synchronization flag matches, it extracts the timestamp and writes it into the local timer to start the task delay countdown, where the delay value is set in the configuration stage, such as 50ms for sensor preheating. After the slave station delay countdown ends, the core tasks are executed synchronously, including data collection by the sensor and the execution of action instructions by the actuator. The master station aligns the start time of all slave station tasks through the timestamp to eliminate the difference in signal transmission delay. In addition, if the slave station does not receive the synchronization frame in the expected window, it uses the timestamp of the previous cycle to predict the execution and reports the synchronization anomaly through the uplink data packet status word.
[0201] It is worth mentioning that it also includes:
[0202] When an abnormality is detected in the feedback from the same slave station, it is marked as an abnormal slave station, and the slave station data packet corresponding to the abnormal slave station is shielded in the aggregated data frame;
[0203] In response to a slave station data packet being missing, resetting the abnormal slave station and initiating a re-registration request;
[0204] In response to the re-registration request, the abnormal slave is re-included in the topology identification table.
[0205] It should be noted that the master station monitors the communication quality in real time. If a single station fails to communicate for three consecutive times, including timeout or CRC error, it will be marked as an abnormal slave station. The data packet with this station number will be skipped when constructing the subsequent aggregated data frame. At the same time, a three-level recovery instruction is sent to the abnormal slave station: first, a software reset command is sent to try to recover; then, if there is no response within the preset time, the hardware reset line is triggered; finally, a re-registration instruction is sent after the reset is successful. The slave station response re-registration process includes returning the device type, end mark and hardware version number to the master station; receiving the latest configuration parameters sent by the master station and reloading; returning the ready status code, and the master station will re-add it to the topology table. If the re-registration fails, the node is isolated and marked as a permanent fault, grayed out in the topology mapping table, and a system expansion warning is triggered.
[0206] A third aspect of the present invention provides a computer-readable storage medium, which includes a one-master-multiple-slave high-speed serial communication and synchronous control method program. When the one-master-multiple-slave high-speed serial communication and synchronous control method program is executed by a processor, the steps of the one-master-multiple-slave high-speed serial communication and synchronous control method as described in any one of the above items are implemented.
[0207] In summary, the present invention provides a one-master-multiple-slave high-speed serial communication and synchronous control method, system and medium. First, the slave station is reset based on the initialization instruction and the device type query instruction is sent in sequence based on the physical connection order to complete the slave station topology identification; then, the aggregated data frame is periodically constructed, wherein the frame header writes the master station status word, the frame body is the slave station data packet spliced in the order of the station number, and the frame tail is the check code; finally, the slave station parses the aggregated data frame based on the station number, and executes the task, and then relays the task execution result in the physical reverse order; in addition, when a new slave station is connected, the master station switches the status word and triggers the re-initialization of the entire system, and the new slave station is dynamically incorporated into the topology; the present invention comprehensively improves the scalability, real-time performance and reliability of multi-node synchronous control in industrial scenarios.
[0208] If the functions are implemented as software modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or the portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage media include various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.
[0209] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.
Claims
1. A one-master-multiple-slave high-speed serial communication and synchronization control method, applied to a one-master-multiple-slave high-speed serial communication device, the device comprising a master station and at least two slave stations, characterized in that: The method comprises: Broadcasting a preset initialization instruction via the master station; In response to the device type query instruction sent by the master station, feeding back, through the slave station, a feedback instruction including end mark information; If the terminal mark information is a preset mark threshold, the slave station topology identification is completed; Broadcasting an aggregate data frame through the master station, the aggregate data frame including all slave station data packets, the slave station data packets including a station number, a data length and slave station data; Extract and parse the corresponding slave station data packet according to the station number, execute the task according to the slave station data, and obtain uplink feedback data; Feedback uplink feedback data sequentially through the slave station based on a preset physical connection sequence; Based on preset check code detection and timeout detection, verify the uplink feedback data and report error information; In response to the newly added slave station instruction, the master station broadcasts a preset initialization instruction to re-perform slave station topology identification; When an abnormality is detected in the feedback from the same slave station, it is marked as an abnormal slave station, and the slave station data packet corresponding to the abnormal slave station is shielded in the aggregated data frame; In response to a slave station data packet being missing, resetting the abnormal slave station and initiating a re-registration request; In response to the re-registration request, re-include the abnormal slave station in the topology identification table; The feeding back of uplink feedback data sequentially by the slave station based on a preset physical connection order is specifically: Determine the end slave station according to the station number sequence; After detecting that the bus is idle, the terminal slave first sends a first priority token and then uploads the uplink feedback data corresponding to the slave; Upon detecting the first priority token and after the backoff timer times out, if the bus is detected to be idle, the second priority token is sent via the penultimate slave station, and then the uplink feedback data corresponding to the slave station is uploaded; All intermediate slave stations repeat backoff timing, bus detection, token upload, and data upload in sequence until the first-end slave station completes uplink feedback data upload; When the head-end slave station completes uploading the uplink feedback data, it appends a frame end character.
2. The one-master-multiple-slave high-speed serial communication and synchronous control method according to claim 1, characterized in that: Includes slave topology identification logic, specifically: Generate an increasing station number sequence based on the preset physical connection sequence; Generate the device type query instruction in sequence according to the station number sequence; In response to the device type query instruction, the slave with the corresponding station number generates a feedback instruction based on the device type and end mark information; In response to the feedback instruction, the master station parses and obtains the device type and terminal mark information; Generating an initialization parameter set matching the device according to the device type; If the end flag information is false, select the next station number according to the station number sequence, and generate and send the device type query instruction again; If the end flag information is true, it means that the slave station topology identification is completed.
3. The one-master-multiple-slave high-speed serial communication and synchronous control method according to claim 1, characterized in that: Including the construction of the aggregation data frame, specifically: By reading the master station status word register, the master station operation status is written into the header of the aggregated data frame; Based on the station number sequence recorded in the topology identification record, each slave station data packet is encapsulated in turn; Obtaining a first check code according to the slave station data packet based on a preset packet check algorithm; forming a slave station data block according to the slave station data packet and the first check code; All slave station data blocks are sequentially spliced after the header of the aggregate data frame according to the station number sequence; Based on a preset frame check algorithm, a second check code is obtained according to the spliced aggregate data frame; The second check code is written into the tail of the aggregated data frame.
4. The one-master-multiple-slave high-speed serial communication and synchronous control method according to claim 3, characterized in that: The extraction and parsing of the corresponding slave station data packet according to the station number is specifically as follows: After receiving the aggregated data frame through the slave station, calculating a third check code based on a preset frame check algorithm; If the third check code is the same as the second check code, scanning and comparing the station number field in the aggregated data frame according to the slave station number; If the station number field matches successfully, the subsequent byte stream is extracted according to the data length to obtain the data packet received from the station; Based on a preset packet verification algorithm, a fourth verification code is obtained according to the data packet received from the slave station; If the fourth check code is the same as the first check code, a task is executed according to the slave station parameter of the data packet received by the slave station.
5. The one-master-multiple-slave high-speed serial communication and synchronous control method according to claim 1, characterized in that: Also includes: Based on the preset configuration library template, the master station generates and sends corresponding slave station configuration instructions; For sensor slaves, generate and send configuration instructions including sampling rate and range; For execution-type slaves, generate and send configuration instructions containing execution parameters and safety thresholds; In response to the slave configuration instruction, it parses the configuration parameters and then feeds back the configuration verification code, and marks it as ready.
6. A one-master-multiple-slave high-speed serial communication and synchronization control system, applied to a one-master-multiple-slave high-speed serial communication device, the device comprising a master station and at least two slave stations, characterized in that: The system includes a memory and a processor. The memory includes a one-master-multiple-slave high-speed serial communication and synchronous control method program. When the one-master-multiple-slave high-speed serial communication and synchronous control method program is executed by the processor, the following steps are implemented: Broadcasting a preset initialization instruction via the master station; In response to the device type query instruction sent by the master station, feeding back, through the slave station, a feedback instruction including end mark information; If the terminal mark information is a preset mark threshold, the slave station topology identification is completed; Broadcasting an aggregate data frame through the master station, the aggregate data frame including all slave station data packets, the slave station data packets including a station number, a data length and slave station data; Extract and parse the corresponding slave station data packet according to the station number, execute the task according to the slave station data, and obtain uplink feedback data; Feedback uplink feedback data sequentially through the slave station based on a preset physical connection sequence; Based on preset check code detection and timeout detection, verify the uplink feedback data and report error information; In response to the newly added slave station instruction, the master station broadcasts a preset initialization instruction to re-perform slave station topology identification; When an abnormality is detected in the feedback from the same slave station, it is marked as an abnormal slave station, and the slave station data packet corresponding to the abnormal slave station is shielded in the aggregated data frame; In response to a slave station data packet being missing, resetting the abnormal slave station and initiating a re-registration request; In response to the re-registration request, re-include the abnormal slave station in the topology identification table; The feeding back of uplink feedback data sequentially by the slave station based on a preset physical connection order is specifically: Determine the end slave station according to the station number sequence; After detecting that the bus is idle, the terminal slave first sends a first priority token and then uploads the uplink feedback data corresponding to the slave; Upon detecting the first priority token and after the backoff timer times out, if the bus is detected to be idle, the second priority token is sent via the penultimate slave station, and then the uplink feedback data corresponding to the slave station is uploaded; All intermediate slave stations repeat backoff timing, bus detection, token upload, and data upload in sequence until the first-end slave station completes uplink feedback data upload; When the head-end slave station completes uploading the uplink feedback data, it appends a frame end character.
7. The one-master-multiple-slave high-speed serial communication and synchronization control system according to claim 6, characterized in that: Includes slave topology identification logic, specifically: Generate an increasing station number sequence based on the preset physical connection sequence; Generate the device type query instruction in sequence according to the station number sequence; In response to the device type query instruction, the slave with the corresponding station number generates a feedback instruction based on the device type and end mark information; In response to the feedback instruction, the master station parses and obtains the device type and terminal mark information; Generating an initialization parameter set matching the device according to the device type; If the end flag information is false, select the next station number according to the station number sequence, and generate and send the device type query instruction again; If the end flag information is true, it means that the slave station topology identification is completed.
8. The one-master-multiple-slave high-speed serial communication and synchronization control system according to claim 6, characterized in that: Including the construction of the aggregation data frame, specifically: By reading the master station status word register, the master station operation status is written into the header of the aggregated data frame; Based on the station number sequence recorded in the topology identification record, each slave station data packet is encapsulated in turn; Obtaining a first check code according to the slave station data packet based on a preset packet check algorithm; forming a slave station data block according to the slave station data packet and the first check code; All slave station data blocks are sequentially spliced after the header of the aggregate data frame according to the station number sequence; Based on a preset frame check algorithm, a second check code is obtained according to the spliced aggregate data frame; The second check code is written into the tail of the aggregated data frame.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer-readable storage medium includes a master-multiple-slave high-speed serial communication and synchronous control method program. When the master-multiple-slave high-speed serial communication and synchronous control method program is executed by a processor, the steps of the master-multiple-slave high-speed serial communication and synchronous control method as described in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Implementation method and device based on EtherCAT master station system without operating system
CN120111115A