WO2024138400A1 - Synchronous data processing method, and device - Google Patents
Synchronous data processing method, and device Download PDFInfo
- Publication number
- WO2024138400A1 WO2024138400A1 PCT/CN2022/142591 CN2022142591W WO2024138400A1 WO 2024138400 A1 WO2024138400 A1 WO 2024138400A1 CN 2022142591 W CN2022142591 W CN 2022142591W WO 2024138400 A1 WO2024138400 A1 WO 2024138400A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- slave
- slave devices
- edge
- sampling
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/42—Bus transfer protocol, e.g. handshake; Synchronisation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
Definitions
- the master device and each slave device have their own clock systems, and there is a certain deviation between the clock systems, which makes it difficult for the master device to obtain highly synchronized data from the slave devices.
- an embodiment of the present application provides a synchronous data processing method, which is applied to a master device, wherein the master device is communicatively connected with a plurality of slave devices, and the method includes:
- the sampled data are processed according to the relative time deviation to obtain synchronous sampled data of the multiple slave devices.
- an embodiment of the present application provides a synchronous data processing method, which is applied to a slave device, wherein the slave device is communicatively connected to a master device, and the method includes:
- the application environment diagram of the synchronous data processing method provided by the embodiment of the present application is illustrated in conjunction with Figure 1.
- the master device and multiple slave devices are connected via RS485 bus communication, and the number of slave devices is not specifically limited.
- the master device and each slave device are controlled by a single-chip microcomputer, and the single-chip microcomputer is provided with a respective clock system, such as a crystal oscillator.
- a respective clock system such as a crystal oscillator
- a DMA (Direct Memory Access) channel can be used to control an ADC (Analog-to-Digital Converter) to perform sampling to obtain sampled data.
- ADC Analog-to-Digital Converter
- the method of using a DMA channel to control the ADC for sampling is not limited in this embodiment and can be any existing technology, which will not be described in detail here.
- the sampling data is processed according to the relative time deviation to obtain synchronous sampling data of multiple slave devices, including:
- each slave device triggers an interrupt and executes an interrupt processing function as the start time of data sampling, and sets the same sampling interval for data sampling. It can be understood that since the edge triggering time is very short, each slave device starts sampling at almost the same time.
- the sampling interval is preset, for example, the sampling interval is 1ms, which is not limited here.
- S23 takes the total time of receiving the synchronous data in the edge trigger mode as the transmission time, and sends the transmission time to the master device.
- each slave device since each slave device is provided with a clock system, there is a certain deviation between each clock system, so each slave device will also have a deviation according to its own clock system timing. On this basis, each slave device performs data sampling according to the agreed sampling interval, and the sampling interval of each slave device is biased, so that the moment of sampling data also has a certain deviation. However, since the deviation caused by the clock system is fixed, therefore, when receiving synchronous data, this deviation also exists.
- the number of slave devices is 2 (slave device A and slave device B respectively) as an example, the transmission time TA recorded by slave device A is not the same as the transmission time TB recorded by slave device B, and there is a time deviation, which is caused by the clock system of each slave device.
- each slave device before receiving the preset synchronization frame, each slave device is in a serial port receiving mode, that is, it responds to the data frame to perform the corresponding operation only after receiving the complete data frame.
- the check bit is used to confirm that the current preset synchronization frame has been received and received correctly. When the preset check bit meets the preset check requirement, it can be confirmed that the preset synchronization frame has been received.
- the slave device updates the receiving mode to the edge trigger mode. When the check bit does not meet the preset check requirement, there is no need to update the receiving mode to the edge trigger mode.
- the calculation process of the transmission time provided in the embodiment of the present application is illustrated in conjunction with FIG8 , and the total time of receiving the synchronization data is calculated as the transmission time, including:
- the synchronization data refers to a preset number of bytes, which is preset, for example, the preset number may be 1000.
- Each byte may include a number of bits, for example, a start bit, a data bit, and a stop bit, wherein the start bit and the stop bit may be 1 bit, and the data bit may be 8 bits.
- the number of bits refers to the number of bits in the synchronization data. When the synchronization data includes 1000 bytes and 1 byte includes 10 bits, the stop bit of the last byte in the synchronization data is not counted, and the number of bits is 10*1000-1.
- the timer is used to record the time when the slave device receives the edge of the synchronization data.
- the slave device enters edge triggering for the first time, resets the timer to 0, and starts timing.
- the stop bit of the last byte in the synchronization data is not counted.
- the timer is controlled to stop timing, and the time is recorded as T 1 .
- FIG11 is a flow chart of a synchronous data processing method provided in an embodiment of the present application, and the synchronous data processing method is applied to a communication system, wherein the communication system includes a master device and a plurality of slave devices, and the master device is in communication connection with the plurality of slave devices.
- the synchronous data processing method may include the following steps S31-S39, and the order of the steps in the flow chart may be changed and some may be omitted according to different requirements.
- the slave device uses the total time of receiving the synchronous data in the edge trigger mode as the transmission time.
- the slave device sends the transmission time and sampling data to the master device.
- the master device calculates the relative time deviation between the multiple slave devices according to the transmission time sent by each slave device.
- steps S31-S39 correspond to steps S11-S16 and steps S21-S24 respectively.
- steps S11-S16 correspond to steps S11-S16 and steps S21-S24 respectively.
- steps S21-S24 correspond to steps S11-S16 and steps S21-S24 respectively.
- a certain slave device among the multiple slave devices is used as the reference device, and in some other embodiments, the master device may also be used as the reference device.
- the master device When the master device is used as the reference device, the relative time deviation between the duration of the preset time period and the transmission time sent by each slave device can be calculated according to the preset time period for the master device to send synchronous data, and the sampled data of each slave device can be processed according to the relative time deviation between the master device and each slave device to obtain the synchronous sampled data of multiple slave devices.
- the synchronous data processing device 20 can be divided into multiple functional modules according to the functions it performs.
- the functional modules may include: a synchronous frame sending module 201, a synchronous data sending module 202, a transmission time receiving module 203, a time deviation calculation module 204, a sampled data receiving module 205, and a sampled data processing module 206.
- the module referred to in this application refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in a memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
- the synchronization frame sending module 201 is used to send a preset synchronization frame to a plurality of slave devices, and the preset synchronization frame is used to instruct each slave device to enter an edge-triggered mode.
- the transmission time receiving module 203 is used to receive the transmission time sent by each slave device.
- the transmission time is the total time recorded by the slave device for receiving synchronous data in the edge trigger mode.
- the time deviation calculation module 204 is used to calculate the relative time deviation between multiple slave devices according to the transmission time sent by each slave device.
- the sampled data receiving module 205 is used to receive the sampled data returned by each slave device.
- the sampled data processing module 206 is used to process the sampled data according to the relative time deviation to obtain synchronous sampled data of multiple slave devices.
- Fig. 13 is a schematic diagram of the structure of a computer device 30 provided in an embodiment of the present application.
- the computer device 30 includes a memory 31, at least one processor 32, and at least one communication bus 33.
- FIG. 13 does not constitute a limitation of the embodiments of the present application, and may be either a bus structure or a star structure.
- the computer device 30 may also include more or less other hardware or software than shown in the figure, or a different component arrangement.
- the computer device 30 is a device that can automatically perform numerical calculations and/or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application-specific integrated circuits, programmable gate arrays, digital processors, and embedded devices.
- the computer device 30 may also include client devices, which include but are not limited to any electronic product that can interact with the client through a keyboard, mouse, remote control, touchpad, or voice-controlled device, such as a personal computer, tablet computer, smart phone, digital camera, etc.
- the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the computer device 30, etc.
- At least one processor 32 is the control core (Control Unit) of the computer device 30, and uses various interfaces and lines to connect various components of the entire computer device 30, and executes various functions and processes data of the computer device 30 by running or executing programs or modules stored in the memory 31, and calling data stored in the memory 31.
- at least one processor 32 executes the computer program stored in the memory, it implements all or part of the steps of the synchronous data processing method in the embodiment of the present application; or implements all or part of the functions of the synchronous data processing device.
- each functional module in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
- the above-mentioned integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional modules.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Data Mining & Analysis (AREA)
- Synchronisation In Digital Transmission Systems (AREA)
Abstract
Description
本申请属于通信技术领域,尤其涉及一种同步数据处理方法及设备。The present application belongs to the field of communication technology, and in particular, relates to a synchronous data processing method and device.
这里的陈述仅提供与本申请有关的背景信息,而不必然地构成示例性技术。The statements herein merely provide background information related to the present application and do not necessarily constitute exemplary techniques.
当前通信总线的应用场景广泛,通信总线可用于各类设备间通信。在实际应用中,在包括一个主设备控制和以多个从设备为数据采样单元的通信总线中,对各个从设备进行数据采样的时钟同步性要求高。The current communication bus has a wide range of application scenarios, and the communication bus can be used for communication between various devices. In practical applications, in a communication bus that includes a master device control and multiple slave devices as data sampling units, the clock synchronization of data sampling of each slave device is highly required.
然而,主设备和各个从设备上都有各自的时钟系统,且各个时钟系统之间存在一定的偏差,导致主设备难以从上述从设备得到高同步性的数据。However, the master device and each slave device have their own clock systems, and there is a certain deviation between the clock systems, which makes it difficult for the master device to obtain highly synchronized data from the slave devices.
发明内容Summary of the invention
根据本申请的各种实施例,提供一种同步数据处理方法、设备及存储介质。According to various embodiments of the present application, a synchronous data processing method, device and storage medium are provided.
第一方面,本申请实施例提供一种同步数据处理方法,应用于主设备,所述主设备与多个从设备通信连接,所述方法包括:In a first aspect, an embodiment of the present application provides a synchronous data processing method, which is applied to a master device, wherein the master device is communicatively connected with a plurality of slave devices, and the method includes:
发送预设同步帧至所述多个从设备,所述预设同步帧用于指示各所述从设备进入边沿触发模式;Sending a preset synchronization frame to the plurality of slave devices, wherein the preset synchronization frame is used to instruct each of the slave devices to enter an edge-triggered mode;
向所述多个从设备发送同步数据,所述同步数据用于指示各所述从设备在接收到所述同步数据的首个边沿时开始进行数据采样;Sending synchronization data to the multiple slave devices, wherein the synchronization data is used to instruct each of the slave devices to start data sampling when receiving a first edge of the synchronization data;
接收各所述从设备发送的传输时间,所述传输时间为所述从设备在所述边沿触发模式下记录的接收所述同步数据的总时间;Receiving the transmission time sent by each of the slave devices, wherein the transmission time is the total time recorded by the slave device for receiving the synchronization data in the edge-triggered mode;
根据每个所述从设备发送的传输时间计算所述多个从设备间的相对时间偏差;Calculating the relative time deviation between the plurality of slave devices according to the transmission time sent by each of the slave devices;
接收各所述从设备返回到的采样数据;Receiving the sampled data returned from each of the slave devices;
根据所述相对时间偏差对所述采样数据进行处理,得到所述多个从设备的同步采样数据。The sampled data are processed according to the relative time deviation to obtain synchronous sampled data of the multiple slave devices.
第二方面,本申请实施例提供一种同步数据处理方法,应用于从设备,所述从设备与主设备通信连接,所述方法包括:In a second aspect, an embodiment of the present application provides a synchronous data processing method, which is applied to a slave device, wherein the slave device is communicatively connected to a master device, and the method includes:
响应于所述主设备发送的预设同步帧,将接收模式更改为边沿触发模式;In response to a preset synchronization frame sent by the master device, changing a receiving mode to an edge-triggered mode;
在接收到所述主设备发送的同步数据的首个边沿时开始进行数据采样,得到采样数据;Starting data sampling upon receiving the first edge of the synchronization data sent by the master device to obtain sampled data;
将在所述边沿触发模式下接收所述同步数据的总时间作为传输时间,并将所述传输时间发送至所述主设备;using the total time of receiving the synchronization data in the edge-triggered mode as the transmission time, and sending the transmission time to the master device;
将所述采样数据发送至所述主设备,以使所述主设备基于每个所述从设备发送的传输时间计算多个从设备间的相对时间偏差,并根据所述相对时间偏差对所述采样数据进行处理,得到所述多个从设备的同步采样数据。The sampling data is sent to the master device so that the master device calculates the relative time deviation between multiple slave devices based on the transmission time sent by each slave device, and processes the sampling data according to the relative time deviation to obtain synchronous sampling data of the multiple slave devices.
第三方面,本申请实施例提供一种同步数据处理方法,应用于通信系统中,所述通信 系统包括主设备与多个从设备,所述主设备与多个所述从设备通信连接,所述方法包括:In a third aspect, an embodiment of the present application provides a synchronous data processing method, which is applied to a communication system, wherein the communication system includes a master device and multiple slave devices, and the master device is communicatively connected with the multiple slave devices, and the method includes:
所述主设备向所述多个从设备发送预设同步帧;The master device sends a preset synchronization frame to the multiple slave devices;
所述从设备响应于所述主设备发送的预设同步帧,将接收模式更改为边沿触发模式;The slave device changes the receiving mode to the edge triggered mode in response to the preset synchronization frame sent by the master device;
所述主设备向所述多个从设备发送同步数据;The master device sends synchronization data to the multiple slave devices;
所述从设备在接收到所述同步数据的首个边沿时开始进行数据采样,得到采样数据;The slave device starts data sampling upon receiving the first edge of the synchronization data to obtain sampled data;
所述从设备将在所述边沿触发模式下接收所述同步数据的总时间作为传输时间;The slave device uses the total time of receiving the synchronization data in the edge-triggered mode as the transmission time;
所述从设备向所述主设备发送所述传输时间以及所述采样数据;The slave device sends the transmission time and the sampling data to the master device;
所述主设备接收所述多个从设备发送的传输时间以及采样数据;The master device receives the transmission time and sampling data sent by the multiple slave devices;
所述主设备根据每个所述从设备发送的传输时间计算所述多个从设备间的相对时间偏差;The master device calculates the relative time deviation between the plurality of slave devices according to the transmission time sent by each of the slave devices;
所述主设备根据所述相对时间偏差对所述采样数据进行处理,得到所述多个从设备的同步采样数据。The master device processes the sampled data according to the relative time deviation to obtain the synchronous sampled data of the plurality of slave devices.
第四方面,本申请实施例提供一种计算机设备,所述计算机设备包括处理器与存储器,所述处理器用于执行所述存储器中存储的计算机程序时实现上述同步数据处理方法。In a fourth aspect, an embodiment of the present application provides a computer device, comprising a processor and a memory, wherein the processor is configured to implement the above-mentioned synchronous data processing method when executing a computer program stored in the memory.
第五方面,本申请实施例提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现上述同步数据处理方法。In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned synchronous data processing method is implemented.
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其他特征、目的和优点将从说明书、附图以及权利要求书变得明显。The details of one or more embodiments of the present application are set forth in the following drawings and description. Other features, objects, and advantages of the present application will become apparent from the description, drawings, and claims.
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
图1为本申请一实施例提供的同步数据处理方法的应用环境图。FIG. 1 is a diagram showing an application environment of a synchronous data processing method provided in an embodiment of the present application.
图2为本申请一实施例提供的同步数据处理方法的流程图。FIG. 2 is a flowchart of a synchronous data processing method provided in an embodiment of the present application.
图3为本申请一实施例提供同步数据在总线上传输时的信号波形示意图。FIG. 3 is a schematic diagram of signal waveforms when synchronous data is transmitted on a bus according to an embodiment of the present application.
图4为本申请一实施例提供的相对时间偏差的计算流程图。FIG. 4 is a flow chart of calculating a relative time deviation according to an embodiment of the present application.
图5为本申请一实施例提供的同步采样数据的确定流程图。FIG5 is a flowchart of determining synchronous sampling data provided by an embodiment of the present application.
图6为本申请另一实施例提供的同步数据处理方法的流程示意图。FIG6 is a flow chart of a synchronous data processing method provided in another embodiment of the present application.
图7为本申请一实施例提供的边沿触发模式的触发条件流程图。FIG. 7 is a flow chart of trigger conditions of an edge-triggered mode provided in an embodiment of the present application.
图8为本申请一实施例提供的传输时间的计算流程图。FIG8 is a flow chart of calculating the transmission time provided in an embodiment of the present application.
图9为本申请一实施例提供的同步数据结束边沿的确定流程图。FIG. 9 is a flowchart of determining the end edge of synchronization data provided in an embodiment of the present application.
图10为本申请一实施例提供的传输时间的确定流程图。FIG. 10 is a flow chart of determining the transmission time according to an embodiment of the present application.
图11为本申请再一实施例提供的同步数据处理方法的流程示意图。FIG. 11 is a flow chart of a synchronous data processing method provided in yet another embodiment of the present application.
图12为本申请一实施例提供的同步数据处理装置的结构示意图。FIG. 12 is a schematic diagram of the structure of a synchronous data processing device provided in an embodiment of the present application.
图13为本申请一实施例提供的计算机设备的结构。FIG. 13 is a diagram showing the structure of a computer device according to an embodiment of the present application.
为了能够更清楚地理解本申请的上述目的、特征和优点,下面结合附图和具体实施例对本申请进行详细描述。需要说明的是,在不冲突的情况下,本申请的实施例及实施例中的特征可以相互组合。In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the present application is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
在下面的描述中阐述了很多具体细节以便于充分理解本申请,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In the following description, many specific details are set forth to facilitate a full understanding of the present application. The described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中在本申请的说明书中所使用的术语只是为了描述具体的实施例的目的,不是旨在于限制本申请。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.
通信总线的应用场景广泛,可用于各类设备间通信。在实际应用中,在采用一个主设备和多个从设备的通信总线网络拓扑中,对各个从设备进行数据采样的时钟同步性要求高。然而,主设备和各个从设备上都有各自的时钟系统,且各个时钟系统之间存在一定的偏差,导致主设备难以从上述从设备得到高同步性的数据。Communication buses have a wide range of application scenarios and can be used for communication between various devices. In practical applications, in a communication bus network topology with one master device and multiple slave devices, the clock synchronization of data sampling for each slave device is highly required. However, the master device and each slave device have their own clock systems, and there is a certain deviation between each clock system, which makes it difficult for the master device to obtain highly synchronized data from the above slave devices.
其中,按照各类设备间传输的信息种类,通信总线可以划分为数据总线、地址总线和控制总线,分别用于传输数据、数据地址以及控制信号。Among them, according to the type of information transmitted between various devices, the communication bus can be divided into a data bus, an address bus and a control bus, which are used to transmit data, data addresses and control signals respectively.
以通信总线为RS485总线为例,结合图1说明本申请实施例提供的同步数据处理方法的应用环境图。主设备和多个从设备通过RS485总线通信连接,从设备的数量不做具体限制。主设备与各个从设备均以单片机为控制单元,单片机上设有各自的时钟系统,例如晶振。当通过RS485总线在各类设备间传输数据时,由于各个时钟系统之间存在一定的偏差,导致主设备难以从上述从设备得到高同步性的数据。Taking the communication bus as RS485 bus as an example, the application environment diagram of the synchronous data processing method provided by the embodiment of the present application is illustrated in conjunction with Figure 1. The master device and multiple slave devices are connected via RS485 bus communication, and the number of slave devices is not specifically limited. The master device and each slave device are controlled by a single-chip microcomputer, and the single-chip microcomputer is provided with a respective clock system, such as a crystal oscillator. When data is transmitted between various devices via the RS485 bus, due to certain deviations between the various clock systems, it is difficult for the master device to obtain highly synchronized data from the above-mentioned slave devices.
基于上述问题,本申请实施例提供一种同步数据处理方法,使得主设备能够从各个从设备上得到高同步性的数据。Based on the above problems, an embodiment of the present application provides a synchronous data processing method, so that a master device can obtain highly synchronized data from each slave device.
本申请实施例提供的同步数据处理方法可以由计算机设备执行,相应地,同步数据处理装置运行于计算机设备中。图2是本申请实施例提供的同步数据处理方法的流程示意图,该同步数据处理方法应用于主设备。如图2所示,同步数据处理方法可以包括如下步骤S11-S16,根据不同的需求,该流程图中步骤的顺序可以改变,某些可以省略。The synchronous data processing method provided in the embodiment of the present application can be executed by a computer device, and accordingly, the synchronous data processing device runs in the computer device. FIG. 2 is a flow chart of the synchronous data processing method provided in the embodiment of the present application, and the synchronous data processing method is applied to the master device. As shown in FIG. 2, the synchronous data processing method may include the following steps S11-S16. According to different requirements, the order of the steps in the flow chart can be changed, and some can be omitted.
S11,发送预设同步帧至多个从设备,预设同步帧用于指示各从设备进入边沿触发模式。S11, sending a preset synchronization frame to multiple slave devices, where the preset synchronization frame is used to instruct each slave device to enter an edge-triggered mode.
在本申请的至少一实施例中,预设同步帧为自定义设置格式的数据帧。例如,预设同步帧可以包含一个或多个字节,每个字节可以包含起始位、数据位以及停止位,起始位、数据位以及停止位的具体位数可以自定义设置。在一些实施例中,预设同步帧的字节中还可以包括校验位。以RS485总线通信为例,1个字节可以包括10比特。主设备在同一时间点将预设同步帧发送至多个从设备中,从设备在接收到预设同步帧后,将接收模式更改为边沿触发模式。In at least one embodiment of the present application, the preset synchronization frame is a data frame of a custom setting format. For example, the preset synchronization frame can include one or more bytes, each byte can include a start bit, a data bit and a stop bit, and the specific number of bits of the start bit, the data bit and the stop bit can be customized. In some embodiments, the bytes of the preset synchronization frame can also include a check bit. Taking RS485 bus communication as an example, 1 byte can include 10 bits. The master device sends the preset synchronization frame to multiple slave devices at the same time point, and the slave device changes the receiving mode to the edge triggered mode after receiving the preset synchronization frame.
可以理解,在进入边沿触发模式之前,从设备默认工作在串口接收模式。以RS485总线为例,在本实施例中,串口接收模式是指从设备的RS485总线接收端口在接收到完整的1个字节数据后,才通知应用程序进行执行相应的操作。边沿触发模式是指在从设备的RS485总线接收端口接收到的数据发生电平变化时,会触发中断,执行中断处理函数,进行相应的操作,例如,数据采样。电平变化可以是指数据由高电平变为低电平,或者,数据由低电平变为高电平。It can be understood that before entering the edge-triggered mode, the slave device defaults to working in the serial port receiving mode. Taking the RS485 bus as an example, in this embodiment, the serial port receiving mode means that the RS485 bus receiving port of the slave device notifies the application to perform the corresponding operation only after receiving a complete 1-byte data. The edge-triggered mode means that when the data received by the RS485 bus receiving port of the slave device changes in level, an interrupt will be triggered, an interrupt processing function will be executed, and a corresponding operation, such as data sampling, will be performed. The level change can refer to the data changing from a high level to a low level, or the data changing from a low level to a high level.
可以理解,在一些实施例中,多个从设备用于数据采样,主设备用于从各个从设备间得到采样数据。以RS485总线为例,从设备进行数据采样后,通过RS485总线向主设备上报采样数据。It is understood that in some embodiments, multiple slave devices are used for data sampling, and the master device is used to obtain sampled data from each slave device. Taking the RS485 bus as an example, after the slave device samples the data, it reports the sampled data to the master device via the RS485 bus.
S12,向多个从设备发送同步数据,同步数据用于指示各从设备在接收到同步数据的首个边沿时开始进行数据采样。S12, sending synchronization data to multiple slave devices, where the synchronization data is used to instruct each slave device to start data sampling when receiving the first edge of the synchronization data.
在本申请的至少一实施例中,主设备在预设时间段内同时向多个从设备发送同步数据,预设时间段为预先设置的发送同步数据的时长。同步数据是指预设数量的字节,预设数量为预先设置的。例如,预设时间段为2毫秒,预设数量可以为1000,,则表示主设备将在未来的2毫秒内发送1000个字节的同步数据,从设备将在未来的2毫秒内准备随时接收1000字节的同步数据,直至接收完毕。预设时间和预设数量在实际应用中可根据需求进行设置或调整。In at least one embodiment of the present application, the master device simultaneously sends synchronization data to multiple slave devices within a preset time period, and the preset time period is a preset duration for sending synchronization data. Synchronous data refers to a preset number of bytes, and the preset number is preset. For example, the preset time period is 2 milliseconds, and the preset number can be 1000, which means that the master device will send 1000 bytes of synchronization data in the next 2 milliseconds, and the slave device will be ready to receive 1000 bytes of synchronization data at any time in the next 2 milliseconds until the reception is completed. The preset time and preset number can be set or adjusted according to needs in actual applications.
如前所述,每个字节可以包含若干个比特位,例如,包括起始位、数据位以及停止位,其中,起始位与停止位可以为1比特,数据位可以为8比特。在一些实施例中,还可以包括校验位,则此时,起始位和停止位可以为1位,例如,只设置起始位或只设置停止位。As mentioned above, each byte may include a number of bits, for example, including a start bit, a data bit, and a stop bit, wherein the start bit and the stop bit may be 1 bit, and the data bit may be 8 bits. In some embodiments, a check bit may also be included, in which case the start bit and the stop bit may be 1 bit, for example, only the start bit or only the stop bit may be set.
可以理解,对于同步数据,每个字节的比特的值均不同,如此,每次从上一个比特进入当前比特时,会产生上升沿或下降沿,则从设备可以确定接收到的比特数量。结合图3说明本申请实施例提供的从设备在接收到同步数据时的边沿变化示意图。示例性地,从设备在未接收到同步数据前,其总线接口端口为默认电平,例如,高电平。从设备在接收到同步数据的第1个字节的起始位时,起始位为0,则数据发生电平变化,由高电平变为低电平从设备可以在P1处记录到下降沿,该下降沿也是同步数据的首个边沿。之后,从设备接收同步数据的第1个字节的第一个数据位1,数据再次发生电平变化,由低电平变为高电平,从设备可以在P2处记录到上升沿,以此类推,在此不做赘述。从设备在接收到的同步数据的首个边沿时,触发中断,执行中断处理函数。之后,从设备开始进行数据采样,采集各通道数据。It can be understood that for synchronous data, the value of the bit of each byte is different. In this way, each time the current bit is entered from the previous bit, a rising edge or a falling edge will be generated, and the slave device can determine the number of bits received. In conjunction with Figure 3, the schematic diagram of the edge change of the slave device when receiving synchronous data provided by the embodiment of the present application is described. Exemplarily, before the slave device receives the synchronous data, its bus interface port is a default level, for example, a high level. When the slave device receives the start bit of the first byte of the synchronous data, the start bit is 0, then the data level changes, from a high level to a low level, and the slave device can record the falling edge at P1, which is also the first edge of the synchronous data. Afterwards, the slave device receives the first data bit 1 of the first byte of the synchronous data, and the data level changes again, from a low level to a high level, and the slave device can record the rising edge at P2, and so on, which will not be repeated here. At the first edge of the received synchronous data, the slave device triggers an interrupt and executes an interrupt processing function. Afterwards, the slave device starts data sampling and collects data from each channel.
本申请实施例中,主设备向各个从设备发送同步数据,并控制各个从设备在接收到同步数据的首个边沿时开始进行数据采样。由于边沿触发的时间极短,因此,可以让各个从设备在近乎相同的时间启动采样,确保各个从设备启动采样的同步性高。In the embodiment of the present application, the master device sends synchronization data to each slave device, and controls each slave device to start data sampling when receiving the first edge of the synchronization data. Since the edge triggering time is extremely short, each slave device can start sampling at almost the same time, ensuring high synchronization of starting sampling by each slave device.
S13,接收各从设备发送的传输时间,传输时间为从设备在边沿触发模式下记录的接收同步数据的总时间。S13, receiving the transmission time sent by each slave device, where the transmission time is the total time recorded by the slave device for receiving synchronous data in the edge trigger mode.
在本申请的至少一实施例中,各个从设备均有各自的时钟系统。各个从设备在接收到同步数据的第1个字节的起始位时,按照各自的时钟系统开始计时,计算从第1个字节的起始位到最后一个字节的停止位的总时间,并将总时间作为各个从设备的传输时间。在本实施例中,最后一个的停止位不计入。假设同步数据的字节数为1000,每个字节包括10比特则从设备记录接收同步数据的总时间为接收(10*1000-1)比特的总时间。In at least one embodiment of the present application, each slave device has its own clock system. When each slave device receives the start bit of the first byte of the synchronization data, it starts timing according to its own clock system, calculates the total time from the start bit of the first byte to the stop bit of the last byte, and uses the total time as the transmission time of each slave device. In this embodiment, the last stop bit is not counted. Assuming that the number of bytes of the synchronization data is 1000, and each byte includes 10 bits, the total time recorded by the slave device for receiving the synchronization data is the total time for receiving (10*1000-1) bits.
示例性地,以同步数据为1000个字节,从设备的数量为2个(分别为从设备A与从设备B)为例,从设备A在接收到同步数据的第1个字节的起始位时开始计时,在接收到(10*1000-1)个比特时结束计时,将计时时间记录为为T A,则从设备A记录的接收同步数据的总时间即为T A。同样地,从设备B在接收到同步数据的第1个字节的起始位时开始计时,在接收到(10*1000-1)个比特时结束计时,将计时时间记录为T B,从设备B记录的接 收同步数据的总时间即为T B。 For example, if the synchronization data is 1000 bytes and there are 2 slave devices (slave device A and slave device B), slave device A starts timing when it receives the start bit of the first byte of the synchronization data, and ends timing when it receives (10*1000-1) bits, and records the timing time as T A. Then, the total time for receiving the synchronization data recorded by slave device A is T A. Similarly, slave device B starts timing when it receives the start bit of the first byte of the synchronization data, and ends timing when it receives (10*1000-1) bits, and records the timing time as T B. The total time for receiving the synchronization data recorded by slave device B is T B.
S14,根据每个从设备发送的传输时间计算多个从设备间的相对时间偏差。S14, calculating the relative time deviation between the multiple slave devices according to the transmission time sent by each slave device.
在本申请的至少一实施例中,由于各个从设备上均设有时钟系统,各个时钟系统间存在一定的偏差,因此每个从设备按各自的时钟系统计时也会存在偏差。在此基础上,每个从设备按约定采样间隔进行数据采样,每个从设备的采样间隔是存在偏差的,从而导致采样数据的时刻也存在一定偏差。但是,由于时钟系统所带来的偏差是固定的,因此,在接收同步数据时,也同样存在该偏差。仍以同步数据为1000个字节,从设备的数量为2个(分别为从设备A与从设备B)为例,从设备A记录的传输时间T A与从设备B记录的传输时间T B并不相同,存在时间偏差,该偏差正是由各个从设备的时钟系统所导致。 In at least one embodiment of the present application, since each slave device is provided with a clock system, there is a certain deviation between each clock system, so each slave device will also have a deviation according to its own clock system timing. On this basis, each slave device performs data sampling according to the agreed sampling interval, and the sampling interval of each slave device is biased, so that the moment of sampling data also has a certain deviation. However, since the deviation caused by the clock system is fixed, therefore, when receiving synchronous data, this deviation also exists. Still taking the synchronous data as 1000 bytes, the number of slave devices is 2 (slave device A and slave device B respectively) as an example, the transmission time TA recorded by slave device A is not the same as the transmission time TB recorded by slave device B, and there is a time deviation, which is caused by the clock system of each slave device.
在一实施例中,相对时间偏差是以多个从设备中的某一从设备为基准设备,按照预设相对时间偏差计算公式计算出的其余从设备相对于该基准设备的时间偏差。预设相对时间偏差计算公式可进行预先设置。示例性地,以通信总线包含从设备A与从设备B为例,相对时间偏差可以是指从设备A相对从设备B的时间偏差,或者是指从设备B相对从设备A时间偏差,在此不做限制。假设从设备B相对从设备A的时间偏差为ΔT BA,则: In one embodiment, the relative time deviation is the time deviation of the remaining slave devices relative to the reference device calculated according to a preset relative time deviation calculation formula, with one of the multiple slave devices as the reference device. The preset relative time deviation calculation formula can be preset. Exemplarily, taking the communication bus including slave device A and slave device B as an example, the relative time deviation can refer to the time deviation of slave device A relative to slave device B, or the time deviation of slave device B relative to slave device A, which is not limited here. Assuming that the time deviation of slave device B relative to slave device A is ΔT BA , then:
ΔT BA=(T B-T A)/T A。 ΔT BA =( TB - TA )/ TA .
S15,接收各从设备返回到的采样数据。S15, receiving the sampled data returned from each slave device.
在本申请的至少一实施例中,从设备在采样数据时,可以利用DMA(Direct Memory Access,直接存储器访问)通道控制ADC(Analog-to-Digital Converter,模数转换器)进行采样,得到采样数据。利用DMA通道控制ADC进行采样的方式在本实施例中不进行限定,可以为任一种现有的技术,在此不做赘述。In at least one embodiment of the present application, when sampling data from a device, a DMA (Direct Memory Access) channel can be used to control an ADC (Analog-to-Digital Converter) to perform sampling to obtain sampled data. The method of using a DMA channel to control the ADC for sampling is not limited in this embodiment and can be any existing technology, which will not be described in detail here.
在一实施例中,各从设备均以触发中断,执行中断处理函数的时刻为数据采样的起始时刻,设定相同的采样间隔进行数据采样。可以理解,由于边沿触发的时间极短,因此,各个从设备在近乎相同的时间启动采样。采样间隔可进行预先设置,例如,采样间隔为1ms,在此不做限制。In one embodiment, each slave device uses the time when the interrupt is triggered and the interrupt processing function is executed as the starting time of data sampling, and sets the same sampling interval to perform data sampling. It can be understood that since the edge triggering time is very short, each slave device starts sampling at almost the same time. The sampling interval can be preset, for example, the sampling interval is 1ms, which is not limited here.
在一实施例中,在主设备向从设备发送同步数据中最后一个字节后,此时同步流程结束。后续各从设备将采样数据传输至主设备。In one embodiment, after the master device sends the last byte of the synchronization data to the slave device, the synchronization process ends. Subsequently, each slave device transmits the sampled data to the master device.
可以理解,同步数据发送完毕后,从设备可以继续进行数据采样,例如,在预定时间内进行定时采样,或者按预设采样间隔持续采样,直至主设备发送停止采样通知。It can be understood that after the synchronous data is sent, the slave device can continue to sample data, for example, perform timed sampling within a predetermined time, or continue sampling at a preset sampling interval, until the master device sends a stop sampling notification.
S16,根据相对时间偏差对采样数据进行处理,得到多个从设备的同步采样数据。S16, processing the sampled data according to the relative time deviation to obtain synchronous sampled data of multiple slave devices.
在本申请的至少一实施例中,由于各从设备间的时钟系统存在一定的时间偏差。因此,各从设备间的采样间隔实际也存在偏差,从而导致各从设备在相同的起始时刻、按照相同的采样间隔进行数据采样时,最终的采样数据并不同步。以多个从设备中的某一从设备为基准设备,对其余从设备的采样间隔进行修正,之后根据采样间隔修正采样数据中每个采样数据点相对起始时刻的采样时刻,能够得到其余从设备修正后的采样数据,此时,各个从设备的采样数据是同步的。In at least one embodiment of the present application, since there is a certain time deviation in the clock system between the slave devices, there is actually a deviation in the sampling interval between the slave devices, which results in that when the slave devices perform data sampling at the same starting time and the same sampling interval, the final sampled data are not synchronized. A slave device among the multiple slave devices is used as a reference device, and the sampling interval of the remaining slave devices is corrected. Then, the sampling time of each sampled data point in the sampled data relative to the starting time is corrected according to the sampling interval, and the corrected sampled data of the remaining slave devices can be obtained. At this time, the sampled data of each slave device is synchronized.
本申请实施例提供的上述同步数据处理方法,主设备通过预设同步帧控制各个从设备进入边沿触发状态。之后,主设备向各个从设备发送同步数据,并控制各个从设备在接收到同步数据的首个边沿时开始进行数据采样,由于边沿触发的时间极短,因此,可以让各个从设备在近乎相同的时间启动采样,使得各个从设备采样启动的同步性高。后续,主设 备接收各个从设备发送的传输时间,并根据传输时间确定各个从设备间的相对时间偏差,根据相对时间偏差对各个从设备的采样数据进行处理,从而得到高同步性的数据。In the above-mentioned synchronous data processing method provided by the embodiment of the present application, the master device controls each slave device to enter the edge-triggered state by presetting the synchronization frame. Afterwards, the master device sends synchronization data to each slave device, and controls each slave device to start data sampling when receiving the first edge of the synchronization data. Since the edge triggering time is extremely short, each slave device can start sampling at almost the same time, so that the synchronization of sampling startup of each slave device is high. Subsequently, the master device receives the transmission time sent by each slave device, and determines the relative time deviation between each slave device according to the transmission time, and processes the sampled data of each slave device according to the relative time deviation, thereby obtaining highly synchronized data.
以下结合图4说明本申请实施例提供的相对时间偏差的计算流程,在一些实施例中,根据每个从设备发送的传输时间计算多个从设备间的相对时间偏差,包括:The following is a flow chart of calculating the relative time deviation provided by an embodiment of the present application in conjunction with FIG. 4. In some embodiments, the relative time deviation between multiple slave devices is calculated according to the transmission time sent by each slave device, including:
S140,从各从设备中选取第一从设备,并确定第一从设备发送的传输时间。S140, selecting a first slave device from the slave devices, and determining a transmission time sent by the first slave device.
在一实施例中,第一从设备为基准设备。第一从设备的选取方式可以为指定的,也可以是随机的。例如,存在从设备A与从设备B,可以指定从设备A作为第一从设备;或者,在从设备A与从设备B中随机选取一从设备作为第一从设备。In one embodiment, the first slave device is a reference device. The first slave device may be selected in a designated manner or randomly. For example, if there are slave devices A and B, slave device A may be designated as the first slave device; or, a slave device may be randomly selected from slave devices A and B as the first slave device.
S141,将各从设备中除第一从设备外的其他从设备确定为第二从设备,并计算各第二从设备发送的传输时间与第一从设备发送的传输时间的相对时间偏差。S141, determining the slave devices other than the first slave device among the slave devices as second slave devices, and calculating the relative time deviation between the transmission time sent by each second slave device and the transmission time sent by the first slave device.
在一实施例中,第二从设备的数量可以为1个,也可以为多个,在此不做限制。相对时间偏差可以通过预设相对时间偏差计算公式计算得出。示例性地,仍以从设备的数量为2个(分别为从设备A与从设备B)为例,从设备A的传输时间为T A,例如,T A为10085,从设备B的传输时间为T B,例如,T B为99754。从设备B与从设备A发送的传输时间的相对时间偏差ΔT BA为(T B-T A)/T A,也即-1.1%。可以理解,-1.1%表示从设备B比从设备A慢1.1%。 In one embodiment, the number of the second slave devices may be one or more, which is not limited herein. The relative time deviation may be calculated by a preset relative time deviation calculation formula. Exemplarily, still taking the number of slave devices as two (slave device A and slave device B), the transmission time of slave device A is TA , for example, TA is 10085, and the transmission time of slave device B is TB , for example, TB is 99754. The relative time deviation ΔT BA between the transmission time sent by slave device B and slave device A is ( TB -TA )/ TA , which is -1.1%. It can be understood that -1.1% means that slave device B is 1.1% slower than slave device A.
以下结合图5说明本申请实施例提供的同步采样数据的确定流程,在一些实施例中,根据相对时间偏差对采样数据进行处理,得到多个从设备的同步采样数据,包括:The following is a description of the process for determining synchronous sampling data provided by an embodiment of the present application in conjunction with FIG. 5. In some embodiments, the sampling data is processed according to the relative time deviation to obtain synchronous sampling data of multiple slave devices, including:
S160,确定数据采样的起始时刻与第一采样间隔。S160, determining a start time of data sampling and a first sampling interval.
在一实施例中,数据采样的起始时刻与采样间隔均为预先设置的,例如,采样间隔为1ms。各从设备数据采样的起始时刻是相同的,也即接收到同步数据的首个边沿时对应的时刻。可以理解,对于每个从设备而言,其约定的采样间隔应当是相同的,但由于各个从设备时钟偏差,导致每个从设备的实际采样间隔产生了偏差。此处,第一采样间隔是指第一从设备的采样间隔,当以第一从设备作为基准设备时,则默认其采样间隔为准确的,将以第一设备的采样间隔为基准修正其他从设备的采样间隔偏差。In one embodiment, the starting time and sampling interval of data sampling are both pre-set, for example, the sampling interval is 1ms. The starting time of data sampling of each slave device is the same, that is, the time corresponding to the first edge of the synchronization data is received. It can be understood that for each slave device, its agreed sampling interval should be the same, but due to the clock deviation of each slave device, the actual sampling interval of each slave device has a deviation. Here, the first sampling interval refers to the sampling interval of the first slave device. When the first slave device is used as the reference device, its sampling interval is assumed to be accurate, and the sampling interval deviation of other slave devices will be corrected based on the sampling interval of the first device.
S161,根据第一采样间隔与相对时间偏差确定第二从设备的第二采样间隔。S161, determining a second sampling interval of a second slave device according to the first sampling interval and the relative time deviation.
在一实施例中,如前所示,由于各从设备间存在相对时间偏差,因此,各从设备间的实际采样间隔实际也存在偏差,需根据第一采样间隔与相对时间偏差确定第二从设备的第二采样间隔,该第二采样间隔是第二从设备以第一从设备的时钟为基准修正后的采样间隔。示例性地,假设从设备B比从设备A的时钟慢1.1%,从设备A的第一采样间隔为100个时钟周期,则从设备B的第二采样间隔为99个时钟周期。In one embodiment, as shown above, since there is a relative time deviation between the slave devices, the actual sampling intervals between the slave devices also actually have deviations, and the second sampling interval of the second slave device needs to be determined based on the first sampling interval and the relative time deviation. The second sampling interval is the sampling interval of the second slave device corrected based on the clock of the first slave device. Exemplarily, assuming that the clock of slave device B is 1.1% slower than that of slave device A, the first sampling interval of slave device A is 100 clock cycles, and the second sampling interval of slave device B is 99 clock cycles.
S162,根据第二采样间隔修正第二从设备的采样数据中的每个采样数据点相对起始时刻的采样时刻,得到第二从设备的修正后的采样数据。S162, correcting the sampling time of each sampling data point in the sampling data of the second slave device relative to the starting time according to the second sampling interval, to obtain corrected sampling data of the second slave device.
在一实施例中,假设各从设备每100个从站时钟采样1次得到一个数据采样点,则每个采样数据点均存在对应的采样时刻。根据第二采样间隔修正第二从设备的采样数据中每个采样数据点相对起始时刻的采样时刻,得到第二从设备修正后的采样数据。In one embodiment, assuming that each slave device samples once every 100 slave station clocks to obtain a data sampling point, each sampled data point has a corresponding sampling time. The sampling time of each sampled data point in the sampled data of the second slave device relative to the starting time is corrected according to the second sampling interval to obtain the corrected sampled data of the second slave device.
示例性地,以从设备的数量为2个(分别为从设备A与从设备B)为例,设定采样间隔为100个时钟周期,则各从设备每100个从站时钟周期采样1次。可以理解,在从设备A与从设备B不存在时间偏差时,假设从设备A采样的第100个采样数据点对应时刻A(相 对起始时刻),则从设备B采样的第100个采样数据点也应当对应时刻A,也即从设备A和从设备B的第100个采样点对应的是同一个时刻。然而,从设备A与从设备B间存在时间偏差,则上述对应关系将会存在偏差。假设以从设备A为基准设备,从设备B相对从设备A的时间偏差为1%,也即从设备B相比从设备A的时钟慢1%。此时,从设备A的第100个采样数据点,在该时刻A,实际对应从设备B采样的第99个采样数据点。因此,将从设备B的第99个采样数据点与从设备A的第100个采样数据点对应,实际相当于将从设备B的第99个采样点的采样时刻修正为时刻A,如此,可以得到从设备A和从设备B的同步采样数据。Exemplarily, taking the number of slave devices as 2 (slave device A and slave device B), the sampling interval is set to 100 clock cycles, and each slave device samples once every 100 slave station clock cycles. It can be understood that when there is no time deviation between slave device A and slave device B, assuming that the 100th sampled data point sampled from slave device A corresponds to time A (relative to the starting time), then the 100th sampled data point sampled from slave device B should also correspond to time A, that is, the 100th sampled points of slave devices A and slave devices B correspond to the same time. However, if there is a time deviation between slave device A and slave device B, there will be a deviation in the above correspondence. Assuming that slave device A is the reference device, the time deviation of slave device B relative to slave device A is 1%, that is, the clock of slave device B is 1% slower than that of slave device A. At this time, the 100th sampled data point of slave device A, at this time A, actually corresponds to the 99th sampled data point sampled from device B. Therefore, making the 99th sampling data point of slave device B correspond to the 100th sampling data point of slave device A is actually equivalent to correcting the sampling time of the 99th sampling point of slave device B to time A. In this way, the synchronous sampling data of slave devices A and B can be obtained.
S163,将第一从设备的采样数据确定为第一从设备的同步采样数据,以及,将第二从设备的修正后的采样数据确定为第二从设备的同步采样数据。S163, determining the sampled data of the first slave device as the synchronous sampled data of the first slave device, and determining the corrected sampled data of the second slave device as the synchronous sampled data of the second slave device.
可以理解,以第一从设备为基准设备,第一从设备的采样数据无需修正即可以作为同步采样数据。对于如第二从设备的其他从设备的采样数据,根据上述过程进行修正后得到的采样数据,则可以得到同步采样数据。It can be understood that, with the first slave device as the reference device, the sampling data of the first slave device can be used as synchronous sampling data without correction. For the sampling data of other slave devices such as the second slave device, the sampling data obtained after correction according to the above process can be obtained as synchronous sampling data.
图6是本申请实施例提供的同步数据处理方法的流程示意图,该同步数据处理方法应用于从设备。如图6所示,同步数据处理方法可以包括如下步骤S21-S24,根据不同的需求,该流程图中步骤的顺序可以改变,某些可以省略。Fig. 6 is a flowchart of a synchronous data processing method provided in an embodiment of the present application, and the synchronous data processing method is applied to a slave device. As shown in Fig. 6, the synchronous data processing method may include the following steps S21-S24. According to different requirements, the order of the steps in the flowchart may be changed, and some may be omitted.
S21,响应于主设备发送的预设同步帧,将接收模式更改为边沿触发模式。S21, in response to a preset synchronization frame sent by the master device, changing the receiving mode to an edge-triggered mode.
在本申请的至少一实施例中,主设备在同一时间点将预设同步帧发送至多个从设备中,从设备在接收到预设同步帧后,将接收模式更改为边沿触发模式。边沿触发模式是指在从设备的RS485总线接收端口接收到的数据发生电平变化时,会触发中断,执行中断处理函数,进行相应的操作,例如,数据采样。电平变化可以是指数据由高电平变为低电平,或者,数据由低电平变为高电平。In at least one embodiment of the present application, the master device sends a preset synchronization frame to multiple slave devices at the same time point, and the slave device changes the receiving mode to the edge-triggered mode after receiving the preset synchronization frame. The edge-triggered mode means that when the level of the data received by the RS485 bus receiving port of the slave device changes, an interrupt will be triggered, an interrupt processing function will be executed, and corresponding operations, such as data sampling, will be performed. The level change can refer to the data changing from a high level to a low level, or the data changing from a low level to a high level.
S22,在接收到主设备发送的同步数据的首个边沿时开始进行数据采样,得到采样数据。S22, starting data sampling when receiving the first edge of the synchronization data sent by the master device to obtain sampled data.
在本申请的至少一实施例中,从设备在接收到同步数据的首个边沿(也即第1个字节的起始位)时,数据发生电平变化,从设备在接收到的数据发生电平变化时,触发中断,执行中断处理函数。之后,从设备开始进行数据采样,采集各通道数据。In at least one embodiment of the present application, when the slave device receives the first edge of the synchronization data (i.e., the start bit of the first byte), the data level changes, and when the level of the received data changes, the slave device triggers an interrupt and executes an interrupt processing function. After that, the slave device starts data sampling and collects data from each channel.
在一实施例中,从设备在采样数据时,可以利用DMA(Direct Memory Access,直接存储器访问)通道控制ADC(Analog-to-Digital Converter,模数转换器)进行采样,得到采样数据。利用DMA通道控制ADC进行采样的方式为现有技术,在此不做赘述。In one embodiment, when the slave device samples data, it can use a DMA (Direct Memory Access) channel to control an ADC (Analog-to-Digital Converter) to perform sampling to obtain sampled data. The method of using a DMA channel to control an ADC for sampling is a prior art and will not be described in detail herein.
在一实施例中,各从设备均以触发中断,执行中断处理函数的时刻为数据采样的起始时刻,设定相同的采样间隔进行数据采样。可以理解,由于边沿触发的时间极短,因此,各个从设备在近乎相同的时间启动采样。采样间隔为预先设置的,例如,采样间隔为1ms,在此不做限制。In one embodiment, each slave device triggers an interrupt and executes an interrupt processing function as the start time of data sampling, and sets the same sampling interval for data sampling. It can be understood that since the edge triggering time is very short, each slave device starts sampling at almost the same time. The sampling interval is preset, for example, the sampling interval is 1ms, which is not limited here.
在一实施例中,在主设备向从设备发送同步数据中最后一个字节后,此时同步流程结束。后续各从设备将采样数据传输至主设备。In one embodiment, after the master device sends the last byte of the synchronization data to the slave device, the synchronization process ends. Subsequently, each slave device transmits the sampled data to the master device.
可以理解,同步数据发送完毕后,从设备可以继续进行数据采样,例如,在预定时间内进行定时采样,或者按预设采样间隔持续采样,直至主设备发送停止采样通知。It can be understood that after the synchronous data is sent, the slave device can continue to sample data, for example, perform timed sampling within a predetermined time, or continue sampling at a preset sampling interval, until the master device sends a stop sampling notification.
S23,将在边沿触发模式下接收同步数据的总时间作为传输时间,并将传输时间发送至 主设备。S23, takes the total time of receiving the synchronous data in the edge trigger mode as the transmission time, and sends the transmission time to the master device.
在本申请的至少一实施例中,各个从设备均有各自的时钟系统。各个从设备在接收到同步数据的第1个字节的起始位时,按照各自的时钟系统开始计时,计算从第1个字节的起始位到最后一个字节的停止位的总时间,并将总时间作为各个从设备的传输时间。在本实施例中,最后一个的停止位不计入。假设同步数据的字节数为1000,每个字节包括10比特则从设备记录接收同步数据的总时间为接收(10*1000-1)比特的总时间。In at least one embodiment of the present application, each slave device has its own clock system. When each slave device receives the start bit of the first byte of the synchronization data, it starts timing according to its own clock system, calculates the total time from the start bit of the first byte to the stop bit of the last byte, and uses the total time as the transmission time of each slave device. In this embodiment, the last stop bit is not counted. Assuming that the number of bytes of the synchronization data is 1000, and each byte includes 10 bits, the total time recorded by the slave device for receiving the synchronization data is the total time for receiving (10*1000-1) bits.
示例性地,从设备A在接收到同步数据的第1个字节的起始位时,在接收到(10*1000-1)个比特时结束计时,将计时时间记录为T A,则从设备A记录的接收同步数据的总时间即为T A。 Exemplarily, when slave device A receives the start bit of the first byte of synchronization data, it stops timing when it receives (10*1000-1) bits and records the timing time as TA . Then the total time for receiving synchronization data recorded by slave device A is TA .
S24,将采样数据发送至主设备,以使主设备基于每个从设备发送的传输时间计算多个从设备间的相对时间偏差,并根据相对时间偏差对采样数据进行处理,得到多个从设备的同步采样数据。S24, sending the sampled data to the master device, so that the master device calculates the relative time deviation between the multiple slave devices based on the transmission time sent by each slave device, and processes the sampled data according to the relative time deviation to obtain synchronous sampled data of the multiple slave devices.
在本申请的至少一实施例中,由于各个从设备上均设有时钟系统,各个时钟系统间存在一定的偏差,因此每个从设备按各自的时钟系统计时也会存在偏差。在此基础上,每个从设备按约定采样间隔进行数据采样,每个从设备的采样间隔是存在偏差的,从而导致采样数据的时刻也存在一定偏差。但是,由于时钟系统所带来的偏差是固定的,因此,在接收同步数据时,也同样存在该偏差。仍以同步数据为1000个字节,从设备的数量为2个(分别为从设备A与从设备B)为例,从设备A记录的传输时间T A与从设备B记录的传输时间T B并不相同,存在时间偏差,该偏差正是由各个从设备的时钟系统所导致。 In at least one embodiment of the present application, since each slave device is provided with a clock system, there is a certain deviation between each clock system, so each slave device will also have a deviation according to its own clock system timing. On this basis, each slave device performs data sampling according to the agreed sampling interval, and the sampling interval of each slave device is biased, so that the moment of sampling data also has a certain deviation. However, since the deviation caused by the clock system is fixed, therefore, when receiving synchronous data, this deviation also exists. Still taking the synchronous data as 1000 bytes, the number of slave devices is 2 (slave device A and slave device B respectively) as an example, the transmission time TA recorded by slave device A is not the same as the transmission time TB recorded by slave device B, and there is a time deviation, which is caused by the clock system of each slave device.
在一实施例中,主设备以多个从设备中的某一从设备为基准设备,按照预设相对时间偏差计算公式计算出的其余从设备相对该基准设备的时间偏差。预设相对时间偏差计算公式为预先设置的。由于各从设备间存在相对时间偏差,因此,各从设备间的采样间隔实际也存在偏差,从而导致各从设备在相同的起始时刻、按照相同的采样间隔进行数据采样时,最终的采样数据并不同步。以多个从设备中的某一从设备为基准设备,对其余从设备的采样间隔进行修正,之后根据采样间隔修正采样数据中每个采样数据点相对起始时刻的采样时刻,能够得到其余从设备修正后的采样数据,此时,各个从设备的采样数据是同步的。In one embodiment, the master device uses a slave device among multiple slave devices as a reference device, and calculates the time deviation of the remaining slave devices relative to the reference device according to a preset relative time deviation calculation formula. The preset relative time deviation calculation formula is pre-set. Since there is a relative time deviation between the slave devices, there is actually a deviation in the sampling interval between the slave devices, which causes the final sampling data to be not synchronized when the slave devices perform data sampling at the same starting time and the same sampling interval. Using a slave device among multiple slave devices as a reference device, the sampling interval of the remaining slave devices is corrected, and then the sampling time of each sampling data point in the sampling data relative to the starting time is corrected according to the sampling interval, and the corrected sampling data of the remaining slave devices can be obtained. At this time, the sampling data of each slave device is synchronized.
结合图7说明本申请实施例提供的边沿触发模式的触发条件,在响应于主设备发送的预设同步帧之后,方法还包括:The triggering condition of the edge triggering mode provided in the embodiment of the present application is illustrated in conjunction with FIG. 7 . After responding to the preset synchronization frame sent by the master device, the method further includes:
S210,确定预设同步帧对应的校验位。S210, determining a check bit corresponding to a preset synchronization frame.
在一实施例中,预设同步帧可以包含一个或多个字节,每个字节可以包含起始位、数据位以及停止位,起始位、数据位以及停止位的具体位数可以自定义设置。在一些实施例中,预设同步帧中的字节还可以包括校验位。In one embodiment, the preset synchronization frame may include one or more bytes, each byte may include a start bit, a data bit, and a stop bit, and the specific number of the start bit, the data bit, and the stop bit may be customized. In some embodiments, the bytes in the preset synchronization frame may also include a check bit.
S211,当校验位符合预设校验要求时,确定校验正确并更新接收模式为边沿触发模式。S211, when the check bit meets the preset check requirement, determine that the check is correct and update the receiving mode to the edge trigger mode.
在一实施例中,在接收预设同步帧前,各个从设备处于串口接收模式,也即,接收到完整数据帧后才响应该数据帧以执行相应操作。校验位用于确认当前预设同步帧接收完毕且接收正确,当预设校验位符合预设校验要求时,则可以确认预设同步帧已经接收完毕。此时,从设备将接收模式更新为边沿触发模式。当校验位未符合预设校验要求时,无需更新接收模式为边沿触发模式。In one embodiment, before receiving the preset synchronization frame, each slave device is in a serial port receiving mode, that is, it responds to the data frame to perform the corresponding operation only after receiving the complete data frame. The check bit is used to confirm that the current preset synchronization frame has been received and received correctly. When the preset check bit meets the preset check requirement, it can be confirmed that the preset synchronization frame has been received. At this time, the slave device updates the receiving mode to the edge trigger mode. When the check bit does not meet the preset check requirement, there is no need to update the receiving mode to the edge trigger mode.
结合图8说明本申请实施例提供的传输时间的计算流程,计算接收同步数据的总时间 作为传输时间,包括:The calculation process of the transmission time provided in the embodiment of the present application is illustrated in conjunction with FIG8 , and the total time of receiving the synchronization data is calculated as the transmission time, including:
S230,确定同步数据对应的比特数量。S230, determine the number of bits corresponding to the synchronization data.
在一实施例中,同步数据是指预设数量的字节,预设数量为预先设置的,例如,预设数量可以为1000。每个字节可以包含若干个比特位,例如,包括起始位、数据位以及停止位,其中,起始位与停止位可以为1比特,数据位可以为8比特。比特数量是指同步数据中的比特位的数量,当同步数据包含1000个字节,1个字节包含10个比特位时,考虑同步数据中最后1个字节的停止位不计入,比特数量为10*1000-1。In one embodiment, the synchronization data refers to a preset number of bytes, which is preset, for example, the preset number may be 1000. Each byte may include a number of bits, for example, a start bit, a data bit, and a stop bit, wherein the start bit and the stop bit may be 1 bit, and the data bit may be 8 bits. The number of bits refers to the number of bits in the synchronization data. When the synchronization data includes 1000 bytes and 1 byte includes 10 bits, the stop bit of the last byte in the synchronization data is not counted, and the number of bits is 10*1000-1.
S231,根据同步数据的首个边沿以及比特数量确定同步数据的结束边沿。S231, determining the end edge of the synchronization data according to the first edge of the synchronization data and the number of bits.
在一实施例中,主设备向各从设备传输同步数据中第1字节的起始位作为首个边沿,考虑同步数据中最后1个字节的停止位不计入,将同步数据中第10*1000-1个比特位作为结束边沿。In one embodiment, the master device transmits the start bit of the first byte of synchronization data to each slave device as the first edge, and considers that the stop bit of the last byte of synchronization data is not included, and the 10*1000-1th bit of the synchronization data is used as the end edge.
S232,确定接收到首个边沿与结束边沿之间的时间间隔为传输时间。S232, determining the time interval between the first edge received and the end edge received as the transmission time.
在一实施例中,以同步数据为1000个字节为例,从设备A在接收到同步数据的第1个字节的起始位时开始计时,在接收到(10*1000-1)个比特时结束计时,将计时时间记录为T A,从设备A记录的接收同步数据的总时间(也即传输时间)为T A。 In one embodiment, taking the synchronization data as 1000 bytes as an example, the slave device A starts timing when receiving the start bit of the first byte of the synchronization data, and stops timing when receiving (10*1000-1) bits, and records the timing time as TA . The total time (i.e., transmission time) for receiving the synchronization data recorded by the slave device A is TA .
结合图9说明本申请实施例提供的同步数据的结束边沿的确定流程,根据同步数据的首个边沿以及比特数量确定同步数据的结束边沿,包括:The process of determining the end edge of the synchronization data provided in the embodiment of the present application is described in conjunction with FIG. 9 . The process of determining the end edge of the synchronization data according to the first edge of the synchronization data and the number of bits includes:
S2310,当接收到同步数据的首个边沿时,启动计数器累计接收到的边沿的数量。S2310, when the first edge of the synchronization data is received, start a counter to accumulate the number of received edges.
在一实施例中,此处边沿是指上升沿或下降沿。如前所述,同步数据中,每个字节的每个比特的值都不同,也即,同步数据每个字节中每个比特的开始都是上升沿或下降沿。在接收到预同步帧后,从设备进入边沿触发模式。当主设备开始发送同步数据时,从设备在识别到首个上升沿或下降沿时,即可以确认该上升沿或下降沿为同步数据的首个边沿,启动计数器开始计数。可以理解,首个边沿的类型取决于起始位和停止位的设置,例如,若设置起始位的值为0,停止位为1,则首个边沿为下降沿,反之,则为上升沿。计数器用于记录从设备接收到同步数据中边沿的数量。当接收到同步数据的首个边沿(以首个边沿为下降沿为例)时,从设备第1次进入边沿触发,启动计数器从0开始计数;当从设备接收到第二个边沿(以第二个边沿为上升沿为例)时,从设备第2次进入边沿触发,计数加1,以此类推,计数器可以统计接收到的边沿数量,也即,接收到的同步数据的比特数量。In one embodiment, the edge here refers to a rising edge or a falling edge. As mentioned above, in the synchronization data, the value of each bit of each byte is different, that is, the beginning of each bit in each byte of the synchronization data is a rising edge or a falling edge. After receiving the pre-synchronization frame, the slave device enters the edge trigger mode. When the master device starts to send synchronization data, when the slave device identifies the first rising edge or falling edge, it can be confirmed that the rising edge or falling edge is the first edge of the synchronization data, and the counter is started to count. It can be understood that the type of the first edge depends on the setting of the start bit and the stop bit. For example, if the value of the start bit is set to 0 and the stop bit is 1, the first edge is a falling edge, otherwise, it is a rising edge. The counter is used to record the number of edges in the synchronization data received from the slave device. When the first edge of the synchronization data is received (taking the first edge as a falling edge as an example), the slave device enters edge triggering for the first time and starts counting from 0; when the slave device receives the second edge (taking the second edge as a rising edge as an example), the slave device enters edge triggering for the second time and the count is increased by 1, and so on. The counter can count the number of edges received, that is, the number of bits of synchronization data received.
在一实施例中,以同步数据为1000个字节,1个字节包含10个比特位为例,共包含10*1000个比特位。当从设备接收到10*1000个边沿时,计数器的数量为10*1000-1。In one embodiment, taking the synchronization data as 1000 bytes, where 1 byte contains 10 bits, a total of 10*1000 bits are contained. When the slave device receives 10*1000 edges, the number of counters is 10*1000-1.
S2311,当计数器的计数等于比特数量时,确定当前边沿为同步数据的结束边沿。S2311, when the count of the counter is equal to the number of bits, determine that the current edge is the end edge of the synchronization data.
在一实施例中,当同步数据包含1000个字节,1个字节包含10个比特位时,考虑同步数据中最后1个字节的停止位不计入,比特数量为10*1000-1。当计时器的计数也为10*1000-1时,确定当前边沿为同步数据的结束边沿。In one embodiment, when the synchronization data includes 1000 bytes and 1 byte includes 10 bits, the stop bit of the last byte in the synchronization data is not counted, and the number of bits is 10*1000-1. When the count of the timer is also 10*1000-1, the current edge is determined to be the end edge of the synchronization data.
结合图10说明本申请实施例提供的传输时间的确定流程,确定接收到首个边沿与结束边沿之间的时间间隔为传输时间,包括:The process of determining the transmission time provided in the embodiment of the present application is described in conjunction with FIG. 10 , and determining the time interval between the first edge received and the end edge received as the transmission time includes:
S2320,当接收到同步数据的首个边沿时,启动计时器进行计时。S2320: When the first edge of the synchronization data is received, start the timer to start timing.
在一实施例中,计时器用于记录从设备接收到同步数据中边沿的时间。当接收到同步数据的首个边沿(以首个边沿为下降沿为例)时,从设备第1次进入边沿触发,重置计时 器为0,开始计时。In one embodiment, the timer is used to record the time when the slave device receives the edge of the synchronization data. When the first edge of the synchronization data is received (taking the first edge as a falling edge as an example), the slave device enters edge triggering for the first time, resets the timer to 0, and starts timing.
S2321,当接收到同步数据的结束边沿时,停止计时。S2321, when the end edge of the synchronization data is received, stop timing.
在一实施例中,当同步数据包含1000个字节,1个字节包含10个比特位时,考虑同步数据中最后1个字节的停止位不计入,当接收到10*1000-1的结束边沿时,控制计时器停止计时,时间记作T 1。 In one embodiment, when the synchronization data includes 1000 bytes and 1 byte includes 10 bits, the stop bit of the last byte in the synchronization data is not counted. When the end edge of 10*1000-1 is received, the timer is controlled to stop timing, and the time is recorded as T 1 .
S2322,将计时器的计时时间确定为传输时间。S2322, determine the timing time of the timer as the transmission time.
在一实施例中,传输时间为T 1。 In one embodiment, the transmission time is T 1 .
图11是本申请实施例提供的同步数据处理方法的流程示意图,该同步数据处理方法应用于通信系统,通信系统包括主设备与多个从设备,主设备与多个从设备通信连接。如图11所示,同步数据处理方法可以包括如下步骤S31-S39,根据不同的需求,该流程图中步骤的顺序可以改变,某些可以省略。FIG11 is a flow chart of a synchronous data processing method provided in an embodiment of the present application, and the synchronous data processing method is applied to a communication system, wherein the communication system includes a master device and a plurality of slave devices, and the master device is in communication connection with the plurality of slave devices. As shown in FIG11 , the synchronous data processing method may include the following steps S31-S39, and the order of the steps in the flow chart may be changed and some may be omitted according to different requirements.
S31,主设备向多个从设备发送预设同步帧。S31, the master device sends a preset synchronization frame to multiple slave devices.
S32,从设备响应于主设备发送的预设同步帧,将接收模式更改为边沿触发模式。S32, the slave device changes the receiving mode to the edge triggering mode in response to the preset synchronization frame sent by the master device.
S33,主设备向多个从设备发送同步数据。S33, the master device sends synchronization data to multiple slave devices.
S34,从设备在接收到同步数据的首个边沿时开始进行数据采样,得到采样数据。S34, the slave device starts data sampling upon receiving the first edge of the synchronization data to obtain sampled data.
S35,从设备将在边沿触发模式下接收同步数据的总时间作为传输时间。S35, the slave device uses the total time of receiving the synchronous data in the edge trigger mode as the transmission time.
S36,从设备向主设备发送传输时间以及采样数据。S36, the slave device sends the transmission time and sampling data to the master device.
S37,主设备接收多个从设备发送的传输时间以及采样数据。S37, the master device receives the transmission time and sampling data sent by multiple slave devices.
S38,主设备根据每个从设备发送的传输时间计算多个从设备间的相对时间偏差。S38, the master device calculates the relative time deviation between the multiple slave devices according to the transmission time sent by each slave device.
S39,主设备根据相对时间偏差对采样数据进行处理,得到多个从设备的同步采样数据。S39, the master device processes the sampled data according to the relative time deviation to obtain synchronous sampled data of multiple slave devices.
上述步骤S31-S39与步骤S11-S16和步骤S21-S24分别对应,具体实现过程请参考前述实施例的描述,此处不赘述。The above steps S31-S39 correspond to steps S11-S16 and steps S21-S24 respectively. For the specific implementation process, please refer to the description of the above embodiment, which will not be repeated here.
应当理解的是,在以上的实施例中,以多个从设备中的某一从设备为基准设备,在其他的一些实施例中,也可以以主设备为基准设备。在以主设备为基准设备时,可以根据主设备发送同步数据的预设时间段,计算预设时间段的时长与每个从设备发送的传输时间之间的相对时间偏差,并根据主设备与各个从设备的相对时间偏差对各个从设备的采样数据进行处理,得到多个从设备的同步采样数据。It should be understood that in the above embodiments, a certain slave device among the multiple slave devices is used as the reference device, and in some other embodiments, the master device may also be used as the reference device. When the master device is used as the reference device, the relative time deviation between the duration of the preset time period and the transmission time sent by each slave device can be calculated according to the preset time period for the master device to send synchronous data, and the sampled data of each slave device can be processed according to the relative time deviation between the master device and each slave device to obtain the synchronous sampled data of multiple slave devices.
请参阅图12,图12是本申请实施例提供的同步数据处理装置的结构示意图。在一些实施例中,同步数据处理装置20可以包括多个由计算机程序段所组成的功能模块。同步数据处理装置20中的各个程序段的计算机程序可以存储于计算机设备30的存储器中,并由至少一个处理器所执行,以执行(详见图1描述)同步数据处理的功能。Please refer to FIG. 12, which is a schematic diagram of the structure of the synchronous data processing device provided in an embodiment of the present application. In some embodiments, the synchronous data processing device 20 may include a plurality of functional modules composed of computer program segments. The computer program of each program segment in the synchronous data processing device 20 may be stored in the memory of the
本实施例中,同步数据处理装置20根据其所执行的功能,可以被划分为多个功能模块。当同步数据处理装置20应用于主设备时,功能模块可以包括:同步帧发送模块201、同步数据发送模块202、传输时间接收模块203、时间偏差计算模块204、采样数据接收模块205以及采样数据处理模块206。本申请所称的模块是指一种能够被至少一个处理器所执行并且能够完成固定功能的一系列计算机程序段,其存储在存储器中。在本实施例中,关于各模块的功能将在后续的实施例中详述。In this embodiment, the synchronous data processing device 20 can be divided into multiple functional modules according to the functions it performs. When the synchronous data processing device 20 is applied to the master device, the functional modules may include: a synchronous frame sending module 201, a synchronous data sending module 202, a transmission time receiving module 203, a time deviation calculation module 204, a sampled data receiving module 205, and a sampled data processing module 206. The module referred to in this application refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in a memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
同步帧发送模块201用于发送预设同步帧至多个从设备,预设同步帧用于指示各从设备进入边沿触发模式。The synchronization frame sending module 201 is used to send a preset synchronization frame to a plurality of slave devices, and the preset synchronization frame is used to instruct each slave device to enter an edge-triggered mode.
同步数据发送模块202用于向多个从设备发送同步数据,同步数据用于指示各从设备在接收到同步数据的首个边沿时开始进行数据采样。The synchronous data sending module 202 is used to send synchronous data to multiple slave devices. The synchronous data is used to instruct each slave device to start data sampling when receiving the first edge of the synchronous data.
传输时间接收模块203用于接收各从设备发送的传输时间,传输时间为从设备在边沿触发模式下记录的接收同步数据的总时间。The transmission time receiving module 203 is used to receive the transmission time sent by each slave device. The transmission time is the total time recorded by the slave device for receiving synchronous data in the edge trigger mode.
时间偏差计算模块204用于根据每个从设备发送的传输时间计算多个从设备间的相对时间偏差。The time deviation calculation module 204 is used to calculate the relative time deviation between multiple slave devices according to the transmission time sent by each slave device.
采样数据接收模块205用于接收各从设备返回到的采样数据。The sampled data receiving module 205 is used to receive the sampled data returned by each slave device.
采样数据处理模块206用于根据相对时间偏差对采样数据进行处理,得到多个从设备的同步采样数据。The sampled data processing module 206 is used to process the sampled data according to the relative time deviation to obtain synchronous sampled data of multiple slave devices.
请参阅图13,图13是本申请实施例提供的计算机设备30的结构示意图。在本申请较佳实施例中,计算机设备30包括存储器31、至少一个处理器32、至少一条通信总线33。Please refer to Fig. 13, which is a schematic diagram of the structure of a
本领域技术人员应该了解,图13示出的计算机设备的结构并不构成本申请实施例的限定,既可以是总线型结构,也可以是星形结构,计算机设备30还可以包括比图示更多或更少的其他硬件或者软件,或者不同的部件布置。Those skilled in the art should understand that the structure of the computer device shown in FIG. 13 does not constitute a limitation of the embodiments of the present application, and may be either a bus structure or a star structure. The
在一些实施例中,计算机设备30是一种能够按照事先设定或存储的指令,自动进行数值计算和/或信息处理的设备,其硬件包括但不限于微处理器、专用集成电路、可编程门阵列、数字处理器及嵌入式设备等。计算机设备30还可包括客户设备,客户设备包括但不限于任何一种可与客户通过键盘、鼠标、遥控器、触摸板或声控设备等方式进行人机交互的电子产品,例如,个人计算机、平板电脑、智能手机、数码相机等。In some embodiments, the
需要说明的是,计算机设备30仅为举例,其他现有的或今后可能出现的电子产品如可适应于本申请,也应包含在本申请的保护范围以内,并以引用方式包含于此。It should be noted that the
在一些实施例中,存储器31中存储有计算机程序,计算机程序被至少一个处理器32执行时实现如的同步数据处理方法中的全部或者部分步骤。存储器31包括只读存储器(Read-Only Memory,ROM)、可编程只读存储器(Programmable Read-Only Memory,PROM)、可擦除可编程只读存储器(Erasable Programmable Read-Only Memory,EPROM)、一次可编程只读存储器(One-time Programmable Read-Only Memory,OTPROM)、电子擦除式可复写只读存储器(Electrically-Erasable Programmable Read-Only Memory,EEPROM)、只读光盘(Compact Disc Read-Only Memory,CD-ROM)或其他光盘存储器、磁盘存储器、磁带存储器、或者能够用于携带或存储数据的计算机可读的任何其他介质。In some embodiments, a computer program is stored in the
进一步地,计算机可读存储介质可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等;存储数据区可存储根据计算机设备30的使用所创建的数据等。Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the
在一些实施例中,至少一个处理器32是计算机设备30的控制核心(Control Unit),利用各种接口和线路连接整个计算机设备30的各个部件,通过运行或执行存储在存储器31内的程序或者模块,以及调用存储在存储器31内的数据,以执行计算机设备30的各种功能和处理数据。例如,至少一个处理器32执行存储器中存储的计算机程序时实现本申请实施例中的同步数据处理方法的全部或者部分步骤;或者实现同步数据处理装置的全部或者部分功能。至少一个处理器32可以由集成电路组成,例如可以由单个封装的集成电路所组 成,也可以是由多个相同功能或不同功能封装的集成电路所组成,包括一个或者多个中央处理器(Central Processing unit,CPU)、微处理器、数字处理芯片、图形处理器及各种控制芯片的组合等。In some embodiments, at least one
在一些实施例中,至少一条通信总线33被设置为实现存储器31以及至少一个处理器32等之间的连接通信。In some embodiments, at least one
尽管未示出,计算机设备30还可以包括给各个部件供电的电源(比如电池),优选的,电源可以通过电源管理装置与至少一个处理器32逻辑相连,从而通过电源管理装置实现管理充电、放电、以及功耗管理等功能。电源还可以包括一个或一个以上的直流或交流电源、再充电装置、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。计算机设备30还可以包括多种传感器、蓝牙模块、Wi-Fi模块等,在此不再赘述。Although not shown, the
上述以软件功能模块的形式实现的集成的单元,可以存储在一个计算机可读取存储介质中。上述软件功能模块存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,计算机设备,或者网络设备等)或处理器(processor)执行本申请各个实施例方法的部分。The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to execute parts of the methods of various embodiments of the present application.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation.
作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理单元,既可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, and may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各个实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional modules.
对于本领域技术人员而言,显然本申请不限于上述示范性实施例的细节,而且在不背离本申请的精神或基本特征的情况下,能够以其他的具体形式实现本申请。因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本申请的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本申请内。不应将权利要求中的任何附图标记视为限制所涉及的权利要求。此外,显然“包括”一词不排除其他单元或,单数不排除复数。说明书中陈述的多个单元或装置也可以由一个单元或装置通过软件或者硬件来实现。第一,第二等词语用来表示名称,而并不表示任何特定的顺序。It is obvious to those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic features of the present application. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present application is limited by the attached claims rather than the above description, so it is intended to include all changes that fall within the meaning and scope of the equivalent elements of the claims in the present application. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "including" does not exclude other units or, and the singular does not exclude the plural. Multiple units or devices stated in the specification can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
最后应说明的是,以上实施例仅用以说明本申请的技术方案而非限制,尽管参照较佳实施例对本申请进行了详细说明,本领域的普通技术人员应当理解,可以对本申请的技术方案进行修改或等同替换,而不脱离本申请技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.
Claims (10)
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202280006021.7A CN116157786B (en) | 2022-12-28 | 2022-12-28 | Synchronous data processing method and equipment |
| PCT/CN2022/142591 WO2024138400A1 (en) | 2022-12-28 | 2022-12-28 | Synchronous data processing method, and device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2022/142591 WO2024138400A1 (en) | 2022-12-28 | 2022-12-28 | Synchronous data processing method, and device |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2024138400A1 true WO2024138400A1 (en) | 2024-07-04 |
Family
ID=86352934
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2022/142591 Ceased WO2024138400A1 (en) | 2022-12-28 | 2022-12-28 | Synchronous data processing method, and device |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN116157786B (en) |
| WO (1) | WO2024138400A1 (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118487697A (en) * | 2024-07-16 | 2024-08-13 | 湖北星纪魅族集团有限公司 | Time synchronization method |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20190110264A1 (en) * | 2017-10-11 | 2019-04-11 | Google Llc | System and method for accurate timestamping of virtual reality controller data |
| CN110493744A (en) * | 2019-08-20 | 2019-11-22 | 郑州大学 | A kind of synchronous data sampling method and system of master-slave radio sensor |
| CN112769516A (en) * | 2020-12-24 | 2021-05-07 | 深兰人工智能(深圳)有限公司 | Data synchronous acquisition method and device, electronic equipment and storage medium |
| CN114063703A (en) * | 2021-10-12 | 2022-02-18 | 奥比中光科技集团股份有限公司 | Data synchronization method and device, data processing equipment and storage medium |
| CN114415560A (en) * | 2021-12-24 | 2022-04-29 | 浙江清华柔性电子技术研究院 | Data synchronous acquisition and processing method and device and storage medium |
| CN115361084A (en) * | 2022-08-23 | 2022-11-18 | 歌尔科技有限公司 | A method, device, equipment and medium for synchronizing clocks |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPS63119341A (en) * | 1986-11-07 | 1988-05-24 | Hitachi Ltd | Sampling synchronizing system |
| EP2150062B1 (en) * | 2008-07-28 | 2022-10-26 | Imagine Communications Corp. | Improved method, system and apparatus for synchronizing signals |
| CN110176974B (en) * | 2019-05-30 | 2021-04-06 | 郑州轨道交通信息技术研究院 | Data sampling synchronization method, device and unit for wide-area relay protection |
-
2022
- 2022-12-28 WO PCT/CN2022/142591 patent/WO2024138400A1/en not_active Ceased
- 2022-12-28 CN CN202280006021.7A patent/CN116157786B/en active Active
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20190110264A1 (en) * | 2017-10-11 | 2019-04-11 | Google Llc | System and method for accurate timestamping of virtual reality controller data |
| CN110493744A (en) * | 2019-08-20 | 2019-11-22 | 郑州大学 | A kind of synchronous data sampling method and system of master-slave radio sensor |
| CN112769516A (en) * | 2020-12-24 | 2021-05-07 | 深兰人工智能(深圳)有限公司 | Data synchronous acquisition method and device, electronic equipment and storage medium |
| CN114063703A (en) * | 2021-10-12 | 2022-02-18 | 奥比中光科技集团股份有限公司 | Data synchronization method and device, data processing equipment and storage medium |
| CN114415560A (en) * | 2021-12-24 | 2022-04-29 | 浙江清华柔性电子技术研究院 | Data synchronous acquisition and processing method and device and storage medium |
| CN115361084A (en) * | 2022-08-23 | 2022-11-18 | 歌尔科技有限公司 | A method, device, equipment and medium for synchronizing clocks |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118487697A (en) * | 2024-07-16 | 2024-08-13 | 湖北星纪魅族集团有限公司 | Time synchronization method |
Also Published As
| Publication number | Publication date |
|---|---|
| CN116157786A (en) | 2023-05-23 |
| CN116157786B (en) | 2025-10-17 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US8190941B2 (en) | Field control system | |
| JP6523497B1 (en) | Master controller and synchronous communication system using the same | |
| US11316605B2 (en) | Method, device, and computer program for improving synchronization of clocks in devices linked according to a daisy-chain topology | |
| CN109683567B (en) | System Clock Synchronization Method Based on RS485 Network | |
| CN107959564A (en) | Control device and communicator | |
| CN114567926B (en) | Clock synchronization and trigger device for wireless distributed test system | |
| CN106664145A (en) | Method for transmitting time synchronization messages in a communication network, network component, and communication network | |
| WO2025061087A1 (en) | System-on-a-chip and timestamp capturing method and apparatus thereof, and storage medium | |
| WO2021253596A1 (en) | Dual-channel secure plc-based synchronous control and data voting methods | |
| CN112162591A (en) | Electronic device with multiple processors and synchronization method thereof | |
| WO2024138400A1 (en) | Synchronous data processing method, and device | |
| CN109543811B (en) | Counting circuit, counting method and chip | |
| CN110572234A (en) | Method for realizing clock synchronization based on serial port, intelligent terminal and storage medium | |
| US12225487B2 (en) | Communication device, communication system, and recording medium | |
| WO2024109696A1 (en) | Multi-sensor trigger control method, apparatus and device, and storage medium | |
| US9703315B2 (en) | Transmission device and time synchronization method | |
| US20240146432A1 (en) | Time synchronization communication system, time synchronization end station, and message transmission control program | |
| CN110912634A (en) | Method for realizing clock synchronization based on SPI, storage medium and terminal equipment | |
| JPS59176863A (en) | Timer synchronizing system | |
| JPH10247121A (en) | Microcomputer | |
| JP6627958B1 (en) | Communications system | |
| CN119766374A (en) | Time synchronization method, vehicle system, node, vehicle, computer-readable storage medium, and computer program product | |
| RU2674878C1 (en) | Device for synchronizing microcontrollers | |
| CN117406828A (en) | Method, device, terminal equipment and storage medium for unifying embedded system time | |
| CN119094273A (en) | Periodic time-sharing communication method, system, device and storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 22969556 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| WWG | Wipo information: grant in national office |
Ref document number: 202280006021.7 Country of ref document: CN |
|
| 32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 24.10.2025) |